public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Thomas Richard <thomas.richard@bootlin.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
	Andreas Kemnade <andreas@kemnade.info>,
	Kevin Hilman <khilman@baylibre.com>,
	Roger Quadros <rogerq@kernel.org>,
	Tony Lindgren <tony@atomide.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 07/11] mfd: omap-usb-host: Refactor suspend and resume callbacks
Date: Wed, 29 Apr 2026 13:59:48 +0100	[thread overview]
Message-ID: <20260429125948.GC1806155@google.com> (raw)
In-Reply-To: <20260330-omap4-fix-usb-support-v2-7-1c1e11b190dc@bootlin.com>

On Mon, 30 Mar 2026, Thomas Richard wrote:

> The clock handling logic in suspend and resume callbacks is very similar.
> Create a new usbhs_clocks_enable() function to avoid code duplication.
> Also remove ftrace-like debug messages.

They're not similar at all - they use opposing calls.

Bundling them up like this makes them _more_ complicated and hurts readability IMHO.

> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
> ---
>  drivers/mfd/omap-usb-host.c | 94 ++++++++++++++++++++++-----------------------
>  1 file changed, 46 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index ac974285be34..17a54f0087c3 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -270,48 +270,56 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
>  	}
>  }
>  
> -static int usbhs_runtime_resume(struct device *dev)
> +static int usbhs_clocks_enable(struct device *dev, bool enable)
>  {
> -	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
> -	struct usbhs_omap_platform_data	*pdata = omap->pdata;
> -	int i, r;
> -
> -	dev_dbg(dev, "usbhs_runtime_resume\n");
> +	struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
> +	struct usbhs_omap_platform_data *pdata = omap->pdata;
> +	int r = 0, i;
>  
> -	omap_tll_enable(pdata);
> -
> -	if (!IS_ERR(omap->ehci_logic_fck))
> -		clk_prepare_enable(omap->ehci_logic_fck);
> +	if (!enable && !IS_ERR(omap->ehci_logic_fck))
> +		clk_disable_unprepare(omap->ehci_logic_fck);
>  
>  	for (i = 0; i < omap->nports; i++) {
>  		switch (pdata->port_mode[i]) {
>  		case OMAP_EHCI_PORT_MODE_HSIC:
>  			if (!IS_ERR(omap->hsic60m_clk[i])) {
> -				r = clk_prepare_enable(omap->hsic60m_clk[i]);
> -				if (r) {
> -					dev_err(dev,
> -					 "Can't enable port %d hsic60m clk:%d\n",
> -					 i, r);
> +				if (enable) {
> +					r = clk_prepare_enable(omap->hsic60m_clk[i]);
> +					if (r) {
> +						dev_err(dev,
> +							"Can't enable port %d hsic60m clk:%d\n",
> +							i, r);
> +					}
> +				} else {
> +					clk_disable_unprepare(omap->hsic60m_clk[i]);
>  				}
>  			}
>  
>  			if (!IS_ERR(omap->hsic480m_clk[i])) {
> -				r = clk_prepare_enable(omap->hsic480m_clk[i]);
> -				if (r) {
> -					dev_err(dev,
> -					 "Can't enable port %d hsic480m clk:%d\n",
> -					 i, r);
> +				if (enable) {
> +					r = clk_prepare_enable(omap->hsic480m_clk[i]);
> +					if (r) {
> +						dev_err(dev,
> +							"Can't enable port %d hsic480m clk:%d\n",
> +							i, r);
> +					}
> +				} else {
> +					clk_disable_unprepare(omap->hsic480m_clk[i]);
>  				}
>  			}
>  			fallthrough;	/* as HSIC mode needs utmi_clk */
>  
>  		case OMAP_EHCI_PORT_MODE_TLL:
>  			if (!IS_ERR(omap->utmi_clk[i])) {
> -				r = clk_prepare_enable(omap->utmi_clk[i]);
> -				if (r) {
> -					dev_err(dev,
> -					 "Can't enable port %d clk : %d\n",
> -					 i, r);
> +				if (enable) {
> +					r = clk_prepare_enable(omap->utmi_clk[i]);
> +					if (r) {
> +						dev_err(dev,
> +							"Can't enable port %d clk : %d\n",
> +							i, r);
> +					}
> +				} else {
> +					clk_disable_unprepare(omap->utmi_clk[i]);
>  				}
>  			}
>  			break;
> @@ -320,38 +328,28 @@ static int usbhs_runtime_resume(struct device *dev)
>  		}
>  	}
>  
> -	return 0;
> +	if (enable && !IS_ERR(omap->ehci_logic_fck))
> +		r = clk_prepare_enable(omap->ehci_logic_fck);
> +
> +	return r;
>  }
>  
> -static int usbhs_runtime_suspend(struct device *dev)
> +static int usbhs_runtime_resume(struct device *dev)
>  {
>  	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
>  	struct usbhs_omap_platform_data	*pdata = omap->pdata;
> -	int i;
>  
> -	dev_dbg(dev, "usbhs_runtime_suspend\n");
> -
> -	for (i = 0; i < omap->nports; i++) {
> -		switch (pdata->port_mode[i]) {
> -		case OMAP_EHCI_PORT_MODE_HSIC:
> -			if (!IS_ERR(omap->hsic60m_clk[i]))
> -				clk_disable_unprepare(omap->hsic60m_clk[i]);
> +	omap_tll_enable(pdata);
>  
> -			if (!IS_ERR(omap->hsic480m_clk[i]))
> -				clk_disable_unprepare(omap->hsic480m_clk[i]);
> -			fallthrough;	/* as utmi_clks were used in HSIC mode */
> +	return usbhs_clocks_enable(dev, true);
> +}
>  
> -		case OMAP_EHCI_PORT_MODE_TLL:
> -			if (!IS_ERR(omap->utmi_clk[i]))
> -				clk_disable_unprepare(omap->utmi_clk[i]);
> -			break;
> -		default:
> -			break;
> -		}
> -	}
> +static int usbhs_runtime_suspend(struct device *dev)
> +{
> +	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
> +	struct usbhs_omap_platform_data	*pdata = omap->pdata;
>  
> -	if (!IS_ERR(omap->ehci_logic_fck))
> -		clk_disable_unprepare(omap->ehci_logic_fck);
> +	usbhs_clocks_enable(dev, false);
>  
>  	omap_tll_disable(pdata);
>  
> 
> -- 
> 2.53.0
> 

-- 
Lee Jones

  reply	other threads:[~2026-04-29 12:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 13:43 [PATCH v2 00/11] Add SIM pbias regulator support for USB on OMAP4 Thomas Richard
2026-03-30 13:43 ` [PATCH v2 01/11] dt-bindings: regulator: ti,pbias-regulator: Convert to DT schema Thomas Richard
2026-03-31  8:21   ` Krzysztof Kozlowski
2026-04-08  7:57     ` Thomas Richard
2026-04-08 12:38       ` Rob Herring
2026-03-30 13:43 ` [PATCH v2 02/11] dt-bindings: regulator: ti,pbias-regulator: Add pbias_sim_omap4 regulator Thomas Richard
2026-03-31  8:22   ` Krzysztof Kozlowski
2026-04-08  7:58     ` Thomas Richard
2026-04-08 12:41       ` Rob Herring
2026-04-08 13:01         ` Thomas Richard
2026-03-30 13:44 ` [PATCH v2 03/11] regulator: pbias: Add pbias SIM regulator for OMAP4 Thomas Richard
2026-03-30 13:44 ` [PATCH v2 04/11] ARM: dts: ti: omap4: Add pbias SIM regulator Thomas Richard
2026-03-30 13:44 ` [PATCH v2 05/11] mfd: omap-usb-host: Cleanup header includes Thomas Richard
2026-03-30 13:44 ` [PATCH v2 06/11] mfd: omap-usb-host: Sanitize error path in the probe() Thomas Richard
2026-04-29 11:58   ` Lee Jones
2026-03-30 13:44 ` [PATCH v2 07/11] mfd: omap-usb-host: Refactor suspend and resume callbacks Thomas Richard
2026-04-29 12:59   ` Lee Jones [this message]
2026-03-30 13:44 ` [PATCH v2 08/11] dt-bindings: mfd: ti,omap-usb-host: Convert to DT schema Thomas Richard
2026-04-08 12:55   ` Rob Herring
2026-03-30 13:44 ` [PATCH v2 09/11] dt-bindings: mfd: ti,omap-usb-host: Add 'pbias-supply' property Thomas Richard
2026-03-30 16:40   ` Thomas Richard
2026-03-30 13:44 ` [PATCH v2 10/11] mfd: omap-usb-host: Add pbias regulator support Thomas Richard
2026-04-29 13:06   ` Lee Jones
2026-03-30 13:44 ` [PATCH v2 11/11] ARM: dts: ti: omap4: Add pbias regulator to the HS USB Host Thomas Richard

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=20260429125948.GC1806155@google.com \
    --to=lee@kernel.org \
    --cc=aaro.koskinen@iki.fi \
    --cc=andreas@kemnade.info \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=khilman@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=rogerq@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=tony@atomide.com \
    /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