From: Jonathan Cameron <jic23@kernel.org>
To: Sanjay Chitroda via B4 Relay
<devnull+sanjayembeddedse.gmail.com@kernel.org>
Cc: sanjayembeddedse@gmail.com, "Jiri Kosina" <jikos@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
Date: Mon, 27 Jul 2026 02:25:58 +0100 [thread overview]
Message-ID: <20260727022546.6d5336e6@jic23-huawei> (raw)
In-Reply-To: <20260724-24-july-hid-gyro-dev-log-clenaup-v2-2-01671b07b181@gmail.com>
On Fri, 24 Jul 2026 22:57:21 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> Replace dev_err() calls with dev_err_probe() during probe.
>
> dev_err_probe() makes error code handling simpler and handle
> deferred probe nicely (avoid spamming logs).
There are changes in here that aren't mentioned.
A common way to handle this is to add.
"To simplify the added dev_err_probe() calls, add a local struct devic
variable."
Then in a follow up patch do the rest and state something like
"Use the local struct device *dev to replace &pdev->dev, simplifying
code."
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
> ---
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index bcf53e267701..749a2ecbc2d1 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -264,13 +264,14 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
> /* Function to initialize the processing for usage id */
> static int hid_gyro_3d_probe(struct platform_device *pdev)
> {
> - struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
> + struct device *dev = &pdev->dev;
> + struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
> int ret = 0;
> static const char *name = "gyro_3d";
> struct iio_dev *indio_dev;
> struct gyro_3d_state *gyro_state;
>
> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
> + indio_dev = devm_iio_device_alloc(dev, sizeof(*gyro_state));
> if (!indio_dev)
> return -ENOMEM;
> platform_set_drvdata(pdev, indio_dev);
> @@ -284,12 +285,10 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> &gyro_state->common_attributes,
> gyro_3d_sensitivity_addresses,
> ARRAY_SIZE(gyro_3d_sensitivity_addresses));
> - if (ret) {
> - dev_err(&pdev->dev, "failed to setup common attributes\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to setup common attributes\n");
>
> - indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels,
> + indio_dev->channels = devm_kmemdup(dev, gyro_3d_channels,
> sizeof(gyro_3d_channels), GFP_KERNEL);
This is the case I'm saying doesn't belong in this patch.
Jonathan
> if (!indio_dev->channels)
> return -ENOMEM;
> @@ -297,10 +296,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> ret = gyro_3d_parse_report(pdev, hsdev,
> (struct iio_chan_spec *)indio_dev->channels,
> HID_USAGE_SENSOR_GYRO_3D, gyro_state);
> - if (ret) {
> - dev_err(&pdev->dev, "failed to setup attributes\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to setup attributes\n");
>
> indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
> indio_dev->info = &gyro_3d_info;
>
prev parent reply other threads:[~2026-07-27 1:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 17:27 [PATCH v2 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
2026-07-24 17:27 ` [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
2026-07-27 1:22 ` Jonathan Cameron
2026-07-24 17:27 ` [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
2026-07-27 1:25 ` Jonathan Cameron [this message]
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=20260727022546.6d5336e6@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=devnull+sanjayembeddedse.gmail.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sanjayembeddedse@gmail.com \
--cc=srinivas.pandruvada@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox