On Tue, Mar 14, 2023 at 11:15:08AM +0100, Christian Marangi wrote: > From: Andrew Lunn <andrew@xxxxxxx> > > Add a brightness function, so the LEDs can be controlled from > software using the standard Linux LED infrastructure. > > Signed-off-by: Andrew Lunn <andrew@xxxxxxx> > Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx> > --- > +static int m88e1318_led_brightness_set(struct phy_device *phydev, > + u32 index, enum led_brightness value) > +{ > + u16 reg; > + > + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, > + MII_88E1318S_PHY_LED_FUNC); > + if (reg < 0) > + return reg; "reg" is declared as unsigned, so it's surely positive. > + > + switch (index) { > + case 0: > + case 1: > + case 2: > + reg &= ~(0xf << (4 * index)); > + if (value == LED_OFF) > + reg |= MII_88E1318S_PHY_LED_FUNC_OFF << (4 * index); > + else > + reg |= MII_88E1318S_PHY_LED_FUNC_ON << (4 * index); > + break; > + default: > + return -EINVAL; > + } > + > + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, > + MII_88E1318S_PHY_LED_FUNC, reg); > +}