Skip to content

Commit

Permalink
net: phy: Fix reading LED reg property
Browse files Browse the repository at this point in the history
'reg' is always encoded in 32 bits, thus it has to be read using the
function with the corresponding bit width.

Fixes: 01e5b72 ("net: phy: Add a binding for PHY LEDs")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230424141648.317944-1-alexander.stein@ew.tq-group.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Alexander Stein authored and Jakub Kicinski committed Apr 25, 2023
1 parent e515c33 commit aed8fda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,7 @@ static int of_phy_led(struct phy_device *phydev,
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);
Expand All @@ -3037,10 +3038,13 @@ static int of_phy_led(struct phy_device *phydev,
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)
Expand Down

0 comments on commit aed8fda

Please sign in to comment.