Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cdrom: move shared static to cdrom_device_info

The keeplocked variable in the cdrom driver is shared across multiple
drives, but set in per-device ioctls. Move it to the per-device struct,
avoiding that the setting on one drive affects the driver's behavior
when closing another.

[ Impact: limit udev's confusion to one drive when a CD burning program
unlocks the CD door at the end of burning. ]

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Paolo Bonzini and committed by
Jens Axboe
cdccaa94 37b40adf

+7 -8
+5 -7
drivers/cdrom/cdrom.c
··· 286 286 287 287 /* used to tell the module to turn on full debugging messages */ 288 288 static bool debug; 289 - /* used to keep tray locked at all times */ 290 - static int keeplocked; 291 289 /* default compatibility mode */ 292 290 static bool autoclose=1; 293 291 static bool autoeject; ··· 1202 1204 cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name); 1203 1205 cdrom_dvd_rw_close_write(cdi); 1204 1206 1205 - if ((cdo->capability & CDC_LOCK) && !keeplocked) { 1207 + if ((cdo->capability & CDC_LOCK) && !cdi->keeplocked) { 1206 1208 cdinfo(CD_CLOSE, "Unlocking door!\n"); 1207 1209 cdo->lock_door(cdi, 0); 1208 1210 } ··· 1369 1371 curslot = info->hdr.curslot; 1370 1372 kfree(info); 1371 1373 1372 - if (cdi->use_count > 1 || keeplocked) { 1374 + if (cdi->use_count > 1 || cdi->keeplocked) { 1373 1375 if (slot == CDSL_CURRENT) { 1374 1376 return curslot; 1375 1377 } else { ··· 2287 2289 2288 2290 if (!CDROM_CAN(CDC_OPEN_TRAY)) 2289 2291 return -ENOSYS; 2290 - if (cdi->use_count != 1 || keeplocked) 2292 + if (cdi->use_count != 1 || cdi->keeplocked) 2291 2293 return -EBUSY; 2292 2294 if (CDROM_CAN(CDC_LOCK)) { 2293 2295 int ret = cdi->ops->lock_door(cdi, 0); ··· 2314 2316 2315 2317 if (!CDROM_CAN(CDC_OPEN_TRAY)) 2316 2318 return -ENOSYS; 2317 - if (keeplocked) 2319 + if (cdi->keeplocked) 2318 2320 return -EBUSY; 2319 2321 2320 2322 cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); ··· 2445 2447 if (!CDROM_CAN(CDC_LOCK)) 2446 2448 return -EDRIVE_CANT_DO_THIS; 2447 2449 2448 - keeplocked = arg ? 1 : 0; 2450 + cdi->keeplocked = arg ? 1 : 0; 2449 2451 2450 2452 /* 2451 2453 * Don't unlock the door on multiple opens by default, but allow
+2 -1
include/linux/cdrom.h
··· 952 952 char name[20]; /* name of the device type */ 953 953 /* per-device flags */ 954 954 __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ 955 - __u8 reserved : 6; /* not used yet */ 955 + __u8 keeplocked : 1; /* CDROM_LOCKDOOR status */ 956 + __u8 reserved : 5; /* not used yet */ 956 957 int cdda_method; /* see flags */ 957 958 __u8 last_sense; 958 959 __u8 media_written; /* dirty flag, DVD+RW bookkeeping */