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
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+6−6
@@ -2679,6 +2679,11 @@ static unsigned int pkt_check_events(struct gendisk *disk, · 2678 unmodified lines
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,
@@ -2686,13 +2691,9 @@ static const struct block_device_operations pktcdvd_ops = { · 1 unmodified line
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) · 49 unmodified lines
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+1−0
@@ -1697,6 +1697,7 @@ struct block_device_operations { · 1696 unmodified lines
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+0−1
@@ -191,7 +191,6 @@ struct gendisk { · 190 unmodified lines
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 */