drivers: s390: hmcdrv_dev: remove commented out code
PATCH 1/1 drivers: s390: hmcdrv_dev: 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.
--- drivers/s390/char/hmcdrv_dev.c | 114 +-------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-)
drivers/s390/char/hmcdrv_dev.c +1 -113
@@ -30,26 +30,12 @@#include "hmcdrv_dev.h" #include "hmcdrv_ftp.h" -/* If the following macro is defined, then the HMC device creates it's own -* separated device class (and dynamically assigns a major number). If not -* defined then the HMC device is assigned to the "misc" class devices. -* -#define HMCDRV_DEV_CLASS "hmcftp" -*/ -#define HMCDRV_DEV_NAME "hmcdrv"#define HMCDRV_DEV_BUSY_DELAY 500/* delay between -EBUSY trials in ms */ #define HMCDRV_DEV_BUSY_RETRIES 3/* number of retries on -EBUSY */ struct hmcdrv_dev_node { - -#ifdef HMCDRV_DEV_CLASS -struct cdev dev;/* character device structure */ -umode_t mode;/* mode of device node (unused, zero) */ -#else struct miscdevice dev;/* "misc" device structure */ -#endif - };static int hmcdrv_dev_open (struct inode *inode,struct file *fp);
@@ -75,38 +61,6 @@ static const struct file_operations hmcdrv_dev_fops = {static struct hmcdrv_dev_node hmcdrv_dev;/* HMC device struct (static) */ -#ifdef HMCDRV_DEV_CLASS - -static struct class *hmcdrv_dev_class;/* device class pointer */ -static dev_t hmcdrv_dev_no;/* device number (major/minor) */ - -/** -* hmcdrv_dev_name() - provides a naming hint for a device node in /dev -* @dev: device for which the naming/mode hint is -* @mode: file mode for device node created in /dev -* -* See: devtmpfs.c, function devtmpfs_create_node() -* -* Return: recommended device file name in /dev -*/ -static char *hmcdrv_dev_name (const struct device *dev,umode_t *mode) -{ -char *nodename =NULL ; -const char *devname =dev_name (dev);/* kernel device name */ - -if (devname) - nodename =kasprintf (GFP_KERNEL ,"%s" , devname); - -/* on device destroy (rmmod) the mode pointer may be NULL -*/ -if (mode) - *mode = hmcdrv_dev.mode; - -return nodename; -} - -#endif /* HMCDRV_DEV_CLASS */ -/* * open() */
@@ -276,67 +230,11 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,*/ int hmcdrv_dev_init (void ) { -int rc; - -#ifdef HMCDRV_DEV_CLASS -struct device *dev; - - rc =alloc_chrdev_region (&hmcdrv_dev_no,0 ,1 ,HMCDRV_DEV_NAME ); - -if (rc) - goto out_err; - -cdev_init (&hmcdrv_dev.dev, &hmcdrv_dev_fops); - hmcdrv_dev.dev.owner =THIS_MODULE ; - rc =cdev_add (&hmcdrv_dev.dev, hmcdrv_dev_no,1 ); - -if (rc) - goto out_unreg; - -/* At this point the character device exists in the kernel (see -* /proc/devices), but not under /dev nor /sys/devices/virtual. So -* we have to create an associated class (see /sys/class). -*/ - hmcdrv_dev_class =class_create (HMCDRV_DEV_CLASS ); - -if (IS_ERR (hmcdrv_dev_class)) { - rc =PTR_ERR (hmcdrv_dev_class); - goto out_devdel; - } - -/* Finally a device node in /dev has to be established (as 'mkdev' -* does from the command line). Notice that assignment of a device -* node name/mode function is optional (only for mode != 0600). -*/ - hmcdrv_dev.mode =0 ;/* "unset" */ - hmcdrv_dev_class->devnode = hmcdrv_dev_name; - - dev =device_create (hmcdrv_dev_class,NULL , hmcdrv_dev_no,NULL , -"%s" ,HMCDRV_DEV_NAME ); -if (!IS_ERR (dev)) -return 0 ; - - rc =PTR_ERR (dev); -class_destroy (hmcdrv_dev_class); - hmcdrv_dev_class =NULL ; - -out_devdel: -cdev_del (&hmcdrv_dev.dev); - -out_unreg: -unregister_chrdev_region (hmcdrv_dev_no,1 ); - -out_err: - -#else /* !HMCDRV_DEV_CLASS */ hmcdrv_dev.dev.minor =MISC_DYNAMIC_MINOR ; hmcdrv_dev.dev.name =HMCDRV_DEV_NAME ; hmcdrv_dev.dev.fops = &hmcdrv_dev_fops; hmcdrv_dev.dev.mode =0 ;/* finally produces 0600 */ - rc =misc_register (&hmcdrv_dev.dev); -#endif /* HMCDRV_DEV_CLASS */ - -return rc; +return misc_register (&hmcdrv_dev.dev); }/**
@@ -344,15 +242,5 @@ int hmcdrv_dev_init(void)*/ void hmcdrv_dev_exit (void ) { -#ifdef HMCDRV_DEV_CLASS -if (!IS_ERR_OR_NULL (hmcdrv_dev_class)) { -device_destroy (hmcdrv_dev_class, hmcdrv_dev_no); -class_destroy (hmcdrv_dev_class); - } - -cdev_del (&hmcdrv_dev.dev); -unregister_chrdev_region (hmcdrv_dev_no,1 ); -#else /* !HMCDRV_DEV_CLASS */ misc_deregister (&hmcdrv_dev.dev); -#endif /* HMCDRV_DEV_CLASS */ }
base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1
Signature · 1 line
2.53.0
Quoted 7 lines · Jori Koolstra
The
create_class()api is retiring in favor ofclass_register()(see:
https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/).
TheHMCDRV_DEV_CLASSdefine is hiding a use ofcreate_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 #ifdefHMCDRV_DEV_CLASS.
Quoted 5 lines
Suggested-by Greg Kroah-Hartman <[email protected]>Signed-off-by Jori Koolstra <[email protected]>--- drivers/s390/char/hmcdrv_dev.c | 114 +-------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-)
Quoted 7 lines · Jori Koolstra
The
create_class()api is retiring in favor ofclass_register()(see:
https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/).
TheHMCDRV_DEV_CLASSdefine is hiding a use ofcreate_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 #ifdefHMCDRV_DEV_CLASS.
Quoted 5 lines
Suggested-by Greg Kroah-Hartman <[email protected]>Signed-off-by Jori Koolstra <[email protected]>--- drivers/s390/char/hmcdrv_dev.c | 114 +-------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-)
Vasily, will you pick this one up?
Quoted 7 lines · Jori Koolstra
The
create_class()api is retiring in favor ofclass_register()(see:
https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/).
TheHMCDRV_DEV_CLASSdefine is hiding a use ofcreate_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 #ifdefHMCDRV_DEV_CLASS.
Quoted 5 lines
Suggested-by Greg Kroah-Hartman <[email protected]>Signed-off-by Jori Koolstra <[email protected]>--- drivers/s390/char/hmcdrv_dev.c | 114 +-------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-)
Applied, thank you!