There really isn't any good reason to stash a method directly into struct gendisk. Move it together with the other block device operations.
Unified · Split
| @@ -1497,8 +1497,8 @@ static char *block_devnode(struct device *dev, umode_t *mode, · 1496 unmodified lines | ||
| 1497 | 1497 | { |
| 1498 | 1498 | struct gendisk *disk = dev_to_disk(dev); |
| 1499 | 1499 | |
| 1500 | − if (disk->devnode) | |
| 1501 | − return disk->devnode(disk, mode); | |
| 1500 | + if (disk->fops->devnode) | |
| 1501 | + return disk->fops->devnode(disk, mode); | |
| 1502 | 1502 | return NULL; |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| @@ -2679,6 +2679,11 @@ static unsigned int pkt_check_events(struct gendisk *disk, · 2678 unmodified lines | ||
| 2679 | 2679 | return attached_disk->fops->check_events(attached_disk, clearing); |
| 2680 | 2680 | } |
| 2681 | 2681 | |
| 2682 | +static char *pkt_devnode(struct gendisk *disk, umode_t *mode) | |
| 2683 | +{ | |
| 2684 | + return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name); | |
| 2685 | +} | |
| 2686 | + | |
| 2682 | 2687 | static const struct block_device_operations pktcdvd_ops = { |
| 2683 | 2688 | .owner = THIS_MODULE, |
| 2684 | 2689 | .open = pkt_open, |
| @@ -2686,13 +2691,9 @@ static const struct block_device_operations pktcdvd_ops = { · 1 unmodified line | ||
| 2686 | 2691 | .ioctl = pkt_ioctl, |
| 2687 | 2692 | .compat_ioctl = blkdev_compat_ptr_ioctl, |
| 2688 | 2693 | .check_events = pkt_check_events, |
| 2694 | + .devnode = pkt_devnode, | |
| 2689 | 2695 | }; |
| 2690 | 2696 | |
| 2691 | −static 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 | 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 | 2749 | disk->fops = &pktcdvd_ops; |
| 2749 | 2750 | disk->flags = GENHD_FL_REMOVABLE; |
| 2750 | 2751 | strcpy(disk->disk_name, pd->name); |
| 2751 | − disk->devnode = pktcdvd_devnode; | |
| 2752 | 2752 | disk->private_data = pd; |
| 2753 | 2753 | disk->queue = blk_alloc_queue(GFP_KERNEL); |
| 2754 | 2754 | if (!disk->queue) |
| @@ -1697,6 +1697,7 @@ struct block_device_operations { · 1696 unmodified lines | ||
| 1697 | 1697 | void (*swap_slot_free_notify) (struct block_device *, unsigned long); |
| 1698 | 1698 | int (*report_zones)(struct gendisk *, sector_t sector, |
| 1699 | 1699 | unsigned int nr_zones, report_zones_cb cb, void *data); |
| 1700 | + char *(*devnode)(struct gendisk *disk, umode_t *mode); | |
| 1700 | 1701 | struct module *owner; |
| 1701 | 1702 | const struct pr_ops *pr_ops; |
| 1702 | 1703 | }; |
| @@ -191,7 +191,6 @@ struct gendisk { · 190 unmodified lines | ||
| 191 | 191 | * disks that can't be partitioned. */ |
| 192 | 192 | |
| 193 | 193 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ |
| 194 | − char *(*devnode)(struct gendisk *gd, umode_t *mode); | |
| 195 | 194 | |
| 196 | 195 | unsigned short events; /* supported events */ |
| 197 | 196 | unsigned short event_flags; /* flags related to event processing */ |