All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	kernel@collabora.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v2 3/4] Input: adc-keys - Use dev_err_probe in probe function
Date: Tue, 16 Dec 2025 09:45:33 +0100	[thread overview]
Message-ID: <20251216084533c8786b5d@mail.local> (raw)
In-Reply-To: <20251215-rock4d-audio-v2-3-82a61de39b4c@collabora.com>

On 15/12/2025 13:29:31+0100, Nicolas Frattaroli wrote:
> Rework the probe function, and functions called by the probe function,
> to use dev_err_probe for error logging.
> 
> While at it, also do some minor style cleanups, like not error logging
> on -ENOMEM and using ! instead of == 0.
> 
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/input/keyboard/adc-keys.c | 53 ++++++++++++++++-----------------------
>  1 file changed, 21 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc-keys.c
> index 62376f34f7d0..6f2ddcecea99 100644
> --- a/drivers/input/keyboard/adc-keys.c
> +++ b/drivers/input/keyboard/adc-keys.c
> @@ -74,10 +74,8 @@ static int adc_keys_load_keymap(struct device *dev, struct adc_keys_state *st)
>  	int i;
>  
>  	st->num_keys = device_get_child_node_count(dev);
> -	if (st->num_keys == 0) {
> -		dev_err(dev, "keymap is missing\n");
> -		return -EINVAL;
> -	}
> +	if (!st->num_keys)
> +		return dev_err_probe(dev, -EINVAL, "keymap is missing\n");
>  
>  	map = devm_kmalloc_array(dev, st->num_keys, sizeof(*map), GFP_KERNEL);
>  	if (!map)
> @@ -86,17 +84,16 @@ static int adc_keys_load_keymap(struct device *dev, struct adc_keys_state *st)
>  	i = 0;
>  	device_for_each_child_node_scoped(dev, child) {
>  		if (fwnode_property_read_u32(child, "press-threshold-microvolt",
> -					     &map[i].voltage)) {
> -			dev_err(dev, "Key with invalid or missing voltage\n");
> -			return -EINVAL;
> -		}
> +					     &map[i].voltage))
> +			return dev_err_probe(dev, -EINVAL,
> +					     "Key with invalid or missing voltage\n");
> +
>  		map[i].voltage /= 1000;
>  
>  		if (fwnode_property_read_u32(child, "linux,code",
> -					     &map[i].code)) {
> -			dev_err(dev, "Key with invalid or missing linux,code\n");
> -			return -EINVAL;
> -		}
> +					     &map[i].code))
> +			return dev_err_probe(dev, -EINVAL,
> +					     "Key with invalid or missing linux,code\n");
>  
>  		if (fwnode_property_read_u32(child, "linux,input-type",
>  					     &map[i].type))
> @@ -129,7 +126,8 @@ static int adc_keys_probe(struct platform_device *pdev)
>  
>  	st->channel = devm_iio_channel_get(dev, "buttons");
>  	if (IS_ERR(st->channel))
> -		return PTR_ERR(st->channel);
> +		return dev_err_probe(dev, PTR_ERR(st->channel),
> +				     "Could not get iio channel\n");
>  
>  	if (!st->channel->indio_dev)
>  		return -ENXIO;
> @@ -138,16 +136,13 @@ static int adc_keys_probe(struct platform_device *pdev)
>  	if (error < 0)
>  		return error;
>  
> -	if (type != IIO_VOLTAGE) {
> -		dev_err(dev, "Incompatible channel type %d\n", type);
> -		return -EINVAL;
> -	}
> +	if (type != IIO_VOLTAGE)
> +		return dev_err_probe(dev, -EINVAL, "Incompatible channel type %d\n", type);
>  
>  	if (device_property_read_u32(dev, "keyup-threshold-microvolt",
> -				     &st->keyup_voltage)) {
> -		dev_err(dev, "Invalid or missing keyup voltage\n");
> -		return -EINVAL;
> -	}
> +				     &st->keyup_voltage))
> +		return dev_err_probe(dev, -EINVAL, "Invalid or missing keyup voltage\n");
> +
>  	st->keyup_voltage /= 1000;
>  
>  	error = adc_keys_load_keymap(dev, st);
> @@ -155,10 +150,8 @@ static int adc_keys_probe(struct platform_device *pdev)
>  		return error;
>  
>  	input = devm_input_allocate_device(dev);
> -	if (!input) {
> -		dev_err(dev, "failed to allocate input device\n");
> +	if (!input)
>  		return -ENOMEM;
> -	}
>  
>  	input_set_drvdata(input, st);
>  
> @@ -178,19 +171,15 @@ static int adc_keys_probe(struct platform_device *pdev)
>  
>  
>  	error = input_setup_polling(input, adc_keys_poll);
> -	if (error) {
> -		dev_err(dev, "Unable to set up polling: %d\n", error);
> -		return error;
> -	}
> +	if (error)
> +		return dev_err_probe(dev, error, "Unable to set up polling\n");
>  
>  	if (!device_property_read_u32(dev, "poll-interval", &value))
>  		input_set_poll_interval(input, value);
>  
>  	error = input_register_device(input);
> -	if (error) {
> -		dev_err(dev, "Unable to register input device: %d\n", error);
> -		return error;
> -	}
> +	if (error)
> +		return dev_err_probe(dev, error, "Unable to register input device\n");
>  
>  	return 0;
>  }
> 
> -- 
> 2.52.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	kernel@collabora.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v2 3/4] Input: adc-keys - Use dev_err_probe in probe function
Date: Tue, 16 Dec 2025 09:45:33 +0100	[thread overview]
Message-ID: <20251216084533c8786b5d@mail.local> (raw)
In-Reply-To: <20251215-rock4d-audio-v2-3-82a61de39b4c@collabora.com>

On 15/12/2025 13:29:31+0100, Nicolas Frattaroli wrote:
> Rework the probe function, and functions called by the probe function,
> to use dev_err_probe for error logging.
> 
> While at it, also do some minor style cleanups, like not error logging
> on -ENOMEM and using ! instead of == 0.
> 
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/input/keyboard/adc-keys.c | 53 ++++++++++++++++-----------------------
>  1 file changed, 21 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc-keys.c
> index 62376f34f7d0..6f2ddcecea99 100644
> --- a/drivers/input/keyboard/adc-keys.c
> +++ b/drivers/input/keyboard/adc-keys.c
> @@ -74,10 +74,8 @@ static int adc_keys_load_keymap(struct device *dev, struct adc_keys_state *st)
>  	int i;
>  
>  	st->num_keys = device_get_child_node_count(dev);
> -	if (st->num_keys == 0) {
> -		dev_err(dev, "keymap is missing\n");
> -		return -EINVAL;
> -	}
> +	if (!st->num_keys)
> +		return dev_err_probe(dev, -EINVAL, "keymap is missing\n");
>  
>  	map = devm_kmalloc_array(dev, st->num_keys, sizeof(*map), GFP_KERNEL);
>  	if (!map)
> @@ -86,17 +84,16 @@ static int adc_keys_load_keymap(struct device *dev, struct adc_keys_state *st)
>  	i = 0;
>  	device_for_each_child_node_scoped(dev, child) {
>  		if (fwnode_property_read_u32(child, "press-threshold-microvolt",
> -					     &map[i].voltage)) {
> -			dev_err(dev, "Key with invalid or missing voltage\n");
> -			return -EINVAL;
> -		}
> +					     &map[i].voltage))
> +			return dev_err_probe(dev, -EINVAL,
> +					     "Key with invalid or missing voltage\n");
> +
>  		map[i].voltage /= 1000;
>  
>  		if (fwnode_property_read_u32(child, "linux,code",
> -					     &map[i].code)) {
> -			dev_err(dev, "Key with invalid or missing linux,code\n");
> -			return -EINVAL;
> -		}
> +					     &map[i].code))
> +			return dev_err_probe(dev, -EINVAL,
> +					     "Key with invalid or missing linux,code\n");
>  
>  		if (fwnode_property_read_u32(child, "linux,input-type",
>  					     &map[i].type))
> @@ -129,7 +126,8 @@ static int adc_keys_probe(struct platform_device *pdev)
>  
>  	st->channel = devm_iio_channel_get(dev, "buttons");
>  	if (IS_ERR(st->channel))
> -		return PTR_ERR(st->channel);
> +		return dev_err_probe(dev, PTR_ERR(st->channel),
> +				     "Could not get iio channel\n");
>  
>  	if (!st->channel->indio_dev)
>  		return -ENXIO;
> @@ -138,16 +136,13 @@ static int adc_keys_probe(struct platform_device *pdev)
>  	if (error < 0)
>  		return error;
>  
> -	if (type != IIO_VOLTAGE) {
> -		dev_err(dev, "Incompatible channel type %d\n", type);
> -		return -EINVAL;
> -	}
> +	if (type != IIO_VOLTAGE)
> +		return dev_err_probe(dev, -EINVAL, "Incompatible channel type %d\n", type);
>  
>  	if (device_property_read_u32(dev, "keyup-threshold-microvolt",
> -				     &st->keyup_voltage)) {
> -		dev_err(dev, "Invalid or missing keyup voltage\n");
> -		return -EINVAL;
> -	}
> +				     &st->keyup_voltage))
> +		return dev_err_probe(dev, -EINVAL, "Invalid or missing keyup voltage\n");
> +
>  	st->keyup_voltage /= 1000;
>  
>  	error = adc_keys_load_keymap(dev, st);
> @@ -155,10 +150,8 @@ static int adc_keys_probe(struct platform_device *pdev)
>  		return error;
>  
>  	input = devm_input_allocate_device(dev);
> -	if (!input) {
> -		dev_err(dev, "failed to allocate input device\n");
> +	if (!input)
>  		return -ENOMEM;
> -	}
>  
>  	input_set_drvdata(input, st);
>  
> @@ -178,19 +171,15 @@ static int adc_keys_probe(struct platform_device *pdev)
>  
>  
>  	error = input_setup_polling(input, adc_keys_poll);
> -	if (error) {
> -		dev_err(dev, "Unable to set up polling: %d\n", error);
> -		return error;
> -	}
> +	if (error)
> +		return dev_err_probe(dev, error, "Unable to set up polling\n");
>  
>  	if (!device_property_read_u32(dev, "poll-interval", &value))
>  		input_set_poll_interval(input, value);
>  
>  	error = input_register_device(input);
> -	if (error) {
> -		dev_err(dev, "Unable to register input device: %d\n", error);
> -		return error;
> -	}
> +	if (error)
> +		return dev_err_probe(dev, error, "Unable to register input device\n");
>  
>  	return 0;
>  }
> 
> -- 
> 2.52.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2025-12-16  8:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 12:29 [PATCH v2 0/4] ROCK 4D audio enablement Nicolas Frattaroli
2025-12-15 12:29 ` Nicolas Frattaroli
2025-12-15 12:29 ` [PATCH v2 1/4] dt-bindings: input: adc-keys: allow linux,input-type property Nicolas Frattaroli
2025-12-15 12:29   ` Nicolas Frattaroli
2025-12-16  8:47   ` Alexandre Belloni
2025-12-16  8:47     ` Alexandre Belloni
2025-12-17  8:31   ` Krzysztof Kozlowski
2025-12-17  8:31     ` Krzysztof Kozlowski
2025-12-17 12:57     ` Nicolas Frattaroli
2025-12-17 12:57       ` Nicolas Frattaroli
2025-12-17 13:34       ` Rob Herring
2025-12-17 13:34         ` Rob Herring
2026-04-08 16:59         ` Dmitry Torokhov
2026-04-08 16:59           ` Dmitry Torokhov
2026-04-08 17:11           ` Nicolas Frattaroli
2026-04-08 17:11             ` Nicolas Frattaroli
2025-12-15 12:29 ` [PATCH v2 2/4] Input: adc-keys - support EV_SW as well, not just EV_KEY Nicolas Frattaroli
2025-12-15 12:29   ` Nicolas Frattaroli
2025-12-16  8:45   ` Alexandre Belloni
2025-12-16  8:45     ` Alexandre Belloni
2025-12-15 12:29 ` [PATCH v2 3/4] Input: adc-keys - Use dev_err_probe in probe function Nicolas Frattaroli
2025-12-15 12:29   ` Nicolas Frattaroli
2025-12-16  8:45   ` Alexandre Belloni [this message]
2025-12-16  8:45     ` Alexandre Belloni
2025-12-15 12:29 ` [PATCH v2 4/4] arm64: dts: rockchip: add analog audio to ROCK 4D Nicolas Frattaroli
2025-12-15 12:29   ` Nicolas Frattaroli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251216084533c8786b5d@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.