From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF63C32E128 for ; Thu, 26 Mar 2026 18:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774548343; cv=none; b=p+B0wbjV9PVe+ITl5PQe1NVT0P4egV0nqes8QKCTXRPUooKkNSNIxKxinvfVtDvetA3QL1BwQuarLxE2gnLZGDpow64/9miTYtnAr9v5W1NQimxi8z1iI1dDy5jzPxwScQzqXPuZVVv66IHW9kdQQyQA2jy/DZWkEixwAV+kSXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774548343; c=relaxed/simple; bh=KMyrE2qkw1LechdF6qnRo6B24M8Q20QwW/OKpwQDK6w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hAUdtgk0lij5HyWnQVQEe2Xou7+wjaOClQjOP6vDgxPySyjxjE7jEal2gY17C51i+u595WYmK9AeB6wMNrzRLn9kko8on853Uao5RKFvVtABD5wBawLQTWTps+i4Vuah5+JgkzM6Ct/IEkUKCQfqwoXGNw5U2J7WylP/WPRSLbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dE18AIz1; arc=none smtp.client-ip=209.85.214.172 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.b="dE18AIz1" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2ab232cc803so5837015ad.3 for ; Thu, 26 Mar 2026 11:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774548340; x=1775153140; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vpthkYpLj8cNSLC3RcPhKZj25oOTxi5kjVrmiX4JoLk=; b=dE18AIz1n+hymKGvf5qDZ6Y2abjXgntFM4KaDyXpVMzOE7p4y/wKbQkkyNcY6b2VDM OqP+VcKFyI1yNVjK45j5kuAbM7N1Vt7sV+lIkvpWx7r0upoeNTknmkZeV8R92blmkCq5 qhHZ+tlXYEmLtmwnvAL14X16kRSjv/H5Cf8AD5+jB8js8nLX8W2pl35WD+ClR5lsn5zJ r+q/06ORbEEuZtGFJIV4gyeS5YlZ1tqVv5tYRpa9H0QOJ2OKLxveY1RVpTCy8v3I7Dy/ I25ZzTA5n3N4xIGy20WJhDEIdKmgsAuvxmJP4tR8OknfIhJv8WmIbbgahf1cWIkLdycl Fzug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774548340; x=1775153140; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vpthkYpLj8cNSLC3RcPhKZj25oOTxi5kjVrmiX4JoLk=; b=CBq0/TNsbquY6cHOoKQM7kRHVKrsj18601AHovttoMWQqNArevF5ODdG63Z7r9pl+k QRm5gjqByJjSSqwHSpG31Ltipg0zN4DpmZ9OKiwGALwCdQ0yhy5CpzMwnAgMfJv1nLm+ pEexDo1NcMXoodpZMZ3IfhC7OMtdvwcCNKg3QfMp58uSHcyDFSPaHaNdNs14dWPmNhGe BtUIr7twgJ7PEWC6omsDEp7sroQIFccryATojj0hlhvgqCqdZhKa1V7aX8rr+nMqOE75 mCyBD960uPsOYmtGk2AhfxnDNZCnx1WxeNduDE+e2toMjGfOKOThotxIvIJxYNvzJbi9 UYng== X-Forwarded-Encrypted: i=1; AJvYcCVi5AlDw7aKMGYn1DPtGBSR+pKVjtmz7Mr0RHtIuPAP4UYHKYddYvDLKNt/mjQhnHm7IchYIakLM+EsvZE=@vger.kernel.org X-Gm-Message-State: AOJu0YwpaHiRQh2FN6blpEYTkstZQODZnHtvMWvegbC0+/A6mtPZvHHL B4uw9DrM5UlM4Z+7KUJnVPWGzkHY5mVGmf0WB0O0WyYwizeMVhp6GJS2 X-Gm-Gg: ATEYQzxf8mj4y3lZrIE8SUjXtEYIXpu8mjnfxuyIYkhmJTjFzbg54Vo16hkrajrzwVc PAs67OX858XKoRIViVyMjpGh2yZEFrT+HxovwFRZwm67wX9HF2t5fhVGzIKtGurAb7mSrkG719a NPRjwjgSEd86SmBBVwn95fMx18JMCza3tXYYkHdNwpzZF0MBF3MN/HN2bmfc2JxuxW/E9XByJFb bprRbdbcvV/OURKZkVt5HEmv4BTshHnLUhL7CsjN7aqVsGCzaxy6IOZhCFu1JhKVe1JWko0A26z nWuD0bh6ut2nUanL3O8c3nJKZiVCsajpoSiFq40huEJwk770Om9G7kmLEj8xPz2tL0YkZWddsDn 0yTBno9IesnPk9Ep0Oio5In1oddk6nnqy72Njcr4XQ8gBU1KOW71Qi4K4Sii3YNXgeUP6Sm+b3i BX68e/LEMykQFNjNR2HsI91Q6aM9+uPX1lstvvNDzuoNkxOcQAPKB+wBSJxIJG6OLENnAivJcJv 9Y= X-Received: by 2002:a17:903:440f:b0:2ae:825b:49a5 with SMTP id d9443c01a7336-2b0b084f448mr92943465ad.0.1774548339551; Thu, 26 Mar 2026 11:05:39 -0700 (PDT) Received: from debian.ari ([47.30.237.79]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0bc7a17c5sm43823545ad.26.2026.03.26.11.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:05:38 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant Subject: [PATCH v6 0/4] iio: adc: ad799x: modernize resource management Date: Thu, 26 Mar 2026 23:35:25 +0530 Message-Id: <20260326180529.19154-1-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series modernizes the ad799x driver by converting resource management to the devm_ infrastructure. This results in cleaner probe error handling, the removal of the ad799x_remove() function, and improved code maintainability. Key changes in this series include: - Static allocation of the rx_buf using IIO_DECLARE_BUFFER_WITH_TS() to avoid dynamic memory leaks during scan mode updates. - Caching of VCC and VREF regulator voltages during probe() to optimize read_raw() performance and simplify power management logic. - Migration of regulators and mutex initialization to device-managed resources (devm). - Removal of the manual ad799x_remove() function and all goto-based error cleanup labels in ad799x_probe(). These changes ensure the teardown sequence is always correct, following the reverse order of allocation, and remove unnecessary boilerplate code from the driver. Changes in v6: - Addressed style feedback from Andy Shevchenko: used '(MICRO / MILLI)' for clearer unit conversion and refactored the optional VREF error path for better readability. - Removed the phrase "Reading the regulator voltage via regulator_get_voltage() can be a slow operation" from the commit message of patch 3/4 as requested by Jonathan Cameron. - Confirmed with maintainers that the devm_add_action_or_reset() pattern must remain to preserve PM functionality. Changes in v5: - Used devm_add_action_or_reset() for regulator disabling instead of devm_regulator_get_enable_read_voltage() as suggested by Jonathan Cameron. This was necessary to preserve the regulator pointers (st->reg and st->vref) required by the driver's suspend/resume power management callbacks. - Simplified voltage caching to use a single 'vref_uV' variable. - Converted mutex_init() to devm_mutex_init(). - Resolved error path ordering issues by using devm_* exclusively, allowing for the complete removal of the ad799x_remove() function. Changes in v4: - Simplified voltage caching to use a single 'vref_uV' variable as suggested by David Lechner. - Capitalized 'uV' in variable names as suggested by Andy Shevchenko. - Removed redundant 'if (ret < 0)' check in read_raw() (dead check). - Used devm_mutex_init() to replace manual mutex handling. - Introduced a local 'dev' pointer in probe() to simplify function calls. - Switched to IIO_DECLARE_BUFFER_WITH_TS() for the buffer declaration. - Moved goto removals into the respective patches where devm conversion occurs. Changes in v3: - Split the monolithic v2 patch into 4 logical commits as requested by Andy Shevchenko. Changes in v2: - Eliminated dynamic buffer allocation (feedback from David Lechner). - Cached voltages to prevent devm/manual ordering hazards (feedback from Jonathan Cameron). Archit Anant (4): iio: adc: ad799x: use local device pointer in probe iio: adc: ad799x: use a static buffer for scan data iio: adc: ad799x: cache regulator voltages during probe iio: adc: ad799x: use devm_iio_device_register and drop remove() drivers/iio/adc/ad799x.c | 110 ++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 59 deletions(-) -- 2.39.5