Received: by 10.192.165.156 with SMTP id m28csp2031753imm; Thu, 12 Apr 2018 07:32:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx49aiCvlLPNos0XOm2yzxT00K1Z1dNQQru0LBE3MaXT9yXoFWWjwD/7uZvSVKh88dPc4nq6u X-Received: by 10.98.32.80 with SMTP id g77mr7959396pfg.216.1523543560047; Thu, 12 Apr 2018 07:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523543560; cv=none; d=google.com; s=arc-20160816; b=zsMzxYNp2MdHJdqaPD0kubtAyOqqAgoEMKdp3RGJlcjR6xwa1O5v74rHwMPtT6Swdy 0ryogGFXQjFNDBcc2UGSlibJiafgDz4W3rS3JIzkG9lqTi1yLwkqjOsySjTqSUVuaEpl nNW5PvzAVlZlrwBUh+fRRx0lskUr98PFylZphhCTw3+ApGPitxXX3u67h0mAoxzL/+1/ 06216hou/S6fVCJd9JlMaE/BQfyrwzpWmzd4BhnnDyHapkTmqCFPJ1U5ZofItQGdEsEC Zklhqw8bpx0CJmOfcH9iRmqkU2/TeBJFlk/iCKtf7wodRo/5SneTxBcp3Fp60m/JPnnh hD7w== 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=OyuXyrXnVYBjEp707UIYhbxdkTR6JqaFTUtw7crnKU4=; b=zGw9WKBD3cMzQc+L1QtMeNSbnTQN7T9N8I1ye8SnnaEEkx3lCkXnsHtY6ppVT5AFYf pQJbVohDvfxJkXb20tzlVXlJckimRMJRcSGm3BbkD2ju5yMhrfy3a3yQqx2uLBkeU+4T 9cKeq0Ch8F1M9a66AXT58gfpWUhnQhzkVdLxPZAYrhIy0cER9R9y685Qo+CRGlf3w/QD L+F5siTJ9nWBvv3AY9gEl0f9pwOvgEpmABUYB2yncgyM6WVWkWRC4zxvoRJSLHKT8KAD 0NMFypnhW2LO20e7bxRjpEFTJVg3EEfwL/vSnqvAK1jR9IBf+a1fsB5QWWz8xX3YuaX9 itng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=UvXuqkAE; 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 p19-v6si3524232plo.708.2018.04.12.07.32.03; Thu, 12 Apr 2018 07:32:40 -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=UvXuqkAE; 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 S1752966AbeDLO00 (ORCPT + 99 others); Thu, 12 Apr 2018 10:26:26 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:56629 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbeDLO0Z (ORCPT ); Thu, 12 Apr 2018 10:26:25 -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=OyuXyrXnVYBjEp707UIYhbxdkTR6JqaFTUtw7crnKU4=; b=UvXuqkAEI+beJ4gDZ5svlUQy0rR31tWGiJiio3PZunhDxEZYoFe6M62xW6ihI0aawXFw6WbYyuZs55IRLcJDM5NNkwV9j44uAvxtTiZxdHsboQqDddS+8z3IjcIM53sPWOaZBiLVjNHBWAEuG11Vmhv9jEz4FX6WcKyPJefMfuM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1f6dB1-0008VA-Ha; Thu, 12 Apr 2018 16:26:15 +0200 Date: Thu, 12 Apr 2018 16:26:15 +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 3/4] lan78xx: Read LED modes from Device Tree Message-ID: <20180412142615.GO28963@lunn.ch> References: <1523541336-145953-1-git-send-email-phil@raspberrypi.org> <1523541336-145953-4-git-send-email-phil@raspberrypi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523541336-145953-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 On Thu, Apr 12, 2018 at 02:55:35PM +0100, Phil Elwell wrote: > Add support for DT property "microchip,led-modes", a vector of two > cells (u32s) in the range 0-15, each of which sets the mode for one > of the two LEDs. Some possible values are: > > 0=link/activity 1=link1000/activity > 2=link100/activity 3=link10/activity > 4=link100/1000/activity 5=link10/1000/activity > 6=link10/100/activity 14=off 15=on > > Also use the presence of the DT property to indicate that the > LEDs should be enabled - necessary in the event that no valid OTP > or EEPROM is available. I'm not a fan of this, but at the moment, we don't have anything better. Please follow what mscc does, add a header file for the LED settings. Andrew > > Signed-off-by: Phil Elwell > --- > drivers/net/usb/lan78xx.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c > index d98397b..ffb483d 100644 > --- a/drivers/net/usb/lan78xx.c > +++ b/drivers/net/usb/lan78xx.c > @@ -2008,6 +2008,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) > { > int ret; > u32 mii_adv; > + u32 led_modes[2]; > struct phy_device *phydev; > > phydev = phy_find_first(dev->mdiobus); > @@ -2097,6 +2098,25 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) > (void)lan78xx_set_eee(dev->net, &edata); > } > > + if (!of_property_read_u32_array(dev->udev->dev.of_node, > + "microchip,led-modes", > + led_modes, ARRAY_SIZE(led_modes))) { > + u32 reg; > + int i; > + > + reg = phy_read(phydev, 0x1d); > + for (i = 0; i < ARRAY_SIZE(led_modes); i++) { > + reg &= ~(0xf << (i * 4)); > + reg |= (led_modes[i] & 0xf) << (i * 4); > + } Please add range checks for led_modes[i] and return -EINVAL if the check fails. Andrew