Skip to content

Commit

Permalink
ide: switch to __register_blkdev for command set probing
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 16, 2020
1 parent 28144f9 commit bbc26e8
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,31 +902,12 @@ static int init_irq (ide_hwif_t *hwif)
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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit bbc26e8

Please sign in to comment.