diff mbox

[v2,3/7] PCI: dra7xx: Set drvdata at end of probe function

Message ID 20161012133258.27714.51056.stgit@bhelgaas-glaptop2.roam.corp.google.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Bjorn Helgaas Oct. 12, 2016, 1:32 p.m. UTC
Set the drvdata pointer at the end of probe function for consistency with
other drivers.  We don't need the drvdata until after the probe completes,
and we don't need it at all if the probe fails.  No functional change
intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-dra7xx.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andrew Davis Oct. 12, 2016, 7:48 p.m. UTC | #1
On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
> Set the drvdata pointer at the end of probe function for consistency with
> other drivers. 

I've seen it done the current way many places.

> We don't need the drvdata until after the probe completes,
> and we don't need it at all if the probe fails. 

Are you sure this will always be true? Why not set it as soon as we have
the ability to, what do we gain by waiting till the end, something like
one less instruction in the failure case?

> No functional change
> intended.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host/pci-dra7xx.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
> index 1c24f34..3d184f6 100644
> --- a/drivers/pci/host/pci-dra7xx.c
> +++ b/drivers/pci/host/pci-dra7xx.c
> @@ -418,12 +418,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	reg &= ~LTSSM_EN;
>  	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
>  
> -	platform_set_drvdata(pdev, dra7xx);
> -
>  	ret = dra7xx_add_pcie_port(dra7xx, pdev);
>  	if (ret < 0)
>  		goto err_gpio;
>  
> +	platform_set_drvdata(pdev, dra7xx);

Space here.

>  	return 0;
>  
>  err_gpio:
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas Oct. 12, 2016, 10:21 p.m. UTC | #2
On Wed, Oct 12, 2016 at 02:48:02PM -0500, Andrew F. Davis wrote:
> On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
> > Set the drvdata pointer at the end of probe function for consistency with
> > other drivers. 
> 
> I've seen it done the current way many places.
> 
> > We don't need the drvdata until after the probe completes,
> > and we don't need it at all if the probe fails. 
> 
> Are you sure this will always be true? Why not set it as soon as we have
> the ability to, what do we gain by waiting till the end, something like
> one less instruction in the failure case?

I don't think it's likely anybody will need it before .probe()
completes, because the purpose of drvdata is for an external driver
entry point to locate its device data, and none of those entry points
will be called until after .probe() completes successfully.

But I don't care at all if we do it earlier, as long as all the
drivers do it the same way.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Davis Oct. 13, 2016, 3:24 p.m. UTC | #3
On 10/12/2016 05:21 PM, Bjorn Helgaas wrote:
> On Wed, Oct 12, 2016 at 02:48:02PM -0500, Andrew F. Davis wrote:
>> On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
>>> Set the drvdata pointer at the end of probe function for consistency with
>>> other drivers. 
>>
>> I've seen it done the current way many places.
>>
>>> We don't need the drvdata until after the probe completes,
>>> and we don't need it at all if the probe fails. 
>>
>> Are you sure this will always be true? Why not set it as soon as we have
>> the ability to, what do we gain by waiting till the end, something like
>> one less instruction in the failure case?
> 
> I don't think it's likely anybody will need it before .probe()
> completes, because the purpose of drvdata is for an external driver
> entry point to locate its device data, and none of those entry points
> will be called until after .probe() completes successfully.
> 
> But I don't care at all if we do it earlier, as long as all the
> drivers do it the same way.
> 

Agree, then the standard needs to be one that will work for everyone, so
setting it early is my preference as some drivers may need to call into
their external entry points during probe to prime them for later calls
or initialization (like a device reset call you want to manually call
the first time during probe).

Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 1c24f34..3d184f6 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -418,12 +418,11 @@  static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	reg &= ~LTSSM_EN;
 	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
 
-	platform_set_drvdata(pdev, dra7xx);
-
 	ret = dra7xx_add_pcie_port(dra7xx, pdev);
 	if (ret < 0)
 		goto err_gpio;
 
+	platform_set_drvdata(pdev, dra7xx);
 	return 0;
 
 err_gpio: