[PATCH 06/14] platform/chrome: utilize new device_add_cdev helper function

Logan Gunthorpe logang at deltatee.com
Mon Feb 20 21:00:45 PST 2017


Signed-off-by: Logan Gunthorpe <logang at deltatee.com>
---
 drivers/platform/chrome/cros_ec_dev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_dev.c b/drivers/platform/chrome/cros_ec_dev.c
index 47268ec..658fb99 100644
--- a/drivers/platform/chrome/cros_ec_dev.c
+++ b/drivers/platform/chrome/cros_ec_dev.c
@@ -388,7 +388,6 @@ static int ec_device_probe(struct platform_device *pdev)
 	int retval = -ENOMEM;
 	struct device *dev = &pdev->dev;
 	struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
-	dev_t devno = MKDEV(ec_major, pdev->id);
 	struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
 
 	if (!ec)
@@ -401,6 +400,7 @@ static int ec_device_probe(struct platform_device *pdev)
 	ec->features[0] = -1U; /* Not cached yet */
 	ec->features[1] = -1U; /* Not cached yet */
 	device_initialize(&ec->class_dev);
+	ec->class_dev.devt = MKDEV(ec_major, pdev->id);
 	cdev_init(&ec->cdev, &fops);
 
 	/*
@@ -408,8 +408,7 @@ static int ec_device_probe(struct platform_device *pdev)
 	 * Link cdev to the class device to be sure device is not used
 	 * before unbinding it.
 	 */
-	ec->cdev.kobj.parent = &ec->class_dev.kobj;
-	retval = cdev_add(&ec->cdev, devno, 1);
+	retval = device_add_cdev(&ec->class_dev, &ec->cdev);
 	if (retval) {
 		dev_err(dev, ": failed to add character device\n");
 		goto cdev_add_failed;
@@ -420,7 +419,6 @@ static int ec_device_probe(struct platform_device *pdev)
 	 * Link to the character device for creating the /dev entry
 	 * in devtmpfs.
 	 */
-	ec->class_dev.devt = ec->cdev.dev;
 	ec->class_dev.class = &cros_class;
 	ec->class_dev.parent = dev;
 	ec->class_dev.release = __remove;
-- 
2.1.4




More information about the linux-mtd mailing list