All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/8] iio: adc: at91_adc: fix NULL trigger dereference and convert to devm
@ 2026-12-03 17:30 Abdelnasser Hussein
  2026-12-03 17:30 ` [PATCH v6 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Abdelnasser Hussein
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Abdelnasser Hussein @ 2026-12-03 17:30 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Greg Kroah-Hartman, u.kleine-koenig
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Abdelnasser Hussein,
	stable, Joshua Crofts, Andy Shevchenko

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>


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-12-05 11:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 17:30 [PATCH v6 0/8] iio: adc: at91_adc: fix NULL trigger dereference and convert to devm Abdelnasser Hussein
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-04  9:21   ` Andy Shevchenko
2026-12-04  9:44     ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 6/8] iio: adc: at91_adc: pass struct device to at91_ts_register() Abdelnasser Hussein
2026-12-04  9:40   ` Andy Shevchenko
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-04  9:41   ` Andy Shevchenko
2026-12-04 14:33   ` David Laight
2026-12-04 14:51     ` Andy Shevchenko
2026-12-05 11:53       ` David Laight
2026-12-03 17:30 ` [PATCH v6 8/8] iio: adc: at91_adc: convert to device-managed resources Abdelnasser Hussein

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.