mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mfd: wm831x: Remove redundant !pdata checks
@ 2017-05-15 12:51 Charles Keepax
  2017-05-22 10:49 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Keepax @ 2017-05-15 12:51 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel

Since a copy of the pdata was added into the core struct in
commit f6dd8449cd50 ("mfd: wm831x: Add basic device tree binding")
the pdata pointer in probe can no longer be NULL. As such remove
the redundant checks for this case.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/wm831x-core.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 13a4c11..e70d35e 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -1766,7 +1766,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 	}
 	wm831x->locked = 1;
 
-	if (pdata && pdata->pre_init) {
+	if (pdata->pre_init) {
 		ret = pdata->pre_init(wm831x);
 		if (ret != 0) {
 			dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
@@ -1774,19 +1774,17 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 		}
 	}
 
-	if (pdata) {
-		for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
-			if (!pdata->gpio_defaults[i])
-				continue;
+	for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
+		if (!pdata->gpio_defaults[i])
+			continue;
 
-			wm831x_reg_write(wm831x,
-					 WM831X_GPIO1_CONTROL + i,
-					 pdata->gpio_defaults[i] & 0xffff);
-		}
+		wm831x_reg_write(wm831x,
+				 WM831X_GPIO1_CONTROL + i,
+				 pdata->gpio_defaults[i] & 0xffff);
 	}
 
 	/* Multiply by 10 as we have many subdevices of the same type */
-	if (pdata && pdata->wm831x_num)
+	if (pdata->wm831x_num)
 		wm831x_num = pdata->wm831x_num * 10;
 	else
 		wm831x_num = -1;
@@ -1809,7 +1807,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 		ret = mfd_add_devices(wm831x->dev, wm831x_num,
 				      wm8311_devs, ARRAY_SIZE(wm8311_devs),
 				      NULL, 0, NULL);
-		if (!pdata || !pdata->disable_touch)
+		if (!pdata->disable_touch)
 			mfd_add_devices(wm831x->dev, wm831x_num,
 					touch_devs, ARRAY_SIZE(touch_devs),
 					NULL, 0, NULL);
@@ -1819,7 +1817,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 		ret = mfd_add_devices(wm831x->dev, wm831x_num,
 				      wm8312_devs, ARRAY_SIZE(wm8312_devs),
 				      NULL, 0, NULL);
-		if (!pdata || !pdata->disable_touch)
+		if (!pdata->disable_touch)
 			mfd_add_devices(wm831x->dev, wm831x_num,
 					touch_devs, ARRAY_SIZE(touch_devs),
 					NULL, 0, NULL);
@@ -1865,7 +1863,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 		dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n");
 	}
 
-	if (pdata && pdata->backlight) {
+	if (pdata->backlight) {
 		/* Treat errors as non-critical */
 		ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs,
 				      ARRAY_SIZE(backlight_devs), NULL,
@@ -1877,7 +1875,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
 
 	wm831x_otp_init(wm831x);
 
-	if (pdata && pdata->post_init) {
+	if (pdata->post_init) {
 		ret = pdata->post_init(wm831x);
 		if (ret != 0) {
 			dev_err(wm831x->dev, "post_init() failed: %d\n", ret);
-- 
2.1.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mfd: wm831x: Remove redundant !pdata checks
  2017-05-15 12:51 [PATCH] mfd: wm831x: Remove redundant !pdata checks Charles Keepax
@ 2017-05-22 10:49 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2017-05-22 10:49 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel

On Mon, 15 May 2017, Charles Keepax wrote:

> Since a copy of the pdata was added into the core struct in
> commit f6dd8449cd50 ("mfd: wm831x: Add basic device tree binding")
> the pdata pointer in probe can no longer be NULL. As such remove
> the redundant checks for this case.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/wm831x-core.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
> index 13a4c11..e70d35e 100644
> --- a/drivers/mfd/wm831x-core.c
> +++ b/drivers/mfd/wm831x-core.c
> @@ -1766,7 +1766,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  	}
>  	wm831x->locked = 1;
>  
> -	if (pdata && pdata->pre_init) {
> +	if (pdata->pre_init) {
>  		ret = pdata->pre_init(wm831x);
>  		if (ret != 0) {
>  			dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
> @@ -1774,19 +1774,17 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  		}
>  	}
>  
> -	if (pdata) {
> -		for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
> -			if (!pdata->gpio_defaults[i])
> -				continue;
> +	for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
> +		if (!pdata->gpio_defaults[i])
> +			continue;
>  
> -			wm831x_reg_write(wm831x,
> -					 WM831X_GPIO1_CONTROL + i,
> -					 pdata->gpio_defaults[i] & 0xffff);
> -		}
> +		wm831x_reg_write(wm831x,
> +				 WM831X_GPIO1_CONTROL + i,
> +				 pdata->gpio_defaults[i] & 0xffff);
>  	}
>  
>  	/* Multiply by 10 as we have many subdevices of the same type */
> -	if (pdata && pdata->wm831x_num)
> +	if (pdata->wm831x_num)
>  		wm831x_num = pdata->wm831x_num * 10;
>  	else
>  		wm831x_num = -1;
> @@ -1809,7 +1807,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  		ret = mfd_add_devices(wm831x->dev, wm831x_num,
>  				      wm8311_devs, ARRAY_SIZE(wm8311_devs),
>  				      NULL, 0, NULL);
> -		if (!pdata || !pdata->disable_touch)
> +		if (!pdata->disable_touch)
>  			mfd_add_devices(wm831x->dev, wm831x_num,
>  					touch_devs, ARRAY_SIZE(touch_devs),
>  					NULL, 0, NULL);
> @@ -1819,7 +1817,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  		ret = mfd_add_devices(wm831x->dev, wm831x_num,
>  				      wm8312_devs, ARRAY_SIZE(wm8312_devs),
>  				      NULL, 0, NULL);
> -		if (!pdata || !pdata->disable_touch)
> +		if (!pdata->disable_touch)
>  			mfd_add_devices(wm831x->dev, wm831x_num,
>  					touch_devs, ARRAY_SIZE(touch_devs),
>  					NULL, 0, NULL);
> @@ -1865,7 +1863,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  		dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n");
>  	}
>  
> -	if (pdata && pdata->backlight) {
> +	if (pdata->backlight) {
>  		/* Treat errors as non-critical */
>  		ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs,
>  				      ARRAY_SIZE(backlight_devs), NULL,
> @@ -1877,7 +1875,7 @@ int wm831x_device_init(struct wm831x *wm831x, int irq)
>  
>  	wm831x_otp_init(wm831x);
>  
> -	if (pdata && pdata->post_init) {
> +	if (pdata->post_init) {
>  		ret = pdata->post_init(wm831x);
>  		if (ret != 0) {
>  			dev_err(wm831x->dev, "post_init() failed: %d\n", ret);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-22 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 12:51 [PATCH] mfd: wm831x: Remove redundant !pdata checks Charles Keepax
2017-05-22 10:49 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome