linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: host: ehci: Use the defined variable to simplify code
@ 2020-05-08 11:45 Tang Bin
  2020-05-08 13:56 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Tang Bin @ 2020-05-08 11:45 UTC (permalink / raw)
  To: stern, gregkh; +Cc: linux-usb, linux-kernel, Tang Bin, Zhang Shengju

Use the defined variable "dev" to make the code cleaner. And
delete an extra blank line.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/usb/host/ehci-mxc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index c9f91e6c7..a1eb5ee77 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -56,7 +56,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	hcd->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(hcd->regs)) {
 		ret = PTR_ERR(hcd->regs);
 		goto err_alloc;
@@ -69,14 +69,14 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
 	priv = (struct ehci_mxc_priv *) ehci->priv;
 
 	/* enable clocks */
-	priv->usbclk = devm_clk_get(&pdev->dev, "ipg");
+	priv->usbclk = devm_clk_get(dev, "ipg");
 	if (IS_ERR(priv->usbclk)) {
 		ret = PTR_ERR(priv->usbclk);
 		goto err_alloc;
 	}
 	clk_prepare_enable(priv->usbclk);
 
-	priv->ahbclk = devm_clk_get(&pdev->dev, "ahb");
+	priv->ahbclk = devm_clk_get(dev, "ahb");
 	if (IS_ERR(priv->ahbclk)) {
 		ret = PTR_ERR(priv->ahbclk);
 		goto err_clk_ahb;
@@ -84,13 +84,12 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
 	clk_prepare_enable(priv->ahbclk);
 
 	/* "dr" device has its own clock on i.MX51 */
-	priv->phyclk = devm_clk_get(&pdev->dev, "phy");
+	priv->phyclk = devm_clk_get(dev, "phy");
 	if (IS_ERR(priv->phyclk))
 		priv->phyclk = NULL;
 	if (priv->phyclk)
 		clk_prepare_enable(priv->phyclk);
 
-
 	/* call platform specific init function */
 	if (pdata->init) {
 		ret = pdata->init(pdev);
-- 
2.20.1.windows.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: host: ehci: Use the defined variable to simplify code
  2020-05-08 11:45 [PATCH] USB: host: ehci: Use the defined variable to simplify code Tang Bin
@ 2020-05-08 13:56 ` Alan Stern
  2020-05-08 14:28   ` [PATCH] USB: host: ehci: Use the defined variable to simplifycode Tang Bin
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2020-05-08 13:56 UTC (permalink / raw)
  To: Tang Bin; +Cc: gregkh, linux-usb, linux-kernel, Zhang Shengju

On Fri, 8 May 2020, Tang Bin wrote:

> Use the defined variable "dev" to make the code cleaner. And
> delete an extra blank line.

Again, the Subject: line should say "ehci-mxc".

> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  drivers/usb/host/ehci-mxc.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
> index c9f91e6c7..a1eb5ee77 100644
> --- a/drivers/usb/host/ehci-mxc.c
> +++ b/drivers/usb/host/ehci-mxc.c
> @@ -56,7 +56,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> +	hcd->regs = devm_ioremap_resource(dev, res);

As long as you're making these changes, why not also move the 
definition of dev up before the definition of pdata?  Then you could 
change the definition of pdata to:

	struct mxc_usbh_platform_data *pdata = dev_get_platdata(dev);

Alan Stern

>  	if (IS_ERR(hcd->regs)) {
>  		ret = PTR_ERR(hcd->regs);
>  		goto err_alloc;
> @@ -69,14 +69,14 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
>  	priv = (struct ehci_mxc_priv *) ehci->priv;
>  
>  	/* enable clocks */
> -	priv->usbclk = devm_clk_get(&pdev->dev, "ipg");
> +	priv->usbclk = devm_clk_get(dev, "ipg");
>  	if (IS_ERR(priv->usbclk)) {
>  		ret = PTR_ERR(priv->usbclk);
>  		goto err_alloc;
>  	}
>  	clk_prepare_enable(priv->usbclk);
>  
> -	priv->ahbclk = devm_clk_get(&pdev->dev, "ahb");
> +	priv->ahbclk = devm_clk_get(dev, "ahb");
>  	if (IS_ERR(priv->ahbclk)) {
>  		ret = PTR_ERR(priv->ahbclk);
>  		goto err_clk_ahb;
> @@ -84,13 +84,12 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
>  	clk_prepare_enable(priv->ahbclk);
>  
>  	/* "dr" device has its own clock on i.MX51 */
> -	priv->phyclk = devm_clk_get(&pdev->dev, "phy");
> +	priv->phyclk = devm_clk_get(dev, "phy");
>  	if (IS_ERR(priv->phyclk))
>  		priv->phyclk = NULL;
>  	if (priv->phyclk)
>  		clk_prepare_enable(priv->phyclk);
>  
> -
>  	/* call platform specific init function */
>  	if (pdata->init) {
>  		ret = pdata->init(pdev);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: host: ehci: Use the defined variable to simplifycode
  2020-05-08 13:56 ` Alan Stern
@ 2020-05-08 14:28   ` Tang Bin
  0 siblings, 0 replies; 3+ messages in thread
From: Tang Bin @ 2020-05-08 14:28 UTC (permalink / raw)
  To: Alan Stern; +Cc: gregkh, linux-usb, linux-kernel, Zhang Shengju


On 2020/5/8 21:56, Alan Stern wrote:
> On Fri, 8 May 2020, Tang Bin wrote:
>
>> Use the defined variable "dev" to make the code cleaner. And
>> delete an extra blank line.
> Again, the Subject: line should say "ehci-mxc".
Got it.
>
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
>> ---
>>   drivers/usb/host/ehci-mxc.c | 9 ++++-----
>>   1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
>> index c9f91e6c7..a1eb5ee77 100644
>> --- a/drivers/usb/host/ehci-mxc.c
>> +++ b/drivers/usb/host/ehci-mxc.c
>> @@ -56,7 +56,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   
>>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
>> +	hcd->regs = devm_ioremap_resource(dev, res);
> As long as you're making these changes, why not also move the
> definition of dev up before the definition of pdata?  Then you could
> change the definition of pdata to:
>
> 	struct mxc_usbh_platform_data *pdata = dev_get_platdata(dev);
>
Got it.

Thanks




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-08 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 11:45 [PATCH] USB: host: ehci: Use the defined variable to simplify code Tang Bin
2020-05-08 13:56 ` Alan Stern
2020-05-08 14:28   ` [PATCH] USB: host: ehci: Use the defined variable to simplifycode Tang Bin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).