All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] backlight: sky81452: Remove unneeded use of IS_ERR_VALUE() macro
@ 2015-08-17  7:59 Axel Lin
  2015-08-17  8:21 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2015-08-17  7:59 UTC (permalink / raw)
  To: linux-fbdev

IS_ERR_VALUE() makes sense only *if* there could be valid values in
negative error range.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/video/backlight/sky81452-backlight.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 052fa1b..d414c7a 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -65,7 +65,7 @@ static int sky81452_bl_update_status(struct backlight_device *bd)
 
 	if (brightness > 0) {
 		ret = regmap_write(regmap, SKY81452_REG0, brightness - 1);
-		if (IS_ERR_VALUE(ret))
+		if (ret < 0)
 			return ret;
 
 		return regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN,
@@ -87,12 +87,12 @@ static ssize_t sky81452_bl_store_enable(struct device *dev,
 	int ret;
 
 	ret = kstrtoul(buf, 16, &value);
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		return ret;
 
 	ret = regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN,
 					value << CTZ(SKY81452_EN));
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		return ret;
 
 	return count;
@@ -108,7 +108,7 @@ static ssize_t sky81452_bl_show_open_short(struct device *dev,
 
 	reg = !strcmp(attr->attr.name, "open") ? SKY81452_REG5 : SKY81452_REG4;
 	ret = regmap_read(regmap, reg, &value);
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		return ret;
 
 	if (value & SKY81452_SHRT) {
@@ -136,7 +136,7 @@ static ssize_t sky81452_bl_show_fault(struct device *dev,
 	int ret;
 
 	ret = regmap_read(regmap, SKY81452_REG4, &value);
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		return ret;
 
 	*buf = 0;
@@ -196,7 +196,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
 	pdata->gpio_enable = of_get_gpio(np, 0);
 
 	ret = of_property_count_u32_elems(np, "led-sources");
-	if (IS_ERR_VALUE(ret)) {
+	if (ret < 0) {
 		pdata->enable = SKY81452_EN >> CTZ(SKY81452_EN);
 	} else {
 		num_entry = ret;
@@ -205,7 +205,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
 
 		ret = of_property_read_u32_array(np, "led-sources", sources,
 					num_entry);
-		if (IS_ERR_VALUE(ret)) {
+		if (ret < 0) {
 			dev_err(dev, "led-sources node is invalid.\n");
 			return ERR_PTR(-EINVAL);
 		}
@@ -218,12 +218,12 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
 	ret = of_property_read_u32(np,
 			"skyworks,short-detection-threshold-volt",
 			&pdata->short_detection_threshold);
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		pdata->short_detection_threshold = 7;
 
 	ret = of_property_read_u32(np, "skyworks,current-limit-mA",
 			&pdata->boost_current_limit);
-	if (IS_ERR_VALUE(ret))
+	if (ret < 0)
 		pdata->boost_current_limit = 2750;
 
 	of_node_put(np);
@@ -278,14 +278,14 @@ static int sky81452_bl_probe(struct platform_device *pdev)
 	if (gpio_is_valid(pdata->gpio_enable)) {
 		ret = devm_gpio_request_one(dev, pdata->gpio_enable,
 					GPIOF_OUT_INIT_HIGH, "sky81452-en");
-		if (IS_ERR_VALUE(ret)) {
+		if (ret < 0) {
 			dev_err(dev, "failed to request GPIO. err=%d\n", ret);
 			return ret;
 		}
 	}
 
 	ret = sky81452_bl_init_device(regmap, pdata);
-	if (IS_ERR_VALUE(ret)) {
+	if (ret < 0) {
 		dev_err(dev, "failed to initialize. err=%d\n", ret);
 		return ret;
 	}
@@ -302,8 +302,8 @@ static int sky81452_bl_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, bd);
 
-	ret  = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group);
-	if (IS_ERR_VALUE(ret)) {
+	ret = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group);
+	if (ret < 0) {
 		dev_err(dev, "failed to create attribute. err=%d\n", ret);
 		return ret;
 	}
-- 
2.1.0




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

* Re: [PATCH] backlight: sky81452: Remove unneeded use of IS_ERR_VALUE() macro
  2015-08-17  7:59 [PATCH] backlight: sky81452: Remove unneeded use of IS_ERR_VALUE() macro Axel Lin
@ 2015-08-17  8:21 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2015-08-17  8:21 UTC (permalink / raw)
  To: linux-fbdev

On Mon, 17 Aug 2015, Axel Lin wrote:

> IS_ERR_VALUE() makes sense only *if* there could be valid values in
> negative error range.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/video/backlight/sky81452-backlight.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)

Applied, thanks.

> diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
> index 052fa1b..d414c7a 100644
> --- a/drivers/video/backlight/sky81452-backlight.c
> +++ b/drivers/video/backlight/sky81452-backlight.c
> @@ -65,7 +65,7 @@ static int sky81452_bl_update_status(struct backlight_device *bd)
>  
>  	if (brightness > 0) {
>  		ret = regmap_write(regmap, SKY81452_REG0, brightness - 1);
> -		if (IS_ERR_VALUE(ret))
> +		if (ret < 0)
>  			return ret;
>  
>  		return regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN,
> @@ -87,12 +87,12 @@ static ssize_t sky81452_bl_store_enable(struct device *dev,
>  	int ret;
>  
>  	ret = kstrtoul(buf, 16, &value);
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		return ret;
>  
>  	ret = regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN,
>  					value << CTZ(SKY81452_EN));
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		return ret;
>  
>  	return count;
> @@ -108,7 +108,7 @@ static ssize_t sky81452_bl_show_open_short(struct device *dev,
>  
>  	reg = !strcmp(attr->attr.name, "open") ? SKY81452_REG5 : SKY81452_REG4;
>  	ret = regmap_read(regmap, reg, &value);
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		return ret;
>  
>  	if (value & SKY81452_SHRT) {
> @@ -136,7 +136,7 @@ static ssize_t sky81452_bl_show_fault(struct device *dev,
>  	int ret;
>  
>  	ret = regmap_read(regmap, SKY81452_REG4, &value);
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		return ret;
>  
>  	*buf = 0;
> @@ -196,7 +196,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>  	pdata->gpio_enable = of_get_gpio(np, 0);
>  
>  	ret = of_property_count_u32_elems(np, "led-sources");
> -	if (IS_ERR_VALUE(ret)) {
> +	if (ret < 0) {
>  		pdata->enable = SKY81452_EN >> CTZ(SKY81452_EN);
>  	} else {
>  		num_entry = ret;
> @@ -205,7 +205,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>  
>  		ret = of_property_read_u32_array(np, "led-sources", sources,
>  					num_entry);
> -		if (IS_ERR_VALUE(ret)) {
> +		if (ret < 0) {
>  			dev_err(dev, "led-sources node is invalid.\n");
>  			return ERR_PTR(-EINVAL);
>  		}
> @@ -218,12 +218,12 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
>  	ret = of_property_read_u32(np,
>  			"skyworks,short-detection-threshold-volt",
>  			&pdata->short_detection_threshold);
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		pdata->short_detection_threshold = 7;
>  
>  	ret = of_property_read_u32(np, "skyworks,current-limit-mA",
>  			&pdata->boost_current_limit);
> -	if (IS_ERR_VALUE(ret))
> +	if (ret < 0)
>  		pdata->boost_current_limit = 2750;
>  
>  	of_node_put(np);
> @@ -278,14 +278,14 @@ static int sky81452_bl_probe(struct platform_device *pdev)
>  	if (gpio_is_valid(pdata->gpio_enable)) {
>  		ret = devm_gpio_request_one(dev, pdata->gpio_enable,
>  					GPIOF_OUT_INIT_HIGH, "sky81452-en");
> -		if (IS_ERR_VALUE(ret)) {
> +		if (ret < 0) {
>  			dev_err(dev, "failed to request GPIO. err=%d\n", ret);
>  			return ret;
>  		}
>  	}
>  
>  	ret = sky81452_bl_init_device(regmap, pdata);
> -	if (IS_ERR_VALUE(ret)) {
> +	if (ret < 0) {
>  		dev_err(dev, "failed to initialize. err=%d\n", ret);
>  		return ret;
>  	}
> @@ -302,8 +302,8 @@ static int sky81452_bl_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, bd);
>  
> -	ret  = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group);
> -	if (IS_ERR_VALUE(ret)) {
> +	ret = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group);
> +	if (ret < 0) {
>  		dev_err(dev, "failed to create attribute. err=%d\n", ret);
>  		return 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:[~2015-08-17  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17  7:59 [PATCH] backlight: sky81452: Remove unneeded use of IS_ERR_VALUE() macro Axel Lin
2015-08-17  8:21 ` Lee Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.