Re: [PATCH v2 3/6] iio: hid-sensors: Use implicit NULL pointer checks
From: Sanjay Chitroda <hidden>
Date: 2026-07-05 18:17:41
Also in:
linux-iio, lkml
On 2 July 2026 10:52:05 pm IST, Jonathan Cameron [off-list ref] wrote:
On Thu, 02 Jul 2026 21:48:00 +0530 Sanjay Chitroda via B4 Relay [off-list ref] wrote:quoted
From: Sanjay Chitroda <redacted> Replace explicit NULL pointer comparisons with implicit checks across HID sensor IIO drivers to follow the preferred kernel coding style.Is there anything in the kernel wide style guides about this? I do prefer this style in IIO but perhaps we should document it as local IIO style rather than implying general guidance (unless there is some!)
Hi Jonathan, I took reference of existing IIO commit message and followed the same. There is no kernel coding guideline for NULL pointer. If you think it would be useful, I would be happy to work on documenting the preferred conventions under "Documentation/driver-api/iio/", for example as a new "coding-style.rst" or similar document. Thanks, Sanjay
quoted
Convert 'if (indio_dev == NULL)' -> 'if (!indio_dev)'. No functional change. Signed-off-by: Sanjay Chitroda <redacted> Reviewed-by: Maxwell Doose <m32285159@gmail.com> --- drivers/iio/accel/hid-sensor-accel-3d.c | 2 +- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 2 +- drivers/iio/orientation/hid-sensor-incl-3d.c | 2 +- drivers/iio/orientation/hid-sensor-rotation.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 9197f3424c0c..225f8dd65ab1 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c@@ -325,7 +325,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct accel_3d_state)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; platform_set_drvdata(pdev, indio_dev);diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index ad10fa20fae0..738bad65d74d 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c@@ -463,7 +463,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev) indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct magn_3d_state)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; platform_set_drvdata(pdev, indio_dev);diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index 870c8929491e..c8efb0dab8b6 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c@@ -302,7 +302,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct incl_3d_state)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; platform_set_drvdata(pdev, indio_dev);diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 2dad0453fc67..6db253c1635d 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c@@ -274,7 +274,7 @@ static int hid_dev_rot_probe(struct platform_device *pdev) indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct dev_rot_state)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; platform_set_drvdata(pdev, indio_dev);