lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 17 Jan 2013 13:44:01 +0200
From:	Felipe Balbi <balbi@...com>
To:	Roger Quadros <rogerq@...com>
CC:	<balbi@...com>, <sameo@...ux.intel.com>, <tony@...mide.com>,
	<kishon@...com>, <sshtylyov@...sta.com>, <bjorn@...k.no>,
	<linux@....linux.org.uk>, <linux-usb@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v7 14/22] mfd: omap-usb-host: cleanup clock management
 code

On Thu, Jan 17, 2013 at 01:30:23PM +0200, Roger Quadros wrote:
> All ports have similarly named port clocks so we can
> bunch them into a port data structure and use for loop
> to enable/disable the clocks.
> 
> Dynamically allocate and get clocks based on number of ports
> available on the platform
> 
> Signed-off-by: Roger Quadros <rogerq@...com>
> ---
>  drivers/mfd/omap-usb-host.c |  180 ++++++++++++++++++++++++------------------
>  1 files changed, 103 insertions(+), 77 deletions(-)
> 
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index 779588b..c75b79d 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -92,13 +92,12 @@
>  
>  struct usbhs_hcd_omap {
>  	int				nports;
> +	struct clk			**utmi_clk;
>  
>  	struct clk			*xclk60mhsp1_ck;
>  	struct clk			*xclk60mhsp2_ck;
> -	struct clk			*utmi_p1_fck;
> -	struct clk			*usbhost_p1_fck;
> -	struct clk			*utmi_p2_fck;
> -	struct clk			*usbhost_p2_fck;
> +	struct clk			*utmi_p1_gfclk;
> +	struct clk			*utmi_p2_gfclk;
>  	struct clk			*init_60m_fclk;
>  	struct clk			*ehci_logic_fck;
>  
> @@ -276,6 +275,7 @@ 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;
>  	unsigned long			flags;
> +	int i, r;
>  
>  	dev_dbg(dev, "usbhs_runtime_resume\n");
>  
> @@ -285,13 +285,18 @@ static int usbhs_runtime_resume(struct device *dev)
>  	if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
>  		clk_enable(omap->ehci_logic_fck);
>  
> -	if (is_ehci_tll_mode(pdata->port_mode[0]))
> -		clk_enable(omap->usbhost_p1_fck);
> -	if (is_ehci_tll_mode(pdata->port_mode[1]))
> -		clk_enable(omap->usbhost_p2_fck);
> -
> -	clk_enable(omap->utmi_p1_fck);
> -	clk_enable(omap->utmi_p2_fck);
> +	for (i = 0; i < omap->nports; i++) {
> +		if (is_ehci_tll_mode(pdata->port_mode[i])) {
> +			if (omap->utmi_clk[i]) {
> +				r = clk_enable(omap->utmi_clk[i]);
> +				if (r) {
> +					dev_err(dev,
> +					 "Can't enable port %d clk : %d\n",
> +					 i, r);
> +				}
> +			}
> +		}
> +	}

you can decrease indentation here a little bit:

	for (i = 0; i < omap->nports; i++) {
		if (!is_ehci_tll_mode(pdata->port_mode[i]))
			continue;

		if (!omap->utmi_clk[i])
			continue;

		r = clk_enable(omap->utmi_clk[i]);
		if (r) {
			dev_err(dev,
			 "Can't enable port %d clk : %d\n",
			 i, r);
		}
	}


> @@ -303,18 +308,18 @@ 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;
>  	unsigned long			flags;
> +	int i;
>  
>  	dev_dbg(dev, "usbhs_runtime_suspend\n");
>  
>  	spin_lock_irqsave(&omap->lock, flags);
>  
> -	if (is_ehci_tll_mode(pdata->port_mode[0]))
> -		clk_disable(omap->usbhost_p1_fck);
> -	if (is_ehci_tll_mode(pdata->port_mode[1]))
> -		clk_disable(omap->usbhost_p2_fck);
> -
> -	clk_disable(omap->utmi_p2_fck);
> -	clk_disable(omap->utmi_p1_fck);
> +	for (i = 0; i < omap->nports; i++) {
> +		if (is_ehci_tll_mode(pdata->port_mode[i])) {
> +			if (omap->utmi_clk[i])
> +				clk_disable(omap->utmi_clk[i]);
> +		}
> +	}

same as above.

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ