12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- From aed8fdad2152d946add50bec00a6b07c457bdcdf Mon Sep 17 00:00:00 2001
- From: Alexander Stein <[email protected]>
- Date: Mon, 24 Apr 2023 16:16:48 +0200
- Subject: [PATCH] net: phy: Fix reading LED reg property
- 'reg' is always encoded in 32 bits, thus it has to be read using the
- function with the corresponding bit width.
- Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
- Signed-off-by: Alexander Stein <[email protected]>
- Reviewed-by: Andrew Lunn <[email protected]>
- Reviewed-by: Florian Fainelli <[email protected]>
- Link: https://lore.kernel.org/r/[email protected]
- Signed-off-by: Jakub Kicinski <[email protected]>
- ---
- drivers/net/phy/phy_device.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
- --- a/drivers/net/phy/phy_device.c
- +++ b/drivers/net/phy/phy_device.c
- @@ -2974,6 +2974,7 @@ static int of_phy_led(struct phy_device
- struct led_init_data init_data = {};
- struct led_classdev *cdev;
- struct phy_led *phyled;
- + u32 index;
- int err;
-
- phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL);
- @@ -2983,10 +2984,13 @@ static int of_phy_led(struct phy_device
- cdev = &phyled->led_cdev;
- phyled->phydev = phydev;
-
- - err = of_property_read_u8(led, "reg", &phyled->index);
- + err = of_property_read_u32(led, "reg", &index);
- if (err)
- return err;
- + if (index > U8_MAX)
- + return -EINVAL;
-
- + phyled->index = index;
- if (phydev->drv->led_brightness_set)
- cdev->brightness_set_blocking = phy_led_set_brightness;
- if (phydev->drv->led_blink_set)
|