| Message ID | 20260513-sunxi-a523-gpadc-v2-2-d5efde151dac@mmpsystems.pl (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23319-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 209441C0709 for <noreply@patchwork.local>; Wed, 13 May 2026 07:01:08 +0200 (CEST) Authentication-Results: mxe881; dkim=fail header.d=mmpsystems.pl; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23319-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23319-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 092E430570C2 for <noreply@patchwork.local>; Wed, 13 May 2026 05:00:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F1E6395240; Wed, 13 May 2026 05:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mmpsystems.pl header.i=@mmpsystems.pl header.b="RY1eRyoq" X-Original-To: linux-sunxi@lists.linux.dev Received: from s106b.cyber-folks.pl (s106b.cyber-folks.pl [195.78.66.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6088F37BE6B; Wed, 13 May 2026 05:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.78.66.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778648451; cv=none; b=LOxp8bJeo7IO2xF7g4yyqZ//X2u7K0XyUF6uZ3nrpdwgdwNUkb5zRoFQIMypIUJ13gDOQOAfv17rIaNP2cJ0+B970GgvhLdteUhpBP1Nn5tBGBslV+tBPwzdgJ+WbWGlOxXWT/ks23vKXxny7Kd7aUiRwHI2uGY8mNkJKfKh6T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778648451; c=relaxed/simple; bh=I8HMsZirgXX885nuJJP7JQN223GiZKMXE/BN5ZNXDh0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hqorJ1PSngIhO5B+ycH9oPP3evo3oKVLqKo+mhZFw7M9tnlMM9qDjCvp1wJpRs+Y1fPKvCegQf7izlnxjePsJJILvqo1xVgRgdcT3m2hVhTJ2LDRSDHBbXNvMOHKfM+uU5DQPMq/qqtg03V3CWq1qAqvD/s2QPE6wFk1mu14+YA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mmpsystems.pl; spf=pass smtp.mailfrom=mmpsystems.pl; dkim=pass (2048-bit key) header.d=mmpsystems.pl header.i=@mmpsystems.pl header.b=RY1eRyoq; arc=none smtp.client-ip=195.78.66.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mmpsystems.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mmpsystems.pl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mmpsystems.pl; s=x; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AyyMPtOl9wP1fMDaeO+c2BR6cLsA+AOebpc5PnOHZCg=; b=RY1eRyoqg4Dh7MoMTripUeubfu CjYcbXK8Br0OzeBE8cj4nFlg2G3PCFY1sdNBhtX7JLTiVfboFHlSjUX37ckPrtaWf+6XAXCcJNkBO BBiWbWCf16FpppES1CX0ROZOXpRdzRjQMkdTN9+GrQ8Btg1nzXFYc80LowtuCttwPnQJSNVD4gOCi GSHuSymhjmOAOhaUbAGwz4UNlRUfJR2l6KeaxMAxpx9MRny9pxzXYDj9ZTb4AZrDZFzuvsdDxG0Ec +6+mYLWL4+AZnV+Oew1S2kkaHOOu1sb3q/3m6WYUX0e5rJhVAkwEci2Rl6WQP3er/g+BzDiZ7peWI Mk6pPY1A==; Received: from [91.102.182.218] (helo=localhost) by s106.cyber-folks.pl with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from <michal.piekos@mmpsystems.pl>) id 1wN1iA-0000000EbXi-35LL; Wed, 13 May 2026 07:00:46 +0200 From: Michal Piekos <michal.piekos@mmpsystems.pl> Date: Wed, 13 May 2026 06:59:43 +0200 Subject: [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260513-sunxi-a523-gpadc-v2-2-d5efde151dac@mmpsystems.pl> References: <20260513-sunxi-a523-gpadc-v2-0-d5efde151dac@mmpsystems.pl> In-Reply-To: <20260513-sunxi-a523-gpadc-v2-0-d5efde151dac@mmpsystems.pl> To: Jonathan Cameron <jic23@kernel.org>, David Lechner <dlechner@baylibre.com>, =?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>, Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Conor Dooley <conor+dt@kernel.org>, Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Maksim Kiselev <bigunclemax@gmail.com> Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Michal Piekos <michal.piekos@mmpsystems.pl> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778648397; l=1618; i=michal.piekos@mmpsystems.pl; s=20260301; h=from:subject:message-id; bh=I8HMsZirgXX885nuJJP7JQN223GiZKMXE/BN5ZNXDh0=; b=9R/92n4OO7rz0UOg1KOojjxsQ2ixBGVbfkuPW7Agy7qsR5pS/ZHeTurTPQj4ZBpnEIsCSNCw/ bfrCRcMH9Z9BVQcIIjvB/FZe9zMtH/Oz45RFgKuEGbks/H4kdnS62EH X-Developer-Key: i=michal.piekos@mmpsystems.pl; a=ed25519; pk=Aixyx03If7ZDamiKKN0lsa+0mtA+WjIuIf2ZQVYNBqg= X-Authenticated-Id: michal.piekos@mmpsystems.pl X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
Add GPADC support for A523
|
|
Commit Message
Michal Piekos
May 13, 2026, 4:59 a.m. UTC
A523 differs from existing sun20i-gpadc-iio by having two clocks; bus
clock and module clock.
Change driver to enable all clocks.
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
Comments
On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: >A523 differs from existing sun20i-gpadc-iio by having two clocks; bus >clock and module clock. > >Change driver to enable all clocks. > >Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl> >--- > drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > >diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c >index 861c14da75ad..3f1f07b3a385 100644 >--- a/drivers/iio/adc/sun20i-gpadc-iio.c >+++ b/drivers/iio/adc/sun20i-gpadc-iio.c >@@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > struct iio_dev *indio_dev; > struct sun20i_gpadc_iio *info; > struct reset_control *rst; >- struct clk *clk; >+ struct clk_bulk_data *clks; > int irq; > int ret; > >@@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > if (IS_ERR(info->regs)) > return PTR_ERR(info->regs); > >- clk = devm_clk_get_enabled(dev, NULL); >- if (IS_ERR(clk)) >- return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); >+ ret = devm_clk_bulk_get_all_enabled(dev, &clks); >+ if (ret <= 0) Thank you Michal for the change. Have you validated the changes ? It looks while success ret would be 0 and it would give return error. Thanks, Sanjay >+ return dev_err_probe( >+ dev, ret, >+ "failed to enable clocks or no clocks defined\n"); > > rst = devm_reset_control_get_exclusive(dev, NULL); > if (IS_ERR(rst)) >@@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > > static const struct of_device_id sun20i_gpadc_of_id[] = { > { .compatible = "allwinner,sun20i-d1-gpadc" }, >+ { .compatible = "allwinner,sun55i-a523-gpadc" }, > { } > }; > MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id); >
Hi Sanjay, thanks for having a look! On 5/13/26 13:44, Sanjay Chitroda wrote: > > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: >> A523 differs from existing sun20i-gpadc-iio by having two clocks; bus >> clock and module clock. >> >> Change driver to enable all clocks. >> >> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl> >> --- >> drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++---- >> 1 file changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c >> index 861c14da75ad..3f1f07b3a385 100644 >> --- a/drivers/iio/adc/sun20i-gpadc-iio.c >> +++ b/drivers/iio/adc/sun20i-gpadc-iio.c >> @@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) >> struct iio_dev *indio_dev; >> struct sun20i_gpadc_iio *info; >> struct reset_control *rst; >> - struct clk *clk; >> + struct clk_bulk_data *clks; >> int irq; >> int ret; >> >> @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) >> if (IS_ERR(info->regs)) >> return PTR_ERR(info->regs); >> >> - clk = devm_clk_get_enabled(dev, NULL); >> - if (IS_ERR(clk)) >> - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); >> + ret = devm_clk_bulk_get_all_enabled(dev, &clks); >> + if (ret <= 0) > > Thank you Michal for the change. > > Have you validated the changes ? > It looks while success ret would be 0 and it would give return error. But devm_clk_bulk_get_all_enabled() returns the number of clocks found and enabled. And since we need at least one, I think this is correct, and the error message below reflects that. To me that change looks good: Reviewed-by: Andre Przywara <andre.przywara@arm.com> Cheers, Andre > > Thanks, Sanjay > > >> + return dev_err_probe( >> + dev, ret, >> + "failed to enable clocks or no clocks defined\n"); >> >> rst = devm_reset_control_get_exclusive(dev, NULL); >> if (IS_ERR(rst)) >> @@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) >> >> static const struct of_device_id sun20i_gpadc_of_id[] = { >> { .compatible = "allwinner,sun20i-d1-gpadc" }, >> + { .compatible = "allwinner,sun55i-a523-gpadc" }, >> { } >> }; >> MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id); >> >
On Wed, 13 May 2026 13:53:49 +0200 Andre Przywara <andre.przywara@arm.com> wrote: > Hi Sanjay, > > thanks for having a look! > > On 5/13/26 13:44, Sanjay Chitroda wrote: > > > > > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: > >> A523 differs from existing sun20i-gpadc-iio by having two clocks; bus > >> clock and module clock. > >> > >> Change driver to enable all clocks. > >> > >> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl> > >> --- > >> drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++---- > >> 1 file changed, 7 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c > >> index 861c14da75ad..3f1f07b3a385 100644 > >> --- a/drivers/iio/adc/sun20i-gpadc-iio.c > >> +++ b/drivers/iio/adc/sun20i-gpadc-iio.c > >> @@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > >> struct iio_dev *indio_dev; > >> struct sun20i_gpadc_iio *info; > >> struct reset_control *rst; > >> - struct clk *clk; > >> + struct clk_bulk_data *clks; > >> int irq; > >> int ret; > >> > >> @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > >> if (IS_ERR(info->regs)) > >> return PTR_ERR(info->regs); > >> > >> - clk = devm_clk_get_enabled(dev, NULL); > >> - if (IS_ERR(clk)) > >> - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); > >> + ret = devm_clk_bulk_get_all_enabled(dev, &clks); > >> + if (ret <= 0) > > > > Thank you Michal for the change. > > > > Have you validated the changes ? > > It looks while success ret would be 0 and it would give return error. > > But devm_clk_bulk_get_all_enabled() returns the number of clocks found > and enabled. And since we need at least one, I think this is correct, > and the error message below reflects that. True but passing 0 to dev_err_probe() isn't going to do the right thing. Though from this function, 0 is an error you need to return an error code not 0 which to the caller looks like a success. > > To me that change looks good: > > Reviewed-by: Andre Przywara <andre.przywara@arm.com> > > Cheers, > Andre > > > > > > Thanks, Sanjay > > > > > >> + return dev_err_probe( > >> + dev, ret, > >> + "failed to enable clocks or no clocks defined\n"); > >> > >> rst = devm_reset_control_get_exclusive(dev, NULL); > >> if (IS_ERR(rst)) > >> @@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > >> > >> static const struct of_device_id sun20i_gpadc_of_id[] = { > >> { .compatible = "allwinner,sun20i-d1-gpadc" }, > >> + { .compatible = "allwinner,sun55i-a523-gpadc" }, > >> { } > >> }; > >> MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id); > >> > > >
On Wed, May 13, 2026 at 06:59:43AM +0200, Michal Piekos wrote: > A523 differs from existing sun20i-gpadc-iio by having two clocks; bus > clock and module clock. > > Change driver to enable all clocks. ... > struct iio_dev *indio_dev; > struct sun20i_gpadc_iio *info; > struct reset_control *rst; > - struct clk *clk; > + struct clk_bulk_data *clks; Try to follow reversed xmas tree order. > int irq; > int ret; ... > - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); > + ret = devm_clk_bulk_get_all_enabled(dev, &clks); > + if (ret <= 0) > + return dev_err_probe( > + dev, ret, > + "failed to enable clocks or no clocks defined\n"); Is this done by clang-format or so? Please, don't do wrapping on the open parenthesis. Also note for more than 10 years checkpatch does not complain on the trailing string literals that go over 80 characters.
On Wed, May 13, 2026 at 01:53:49PM +0200, Andre Przywara wrote: > On 5/13/26 13:44, Sanjay Chitroda wrote: > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: > > > + if (ret <= 0) > > > > Thank you Michal for the change. > > > > Have you validated the changes ? > > It looks while success ret would be 0 and it would give return error. Good catch! > But devm_clk_bulk_get_all_enabled() returns the number of clocks found and > enabled. And since we need at least one, I think this is correct, and the > error message below reflects that. > > To me that change looks good: > > Reviewed-by: Andre Przywara <andre.przywara@arm.com> == 0 ??? Doesn't look like correct code.
On Wed, 13 May 2026 23:12:05 +0300 Andy Shevchenko <andriy.shevchenko@intel.com> wrote: Hi Andy, > On Wed, May 13, 2026 at 01:53:49PM +0200, Andre Przywara wrote: > > On 5/13/26 13:44, Sanjay Chitroda wrote: > > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: > > > > > + if (ret <= 0) > > > > > > Thank you Michal for the change. > > > > > > Have you validated the changes ? > > > It looks while success ret would be 0 and it would give return error. No, it doesn't. Returning 0 means no clocks found: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-devres.c#n300 > > Good catch! > > > But devm_clk_bulk_get_all_enabled() returns the number of clocks found and > > enabled. And since we need at least one, I think this is correct, and the > > error message below reflects that. > > > > To me that change looks good: > > > > Reviewed-by: Andre Przywara <andre.przywara@arm.com> > > == 0 ??? > Doesn't look like correct code. Not sure I follow: devm_clk_bulk_get_all_enabled() returns the number of clocks in that node, or a negative error value. If it returns 0, that means no clocks have been found, which is an error in our case, since we expect at least one clock. This is what the second part of the error message refers to. So we want one or two as the return value, with the current bindings, but really anything greater than 0 is fine, from the driver's perspective, since we don't care about the clocks beyond them being enabled. So am I missing something? Cheers, Andre
On Wed, May 13, 2026 at 11:19:01PM +0200, Andre Przywara wrote: > On Wed, 13 May 2026 23:12:05 +0300 > Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > On Wed, May 13, 2026 at 01:53:49PM +0200, Andre Przywara wrote: > > > On 5/13/26 13:44, Sanjay Chitroda wrote: > > > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: ... > > > > > + if (ret <= 0) > > > > > > > > Thank you Michal for the change. > > > > > > > > Have you validated the changes ? > > > > It looks while success ret would be 0 and it would give return error. > > No, it doesn't. Returning 0 means no clocks found: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-devres.c#n300 > > > Good catch! > > > > > But devm_clk_bulk_get_all_enabled() returns the number of clocks found and > > > enabled. And since we need at least one, I think this is correct, and the > > > error message below reflects that. > > > > > > To me that change looks good: > > > > > > Reviewed-by: Andre Przywara <andre.przywara@arm.com> > > > > == 0 ??? > > Doesn't look like correct code. > > Not sure I follow: > devm_clk_bulk_get_all_enabled() returns the number of clocks in that > node, or a negative error value. If it returns 0, that means no clocks > have been found, Not in this code. Here it will be resent to the caller as success. > which is an error in our case, since we expect at > least one clock. This is what the second part of the error message > refers to. But not the error code itself! There will be no error message, IIRC the implementation of dev_err_probe(). > So we want one or two as the return value, with the current bindings, > but really anything greater than 0 is fine, from the driver's > perspective, since we don't care about the clocks beyond them being > enabled. > > So am I missing something? Yes! You returned that to the caller, meaning everything is fine. There is a success that is returned. The code is buggy (okay, not that, it rather will behave not as intended). TL;DR: You should have something like if (ret < 0) return dev_err_probe(ret); if (ret == 0) return dev_err_probe(-Exxx, "Needs at least one clock!\n");
On Wed, 13 May 2026 17:16:38 +0100 Jonathan Cameron <jic23@kernel.org> wrote: Hi, > On Wed, 13 May 2026 13:53:49 +0200 > Andre Przywara <andre.przywara@arm.com> wrote: > > > Hi Sanjay, > > > > thanks for having a look! > > > > On 5/13/26 13:44, Sanjay Chitroda wrote: > > > > > > > > > On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote: > > >> A523 differs from existing sun20i-gpadc-iio by having two clocks; bus > > >> clock and module clock. > > >> > > >> Change driver to enable all clocks. > > >> > > >> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl> > > >> --- > > >> drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++---- > > >> 1 file changed, 7 insertions(+), 4 deletions(-) > > >> > > >> diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c > > >> index 861c14da75ad..3f1f07b3a385 100644 > > >> --- a/drivers/iio/adc/sun20i-gpadc-iio.c > > >> +++ b/drivers/iio/adc/sun20i-gpadc-iio.c > > >> @@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > > >> struct iio_dev *indio_dev; > > >> struct sun20i_gpadc_iio *info; > > >> struct reset_control *rst; > > >> - struct clk *clk; > > >> + struct clk_bulk_data *clks; > > >> int irq; > > >> int ret; > > >> > > >> @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > > >> if (IS_ERR(info->regs)) > > >> return PTR_ERR(info->regs); > > >> > > >> - clk = devm_clk_get_enabled(dev, NULL); > > >> - if (IS_ERR(clk)) > > >> - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); > > >> + ret = devm_clk_bulk_get_all_enabled(dev, &clks); > > >> + if (ret <= 0) > > > > > > Thank you Michal for the change. > > > > > > Have you validated the changes ? > > > It looks while success ret would be 0 and it would give return error. > > > > But devm_clk_bulk_get_all_enabled() returns the number of clocks found > > and enabled. And since we need at least one, I think this is correct, > > and the error message below reflects that. > > True but passing 0 to dev_err_probe() isn't going to do the right thing. > > Though from this function, 0 is an error you need to return an error code > not 0 which to the caller looks like a success. Ah, that's true - should have read your email first before answering to Andy ;-) So yeah, that needs a split handling, for == 0, and for < 0. Cheers, Andre > > > > > > > To me that change looks good: > > > > Reviewed-by: Andre Przywara <andre.przywara@arm.com> > > > > Cheers, > > Andre > > > > > > > > > > Thanks, Sanjay > > > > > > > > >> + return dev_err_probe( > > >> + dev, ret, > > >> + "failed to enable clocks or no clocks defined\n"); > > >> > > >> rst = devm_reset_control_get_exclusive(dev, NULL); > > >> if (IS_ERR(rst)) > > >> @@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > > >> > > >> static const struct of_device_id sun20i_gpadc_of_id[] = { > > >> { .compatible = "allwinner,sun20i-d1-gpadc" }, > > >> + { .compatible = "allwinner,sun55i-a523-gpadc" }, > > >> { } > > >> }; > > >> MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id); > > >> > > > > > > >
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] If `devm_clk_bulk_get_all_enabled()` returns 0 (meaning no clocks are defined in the device tree), the driver aborts the probe early but incorrectly returns 0 (success). -- commit 6e1c58e982371b9be677bdb51d74117b3577cd6f Author: Michal Piekos <michal.piekos@mmpsystems.pl> iio: adc: sun20i-gpadc: add A523 gpadc support This commit adds support for the A523 gpadc by switching to the bulk clock API to handle both bus and module clocks. > diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c > index 861c14da75add..3f1f07b3a3856 100644 > --- a/drivers/iio/adc/sun20i-gpadc-iio.c > +++ b/drivers/iio/adc/sun20i-gpadc-iio.c [ ... ] > @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) > if (IS_ERR(info->regs)) > return PTR_ERR(info->regs); > > - clk = devm_clk_get_enabled(dev, NULL); > - if (IS_ERR(clk)) > - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); > + ret = devm_clk_bulk_get_all_enabled(dev, &clks); > + if (ret <= 0) > + return dev_err_probe( > + dev, ret, > + "failed to enable clocks or no clocks defined\n"); When devm_clk_bulk_get_all_enabled() returns 0 (meaning no clocks are defined), will this code return 0 from the probe function? Since dev_err_probe() returns the error code passed to it, returning 0 here would cause sun20i_gpadc_probe() to succeed while skipping all remaining initialization like reset deassertion, IRQ registration, and IIO device registration. Should ret be explicitly set to a negative error code (like -ENODEV) before calling dev_err_probe() if ret is 0?
diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c index 861c14da75ad..3f1f07b3a385 100644 --- a/drivers/iio/adc/sun20i-gpadc-iio.c +++ b/drivers/iio/adc/sun20i-gpadc-iio.c @@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct sun20i_gpadc_iio *info; struct reset_control *rst; - struct clk *clk; + struct clk_bulk_data *clks; int irq; int ret; @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) if (IS_ERR(info->regs)) return PTR_ERR(info->regs); - clk = devm_clk_get_enabled(dev, NULL); - if (IS_ERR(clk)) - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); + ret = devm_clk_bulk_get_all_enabled(dev, &clks); + if (ret <= 0) + return dev_err_probe( + dev, ret, + "failed to enable clocks or no clocks defined\n"); rst = devm_reset_control_get_exclusive(dev, NULL); if (IS_ERR(rst)) @@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev) static const struct of_device_id sun20i_gpadc_of_id[] = { { .compatible = "allwinner,sun20i-d1-gpadc" }, + { .compatible = "allwinner,sun55i-a523-gpadc" }, { } }; MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id);