diff options
-rw-r--r-- | drivers/cdrom/cdrom.c | 29 | ||||
-rw-r--r-- | include/linux/cdrom.h | 3 |
2 files changed, 8 insertions, 24 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 326ef1b4a4ea..c4213b7d0b20 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -362,7 +362,7 @@ static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information * | |||
362 | 362 | ||
363 | static void cdrom_sysctl_register(void); | 363 | static void cdrom_sysctl_register(void); |
364 | 364 | ||
365 | static struct cdrom_device_info *topCdromPtr; | 365 | static LIST_HEAD(cdrom_list); |
366 | 366 | ||
367 | static int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, | 367 | static int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, |
368 | struct packet_command *cgc) | 368 | struct packet_command *cgc) |
@@ -436,35 +436,18 @@ int register_cdrom(struct cdrom_device_info *cdi) | |||
436 | 436 | ||
437 | cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); | 437 | cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); |
438 | mutex_lock(&cdrom_mutex); | 438 | mutex_lock(&cdrom_mutex); |
439 | cdi->next = topCdromPtr; | 439 | list_add(&cdi->list, &cdrom_list); |
440 | topCdromPtr = cdi; | ||
441 | mutex_unlock(&cdrom_mutex); | 440 | mutex_unlock(&cdrom_mutex); |
442 | return 0; | 441 | return 0; |
443 | } | 442 | } |
444 | #undef ENSURE | 443 | #undef ENSURE |
445 | 444 | ||
446 | int unregister_cdrom(struct cdrom_device_info *unreg) | 445 | int unregister_cdrom(struct cdrom_device_info *cdi) |
447 | { | 446 | { |
448 | struct cdrom_device_info *cdi, *prev; | ||
449 | cdinfo(CD_OPEN, "entering unregister_cdrom\n"); | 447 | cdinfo(CD_OPEN, "entering unregister_cdrom\n"); |
450 | 448 | ||
451 | prev = NULL; | ||
452 | mutex_lock(&cdrom_mutex); | 449 | mutex_lock(&cdrom_mutex); |
453 | cdi = topCdromPtr; | 450 | list_del(&cdi->list); |
454 | while (cdi && cdi != unreg) { | ||
455 | prev = cdi; | ||
456 | cdi = cdi->next; | ||
457 | } | ||
458 | |||
459 | if (cdi == NULL) { | ||
460 | mutex_unlock(&cdrom_mutex); | ||
461 | return -2; | ||
462 | } | ||
463 | if (prev) | ||
464 | prev->next = cdi->next; | ||
465 | else | ||
466 | topCdromPtr = cdi->next; | ||
467 | |||
468 | mutex_unlock(&cdrom_mutex); | 451 | mutex_unlock(&cdrom_mutex); |
469 | 452 | ||
470 | if (cdi->exit) | 453 | if (cdi->exit) |
@@ -3306,7 +3289,7 @@ static int cdrom_print_info(const char *header, int val, char *info, | |||
3306 | 3289 | ||
3307 | *pos += ret; | 3290 | *pos += ret; |
3308 | 3291 | ||
3309 | for (cdi = topCdromPtr; cdi; cdi = cdi->next) { | 3292 | list_for_each_entry(cdi, &cdrom_list, list) { |
3310 | switch (option) { | 3293 | switch (option) { |
3311 | case CTL_NAME: | 3294 | case CTL_NAME: |
3312 | ret = scnprintf(info + *pos, max_size - *pos, | 3295 | ret = scnprintf(info + *pos, max_size - *pos, |
@@ -3428,7 +3411,7 @@ static void cdrom_update_settings(void) | |||
3428 | struct cdrom_device_info *cdi; | 3411 | struct cdrom_device_info *cdi; |
3429 | 3412 | ||
3430 | mutex_lock(&cdrom_mutex); | 3413 | mutex_lock(&cdrom_mutex); |
3431 | for (cdi = topCdromPtr; cdi != NULL; cdi = cdi->next) { | 3414 | list_for_each_entry(cdi, &cdrom_list, list) { |
3432 | if (autoclose && CDROM_CAN(CDC_CLOSE_TRAY)) | 3415 | if (autoclose && CDROM_CAN(CDC_CLOSE_TRAY)) |
3433 | cdi->options |= CDO_AUTO_CLOSE; | 3416 | cdi->options |= CDO_AUTO_CLOSE; |
3434 | else if (!autoclose) | 3417 | else if (!autoclose) |
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h index a5cd2047624e..40e05d0a6e45 100644 --- a/include/linux/cdrom.h +++ b/include/linux/cdrom.h | |||
@@ -910,6 +910,7 @@ struct mode_page_header { | |||
910 | #ifdef __KERNEL__ | 910 | #ifdef __KERNEL__ |
911 | #include <linux/fs.h> /* not really needed, later.. */ | 911 | #include <linux/fs.h> /* not really needed, later.. */ |
912 | #include <linux/device.h> | 912 | #include <linux/device.h> |
913 | #include <linux/list.h> | ||
913 | 914 | ||
914 | struct packet_command | 915 | struct packet_command |
915 | { | 916 | { |
@@ -934,7 +935,7 @@ struct packet_command | |||
934 | /* Uniform cdrom data structures for cdrom.c */ | 935 | /* Uniform cdrom data structures for cdrom.c */ |
935 | struct cdrom_device_info { | 936 | struct cdrom_device_info { |
936 | struct cdrom_device_ops *ops; /* link to device_ops */ | 937 | struct cdrom_device_ops *ops; /* link to device_ops */ |
937 | struct cdrom_device_info *next; /* next device_info for this major */ | 938 | struct list_head list; /* linked list of all device_info */ |
938 | struct gendisk *disk; /* matching block layer disk */ | 939 | struct gendisk *disk; /* matching block layer disk */ |
939 | void *handle; /* driver-dependent data */ | 940 | void *handle; /* driver-dependent data */ |
940 | /* specifications */ | 941 | /* specifications */ |