Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

s390/hmcdrv: Remove commented out code

The create_class() api is retiring in favor of class_register() (see:
https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/).
The HMCDRV_DEV_CLASS define is hiding a use of create_class(), but it is
permanently disabled as it is commented out. To avoid supporting code
that is disabled, the suggestion is to remove all code hiding be behind
any #ifdef HMCDRV_DEV_CLASS.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20260308103255.757461-1-jkoolstra@xs4all.nl
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Jori Koolstra and committed by
Vasily Gorbik
052abf9a 2a0a1db5

+1 -113
+1 -113
drivers/s390/char/hmcdrv_dev.c
··· 30 30 #include "hmcdrv_dev.h" 31 31 #include "hmcdrv_ftp.h" 32 32 33 - /* If the following macro is defined, then the HMC device creates it's own 34 - * separated device class (and dynamically assigns a major number). If not 35 - * defined then the HMC device is assigned to the "misc" class devices. 36 - * 37 - #define HMCDRV_DEV_CLASS "hmcftp" 38 - */ 39 - 40 33 #define HMCDRV_DEV_NAME "hmcdrv" 41 34 #define HMCDRV_DEV_BUSY_DELAY 500 /* delay between -EBUSY trials in ms */ 42 35 #define HMCDRV_DEV_BUSY_RETRIES 3 /* number of retries on -EBUSY */ 43 36 44 37 struct hmcdrv_dev_node { 45 - 46 - #ifdef HMCDRV_DEV_CLASS 47 - struct cdev dev; /* character device structure */ 48 - umode_t mode; /* mode of device node (unused, zero) */ 49 - #else 50 38 struct miscdevice dev; /* "misc" device structure */ 51 - #endif 52 - 53 39 }; 54 40 55 41 static int hmcdrv_dev_open(struct inode *inode, struct file *fp); ··· 60 74 }; 61 75 62 76 static struct hmcdrv_dev_node hmcdrv_dev; /* HMC device struct (static) */ 63 - 64 - #ifdef HMCDRV_DEV_CLASS 65 - 66 - static struct class *hmcdrv_dev_class; /* device class pointer */ 67 - static dev_t hmcdrv_dev_no; /* device number (major/minor) */ 68 - 69 - /** 70 - * hmcdrv_dev_name() - provides a naming hint for a device node in /dev 71 - * @dev: device for which the naming/mode hint is 72 - * @mode: file mode for device node created in /dev 73 - * 74 - * See: devtmpfs.c, function devtmpfs_create_node() 75 - * 76 - * Return: recommended device file name in /dev 77 - */ 78 - static char *hmcdrv_dev_name(const struct device *dev, umode_t *mode) 79 - { 80 - char *nodename = NULL; 81 - const char *devname = dev_name(dev); /* kernel device name */ 82 - 83 - if (devname) 84 - nodename = kasprintf(GFP_KERNEL, "%s", devname); 85 - 86 - /* on device destroy (rmmod) the mode pointer may be NULL 87 - */ 88 - if (mode) 89 - *mode = hmcdrv_dev.mode; 90 - 91 - return nodename; 92 - } 93 - 94 - #endif /* HMCDRV_DEV_CLASS */ 95 77 96 78 /* 97 79 * open() ··· 230 276 */ 231 277 int hmcdrv_dev_init(void) 232 278 { 233 - int rc; 234 - 235 - #ifdef HMCDRV_DEV_CLASS 236 - struct device *dev; 237 - 238 - rc = alloc_chrdev_region(&hmcdrv_dev_no, 0, 1, HMCDRV_DEV_NAME); 239 - 240 - if (rc) 241 - goto out_err; 242 - 243 - cdev_init(&hmcdrv_dev.dev, &hmcdrv_dev_fops); 244 - hmcdrv_dev.dev.owner = THIS_MODULE; 245 - rc = cdev_add(&hmcdrv_dev.dev, hmcdrv_dev_no, 1); 246 - 247 - if (rc) 248 - goto out_unreg; 249 - 250 - /* At this point the character device exists in the kernel (see 251 - * /proc/devices), but not under /dev nor /sys/devices/virtual. So 252 - * we have to create an associated class (see /sys/class). 253 - */ 254 - hmcdrv_dev_class = class_create(HMCDRV_DEV_CLASS); 255 - 256 - if (IS_ERR(hmcdrv_dev_class)) { 257 - rc = PTR_ERR(hmcdrv_dev_class); 258 - goto out_devdel; 259 - } 260 - 261 - /* Finally a device node in /dev has to be established (as 'mkdev' 262 - * does from the command line). Notice that assignment of a device 263 - * node name/mode function is optional (only for mode != 0600). 264 - */ 265 - hmcdrv_dev.mode = 0; /* "unset" */ 266 - hmcdrv_dev_class->devnode = hmcdrv_dev_name; 267 - 268 - dev = device_create(hmcdrv_dev_class, NULL, hmcdrv_dev_no, NULL, 269 - "%s", HMCDRV_DEV_NAME); 270 - if (!IS_ERR(dev)) 271 - return 0; 272 - 273 - rc = PTR_ERR(dev); 274 - class_destroy(hmcdrv_dev_class); 275 - hmcdrv_dev_class = NULL; 276 - 277 - out_devdel: 278 - cdev_del(&hmcdrv_dev.dev); 279 - 280 - out_unreg: 281 - unregister_chrdev_region(hmcdrv_dev_no, 1); 282 - 283 - out_err: 284 - 285 - #else /* !HMCDRV_DEV_CLASS */ 286 279 hmcdrv_dev.dev.minor = MISC_DYNAMIC_MINOR; 287 280 hmcdrv_dev.dev.name = HMCDRV_DEV_NAME; 288 281 hmcdrv_dev.dev.fops = &hmcdrv_dev_fops; 289 282 hmcdrv_dev.dev.mode = 0; /* finally produces 0600 */ 290 - rc = misc_register(&hmcdrv_dev.dev); 291 - #endif /* HMCDRV_DEV_CLASS */ 292 - 293 - return rc; 283 + return misc_register(&hmcdrv_dev.dev); 294 284 } 295 285 296 286 /** ··· 242 344 */ 243 345 void hmcdrv_dev_exit(void) 244 346 { 245 - #ifdef HMCDRV_DEV_CLASS 246 - if (!IS_ERR_OR_NULL(hmcdrv_dev_class)) { 247 - device_destroy(hmcdrv_dev_class, hmcdrv_dev_no); 248 - class_destroy(hmcdrv_dev_class); 249 - } 250 - 251 - cdev_del(&hmcdrv_dev.dev); 252 - unregister_chrdev_region(hmcdrv_dev_no, 1); 253 - #else /* !HMCDRV_DEV_CLASS */ 254 347 misc_deregister(&hmcdrv_dev.dev); 255 - #endif /* HMCDRV_DEV_CLASS */ 256 348 }