From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796319208; b=HiGB629XbfDxZyNKTz0L+D3otb0lepcqbReKkjYM+DYNcTMkuG4Tne2qIN2/arU/CcAm +//u9aNT2c78ykRARSIL0cxUxw+AeLMqk76bfVeH5Pm6p3uWUmRR4zkEZM6G8L0CIbIJP 04jvB1rW8jbRqEMXuOdXc0w9dGCpxclBBDe2G4YU0ICLicoZazZwnixw8xzl7iC8WKMv4 XK+3KYdNPlo3G1rfq0mqBzEk/P2ZrqQJrv4MaA+JSR4z6oZVeJ6L0j5e7xnjlwcemI6lc SvBvz5QkpC9H7DrZKDGqU4SqqVeVcY41+eT8MIdWJnsJtCx7piKMk3GSSyyR8EKaeug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796319208; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=Xc/MkBxs4r8k2BtB60kv4inNCNNnt+cKgoyfSggqakc=; b=d10R2cfsrblIkOeqWm28n8GOTXWI4iTkmV/Xg3s1mMGtX/chXe5Va8PVKTYL9zueaIaK K9u9offjTVC0uZhYRVbbDJ5zKQmx2zvzng+UZUgPOYqXMiUDCMrQQ45iYsqmuEwFh7eqr 14Frtydu4tU2tZVvtG55JN0MNPVZH7JL0aP4yKWOclqODuF81JmGOo+FFt/xDj6EmC47w A3nlEdRSyWHLWbHhZlB75798wwbqaHWXiEnu+BfFTMr0cWC+DjNeiuOBri+eNK8+5sCHa Lj3Y3kMv7atjWbK0lFbSOOFuWWov862v8QXjNaqVp/pdM/PYI7K1LBTZetDqloE3gOA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FBD2lI9Z; arc=none smtp.remote-ip=209.85.221.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E2A9606A322 for ; Thu, 3 Dec 2026 17:33:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E2A9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FBD2lI9Z Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-498f5fa4f70so125119f8f.0 for ; Thu, 03 Dec 2026 09:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796319206; x=1796924006; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Xc/MkBxs4r8k2BtB60kv4inNCNNnt+cKgoyfSggqakc=; b=FBD2lI9Z3YrY/mR6lXyp6xjxcWDAMQH3vIJpN8i0l7YTXNBgNAhVH8Ork6yb5okjxY C4bcUHX2zGMCyCh/0267JAXM/fL1BP1bEVD+k5eFF6JNAHc/A7ONpcn0Q9Zey1eOKfU6 GbZIZUYsvo5+CXNNcfSSuI/dp5Ons504B6SWinmL7jwhjJGas2QrJCIMVkh4LdGxBO2D 6BXt/bTg50+ywYCOziDmRIOkxDsGHIBEC4ovWXxWnVlkVi8DA8dxdt891rKMIjzjVzI4 lg3Z3CuqHW5/PcGvZPUEHGeYoodMt8bTwg9+TB4zBASAMRetKJwDKU+OAwL08aXgBlXr vmcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796319206; x=1796924006; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Xc/MkBxs4r8k2BtB60kv4inNCNNnt+cKgoyfSggqakc=; b=y1V2B4mZCDDINTaYDqCxSY8sBo4HTN7mAnXdfQWeHKU+d7Ma35M4tiG6Gq/sy4BGuo +JRYS1QSohBU7sbHDVG+OEuCPE9nz7j8Uh1efu/jNX8J28xJ8xE3dfGhAo2ghG53FbAN 1bViQtDfzrJISUvgUwiQqXqM3SOochkDA270P3/UiiRRQC2PgCy9C/KshdXltIYvQZiN OIcMHxDTD/gTnfviCL192VVBm1uO9IbutYoD+QWR0jXiw6aX0Dw0vPd3z6FvSgle04n1 onza0abLDb0cFvYA3r1DtLB/xse+TFWpYPAoB8zNvcNv6/iry9iK+iEUF5Zyzoaz8S9U b//Q== X-Forwarded-Encrypted: i=1; AL+hErHdnkS0ABJdA5W+Pqd7NNEMrITaikDIF4FDKTjIWLYqxEG6djMkA1D+5MHHyaqZ2eW/KbjyjgjPjvV+QmU=@vger.kernel.org X-Gm-Message-State: APuU4Z85OpleB+DR9B+whv4BgeEz2Qj7EXBaq6iiyqddMTuZOnQYhnh3 SKXxacrsb7Rl+2vt22mFFHYdTvJihhLXduja9Apwv4bW96c9MCLQyUYq X-Gm-Gg: AZFdTZcRGxd01gP2me9Fvdk9LmZlAGxItDXymlLfq18JzlzGQ406gNq3935IC8hrmQ6 5RU2OGyAft8JrQujhlhqhdR79GGIAQHdD+Y+u5jMnrUy5imJn5KSu0GgQ+CcuqmGN6pRmKtffbc S/IK3+L81y0MFHjsh875SDZNcKgesvnbk0CGDxh2tg03lG+uzV3U+PrqhzutmWpobIBsR3GcZ3W fjcCVsUSMhts1QD0OzFNDPt8ZYoubm6RLOLnGc1pgxvd+6X3YzttOGaCoFpOIAJGO2pwkmltIp7 UdWO5klde2AP8swRhlxBBHDD4lHz/IPCiVOel0MFHJf2AqnSgYVlyY2oL8Ei5ksK6Wlgx0OcS7p pPkTCaw//FN9KOQ7r+MOwXQxjF9Rb8Jgwr/Lh9OyqrRHJDKP0Lkf1PUixqSVJxbjcrzNxsJ9ODt jfwOKW0zXTeaWr2I8pBdfmkdjkPvEqNNBYB400JBf2KJBt2kNn5GLzPcvqdL2T6ajujtcZyh173 /Ci4LszKZK0GdO3/MUcKOOCBHw/Np8uKE91WSGC2n1atU0n11cWz09n02reKDxCdlGzFdUZDzXy ZYmbOb/jEOjGngu1NgYhkSKhYyAu/EWpG02Ct/Drym62qgG2GJK0 X-Received: by 2002:a05:600c:5487:b0:4bb:5de1:e92c with SMTP id 5b1f17b1804b1-4bb88813157mr872173415e9.26.1796319206458; Thu, 03 Dec 2026 09:33:26 -0800 (PST) Received: from [192.168.100.235] ([154.182.95.194]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe0066657sm74447655e9.11.2026.12.03.09.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 09:33:25 -0800 (PST) From: Abdelnasser Hussein 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 Message-Id: <20261203-at91-adc-v6-v6-0-bfa754299f54@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyzHQUlJIzE vPSU3UzU4B8JSMDIzNDQ2MD3cQSS0PdxJRk3TIz3bTk5FRTcwOLVEOzRCWgjoKi1LTMCrBp0bG 1tQCqrnGDXQAAAA== X-Change-ID: 20261130-at91-adc-v6-fcce5708e16a To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Maxime Ripard , Greg Kroah-Hartman , u.kleine-koenig@baylibre.com Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Abdelnasser Hussein , stable@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796319202; l=4838; i=abdelnasserhussein11@gmail.com; s=20261130; h=from:subject:message-id; bh=k6tncuDVf+tu2n6hir6Tbt9/hbS6iot05eRCJgy7LJA=; b=3w7IaPuYqXtOD0T+haov/TvOXnDVXaFllbpdWj6oRa40r1d//6NSHj9DGJGItVD6Hkt0ay3iS lVp8PUjyYo1BLQyVFmPRhGWXoNqKd9Ki/D6gob9WrHpUAVlFL5H6EDw X-Developer-Key: i=abdelnasserhussein11@gmail.com; a=ed25519; pk=Dmo6Edgd8J/+KWpQVKEL2K7SRVNAVmPL14Bhmt3tWrY= 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 without adding ( 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 with . - 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 . - 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 --- 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