Skip to content

Commit 052abf9

Browse files
LATENTBOUNCEVasily Gorbik
authored andcommitted
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>
1 parent 2a0a1db commit 052abf9

1 file changed

Lines changed: 1 addition & 113 deletions

File tree

drivers/s390/char/hmcdrv_dev.c

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,12 @@
3030
#include "hmcdrv_dev.h"
3131
#include "hmcdrv_ftp.h"
3232

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-
4033
#define HMCDRV_DEV_NAME "hmcdrv"
4134
#define HMCDRV_DEV_BUSY_DELAY 500 /* delay between -EBUSY trials in ms */
4235
#define HMCDRV_DEV_BUSY_RETRIES 3 /* number of retries on -EBUSY */
4336

4437
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
5038
struct miscdevice dev; /* "misc" device structure */
51-
#endif
52-
5339
};
5440

5541
static int hmcdrv_dev_open(struct inode *inode, struct file *fp);
@@ -75,38 +61,6 @@ static const struct file_operations hmcdrv_dev_fops = {
7561

7662
static struct hmcdrv_dev_node hmcdrv_dev; /* HMC device struct (static) */
7763

78-
#ifdef HMCDRV_DEV_CLASS
79-
80-
static struct class *hmcdrv_dev_class; /* device class pointer */
81-
static dev_t hmcdrv_dev_no; /* device number (major/minor) */
82-
83-
/**
84-
* hmcdrv_dev_name() - provides a naming hint for a device node in /dev
85-
* @dev: device for which the naming/mode hint is
86-
* @mode: file mode for device node created in /dev
87-
*
88-
* See: devtmpfs.c, function devtmpfs_create_node()
89-
*
90-
* Return: recommended device file name in /dev
91-
*/
92-
static char *hmcdrv_dev_name(const struct device *dev, umode_t *mode)
93-
{
94-
char *nodename = NULL;
95-
const char *devname = dev_name(dev); /* kernel device name */
96-
97-
if (devname)
98-
nodename = kasprintf(GFP_KERNEL, "%s", devname);
99-
100-
/* on device destroy (rmmod) the mode pointer may be NULL
101-
*/
102-
if (mode)
103-
*mode = hmcdrv_dev.mode;
104-
105-
return nodename;
106-
}
107-
108-
#endif /* HMCDRV_DEV_CLASS */
109-
11064
/*
11165
* open()
11266
*/
@@ -276,83 +230,17 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
276230
*/
277231
int hmcdrv_dev_init(void)
278232
{
279-
int rc;
280-
281-
#ifdef HMCDRV_DEV_CLASS
282-
struct device *dev;
283-
284-
rc = alloc_chrdev_region(&hmcdrv_dev_no, 0, 1, HMCDRV_DEV_NAME);
285-
286-
if (rc)
287-
goto out_err;
288-
289-
cdev_init(&hmcdrv_dev.dev, &hmcdrv_dev_fops);
290-
hmcdrv_dev.dev.owner = THIS_MODULE;
291-
rc = cdev_add(&hmcdrv_dev.dev, hmcdrv_dev_no, 1);
292-
293-
if (rc)
294-
goto out_unreg;
295-
296-
/* At this point the character device exists in the kernel (see
297-
* /proc/devices), but not under /dev nor /sys/devices/virtual. So
298-
* we have to create an associated class (see /sys/class).
299-
*/
300-
hmcdrv_dev_class = class_create(HMCDRV_DEV_CLASS);
301-
302-
if (IS_ERR(hmcdrv_dev_class)) {
303-
rc = PTR_ERR(hmcdrv_dev_class);
304-
goto out_devdel;
305-
}
306-
307-
/* Finally a device node in /dev has to be established (as 'mkdev'
308-
* does from the command line). Notice that assignment of a device
309-
* node name/mode function is optional (only for mode != 0600).
310-
*/
311-
hmcdrv_dev.mode = 0; /* "unset" */
312-
hmcdrv_dev_class->devnode = hmcdrv_dev_name;
313-
314-
dev = device_create(hmcdrv_dev_class, NULL, hmcdrv_dev_no, NULL,
315-
"%s", HMCDRV_DEV_NAME);
316-
if (!IS_ERR(dev))
317-
return 0;
318-
319-
rc = PTR_ERR(dev);
320-
class_destroy(hmcdrv_dev_class);
321-
hmcdrv_dev_class = NULL;
322-
323-
out_devdel:
324-
cdev_del(&hmcdrv_dev.dev);
325-
326-
out_unreg:
327-
unregister_chrdev_region(hmcdrv_dev_no, 1);
328-
329-
out_err:
330-
331-
#else /* !HMCDRV_DEV_CLASS */
332233
hmcdrv_dev.dev.minor = MISC_DYNAMIC_MINOR;
333234
hmcdrv_dev.dev.name = HMCDRV_DEV_NAME;
334235
hmcdrv_dev.dev.fops = &hmcdrv_dev_fops;
335236
hmcdrv_dev.dev.mode = 0; /* finally produces 0600 */
336-
rc = misc_register(&hmcdrv_dev.dev);
337-
#endif /* HMCDRV_DEV_CLASS */
338-
339-
return rc;
237+
return misc_register(&hmcdrv_dev.dev);
340238
}
341239

342240
/**
343241
* hmcdrv_dev_exit() - destroys a HMC drive CD/DVD device
344242
*/
345243
void hmcdrv_dev_exit(void)
346244
{
347-
#ifdef HMCDRV_DEV_CLASS
348-
if (!IS_ERR_OR_NULL(hmcdrv_dev_class)) {
349-
device_destroy(hmcdrv_dev_class, hmcdrv_dev_no);
350-
class_destroy(hmcdrv_dev_class);
351-
}
352-
353-
cdev_del(&hmcdrv_dev.dev);
354-
unregister_chrdev_region(hmcdrv_dev_no, 1);
355-
#else /* !HMCDRV_DEV_CLASS */
356245
misc_deregister(&hmcdrv_dev.dev);
357-
#endif /* HMCDRV_DEV_CLASS */
358246
}

0 commit comments

Comments
 (0)