aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cdrom
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cdrom')
-rw-r--r--drivers/cdrom/cdrom.c29
1 files changed, 6 insertions, 23 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
363static void cdrom_sysctl_register(void); 363static void cdrom_sysctl_register(void);
364 364
365static struct cdrom_device_info *topCdromPtr; 365static LIST_HEAD(cdrom_list);
366 366
367static int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, 367static 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
446int unregister_cdrom(struct cdrom_device_info *unreg) 445int 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)