Re: [PATCH] bcma: fix incorrect update of BCMA_CORE_PCI_MDIO_DATA

From: Colin Ian King
Date: Thu Aug 22 2019 - 12:11:26 EST


On 22/08/2019 17:03, Larry Finger wrote:
> On 8/22/19 8:35 AM, Colin King wrote:
>> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>>
>> An earlier commit re-worked the setting of the bitmask and is now
>> assigning v with some bit flags rather than bitwise or-ing them
>> into v, consequently the earlier bit-settings of v are being lost.
>> Fix this by replacing an assignment with the bitwise or instead.
>>
>> Addresses-Coverity: ("Unused value")
>> Fixes: 2be25cac8402 ("bcma: add constants for PCI and use them")
>> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>> ---
>> Â drivers/bcma/driver_pci.c | 2 +-
>> Â 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
>> index f499a469e66d..d219ee947c07 100644
>> --- a/drivers/bcma/driver_pci.c
>> +++ b/drivers/bcma/driver_pci.c
>> @@ -78,7 +78,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci
>> *pc, u16 device, u8 address)
>> ÂÂÂÂÂÂÂÂÂ v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
>> ÂÂÂÂÂ }
>> Â -ÂÂÂ v = BCMA_CORE_PCI_MDIODATA_START;
>> +ÂÂÂ v |= BCMA_CORE_PCI_MDIODATA_START;
>> ÂÂÂÂÂ v |= BCMA_CORE_PCI_MDIODATA_READ;
>> ÂÂÂÂÂ v |= BCMA_CORE_PCI_MDIODATA_TA;
>
> I'm not sure the "Fixes" attribute is correct.
>
> The changes for this section in commit 2be25cac8402 are
>
> -ÂÂÂÂÂÂ v = (1 << 30); /* Start of Transaction */
> -ÂÂÂÂÂÂ v |= (1 << 28); /* Write Transaction */
> -ÂÂÂÂÂÂ v |= (1 << 17); /* Turnaround */
> -ÂÂÂÂÂÂ v |= (0x1F << 18);
> +ÂÂÂÂÂÂ v = BCMA_CORE_PCI_MDIODATA_START;
> +ÂÂÂÂÂÂ v |= BCMA_CORE_PCI_MDIODATA_WRITE;
> +ÂÂÂÂÂÂ v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
> +ÂÂÂÂÂÂÂÂÂÂÂÂ BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
> +ÂÂÂÂÂÂ v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR <<
> +ÂÂÂÂÂÂÂÂÂÂÂÂ BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
> +ÂÂÂÂÂÂ v |= BCMA_CORE_PCI_MDIODATA_TA;
>
> Because the code has done quite a bit of work on v just above this
> section, I agree that this is likely an error, but that error happened
> in an earlier commit. Thus 2be25cac8402 did not introduce the error,
> merely copied it.

Ugh, this goes back further. I didn't spot that. I'm less confident of
what the correct settings should be now.

>
> Has this change been tested?

Afraid not, I don't have the H/W.

>
> Larry