lkml.org 
[lkml]   [2018]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/3] lan78xx: Read LED states from Device Tree
> @@ -2077,6 +2085,28 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
> mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control);
> phydev->advertising |= mii_adv_to_ethtool_adv_t(mii_adv);
>
> + if (phydev->mdio.dev.of_node) {
> + u32 reg;
> + int len;
> +
> + len = of_property_count_elems_of_size(phydev->mdio.dev.of_node,
> + "microchip,led-modes",
> + sizeof(u32));
> + if (len >= 0) {
> + /* Ensure the appropriate LEDs are enabled */
> + lan78xx_read_reg(dev, HW_CFG, &reg);
> + reg &= ~(HW_CFG_LED0_EN_ |
> + HW_CFG_LED1_EN_ |
> + HW_CFG_LED2_EN_ |
> + HW_CFG_LED3_EN_);
> + reg |= (len > 0) * HW_CFG_LED0_EN_ |
> + (len > 1) * HW_CFG_LED1_EN_ |
> + (len > 2) * HW_CFG_LED2_EN_ |
> + (len > 3) * HW_CFG_LED3_EN_;
> + lan78xx_write_reg(dev, HW_CFG, reg);
> + }
> + }
> +

Humm. Not nice. But i cannot think of a cleaner way of doing this.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Andrew

\
 
 \ /
  Last update: 2018-04-19 17:20    [W:0.095 / U:1.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site