mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	u.kleine-koenig@baylibre.com
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org,
	 Abdelnasser Hussein <abdelnasserhussein11@gmail.com>,
	 stable@vger.kernel.org, Joshua Crofts <crofts@kernel.org>,
	 Andy Shevchenko <andriy.shevchenko@intel.com>
Subject: [PATCH v6 0/8] iio: adc: at91_adc: fix NULL trigger dereference and convert to devm
Date: Thu, 03 Dec 2026 19:30:04 +0200	[thread overview]
Message-ID: <20261203-at91-adc-v6-v6-0-bfa754299f54@gmail.com> (raw)

This series fixes a NULL pointer dereference during trigger teardown in
at91_adc and modernizes the driver to use firmware-agnostic property
APIs and device-managed (devm) resources.

When the "atmel,adc-use-external-triggers" property is omitted from the
Device Tree, at91_adc_trigger_init() leaves external trigger slots in
st->trig as NULL. Patch 1 provides a minimal fix in at91_adc for easy
backporting to stable kernels, while the subsequent patches modernize
the driver and convert it to devm_* APIs (removing the manual teardown
code and the st->trig array altogether).

Changes in v6:
- Patch 1: Add a comment explaining that iio_trigger_unregister() is
  intentionally not NULL-aware (Andy Shevchenko, Jonathan Cameron).
- Patch 2: Add Joshua's Reviewed-by tag.
- Patch 3: Return -ENODATA instead of -ENODEV when no matching device
  data is found.
- Patch 4: Introduce local struct device *dev and const char *propname,
  read properties through device_property_read_bool() and
  device_property_read_u32(), return the real property-read error with
  "Missing %s property", and use device_property_match_string() for the
  lowres check (review feedback from Andy Shevchenko and Jonathan
  Cameron). Drop <linux/of.h> without adding
  <linux/mod_devicetable.h> (<linux/platform_device.h> already provides
  struct of_device_id) (feedback from Uwe Kleine-König and Joshua
  Crofts).
- Patch 5: Only convert the remaining device pointer uses in
  at91_adc_probe() now that dev is introduced by patch 4, and update the
  commit message accordingly.
- Patch 6: Add Andy's Suggested-by tag and Joshua's Reviewed-by tag.
- Patch 7: Add Joshua's Reviewed-by tag.
- Patch 8: Shorten the commit message as requested by Jonathan Cameron.

Changes in v5:
- Patch 1: Keep the minimal NULL check in at91_adc instead of modifying
  iio_trigger_unregister(), and explicitly note in the commit message
  that it is a minimal fix for backporting before devm removal (as
  requested by Jonathan Cameron).
- Patch 2: Drop the redundant dev_err_probe() message after
  devm_request_irq() in a separate patch.
- Patch 3: Switch from of_device_get_match_data() to
  device_get_match_data() and check for NULL in a separate patch.
- Patch 4: Convert of_property_*() calls in at91_adc_probe() and
  at91_adc_probe_dt_ts() (renamed to at91_adc_probe_ts()) to
  device_property_*() APIs, removing the local device_node pointer and
  dropping "in the DT" from missing-property logs.  Since no OF APIs
  remain, replace <linux/of.h> with <linux/mod_devicetable.h>.
- Patch 5: Introduce local struct device *dev in at91_adc_probe() and
  switch devm_iio_device_alloc() to sizeof(*st).
- Patch 6: Pass struct device *dev instead of struct platform_device *pdev
  to at91_ts_register() in a separate patch.
- Patch 7: Replace raw 1000 with HZ_PER_KHZ from <linux/units.h>.
- Patch 8: Convert the remaining buffer, trigger, touchscreen input, and
  IIO device registrations to devm_* APIs, use unsigned int for the
  trigger loop index, drop the now-unused st->trig array, drop the
  redundant input->dev.parent assignment, and remove at91_adc_remove().

Changes in v4:
- Split the series into 3 atomic patches: (1) standalone NULL trigger
  teardown fix for stable backporting, (2) local struct device pointer
  cleanup, and (3) full devm_* conversion.

Changes in v3:
- Address review feedback from Andy Shevchenko on v2 (drop redundant
  -ENOMEM log, use local struct device pointer, scope loop index to the
  for-loop, and convert error paths to dev_err_probe()).

Changes in v2:
- Drop the simple NULL check approach from v1 and refactor the driver to
  use device-managed (devm_*) APIs as suggested by Jonathan Cameron,
  removing manual cleanup functions and at91_adc_remove(), and inlining
  trigger initialization into at91_adc_probe().

Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
---
Abdelnasser Hussein (8):
      iio: adc: at91_adc: skip unpopulated triggers on teardown
      iio: adc: at91_adc: drop duplicate IRQ allocation error message
      iio: adc: at91_adc: switch to device_get_match_data()
      iio: adc: at91_adc: convert to device_property_*() APIs
      iio: adc: at91_adc: use local struct device pointer in probe
      iio: adc: at91_adc: pass struct device to at91_ts_register()
      iio: adc: at91_adc: use HZ_PER_KHZ instead of raw 1000
      iio: adc: at91_adc: convert to device-managed resources

 drivers/iio/adc/at91_adc.c | 287 +++++++++++++++------------------------------
 1 file changed, 93 insertions(+), 194 deletions(-)
---
base-commit: 3f66b2a8051f61c2039abdcc26a4e5ed3dbc0009
change-id: 20261130-at91-adc-v6-fcce5708e16a

Best regards,
-- 
Abdelnasser Hussein <abdelnasserhussein11@gmail.com>


             reply	other threads:[~2026-12-03 17:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:30 Abdelnasser Hussein [this message]
2026-12-03 17:30 ` [PATCH v6 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Abdelnasser Hussein
2026-12-03 17:53   ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 2/8] iio: adc: at91_adc: drop duplicate IRQ allocation error message Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 3/8] iio: adc: at91_adc: switch to device_get_match_data() Abdelnasser Hussein
2026-12-03 17:55   ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 4/8] iio: adc: at91_adc: convert to device_property_*() APIs Abdelnasser Hussein
2026-12-03 17:57   ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 5/8] iio: adc: at91_adc: use local struct device pointer in probe Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 6/8] iio: adc: at91_adc: pass struct device to at91_ts_register() Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 7/8] iio: adc: at91_adc: use HZ_PER_KHZ instead of raw 1000 Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 8/8] iio: adc: at91_adc: convert to device-managed resources Abdelnasser Hussein

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=20261203-at91-adc-v6-v6-0-bfa754299f54@gmail.com \
    --to=abdelnasserhussein11@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=crofts@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.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

all inboxes | Powered by JetHome®