[PATCH] drivers/cdrom/cdrom.c: simplify logic in cdrom_release()

linux

[PATCH] drivers/cdrom/cdrom.c: simplify logic in cdrom_release()

Postby Borislav Petkov » Tue, 18 Dec 2007 21:10:15 GMT

---
From: Borislav Petkov < XXXX@XXXXX.COM >

Simplify logic in cdrom_release() without semantical change.

Signed-off-by: Borislav Petkov < XXXX@XXXXX.COM >


 drivers/cdrom/cdrom.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index af05610..037d4ec 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1206,25 +1206,26 @@ int check_for_audio_disc(struct cdrom_device_info * cdi,
 	return 0;
 }
 
-/* Admittedly, the logic below could be performed in a nicer way. */
 int cdrom_release(struct cdrom_device_info *cdi, struct file *fp)
 {
 	struct cdrom_device_ops *cdo = cdi->ops;
 	int opened_for_data;
 
-	cdinfo(CD_CLOSE, "entering cdrom_release\n"); 
+	cdinfo(CD_CLOSE, "entering cdrom_release\n");
 
 	if (cdi->use_count > 0)
 		cdi->use_count--;
-	if (cdi->use_count == 0)
+
+	if (cdi->use_count == 0) {
 		cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
-	if (cdi->use_count == 0)
 		cdrom_dvd_rw_close_write(cdi);
-	if (cdi->use_count == 0 &&
-	    (cdo->capability & CDC_LOCK) && !keeplocked) {
-		cdinfo(CD_CLOSE, "Unlocking door!\n");
-		cdo->lock_door(cdi, 0);
+
+		if ((cdo->capability & CDC_LOCK) && !keeplocked) {
+			cdinfo(CD_CLOSE, "Unlocking door!\n");
+			cdo->lock_door(cdi, 0);
+		}
 	}
+
 	opened_for_data = !(cdi->options & CDO_USE_FFLAGS) ||
 		!(fp && fp->f_flags & O_NONBLOCK);
 
-- 
Regards/Gru
    Boris.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to  XXXX@XXXXX.COM 
More majordomo info at   http://www.**--****.com/ 
Please read the FAQ at   http://www.**--****.com/ 

Similar Threads:

1.YMMD (Was: PATCH/FIX for drivers/cdrom/cdrom.c)

2.PATCH/FIX for drivers/cdrom/cdrom.c

3.[PATCH 23/25] cdrom: move ioctl32 code to drivers/cdrom/compat.c

4.[patch 2.6.15-mm4] drivers/cdrom/cdrom.c fix incorrect test

5.Problem mounting cdrom on CDROM-floppy hot swap Dell laptop

Yong Huang wrote:

> Dell Latitude C640
> Redhat Linux 8.0 (kernel 2.4.18-14 #1)
> 
> I use a floppy bootdisk to boot into Linux since a large portion of my
> disk is Windows XP taking more than 1024 cylinders. The problem is
> that this laptop uses the same slot for the floppy and CD drive. After
> I boot into Linux from the floppy and replace the floppy drive with a
> CD drive, I can't mount the CD. "mount -t iso9660 /dev/cdrom
> /mnt/cdrom returns" says "/dev/cdrom is not a valid block device"
> (/dev/cdrom links to /dev/hdc; but mounting /dev/hd[bcd] makes no
> difference). /var/log/messages says "modprobe: Can't locate module
> block-major-22". "dmesg | grep -i cdrom" returns nothing.
> 
> Then I added "alias block-major-22 off" to modules.conf. The message
> changes to "... block-major-33". Then I added these lines
> 
> alias block-major-33 off
> options ide-cd ignore=hdb
> options ide-cd ignore=hdc
> 
> Now no more modprobe message in /var/log/messages, but I still can't
> mount the CD. Thanks for any advice.
> 
> Yong Huang

Perhaps you should start playing around with your modules. During the boot
process of course no cdrom can be recognized. If your kernel is completely
modulized try to unload the floppy module (rmmod floppy) after your Linux
is up and running, change the floppy with the cd drive and load the ide cd
driver by (modprobe ide-cd). Check out dmesg for new messages...

Regards, Joerg.

6. Two CDROM drives and module compilation of CDROM Support

7. RW DVD tagged as CDROM and using CDROM Drivers

8. [FAQ-PATCH] OE-QuoteFix (Was: PATCH (for 2.6.3-rc1) for cdrom driver dvd_read_struct)



Return to linux

 

Who is online

Users browsing this forum: No registered users and 58 guest