[PATCH v4 1/4] extcon: Removed redundant null checking for class

Bumwoo Lee posted 4 patches 3 years, 1 month ago
There is a newer version of this series
[PATCH v4 1/4] extcon: Removed redundant null checking for class
Posted by Bumwoo Lee 3 years, 1 month ago
create_extcon_class() is already Null checking.

Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
---
 drivers/extcon/extcon.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index e1c71359b605..adcf01132f70 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1012,12 +1012,13 @@ ATTRIBUTE_GROUPS(extcon);
 
 static int create_extcon_class(void)
 {
-	if (!extcon_class) {
-		extcon_class = class_create(THIS_MODULE, "extcon");
-		if (IS_ERR(extcon_class))
-			return PTR_ERR(extcon_class);
-		extcon_class->dev_groups = extcon_groups;
-	}
+	if (extcon_class)
+		return 0;
+
+	extcon_class = class_create(THIS_MODULE, "extcon");
+	if (IS_ERR(extcon_class))
+		return PTR_ERR(extcon_class);
+	extcon_class->dev_groups = extcon_groups;
 
 	return 0;
 }
@@ -1088,11 +1089,9 @@ int extcon_dev_register(struct extcon_dev *edev)
 	int ret, index = 0;
 	static atomic_t edev_no = ATOMIC_INIT(-1);
 
-	if (!extcon_class) {
-		ret = create_extcon_class();
-		if (ret < 0)
-			return ret;
-	}
+	ret = create_extcon_class();
+	if (ret < 0)
+		return ret;
 
 	if (!edev || !edev->supported_cable)
 		return -EINVAL;
-- 
2.35.1
Re: [PATCH v4 1/4] extcon: Removed redundant null checking for class
Posted by Chanwoo Choi 3 years ago
On 23. 3. 2. 18:01, Bumwoo Lee wrote:
> create_extcon_class() is already Null checking.
> 
> Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
> ---
>  drivers/extcon/extcon.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index e1c71359b605..adcf01132f70 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1012,12 +1012,13 @@ ATTRIBUTE_GROUPS(extcon);
>  
>  static int create_extcon_class(void)
>  {
> -	if (!extcon_class) {
> -		extcon_class = class_create(THIS_MODULE, "extcon");
> -		if (IS_ERR(extcon_class))
> -			return PTR_ERR(extcon_class);
> -		extcon_class->dev_groups = extcon_groups;
> -	}
> +	if (extcon_class)
> +		return 0;
> +
> +	extcon_class = class_create(THIS_MODULE, "extcon");
> +	if (IS_ERR(extcon_class))
> +		return PTR_ERR(extcon_class);
> +	extcon_class->dev_groups = extcon_groups;
>  
>  	return 0;
>  }
> @@ -1088,11 +1089,9 @@ int extcon_dev_register(struct extcon_dev *edev)
>  	int ret, index = 0;
>  	static atomic_t edev_no = ATOMIC_INIT(-1);
>  
> -	if (!extcon_class) {
> -		ret = create_extcon_class();
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = create_extcon_class();
> +	if (ret < 0)
> +		return ret;
>  
>  	if (!edev || !edev->supported_cable)
>  		return -EINVAL;


Applied it with following edited title:
On later, please write the patch title in command form.

extcon: Remove redundant null checking for class

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi
RE: [PATCH v4 1/4] extcon: Removed redundant null checking for class
Posted by MyungJoo Ham 3 years, 1 month ago
> create_extcon_class() is already Null checking.
> 
> Signed-off-by: Bumwoo Lee <bw365.lee@samsung.com>
> ---
>  drivers/extcon/extcon.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index e1c71359b605..adcf01132f70 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1012,12 +1012,13 @@ ATTRIBUTE_GROUPS(extcon);
>  

Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

Chanwoo, please take a look at this series.