Re: [PATCH v4 004/115] leds: qcom-lpg: Consistenly use dev_err_probe() in .probe()'s error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 06 Dec 2023, Uwe Kleine-König wrote:

> One error path already used dev_err_probe(). Adapt the other error paths
> that emit an error message to also use this function for consistency and
> slightly simplified code.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> ---
> Note this patch was already sent out individually, find it at
> https://lore.kernel.org/linux-pwm/20231130074133.969806-3-u.kleine-koenig@xxxxxxxxxxxxxx
> 
>  drivers/leds/rgb/leds-qcom-lpg.c | 40 ++++++++++++++------------------
>  1 file changed, 17 insertions(+), 23 deletions(-)

Acked-by: Lee Jones <lee@xxxxxxxxxx>

> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index f5805fd0eb21..54c90ee43ef8 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -552,9 +552,9 @@ static int lpg_parse_dtest(struct lpg *lpg)
>  		ret = count;
>  		goto err_malformed;
>  	} else if (count != lpg->data->num_channels * 2) {
> -		dev_err(lpg->dev, "qcom,dtest needs to be %d items\n",
> -			lpg->data->num_channels * 2);
> -		return -EINVAL;
> +		return dev_err_probe(lpg->dev, -EINVAL,
> +				     "qcom,dtest needs to be %d items\n",
> +				     lpg->data->num_channels * 2);
>  	}
>  
>  	for (i = 0; i < lpg->data->num_channels; i++) {
> @@ -574,8 +574,7 @@ static int lpg_parse_dtest(struct lpg *lpg)
>  	return 0;
>  
>  err_malformed:
> -	dev_err(lpg->dev, "malformed qcom,dtest\n");
> -	return ret;
> +	return dev_err_probe(lpg->dev, ret, "malformed qcom,dtest\n");
>  }
>  
>  static void lpg_apply_dtest(struct lpg_channel *chan)
> @@ -1097,7 +1096,7 @@ static int lpg_add_pwm(struct lpg *lpg)
>  
>  	ret = devm_pwmchip_add(lpg->dev, &lpg->pwm);
>  	if (ret)
> -		dev_err(lpg->dev, "failed to add PWM chip: ret %d\n", ret);
> +		dev_err_probe(lpg->dev, ret, "failed to add PWM chip\n");
>  
>  	return ret;
>  }
> @@ -1111,19 +1110,16 @@ static int lpg_parse_channel(struct lpg *lpg, struct device_node *np,
>  	int ret;
>  
>  	ret = of_property_read_u32(np, "reg", &reg);
> -	if (ret || !reg || reg > lpg->num_channels) {
> -		dev_err(lpg->dev, "invalid \"reg\" of %pOFn\n", np);
> -		return -EINVAL;
> -	}
> +	if (ret || !reg || reg > lpg->num_channels)
> +		return dev_err_probe(lpg->dev, -EINVAL, "invalid \"reg\" of %pOFn\n", np);
>  
>  	chan = &lpg->channels[reg - 1];
>  	chan->in_use = true;
>  
>  	ret = of_property_read_u32(np, "color", &color);
> -	if (ret < 0 && ret != -EINVAL) {
> -		dev_err(lpg->dev, "failed to parse \"color\" of %pOF\n", np);
> -		return ret;
> -	}
> +	if (ret < 0 && ret != -EINVAL)
> +		return dev_err_probe(lpg->dev, ret,
> +				     "failed to parse \"color\" of %pOF\n", np);
>  
>  	chan->color = color;
>  
> @@ -1146,10 +1142,9 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
>  	int i;
>  
>  	ret = of_property_read_u32(np, "color", &color);
> -	if (ret < 0 && ret != -EINVAL) {
> -		dev_err(lpg->dev, "failed to parse \"color\" of %pOF\n", np);
> -		return ret;
> -	}
> +	if (ret < 0 && ret != -EINVAL)
> +		return dev_err_probe(lpg->dev, ret,
> +			      "failed to parse \"color\" of %pOF\n", np);
>  
>  	if (color == LED_COLOR_ID_RGB)
>  		num_channels = of_get_available_child_count(np);
> @@ -1226,7 +1221,7 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
>  	else
>  		ret = devm_led_classdev_register_ext(lpg->dev, &led->cdev, &init_data);
>  	if (ret)
> -		dev_err(lpg->dev, "unable to register %s\n", cdev->name);
> +		dev_err_probe(lpg->dev, ret, "unable to register %s\n", cdev->name);
>  
>  	return ret;
>  }
> @@ -1272,10 +1267,9 @@ static int lpg_init_triled(struct lpg *lpg)
>  
>  	if (lpg->triled_has_src_sel) {
>  		ret = of_property_read_u32(np, "qcom,power-source", &lpg->triled_src);
> -		if (ret || lpg->triled_src == 2 || lpg->triled_src > 3) {
> -			dev_err(lpg->dev, "invalid power source\n");
> -			return -EINVAL;
> -		}
> +		if (ret || lpg->triled_src == 2 || lpg->triled_src > 3)
> +			return dev_err_probe(lpg->dev, -EINVAL,
> +					     "invalid power source\n");
>  	}
>  
>  	/* Disable automatic trickle charge LED */
> -- 
> 2.42.0
> 

-- 
Lee Jones [李琼斯]




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux