lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7f614cd-fe39-4746-8a83-2a2d14fc46f4@denx.de>
Date: Fri, 28 Jun 2024 20:58:51 +0200
From: Marek Vasut <marex@...x.de>
To: Simon Horman <horms@...nel.org>
Cc: netdev@...r.kernel.org, Alexandre Torgue <alexandre.torgue@...s.st.com>,
 Andrew Lunn <andrew@...n.ch>,
 Christophe Roullier <christophe.roullier@...s.st.com>,
 "David S . Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Heiner Kallweit <hkallweit1@...il.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Russell King <linux@...linux.org.uk>, kernel@...electronics.com,
 linux-kernel@...r.kernel.org
Subject: Re: [net-next,PATCH v2] net: phy: realtek: Add support for PHY LEDs
 on RTL8211F

On 6/28/24 4:27 PM, Simon Horman wrote:
> On Tue, Jun 25, 2024 at 10:42:17PM +0200, Marek Vasut wrote:
>> Realtek RTL8211F Ethernet PHY supports 3 LED pins which are used to
>> indicate link status and activity. Add minimal LED controller driver
>> supporting the most common uses with the 'netdev' trigger.
>>
>> Signed-off-by: Marek Vasut <marex@...x.de>
>> ---
>> Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>
>> Cc: Andrew Lunn <andrew@...n.ch>
>> Cc: Christophe Roullier <christophe.roullier@...s.st.com>
>> Cc: David S. Miller <davem@...emloft.net>
>> Cc: Eric Dumazet <edumazet@...gle.com>
>> Cc: Heiner Kallweit <hkallweit1@...il.com>
>> Cc: Jakub Kicinski <kuba@...nel.org>
>> Cc: Paolo Abeni <pabeni@...hat.com>
>> Cc: Russell King <linux@...linux.org.uk>
>> Cc: kernel@...electronics.com
>> Cc: linux-kernel@...r.kernel.org
>> Cc: netdev@...r.kernel.org
>> ---
>> V2: - RX and TX are not differentiated, either both are set or not set,
>>        filter this in rtl8211f_led_hw_is_supported()
>> ---
>>   drivers/net/phy/realtek.c | 106 ++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 106 insertions(+)
>>
>> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
>> index 2174893c974f3..bed839237fb55 100644
>> --- a/drivers/net/phy/realtek.c
>> +++ b/drivers/net/phy/realtek.c
>> @@ -32,6 +32,15 @@
>>   #define RTL8211F_PHYCR2				0x19
>>   #define RTL8211F_INSR				0x1d
>>   
>> +#define RTL8211F_LEDCR				0x10
>> +#define RTL8211F_LEDCR_MODE			BIT(15)
>> +#define RTL8211F_LEDCR_ACT_TXRX			BIT(4)
>> +#define RTL8211F_LEDCR_LINK_1000		BIT(3)
>> +#define RTL8211F_LEDCR_LINK_100			BIT(1)
>> +#define RTL8211F_LEDCR_LINK_10			BIT(0)
>> +#define RTL8211F_LEDCR_MASK			GENMASK(4, 0)
>> +#define RTL8211F_LEDCR_SHIFT			5
>> +
> 
> Hi Marek,
> 
> FWIIW, I think that if you use FIELD_PREP and FIELD_GET then
> RTL8211F_LEDCR_SHIFT can be removed.

FIELD_PREP/FIELD_GET only works for constant mask, in this case the mask 
is not constant but shifted by SHIFT*index .

Other drivers introduce workarounds like this for exactly this issue:

drivers/clk/at91/pmc.h:#define field_prep(_mask, _val) (((_val) << 
(ffs(_mask) - 1)) & (_mask))

I don't think it is worth perpetuating that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ