Received: by 10.192.165.156 with SMTP id m28csp838645imm; Thu, 19 Apr 2018 08:21:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+UppFv8kxujd99IirRuaSGD0F2yNxldL2qwsk93HOoGKy0YM2SW60czHmhueVUANSn7sQW X-Received: by 10.99.99.68 with SMTP id x65mr5550808pgb.34.1524151297753; Thu, 19 Apr 2018 08:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524151297; cv=none; d=google.com; s=arc-20160816; b=hpMGUujMZCBS3rMdF7FubdXfMV9K3sF5q15TOHoF/roOgzNyk/OaoB0ylRSlUAVLUb PM6AcdVnVTJDw+Hr2TbXXfyfNp9a+csqZf59x+Y7xrl5ijI7M7MYPy+M7AX/66qAEZAR BQBSQCIHCw0QeUGgFQG8+9gGSL8Kv8UQe0Y5E7oAQHehBQPtEjwmauhcSRTFjuFfvQV9 zr3v4RruV8firS2EJaDf9KWLmnkLBzpw9V+qsjg7Nbr/VHLxpMqLvTbFtl36IxLlX/H3 EVRkNookTXVb48QVzaaZAd9HExMNHNO16mxA4rd0VaBSaX87wD76yNZFevC1O+l+72hR OZtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Qrlx6ZTSdpzgJr6mK55FDXCoEEjPleAorCf5U/n1BsY=; b=x31cKxixHr3TnT/L7JZP47NelPxzOKw/7+tFrj0w+ulcHNbO7Fdcax+YafqMcJeKPj fds4vvzJzoqZS8LXcAg+u/55AN5hDbozkkpuEJpODutRTx0V4WPALY6yfvqC4K3zk9DT ONmqpm0+6TwgTO+b+zxijESmue90093quT3F3cFBoic+oLyEio6VdUyBYtN3tqCsX1qM 0okhhzbWMH773q39/c3v3W4agxiyB4REjoyAGgW8UZG3yY2AZ6dTxj5g6YoR+j7bxfqo UZzTMu2D+CjlSKJ4hyJcQgR7POJUfHIeMJEczwWLNIo4hcgavpKNfRqkVlsCFpzMP3+h Q+vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=h9AqDPjg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si3426593pfg.298.2018.04.19.08.21.24; Thu, 19 Apr 2018 08:21:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=h9AqDPjg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753340AbeDSPTl (ORCPT + 99 others); Thu, 19 Apr 2018 11:19:41 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:34159 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753290AbeDSPTh (ORCPT ); Thu, 19 Apr 2018 11:19:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Qrlx6ZTSdpzgJr6mK55FDXCoEEjPleAorCf5U/n1BsY=; b=h9AqDPjg2PT73Il7msiYgRcp9MJ/KXwzZ1IyB9fqDYuW9YsBY1jklJP1OlXCEHZtl3dcVpLXYyBrPbeN7HZX+q1FCwDdTSu5QHcltjLElO1XJ2MMVif47tO7lDbJP7r3OiKTy6tIjISK6AUv6PvloqEfKI4u3q6kqv6wrDOuSBw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1f9BLF-0000f2-6X; Thu, 19 Apr 2018 17:19:21 +0200 Date: Thu, 19 Apr 2018 17:19:21 +0200 From: Andrew Lunn To: Phil Elwell Cc: Woojung Huh , Microchip Linux Driver Support , Rob Herring , Mark Rutland , "David S. Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linus Walleij , Andrew Morton , Randy Dunlap , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v3 2/3] lan78xx: Read LED states from Device Tree Message-ID: <20180419151921.GC29658@lunn.ch> References: <1524148325-78945-1-git-send-email-phil@raspberrypi.org> <1524148325-78945-4-git-send-email-phil@raspberrypi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524148325-78945-4-git-send-email-phil@raspberrypi.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -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 &= ~(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