extcon: enable name set for extcon
authorPan Jianxin <jianxin.pan@amlogic.com>
Tue, 27 Jun 2017 09:07:08 +0000 (17:07 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Tue, 11 Jul 2017 09:32:56 +0000 (02:32 -0700)
PD#138714: enable name set for extcon
Without this change, name for extcon is always extcon0, extcon1, and
it can't be set by driver.

set extcon name before extcon_dev_register:
edev->name = "xxx";
dev_set_name(&edev->dev, "xxxxxx");

Change-Id: I22efce87f8fb50f1faf71d254cd03fe292ddb035
Signed-off-by: Pan Jianxin <jianxin.pan@amlogic.com>
drivers/extcon/extcon.c

index 7c1e3a7..e99ad94 100644 (file)
@@ -1075,6 +1075,20 @@ int extcon_dev_register(struct extcon_dev *edev)
        edev->dev.class = extcon_class;
        edev->dev.release = extcon_dev_release;
 
+#ifdef AMLOGIC_MODIFY
+       if (!edev->name) {
+               edev->name = dev_name(edev->dev.parent);
+               if (IS_ERR_OR_NULL(edev->name)) {
+                       dev_err(&edev->dev,
+                               "extcon device name is null\n");
+                       return -EINVAL;
+               }
+       }
+       if (!dev_name(&edev->dev))      {
+               dev_set_name(&edev->dev, "extcon%lu",
+                               (unsigned long)atomic_inc_return(&edev_no));
+       }
+#else
        edev->name = dev_name(edev->dev.parent);
        if (IS_ERR_OR_NULL(edev->name)) {
                dev_err(&edev->dev,
@@ -1083,6 +1097,7 @@ int extcon_dev_register(struct extcon_dev *edev)
        }
        dev_set_name(&edev->dev, "extcon%lu",
                        (unsigned long)atomic_inc_return(&edev_no));
+#endif
 
        if (edev->max_supported) {
                char buf[10];