[PATCH v1 06/14] extcon: Allow name to be assigned outside of the framework

Andy Shevchenko posted 14 patches 3 years ago
There is a newer version of this series
[PATCH v1 06/14] extcon: Allow name to be assigned outside of the framework
Posted by Andy Shevchenko 3 years ago
The documentation states that name of the extcon can be assigned
outside of the framework, however code does something different.
Fix the code to be aligned with the documentation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index ac84f4aafc69..14e66e21597f 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1269,10 +1269,10 @@ int extcon_dev_register(struct extcon_dev *edev)
 	edev->dev.class = extcon_class;
 	edev->dev.release = extcon_dev_release;
 
-	edev->name = dev_name(edev->dev.parent);
-	if (IS_ERR_OR_NULL(edev->name)) {
-		dev_err(&edev->dev,
-			"extcon device name is null\n");
+	if (!edev->name)
+		edev->name = dev_name(edev->dev.parent);
+	if (!edev->name) {
+		dev_err(&edev->dev, "extcon device name is null\n");
 		return -EINVAL;
 	}
 	dev_set_name(&edev->dev, "extcon%lu",
-- 
2.40.0.1.gaa8946217a0b
Re: [PATCH v1 06/14] extcon: Allow name to be assigned outside of the framework
Posted by Chanwoo Choi 3 years ago
On 23. 3. 22. 23:39, Andy Shevchenko wrote:
> The documentation states that name of the extcon can be assigned
> outside of the framework, however code does something different.
> Fix the code to be aligned with the documentation.

Actually, it is not possible to initialize the name outside of the framework
because commit 20f7b53dfc24 ("extcon: Move struct extcon_cable from header file to core")
moved the 'struct extcon_dev' into drivers/extcon/extcon.c in order to prevent
the direct accessing of struct extcon_dev.

Instead of this patch, need to change the description of struct extcon_dev.

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index ac84f4aafc69..14e66e21597f 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1269,10 +1269,10 @@ int extcon_dev_register(struct extcon_dev *edev)
>  	edev->dev.class = extcon_class;
>  	edev->dev.release = extcon_dev_release;
>  
> -	edev->name = dev_name(edev->dev.parent);
> -	if (IS_ERR_OR_NULL(edev->name)) {
> -		dev_err(&edev->dev,
> -			"extcon device name is null\n");
> +	if (!edev->name)
> +		edev->name = dev_name(edev->dev.parent);
> +	if (!edev->name) {
> +		dev_err(&edev->dev, "extcon device name is null\n");
>  		return -EINVAL;
>  	}
>  	dev_set_name(&edev->dev, "extcon%lu",

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi