History

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.

Christoph Hellwig committed 6 years ago

Commit 348e1141 parent c6a564f4 files · +9 −9Browse files

Unified · Split

4 files
  1. block/genhd.c +2 −2
  2. drivers/block/pktcdvd.c +6 −6
  3. include/linux/blkdev.h +1 −0
  4. include/linux/genhd.h +0 −1
block/genhd.c+2−2
@@ -1497,8 +1497,8 @@ static char *block_devnode(struct device *dev, umode_t *mode, · 1496 unmodified lines
1497{1497{
1498 struct gendisk *disk = dev_to_disk(dev);1498 struct gendisk *disk = dev_to_disk(dev);
1499 1499
1500 if (disk->devnode)1500 if (disk->fops->devnode)
1501 return disk->devnode(disk, mode);1501 return disk->fops->devnode(disk, mode);
1502 return NULL;1502 return NULL;
1503}1503}
1504 1504
drivers/block/pktcdvd.c+6−6
@@ -2679,6 +2679,11 @@ static unsigned int pkt_check_events(struct gendisk *disk, · 2678 unmodified lines
2679 return attached_disk->fops->check_events(attached_disk, clearing);2679 return attached_disk->fops->check_events(attached_disk, clearing);
2680}2680}
2681 2681
2682static char *pkt_devnode(struct gendisk *disk, umode_t *mode)
2683{
2684 return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name);
2685}
2686
2682static const struct block_device_operations pktcdvd_ops = {2687static const struct block_device_operations pktcdvd_ops = {
2683 .owner = THIS_MODULE,2688 .owner = THIS_MODULE,
2684 .open = pkt_open,2689 .open = pkt_open,
@@ -2686,13 +2691,9 @@ static const struct block_device_operations pktcdvd_ops = { · 1 unmodified line
2686 .ioctl = pkt_ioctl,2691 .ioctl = pkt_ioctl,
2687 .compat_ioctl = blkdev_compat_ptr_ioctl,2692 .compat_ioctl = blkdev_compat_ptr_ioctl,
2688 .check_events = pkt_check_events,2693 .check_events = pkt_check_events,
2694 .devnode = pkt_devnode,
2689};2695};
2690 2696
2691static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode)
2692{
2693 return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
2694}
2695
2696/*2697/*
2697 * Set up mapping from pktcdvd device to CD-ROM device.2698 * Set up mapping from pktcdvd device to CD-ROM device.
2698 */2699 */
@@ -2748,7 +2749,6 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) · 49 unmodified lines
2748 disk->fops = &pktcdvd_ops;2749 disk->fops = &pktcdvd_ops;
2749 disk->flags = GENHD_FL_REMOVABLE;2750 disk->flags = GENHD_FL_REMOVABLE;
2750 strcpy(disk->disk_name, pd->name);2751 strcpy(disk->disk_name, pd->name);
2751 disk->devnode = pktcdvd_devnode;
2752 disk->private_data = pd;2752 disk->private_data = pd;
2753 disk->queue = blk_alloc_queue(GFP_KERNEL);2753 disk->queue = blk_alloc_queue(GFP_KERNEL);
2754 if (!disk->queue)2754 if (!disk->queue)
include/linux/blkdev.h+1−0
@@ -1697,6 +1697,7 @@ struct block_device_operations { · 1696 unmodified lines
1697 void (*swap_slot_free_notify) (struct block_device *, unsigned long);1697 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
1698 int (*report_zones)(struct gendisk *, sector_t sector,1698 int (*report_zones)(struct gendisk *, sector_t sector,
1699 unsigned int nr_zones, report_zones_cb cb, void *data);1699 unsigned int nr_zones, report_zones_cb cb, void *data);
1700 char *(*devnode)(struct gendisk *disk, umode_t *mode);
1700 struct module *owner;1701 struct module *owner;
1701 const struct pr_ops *pr_ops;1702 const struct pr_ops *pr_ops;
1702};1703};
include/linux/genhd.h+0−1
@@ -191,7 +191,6 @@ struct gendisk { · 190 unmodified lines
191 * disks that can't be partitioned. */191 * disks that can't be partitioned. */
192 192
193 char disk_name[DISK_NAME_LEN]; /* name of major driver */193 char disk_name[DISK_NAME_LEN]; /* name of major driver */
194 char *(*devnode)(struct gendisk *gd, umode_t *mode);
195 194
196 unsigned short events; /* supported events */195 unsigned short events; /* supported events */
197 unsigned short event_flags; /* flags related to event processing */196 unsigned short event_flags; /* flags related to event processing */