[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bcb3b591-c759-2f5e-762b-ea0485e95758@gmail.com>
Date: Fri, 8 Feb 2019 19:34:21 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>,
David Miller <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net: phy: disregard "Clause 22 registers
present" bit in get_phy_c45_devs_in_pkg
On 08.02.2019 19:27, Andrew Lunn wrote:
>>>> - *devices_in_package |= (phy_reg & 0xffff);
>>>> + /* Bit 0 doesn't represent a device, it indicates c22 regs presence */
>>>> + *devices_in_package |= (phy_reg & 0xfffe);
>>>
>>> Hi Heiner
>>>
>>> Just for readability, can we use BIT(0) in there somehow?
>>>
>> You think 0xfffe together with the comment is still not clear enough?
>
> Hi Heiner
>
> It is more i was wondering why the 0xffff was there in the first
> place. PHY registers are 16 bits. Is this because of a compiler
> warning? If the use of 0xffff is not obvious, why would 0xfffe be any
> better.
>
I think there are more places where this masking is used, most likely
to make clearer that we care about the lower 16 bits of the int only.
And I also wondered when seeing such code whether it's technically
needed.
>>>> /* Device present registers. */
>>>> #define MDIO_DEVS_PRESENT(devad) (1 << (devad))
>>>> +#define MDIO_DEVS_C22PRESENT MDIO_DEVS_PRESENT(0)
>>>
>>> Err. The commit message says you did not add this...
>>>
>> Maybe I'm not clear enough in the commit message. Typically we have two
>> constants for a device:
>>
>> MDIO_MMD_XXX (for the device)
>> MDIO_DEVS_XXX (for the bit of the device in the device list bitmap)
>>
>> For the C22PRESENT flag I don't define the first one (because it's
>> not a device) but the second one (because it uses a bit in the device
>> list bitmap).
>
> This would be better as a separate patch. It is not used here, and the
> explanation can then be made clearer.
>
OK. Definition of this constant is more meant as a favor to developers
who may want to check this flag in the future.
> Andrew
>
Heiner
Powered by blists - more mailing lists