linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word()
@ 2019-11-18  0:20 Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 1/4] skd: " Frederick Lawler
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Frederick Lawler @ 2019-11-18  0:20 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas, bvanassche

Hi,

These changes are in reference to Bjorn's suggestions here:
https://lore.kernel.org/lkml/CAErSpo6BmWDxi3Vckm03=fZHEUosTgkMUjqCvYRA186jv8XbFw@mail.gmail.com/
https://lore.kernel.org/lkml/CAErSpo5TZC3iM09SB1td+F7b-+aiu9EHwPYa1ayiU-i1tseV5w@mail.gmail.com/

And the patches are rebased ontop of 54ecb8f7028c ("Linux 5.4-rc1")

Changes since v1:
    * Replace magic numbers constants

This is a long time coming, apologies for dragging my feet on getting
these trivial patches out.

Frederick Lawler (4):
  skd: Prefer pcie_capability_read_word()
  skd: Replace magic numbers with PCI constants
  mtip32xx: Prefer pcie_capability_read_word()
  mtip32xx: Replace magic numbers with PCI constants

 drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++----------------
 drivers/block/skd_main.c          | 14 ++++++--------
 2 files changed, 18 insertions(+), 24 deletions(-)

--
2.20.1


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

* [PATCH v2 1/4] skd: Prefer pcie_capability_read_word()
  2019-11-18  0:20 [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
@ 2019-11-18  0:20 ` Frederick Lawler
  2019-11-18  1:45   ` Damien Le Moal
  2019-11-18  0:20 ` [PATCH v2 2/4] skd: Replace magic numbers with PCI constants Frederick Lawler
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Frederick Lawler @ 2019-11-18  0:20 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas, bvanassche

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
 drivers/block/skd_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 51569c199a6c..f25f6ef6b4c7 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -3134,18 +3134,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
 
 static char *skd_pci_info(struct skd_device *skdev, char *str)
 {
-	int pcie_reg;
-
 	strcpy(str, "PCIe (");
-	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
 
-	if (pcie_reg) {
+	if (pci_is_pcie(skdev->pdev)) {
 
 		char lwstr[6];
 		uint16_t pcie_lstat, lspeed, lwidth;
 
-		pcie_reg += 0x12;
-		pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
+		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
 		lspeed = pcie_lstat & (0xF);
 		lwidth = (pcie_lstat & 0x3F0) >> 4;
 
-- 
2.20.1


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

* [PATCH v2 2/4] skd: Replace magic numbers with PCI constants
  2019-11-18  0:20 [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 1/4] skd: " Frederick Lawler
@ 2019-11-18  0:20 ` Frederick Lawler
  2019-11-18  1:45   ` Damien Le Moal
  2019-11-18  0:20 ` [PATCH v2 3/4] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 4/4] mtip32xx: Replace magic numbers with PCI constants Frederick Lawler
  3 siblings, 1 reply; 10+ messages in thread
From: Frederick Lawler @ 2019-11-18  0:20 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas, bvanassche

Readability was improved by replacing pci_read_config_word() with
pcie_capability_read_word(). Take that a step further by replacing magic
numbers with PCI reg constants.

No functional change intended.

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
v2
- Added this patch
---
 drivers/block/skd_main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index f25f6ef6b4c7..7f8243573ad9 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -3141,9 +3141,11 @@ static char *skd_pci_info(struct skd_device *skdev, char *str)
 		char lwstr[6];
 		uint16_t pcie_lstat, lspeed, lwidth;
 
-		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
-		lspeed = pcie_lstat & (0xF);
-		lwidth = (pcie_lstat & 0x3F0) >> 4;
+		pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
+					  &pcie_lstat);
+		lspeed = pcie_lstat & PCI_EXP_LNKSTA_CLS;
+		lwidth = (pcie_lstat & PCI_EXP_LNKSTA_NLW) >>
+			 PCI_EXP_LNKSTA_NLW_SHIFT;
 
 		if (lspeed == 1)
 			strcat(str, "2.5GT/s ");
-- 
2.20.1


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

* [PATCH v2 3/4] mtip32xx: Prefer pcie_capability_read_word()
  2019-11-18  0:20 [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 1/4] skd: " Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 2/4] skd: Replace magic numbers with PCI constants Frederick Lawler
@ 2019-11-18  0:20 ` Frederick Lawler
  2019-11-18  0:20 ` [PATCH v2 4/4] mtip32xx: Replace magic numbers with PCI constants Frederick Lawler
  3 siblings, 0 replies; 10+ messages in thread
From: Frederick Lawler @ 2019-11-18  0:20 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas, bvanassche

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 964f78cfffa0..35703dc98e25 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3938,22 +3938,18 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 	int pos;
 	unsigned short pcie_dev_ctrl;
 
-	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-	if (pos) {
-		pci_read_config_word(pdev,
-			pos + PCI_EXP_DEVCTL,
-			&pcie_dev_ctrl);
-		if (pcie_dev_ctrl & (1 << 11) ||
-		    pcie_dev_ctrl & (1 << 4)) {
-			dev_info(&dd->pdev->dev,
-				"Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
-					pdev->vendor, pdev->device);
-			pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
-						PCI_EXP_DEVCTL_RELAX_EN);
-			pci_write_config_word(pdev,
-				pos + PCI_EXP_DEVCTL,
-				pcie_dev_ctrl);
-		}
+	if (!pci_is_pcie(pdev))
+		return;
+
+	pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &pcie_dev_ctrl);
+	if (pcie_dev_ctrl & (1 << 11) ||
+	    pcie_dev_ctrl & (1 << 4)) {
+		dev_info(&dd->pdev->dev,
+			 "Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
+			 pdev->vendor, pdev->device);
+		pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
+					PCI_EXP_DEVCTL_RELAX_EN);
+		pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, pcie_dev_ctrl);
 	}
 }
 
-- 
2.20.1


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

* [PATCH v2 4/4] mtip32xx: Replace magic numbers with PCI constants
  2019-11-18  0:20 [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
                   ` (2 preceding siblings ...)
  2019-11-18  0:20 ` [PATCH v2 3/4] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
@ 2019-11-18  0:20 ` Frederick Lawler
  3 siblings, 0 replies; 10+ messages in thread
From: Frederick Lawler @ 2019-11-18  0:20 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas, bvanassche

Readability was improved by replacing pci_read_config_word() with
pcie_capability_read_word(). Take that a step further by replacing magic
numbers with PCI reg constants.

No functional change intended.

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
v2:
- Added this patch
---
 drivers/block/mtip32xx/mtip32xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 35703dc98e25..225c6ae62385 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3942,8 +3942,8 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 		return;
 
 	pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &pcie_dev_ctrl);
-	if (pcie_dev_ctrl & (1 << 11) ||
-	    pcie_dev_ctrl & (1 << 4)) {
+	if (pcie_dev_ctrl & PCI_EXP_DEVCTL_NOSNOOP_EN ||
+	    pcie_dev_ctrl & PCI_EXP_DEVCTL_RELAX_EN) {
 		dev_info(&dd->pdev->dev,
 			 "Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
 			 pdev->vendor, pdev->device);
-- 
2.20.1


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

* Re: [PATCH v2 1/4] skd: Prefer pcie_capability_read_word()
  2019-11-18  0:20 ` [PATCH v2 1/4] skd: " Frederick Lawler
@ 2019-11-18  1:45   ` Damien Le Moal
  2019-11-19  1:20     ` Frederick Lawler
  0 siblings, 1 reply; 10+ messages in thread
From: Damien Le Moal @ 2019-11-18  1:45 UTC (permalink / raw)
  To: Frederick Lawler, axboe; +Cc: linux-block, linux-kernel, bhelgaas, bvanassche

On 2019/11/18 9:21, Frederick Lawler wrote:
> Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
> added accessors for the PCI Express Capability so that drivers didn't
> need to be aware of differences between v1 and v2 of the PCI
> Express Capability.
> 
> Replace pci_read_config_word() and pci_write_config_word() calls with
> pcie_capability_read_word() and pcie_capability_write_word().
> 
> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
> ---
>  drivers/block/skd_main.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> index 51569c199a6c..f25f6ef6b4c7 100644
> --- a/drivers/block/skd_main.c
> +++ b/drivers/block/skd_main.c
> @@ -3134,18 +3134,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>  
>  static char *skd_pci_info(struct skd_device *skdev, char *str)
>  {
> -	int pcie_reg;
> -
>  	strcpy(str, "PCIe (");
> -	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
>  
> -	if (pcie_reg) {
> +	if (pci_is_pcie(skdev->pdev)) {

Maybe return early here ? The reason is that if pci_is_pcie() is false,
then the string "PCIe (" is not terminated with a closing parenthesis.
So something like:

	if (!pci_is_pcie(skdev->pdev)) {
		strcat(str, ")");
		return str;
	}

May be better. Note that the "return str" is also rather pointless since
it is not used by the caller of skd_pci_info().

>  
>  		char lwstr[6];
>  		uint16_t pcie_lstat, lspeed, lwidth;
>  
> -		pcie_reg += 0x12;
> -		pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
> +		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
>  		lspeed = pcie_lstat & (0xF);
>  		lwidth = (pcie_lstat & 0x3F0) >> 4;
>  
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH v2 2/4] skd: Replace magic numbers with PCI constants
  2019-11-18  0:20 ` [PATCH v2 2/4] skd: Replace magic numbers with PCI constants Frederick Lawler
@ 2019-11-18  1:45   ` Damien Le Moal
  2019-11-19  1:21     ` Frederick Lawler
  0 siblings, 1 reply; 10+ messages in thread
From: Damien Le Moal @ 2019-11-18  1:45 UTC (permalink / raw)
  To: Frederick Lawler, axboe; +Cc: linux-block, linux-kernel, bhelgaas, bvanassche

On 2019/11/18 9:21, Frederick Lawler wrote:
> Readability was improved by replacing pci_read_config_word() with
> pcie_capability_read_word(). Take that a step further by replacing magic
> numbers with PCI reg constants.
> 
> No functional change intended.
> 
> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
> ---
> v2
> - Added this patch
> ---
>  drivers/block/skd_main.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> index f25f6ef6b4c7..7f8243573ad9 100644
> --- a/drivers/block/skd_main.c
> +++ b/drivers/block/skd_main.c
> @@ -3141,9 +3141,11 @@ static char *skd_pci_info(struct skd_device *skdev, char *str)
>  		char lwstr[6];
>  		uint16_t pcie_lstat, lspeed, lwidth;
>  
> -		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
> -		lspeed = pcie_lstat & (0xF);
> -		lwidth = (pcie_lstat & 0x3F0) >> 4;
> +		pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
> +					  &pcie_lstat);
> +		lspeed = pcie_lstat & PCI_EXP_LNKSTA_CLS;
> +		lwidth = (pcie_lstat & PCI_EXP_LNKSTA_NLW) >>
> +			 PCI_EXP_LNKSTA_NLW_SHIFT;
>  
>  		if (lspeed == 1)
>  			strcat(str, "2.5GT/s ");
> 

Looks OK to me. But since this is changing again one line that is added
by patch 1/4, why not make patch 1 and this patch changes a single patch ?

-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH v2 1/4] skd: Prefer pcie_capability_read_word()
  2019-11-18  1:45   ` Damien Le Moal
@ 2019-11-19  1:20     ` Frederick Lawler
  2019-11-19  2:41       ` Damien Le Moal
  0 siblings, 1 reply; 10+ messages in thread
From: Frederick Lawler @ 2019-11-19  1:20 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: axboe, linux-block, linux-kernel, bhelgaas, bvanassche

Damien Le Moal wrote on 11/17/19 7:45 PM:
> On 2019/11/18 9:21, Frederick Lawler wrote:
>> Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
>> added accessors for the PCI Express Capability so that drivers didn't
>> need to be aware of differences between v1 and v2 of the PCI
>> Express Capability.
>>
>> Replace pci_read_config_word() and pci_write_config_word() calls with
>> pcie_capability_read_word() and pcie_capability_write_word().
>>
>> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
>> ---
>>   drivers/block/skd_main.c | 8 ++------
>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
>> index 51569c199a6c..f25f6ef6b4c7 100644
>> --- a/drivers/block/skd_main.c
>> +++ b/drivers/block/skd_main.c
>> @@ -3134,18 +3134,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>>   
>>   static char *skd_pci_info(struct skd_device *skdev, char *str)
>>   {
>> -	int pcie_reg;
>> -
>>   	strcpy(str, "PCIe (");
>> -	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
>>   
>> -	if (pcie_reg) {
>> +	if (pci_is_pcie(skdev->pdev)) {
> 
> Maybe return early here ? The reason is that if pci_is_pcie() is false,
> then the string "PCIe (" is not terminated with a closing parenthesis.
> So something like:
> 
> 	if (!pci_is_pcie(skdev->pdev)) {
> 		strcat(str, ")");
> 		return str;
> 	}
> 
> May be better. Note that the "return str" is also rather pointless since
> it is not used by the caller of skd_pci_info().
> 

I agree, but it might be better to include a note that this is not a 
PCIe device. Reading "PCIe ()" seems weird to me.

>>   
>>   		char lwstr[6];
>>   		uint16_t pcie_lstat, lspeed, lwidth;
>>   
>> -		pcie_reg += 0x12;
>> -		pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
>> +		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
>>   		lspeed = pcie_lstat & (0xF);
>>   		lwidth = (pcie_lstat & 0x3F0) >> 4;
>>   
>>
> 
>

Thanks,
Frederick Lawler


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

* Re: [PATCH v2 2/4] skd: Replace magic numbers with PCI constants
  2019-11-18  1:45   ` Damien Le Moal
@ 2019-11-19  1:21     ` Frederick Lawler
  0 siblings, 0 replies; 10+ messages in thread
From: Frederick Lawler @ 2019-11-19  1:21 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: axboe, linux-block, linux-kernel, bhelgaas, bvanassche

Hi,

Damien Le Moal wrote on 11/17/19 7:45 PM:
> On 2019/11/18 9:21, Frederick Lawler wrote:
>> Readability was improved by replacing pci_read_config_word() with
>> pcie_capability_read_word(). Take that a step further by replacing magic
>> numbers with PCI reg constants.
>>
>> No functional change intended.
>>
>> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
>> ---
>> v2
>> - Added this patch
>> ---
>>   drivers/block/skd_main.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
>> index f25f6ef6b4c7..7f8243573ad9 100644
>> --- a/drivers/block/skd_main.c
>> +++ b/drivers/block/skd_main.c
>> @@ -3141,9 +3141,11 @@ static char *skd_pci_info(struct skd_device *skdev, char *str)
>>   		char lwstr[6];
>>   		uint16_t pcie_lstat, lspeed, lwidth;
>>   
>> -		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
>> -		lspeed = pcie_lstat & (0xF);
>> -		lwidth = (pcie_lstat & 0x3F0) >> 4;
>> +		pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
>> +					  &pcie_lstat);
>> +		lspeed = pcie_lstat & PCI_EXP_LNKSTA_CLS;
>> +		lwidth = (pcie_lstat & PCI_EXP_LNKSTA_NLW) >>
>> +			 PCI_EXP_LNKSTA_NLW_SHIFT;
>>   
>>   		if (lspeed == 1)
>>   			strcat(str, "2.5GT/s ");
>>
> 
> Looks OK to me. But since this is changing again one line that is added
> by patch 1/4, why not make patch 1 and this patch changes a single patch ?
> 

Works for me.

Thanks,
Frederick Lawler


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

* Re: [PATCH v2 1/4] skd: Prefer pcie_capability_read_word()
  2019-11-19  1:20     ` Frederick Lawler
@ 2019-11-19  2:41       ` Damien Le Moal
  0 siblings, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2019-11-19  2:41 UTC (permalink / raw)
  To: Frederick Lawler; +Cc: axboe, linux-block, linux-kernel, bhelgaas, bvanassche

On 2019/11/19 10:20, Frederick Lawler wrote:
> Damien Le Moal wrote on 11/17/19 7:45 PM:
>> On 2019/11/18 9:21, Frederick Lawler wrote:
>>> Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
>>> added accessors for the PCI Express Capability so that drivers didn't
>>> need to be aware of differences between v1 and v2 of the PCI
>>> Express Capability.
>>>
>>> Replace pci_read_config_word() and pci_write_config_word() calls with
>>> pcie_capability_read_word() and pcie_capability_write_word().
>>>
>>> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
>>> ---
>>>   drivers/block/skd_main.c | 8 ++------
>>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
>>> index 51569c199a6c..f25f6ef6b4c7 100644
>>> --- a/drivers/block/skd_main.c
>>> +++ b/drivers/block/skd_main.c
>>> @@ -3134,18 +3134,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>>>   
>>>   static char *skd_pci_info(struct skd_device *skdev, char *str)
>>>   {
>>> -	int pcie_reg;
>>> -
>>>   	strcpy(str, "PCIe (");
>>> -	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
>>>   
>>> -	if (pcie_reg) {
>>> +	if (pci_is_pcie(skdev->pdev)) {
>>
>> Maybe return early here ? The reason is that if pci_is_pcie() is false,
>> then the string "PCIe (" is not terminated with a closing parenthesis.
>> So something like:
>>
>> 	if (!pci_is_pcie(skdev->pdev)) {
>> 		strcat(str, ")");
>> 		return str;
>> 	}
>>
>> May be better. Note that the "return str" is also rather pointless since
>> it is not used by the caller of skd_pci_info().
>>
> 
> I agree, but it might be better to include a note that this is not a 
> PCIe device. Reading "PCIe ()" seems weird to me.

Yes indeed. But since this device is PCIe only, if
pci_is_pcie(skdev->pdev) == false, we should probably fail the driver
initialization.

> 
>>>   
>>>   		char lwstr[6];
>>>   		uint16_t pcie_lstat, lspeed, lwidth;
>>>   
>>> -		pcie_reg += 0x12;
>>> -		pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
>>> +		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
>>>   		lspeed = pcie_lstat & (0xF);
>>>   		lwidth = (pcie_lstat & 0x3F0) >> 4;
>>>   
>>>
>>
>>
> 
> Thanks,
> Frederick Lawler
> 
> 


-- 
Damien Le Moal
Western Digital Research

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

end of thread, other threads:[~2019-11-19  2:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  0:20 [PATCH v2 0/4] skd/mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
2019-11-18  0:20 ` [PATCH v2 1/4] skd: " Frederick Lawler
2019-11-18  1:45   ` Damien Le Moal
2019-11-19  1:20     ` Frederick Lawler
2019-11-19  2:41       ` Damien Le Moal
2019-11-18  0:20 ` [PATCH v2 2/4] skd: Replace magic numbers with PCI constants Frederick Lawler
2019-11-18  1:45   ` Damien Le Moal
2019-11-19  1:21     ` Frederick Lawler
2019-11-18  0:20 ` [PATCH v2 3/4] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
2019-11-18  0:20 ` [PATCH v2 4/4] mtip32xx: Replace magic numbers with PCI constants Frederick Lawler

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).