usb: ohci-platform: use helper variables in probe function
Subsystems (2)
PATCH 1/1 usb: ohci-platform: use helper variables in probe function
Probing function was using &dev->dev and dev->dev.of_node over 20 times so I believe it made sense to use helper variables for both of them. To avoid some uncommon variable name for struct device I first replaced existing dev variable with pdev.
--- drivers/usb/host/ohci-platform.c | 66 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-)
drivers/usb/host/ohci-platform.c +32 -34
@@ -111,11 +111,13 @@ static struct usb_ohci_pdata ohci_platform_defaults = { .power_off = ohci_platform_power_off, }; -static int ohci_platform_probe (struct platform_device *dev) +static int ohci_platform_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node;struct usb_hcd *hcd;struct resource *res_mem; -struct usb_ohci_pdata *pdata =dev_get_platdata (&dev->dev); +struct usb_ohci_pdata *pdata =dev_get_platdata (dev);struct ohci_platform_priv *priv;struct ohci_hcd *ohci;int err, irq, phy_num, clk =0 , rst =0 ;
@@ -130,47 +132,45 @@ static int ohci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ohci_platform_defaults; - err =dma_coerce_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (err)return err; - irq =platform_get_irq (dev,0 ); + irq =platform_get_irq (pdev,0 );if (irq <0 ) { -dev_err (&dev->dev,"no irq provided" ); +dev_err (dev,"no irq provided" );return irq; } - hcd =usb_create_hcd (&ohci_platform_hc_driver, &dev->dev, -dev_name (&dev->dev)); + hcd =usb_create_hcd (&ohci_platform_hc_driver, dev,dev_name (dev));if (!hcd)return -ENOMEM ; -platform_set_drvdata (dev, hcd); - dev->dev.platform_data = pdata; +platform_set_drvdata (pdev, hcd); + dev->platform_data = pdata; priv =hcd_to_ohci_priv (hcd); ohci =hcd_to_ohci (hcd); -if (pdata == &ohci_platform_defaults && dev->dev.of_node) { -if (of_property_read_bool (dev->dev.of_node,"big-endian-regs" )) +if (pdata == &ohci_platform_defaults && np) { +if (of_property_read_bool (np,"big-endian-regs" )) ohci->flags |=OHCI_QUIRK_BE_MMIO ; -if (of_property_read_bool (dev->dev.of_node,"big-endian-desc" )) +if (of_property_read_bool (np,"big-endian-desc" )) ohci->flags |=OHCI_QUIRK_BE_DESC ; -if (of_property_read_bool (dev->dev.of_node,"big-endian" )) +if (of_property_read_bool (np,"big-endian" )) ohci->flags |=OHCI_QUIRK_BE_MMIO |OHCI_QUIRK_BE_DESC ; -if (of_property_read_bool (dev->dev.of_node,"no-big-frame-no" )) +if (of_property_read_bool (np,"no-big-frame-no" )) ohci->flags |=OHCI_QUIRK_FRAME_NO ; -of_property_read_u32 (dev->dev.of_node,"num-ports" , - &ohci->num_ports); +of_property_read_u32 (np,"num-ports" , &ohci->num_ports); - priv->num_phys =of_count_phandle_with_args (dev->dev.of_node, -"phys" ,"#phy-cells" ); + priv->num_phys =of_count_phandle_with_args (np,"phys" , +"#phy-cells" );if (priv->num_phys >0 ) { - priv->phys =devm_kcalloc (&dev->dev, priv->num_phys, + priv->phys =devm_kcalloc (dev, priv->num_phys,sizeof (struct phy *),GFP_KERNEL );if (!priv->phys)return -ENOMEM ;
@@ -178,8 +178,8 @@ static int ohci_platform_probe(struct platform_device *dev) priv->num_phys =0 ;for (phy_num =0 ; phy_num < priv->num_phys; phy_num++) { - priv->phys[phy_num] =devm_of_phy_get_by_index ( - &dev->dev, dev->dev.of_node, phy_num); + priv->phys[phy_num] =devm_of_phy_get_by_index (dev, np, + phy_num);if (IS_ERR (priv->phys[phy_num])) { err =PTR_ERR (priv->phys[phy_num]); goto err_put_hcd;
@@ -187,7 +187,7 @@ static int ohci_platform_probe(struct platform_device *dev) }for (clk =0 ; clk <OHCI_MAX_CLKS ; clk++) { - priv->clks[clk] =of_clk_get (dev->dev.of_node, clk); + priv->clks[clk] =of_clk_get (np, clk);if (IS_ERR (priv->clks[clk])) { err =PTR_ERR (priv->clks[clk]);if (err == -EPROBE_DEFER )
@@ -198,8 +198,8 @@ static int ohci_platform_probe(struct platform_device *dev) }for (rst =0 ; rst <OHCI_MAX_RESETS ; rst++) { priv->resets[rst] = -devm_reset_control_get_shared_by_index ( - &dev->dev, rst); +devm_reset_control_get_shared_by_index (dev, + rst);if (IS_ERR (priv->resets[rst])) { err =PTR_ERR (priv->resets[rst]);if (err == -EPROBE_DEFER )
@@ -224,29 +224,27 @@ static int ohci_platform_probe(struct platform_device *dev)#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO if (ohci->flags &OHCI_QUIRK_BE_MMIO ) { -dev_err (&dev->dev, -"Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n" ); +dev_err (dev,"Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n" ); err = -EINVAL ; goto err_reset; }#endif #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC if (ohci->flags &OHCI_QUIRK_BE_DESC ) { -dev_err (&dev->dev, -"Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n" ); +dev_err (dev,"Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n" ); err = -EINVAL ; goto err_reset; }#endif if (pdata->power_on) { - err = pdata->power_on (dev); + err = pdata->power_on (pdev);if (err <0 ) goto err_reset; } - res_mem =platform_get_resource (dev,IORESOURCE_MEM ,0 ); - hcd->regs =devm_ioremap_resource (&dev->dev, res_mem); + res_mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + hcd->regs =devm_ioremap_resource (dev, res_mem);if (IS_ERR (hcd->regs)) { err =PTR_ERR (hcd->regs); goto err_power;
@@ -260,13 +258,13 @@ static int ohci_platform_probe(struct platform_device *dev)device_wakeup_enable (hcd->self.controller); -platform_set_drvdata (dev, hcd); +platform_set_drvdata (pdev, hcd);return err; err_power:if (pdata->power_off) - pdata->power_off (dev); + pdata->power_off (pdev); err_reset:while (--rst >=0 )reset_control_assert (priv->resets[rst]);
@@ -275,7 +273,7 @@ err_put_clks:clk_put (priv->clks[clk]); err_put_hcd:if (pdata == &ohci_platform_defaults) - dev->dev.platform_data =NULL ; + dev->platform_data =NULL ;usb_put_hcd (hcd);
Signature · 1 line
1.8.4.5
Quoted 6 lines · Rafał Miłecki
Probing function was using
&dev->devanddev->dev.of_nodeover 20 times so I believe it made sense to use helper variables for both of them. To avoid some uncommon variable name for struct device I first replaced existing dev variable with pdev.Signed-off-by Rafał Miłecki <[email protected]>
Greg Kroah-Hartman
maintainerQuoted 10 lines · Rafał Miłecki
Probing function was using
&dev->devanddev->dev.of_nodeover 20 times so I believe it made sense to use helper variables for both of them. To avoid some uncommon variable name for struct device I first replaced existing dev variable with pdev.Signed-off-by Rafał Miłecki <[email protected]>Acked-by Alan Stern <[email protected]>--- drivers/usb/host/ohci-platform.c | 66 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-)
While "nice" this really isn't needed, unless you are going to do something after this patch is applied. And if so, please submit it as a patch series. As it is, it just looks like unneeded churn, sorry, so I'm not going to take it.
thanks,
greg k-h