Skip to contentSkip to conversation

s390/char: Fix cdev_add usage

PATCH Applied Jean Delvare 2 participants 2 messages Sep 18, 2017 s390

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390/char: Fix cdev_add usage

Function cdev_add does set cdev->dev, so there is no point in setting it prior to calling this function.

Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>

---
Untested. Changes since v1 (2016-07-13):
* Improved description
* Added a few blank lines to make the code more readable

 drivers/s390/char/tape_class.c |    3 +--
 drivers/s390/char/vmlogrdr.c   |    4 ++--
 drivers/s390/char/vmur.c       |    4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/s390/char/tape_class.c +1 -2
@@ -68,9 +68,8 @@ struct tape_class_device *register_tape_
 
 	tcd->char_device->owner = fops->owner;
 	tcd->char_device->ops   = fops;
-	tcd->char_device->dev   = dev;
 
-	rc = cdev_add(tcd->char_device, tcd->char_device->dev, 1);
+	rc = cdev_add(tcd->char_device, dev, 1);
 	if (rc)
 		goto fail_with_cdev;
 
drivers/s390/char/vmlogrdr.c +2 -2
@@ -812,8 +812,8 @@ static int vmlogrdr_register_cdev(dev_t
 	}
 	vmlogrdr_cdev->owner = THIS_MODULE;
 	vmlogrdr_cdev->ops = &vmlogrdr_fops;
-	vmlogrdr_cdev->dev = dev;
-	rc = cdev_add(vmlogrdr_cdev, vmlogrdr_cdev->dev, MAXMINOR);
+
+	rc = cdev_add(vmlogrdr_cdev, dev, MAXMINOR);
 	if (!rc)
 		return 0;
 
drivers/s390/char/vmur.c +2 -2
@@ -892,12 +892,12 @@ static int ur_set_online(struct ccw_devi
 	}
 
 	urd->char_device->ops = &ur_fops;
-	urd->char_device->dev = MKDEV(major, minor);
 	urd->char_device->owner = ur_fops.owner;
 
-	rc = cdev_add(urd->char_device, urd->char_device->dev, 1);
+	rc = cdev_add(urd->char_device, MKDEV(major, minor), 1);
 	if (rc)
 		goto fail_free_cdev;
+
 	if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) {
 		if (urd->class == DEV_CLASS_UR_I)
 			sprintf(node_id, "vmrdr-%s", dev_name(&cdev->dev));
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw
Quoted 11 lines · Jean Delvare

Function cdev_add does set cdev->dev, so there is no point in setting it prior to calling this function.

Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>

---
Untested. Changes since v1 (2016-07-13):
* Improved description
* Added a few blank lines to make the code more readable

Quoted 4 lines
 drivers/s390/char/tape_class.c |    3 +--
 drivers/s390/char/vmlogrdr.c   |    4 ++--
 drivers/s390/char/vmur.c       |    4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

Applied, however without the extra blank lines ;)
Thanks!