Skip to content

Commit 348e114

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move the ->devnode callback to struct block_device_operations
There really isn't any good reason to stash a method directly into struct gendisk. Move it together with the other block device operations. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c6a564f commit 348e114

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎block/genhd.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,8 @@ static char *block_devnode(struct device *dev, umode_t *mode,
14971497
{
14981498
struct gendisk *disk = dev_to_disk(dev);
14991499

1500-
if (disk->devnode)
1501-
return disk->devnode(disk, mode);
1500+
if (disk->fops->devnode)
1501+
return disk->fops->devnode(disk, mode);
15021502
return NULL;
15031503
}
15041504

‎drivers/block/pktcdvd.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,20 +2679,21 @@ static unsigned int pkt_check_events(struct gendisk *disk,
26792679
return attached_disk->fops->check_events(attached_disk, clearing);
26802680
}
26812681

2682+
static char *pkt_devnode(struct gendisk *disk, umode_t *mode)
2683+
{
2684+
return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name);
2685+
}
2686+
26822687
static const struct block_device_operations pktcdvd_ops = {
26832688
.owner = THIS_MODULE,
26842689
.open = pkt_open,
26852690
.release = pkt_close,
26862691
.ioctl = pkt_ioctl,
26872692
.compat_ioctl = blkdev_compat_ptr_ioctl,
26882693
.check_events = pkt_check_events,
2694+
.devnode = pkt_devnode,
26892695
};
26902696

2691-
static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode)
2692-
{
2693-
return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
2694-
}
2695-
26962697
/*
26972698
* Set up mapping from pktcdvd device to CD-ROM device.
26982699
*/
@@ -2748,7 +2749,6 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
27482749
disk->fops = &pktcdvd_ops;
27492750
disk->flags = GENHD_FL_REMOVABLE;
27502751
strcpy(disk->disk_name, pd->name);
2751-
disk->devnode = pktcdvd_devnode;
27522752
disk->private_data = pd;
27532753
disk->queue = blk_alloc_queue(GFP_KERNEL);
27542754
if (!disk->queue)

‎include/linux/blkdev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@ struct block_device_operations {
16971697
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
16981698
int (*report_zones)(struct gendisk *, sector_t sector,
16991699
unsigned int nr_zones, report_zones_cb cb, void *data);
1700+
char *(*devnode)(struct gendisk *disk, umode_t *mode);
17001701
struct module *owner;
17011702
const struct pr_ops *pr_ops;
17021703
};

‎include/linux/genhd.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ struct gendisk {
191191
* disks that can't be partitioned. */
192192

193193
char disk_name[DISK_NAME_LEN]; /* name of major driver */
194-
char *(*devnode)(struct gendisk *gd, umode_t *mode);
195194

196195
unsigned short events; /* supported events */
197196
unsigned short event_flags; /* flags related to event processing */

0 commit comments

Comments
 (0)