Linux USB
 help / color / mirror / Atom feed
From: Ryan Chen <ryan_chen@aspeedtech.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 2/4] usb: uhci: Add reset control support
Date: Tue, 16 Sep 2025 00:48:02 +0000	[thread overview]
Message-ID: <OS8PR06MB7541673C83BA9B189F04538AF214A@OS8PR06MB7541.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <3cf94df2-48e1-4cbe-8f0a-84f05cb9760d@rowland.harvard.edu>

> Subject: Re: [PATCH 2/4] usb: uhci: Add reset control support
> 
> On Mon, Sep 15, 2025 at 03:39:24PM +0800, Ryan Chen wrote:
> > Some SoCs, such as the Aspeed AST2700, require the UHCI controller to
> > be taken out of reset before it can operate. Add optional reset
> > control support to the UHCI platform driver.
> >
> > The driver now acquires an optional reset line from device tree,
> > deasserts it during probe, and asserts it again in the error path and
> > shutdown.
> >
> > Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
> > ---
> >  drivers/usb/host/uhci-hcd.h      |  1 +
> >  drivers/usb/host/uhci-platform.c | 19 +++++++++++++++++--
> >  2 files changed, 18 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
> > index 13ee2a6144b2..4326d1f3ca76 100644
> > --- a/drivers/usb/host/uhci-hcd.h
> > +++ b/drivers/usb/host/uhci-hcd.h
> > @@ -445,6 +445,7 @@ struct uhci_hcd {
> >  	short load[MAX_PHASE];			/* Periodic allocations */
> >
> >  	struct clk *clk;			/* (optional) clock source */
> > +	struct reset_control *rsts;		/* (optional) clock reset */
> >
> >  	/* Reset host controller */
> >  	void	(*reset_hc) (struct uhci_hcd *uhci);
> > diff --git a/drivers/usb/host/uhci-platform.c
> > b/drivers/usb/host/uhci-platform.c
> > index 62318291f566..010c458e7d8f 100644
> > --- a/drivers/usb/host/uhci-platform.c
> > +++ b/drivers/usb/host/uhci-platform.c
> > @@ -11,6 +11,7 @@
> >  #include <linux/of.h>
> >  #include <linux/device.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/reset.h>
> >
> >  static int uhci_platform_init(struct usb_hcd *hcd)  { @@ -132,19
> > +133,33 @@ static int uhci_hcd_platform_probe(struct platform_device
> *pdev)
> >  		goto err_rmr;
> >  	}
> >
> > +	uhci->rsts = devm_reset_control_array_get_optional_shared(&pdev->dev);
> > +	if (IS_ERR(uhci->rsts)) {
> > +		ret = PTR_ERR(uhci->rsts);
> > +		goto err_clk;
> > +	}
> > +	ret = reset_control_deassert(uhci->rsts);
> > +	if (ret)
> > +		goto err_clk;
> > +
> >  	ret = platform_get_irq(pdev, 0);
> >  	if (ret < 0)
> > -		goto err_clk;
> > +		goto err_reset;
> >
> >  	ret = usb_add_hcd(hcd, ret, IRQF_SHARED);
> >  	if (ret)
> > -		goto err_clk;
> > +		goto err_reset;
> >
> >  	device_wakeup_enable(hcd->self.controller);
> >  	return 0;
> >
> >  err_clk:
> >  	clk_disable_unprepare(uhci->clk);
> > +
> > +err_reset:
> > +	if (!IS_ERR_OR_NULL(uhci->rsts))
> > +		reset_control_assert(uhci->rsts);
> 
> This error handler was added in the wrong place.  It should come before
> err_clk, so that if an error occurs in platform_get_irq(), the clock will be
> unprepared and disabled.

Thanks, will update in next version.

> 
> Alan Stern
> 
> > +
> >  err_rmr:
> >  	usb_put_hcd(hcd);
> >
> > --
> > 2.34.1

  reply	other threads:[~2025-09-16  0:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15  7:39 [PATCH 0/4] Add Aspeed AST2700 uhci support Ryan Chen
2025-09-15  7:39 ` [PATCH 1/4] dt-bindings: usb: uhci: Add reset property Ryan Chen
2025-09-15 17:36   ` Conor Dooley
2025-09-16  1:04     ` Ryan Chen
2025-09-15  7:39 ` [PATCH 2/4] usb: uhci: Add reset control support Ryan Chen
2025-09-15 14:08   ` Alan Stern
2025-09-16  0:48     ` Ryan Chen [this message]
2025-09-15  7:39 ` [PATCH 3/4] dt-bindings: usb: uhci: Add Aspeed AST2700 compatible Ryan Chen
2025-09-15 17:35   ` Conor Dooley
2025-09-16  2:04     ` Ryan Chen
2025-09-15  7:39 ` [PATCH 4/4] usb: uhci: Add Aspeed AST2700 support Ryan Chen

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=OS8PR06MB7541673C83BA9B189F04538AF214A@OS8PR06MB7541.apcprd06.prod.outlook.com \
    --to=ryan_chen@aspeedtech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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