ide: switch to __register_blkdev for command set probing

ide is the last user of the blk_register_region framework except for the
tracking of allocated gendisk.  Switch to __register_blkdev, even if that
doesn't allow us to trivially find out which command set to probe for.
That means we now always request all modules when a user tries to access
an unclaimed ide device node, but except for a few potentially loaded
modules for a fringe use case of a deprecated and soon to be removed
driver that doesn't make a difference.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2020-10-29 15:58:35 +01:00 коммит произвёл Jens Axboe
Родитель 28144f9998
Коммит bbc26e8d93
1 изменённых файлов: 6 добавлений и 28 удалений

Просмотреть файл

@ -902,31 +902,12 @@ out_up:
return 1;
}
static int ata_lock(dev_t dev, void *data)
static void ata_probe(dev_t dev)
{
/* FIXME: we want to pin hwif down */
return 0;
}
static struct kobject *ata_probe(dev_t dev, int *part, void *data)
{
ide_hwif_t *hwif = data;
int unit = *part >> PARTN_BITS;
ide_drive_t *drive = hwif->devices[unit];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
return NULL;
if (drive->media == ide_disk)
request_module("ide-disk");
if (drive->media == ide_cdrom || drive->media == ide_optical)
request_module("ide-cd");
if (drive->media == ide_tape)
request_module("ide-tape");
if (drive->media == ide_floppy)
request_module("ide-floppy");
return NULL;
request_module("ide-disk");
request_module("ide-cd");
request_module("ide-tape");
request_module("ide-floppy");
}
void ide_init_disk(struct gendisk *disk, ide_drive_t *drive)
@ -967,7 +948,7 @@ static int hwif_init(ide_hwif_t *hwif)
return 0;
}
if (register_blkdev(hwif->major, hwif->name))
if (__register_blkdev(hwif->major, hwif->name, ata_probe))
return 0;
if (!hwif->sg_max_nents)
@ -989,8 +970,6 @@ static int hwif_init(ide_hwif_t *hwif)
goto out;
}
blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS,
THIS_MODULE, ata_probe, ata_lock, hwif);
return 1;
out:
@ -1582,7 +1561,6 @@ static void ide_unregister(ide_hwif_t *hwif)
/*
* Remove us from the kernel's knowledge
*/
blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
kfree(hwif->sg_table);
unregister_blkdev(hwif->major, hwif->name);