[dpdk-dev,2/4] bus/pci: reference driver structure
diff mbox

Message ID 1523455637-31719-3-git-send-email-rk@semihalf.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Rafal Kozik April 11, 2018, 2:07 p.m. UTC
Reference driver structure before calling rte_pci_map_device.
It allow to use driver flags for adjusting configuration.

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 drivers/bus/pci/pci_common.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Ferruh Yigit June 27, 2018, 4:36 p.m. UTC | #1
On 4/11/2018 3:07 PM, Rafal Kozik wrote:
> Reference driver structure before calling rte_pci_map_device.
> It allow to use driver flags for adjusting configuration.
> 
> Signed-off-by: Rafal Kozik <rk@semihalf.com>
> ---
>  drivers/bus/pci/pci_common.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 2a00f36..15e9a47 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -159,17 +159,20 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>  	RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
>  		dev->id.device_id, dr->driver.name);
>  
> +	/* reference driver structure */
> +	dev->driver = dr;
> +	dev->device.driver = &dr->driver;

It can be good to comment that this needs to be before rte_pci_map_device()
incase someone wants to refactor code later.

> +
>  	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
>  		/* map resources for devices that use igb_uio */
>  		ret = rte_pci_map_device(dev);
> -		if (ret != 0)
> +		if (ret != 0) {
> +			dev->driver = NULL;
> +			dev->device.driver = NULL;
>  			return ret;
> +		}
>  	}
>  
> -	/* reference driver structure */
> -	dev->driver = dr;
> -	dev->device.driver = &dr->driver;
> -
>  	/* call the driver probe() function */
>  	ret = dr->probe(dr, dev);
>  	if (ret) {
>
Rafal Kozik June 28, 2018, 1:05 p.m. UTC | #2
2018-06-27 18:36 GMT+02:00 Ferruh Yigit <ferruh.yigit@intel.com>:
> On 4/11/2018 3:07 PM, Rafal Kozik wrote:
>> Reference driver structure before calling rte_pci_map_device.
>> It allow to use driver flags for adjusting configuration.
>>
>> Signed-off-by: Rafal Kozik <rk@semihalf.com>
>> ---
>>  drivers/bus/pci/pci_common.c | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
>> index 2a00f36..15e9a47 100644
>> --- a/drivers/bus/pci/pci_common.c
>> +++ b/drivers/bus/pci/pci_common.c
>> @@ -159,17 +159,20 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>>       RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
>>               dev->id.device_id, dr->driver.name);
>>
>> +     /* reference driver structure */
>> +     dev->driver = dr;
>> +     dev->device.driver = &dr->driver;
>
> It can be good to comment that this needs to be before rte_pci_map_device()
> incase someone wants to refactor code later.
>

I will fix it in new, rebased patch set.

>> +
>>       if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
>>               /* map resources for devices that use igb_uio */
>>               ret = rte_pci_map_device(dev);
>> -             if (ret != 0)
>> +             if (ret != 0) {
>> +                     dev->driver = NULL;
>> +                     dev->device.driver = NULL;
>>                       return ret;
>> +             }
>>       }
>>
>> -     /* reference driver structure */
>> -     dev->driver = dr;
>> -     dev->device.driver = &dr->driver;
>> -
>>       /* call the driver probe() function */
>>       ret = dr->probe(dr, dev);
>>       if (ret) {
>>
>

Patch
diff mbox

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 2a00f36..15e9a47 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -159,17 +159,20 @@  rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
 		dev->id.device_id, dr->driver.name);
 
+	/* reference driver structure */
+	dev->driver = dr;
+	dev->device.driver = &dr->driver;
+
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 		/* map resources for devices that use igb_uio */
 		ret = rte_pci_map_device(dev);
-		if (ret != 0)
+		if (ret != 0) {
+			dev->driver = NULL;
+			dev->device.driver = NULL;
 			return ret;
+		}
 	}
 
-	/* reference driver structure */
-	dev->driver = dr;
-	dev->device.driver = &dr->driver;
-
 	/* call the driver probe() function */
 	ret = dr->probe(dr, dev);
 	if (ret) {