Commit 348e114b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c6a564ff
...@@ -1497,8 +1497,8 @@ static char *block_devnode(struct device *dev, umode_t *mode, ...@@ -1497,8 +1497,8 @@ static char *block_devnode(struct device *dev, umode_t *mode,
{ {
struct gendisk *disk = dev_to_disk(dev); struct gendisk *disk = dev_to_disk(dev);
if (disk->devnode) if (disk->fops->devnode)
return disk->devnode(disk, mode); return disk->fops->devnode(disk, mode);
return NULL; return NULL;
} }
......
...@@ -2679,6 +2679,11 @@ static unsigned int pkt_check_events(struct gendisk *disk, ...@@ -2679,6 +2679,11 @@ static unsigned int pkt_check_events(struct gendisk *disk,
return attached_disk->fops->check_events(attached_disk, clearing); return attached_disk->fops->check_events(attached_disk, clearing);
} }
static char *pkt_devnode(struct gendisk *disk, umode_t *mode)
{
return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name);
}
static const struct block_device_operations pktcdvd_ops = { static const struct block_device_operations pktcdvd_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = pkt_open, .open = pkt_open,
...@@ -2686,13 +2691,9 @@ static const struct block_device_operations pktcdvd_ops = { ...@@ -2686,13 +2691,9 @@ static const struct block_device_operations pktcdvd_ops = {
.ioctl = pkt_ioctl, .ioctl = pkt_ioctl,
.compat_ioctl = blkdev_compat_ptr_ioctl, .compat_ioctl = blkdev_compat_ptr_ioctl,
.check_events = pkt_check_events, .check_events = pkt_check_events,
.devnode = pkt_devnode,
}; };
static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode)
{
return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
}
/* /*
* Set up mapping from pktcdvd device to CD-ROM device. * Set up mapping from pktcdvd device to CD-ROM device.
*/ */
...@@ -2748,7 +2749,6 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) ...@@ -2748,7 +2749,6 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
disk->fops = &pktcdvd_ops; disk->fops = &pktcdvd_ops;
disk->flags = GENHD_FL_REMOVABLE; disk->flags = GENHD_FL_REMOVABLE;
strcpy(disk->disk_name, pd->name); strcpy(disk->disk_name, pd->name);
disk->devnode = pktcdvd_devnode;
disk->private_data = pd; disk->private_data = pd;
disk->queue = blk_alloc_queue(GFP_KERNEL); disk->queue = blk_alloc_queue(GFP_KERNEL);
if (!disk->queue) if (!disk->queue)
......
...@@ -1697,6 +1697,7 @@ struct block_device_operations { ...@@ -1697,6 +1697,7 @@ struct block_device_operations {
void (*swap_slot_free_notify) (struct block_device *, unsigned long); void (*swap_slot_free_notify) (struct block_device *, unsigned long);
int (*report_zones)(struct gendisk *, sector_t sector, int (*report_zones)(struct gendisk *, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data); unsigned int nr_zones, report_zones_cb cb, void *data);
char *(*devnode)(struct gendisk *disk, umode_t *mode);
struct module *owner; struct module *owner;
const struct pr_ops *pr_ops; const struct pr_ops *pr_ops;
}; };
......
...@@ -191,7 +191,6 @@ struct gendisk { ...@@ -191,7 +191,6 @@ struct gendisk {
* disks that can't be partitioned. */ * disks that can't be partitioned. */
char disk_name[DISK_NAME_LEN]; /* name of major driver */ char disk_name[DISK_NAME_LEN]; /* name of major driver */
char *(*devnode)(struct gendisk *gd, umode_t *mode);
unsigned short events; /* supported events */ unsigned short events; /* supported events */
unsigned short event_flags; /* flags related to event processing */ unsigned short event_flags; /* flags related to event processing */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment