int ide_register_driver(ide_driver_t *driver)
{
struct list_head list;
+ struct list_head *list_loop;
+ struct list_head *tmp_storage;
spin_lock(&drivers_lock);
list_add(&driver->drivers, &drivers);
list_splice_init(&ata_unused, &list);
spin_unlock(&drives_lock);
- while (!list_empty(&list)) {
- ide_drive_t *drive = list_entry(list.next, ide_drive_t, list);
+ list_for_each_safe(list_loop, tmp_storage, &list) {
+ ide_drive_t *drive = container_of(list_loop, ide_drive_t, list);
list_del_init(&drive->list);
if (drive->present)
ata_attach(drive);