Received: by 10.192.165.156 with SMTP id m28csp2033843imm; Thu, 12 Apr 2018 07:34:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+fJ7Pbx5BridL/CfmBkuf79RsyLsBF7JxOinQhQ4LkUqy1BanYYomaFoHgCYUZhYHJMcdy X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr1321965plg.320.1523543669352; Thu, 12 Apr 2018 07:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523543669; cv=none; d=google.com; s=arc-20160816; b=NPjCZAeHyr+hldr1bQklNEQ4+M83VThG17lKBWBGpV6TNWNHOrE5wWl5KyOGCxoLzG HdVacZUw/c7KFHDX5afzWgO/a5aQJhIurb9Hq+rnBSjzdRhP57aIskqfhthtqEzuw4jU ClvITNBAUAc1Fb3e4YoleRtZLFOfdVhD2+a3rDzPeH9ESW/2SZquKsRzfoT4q8z9LyY6 20sDd2s+OFRhLkqIm7/c0NiAJPBEGombnQfWIRq2qPQXGCWmyrNVvYmWkP6wzWRJ5vt2 aCJOM0Hr9pDq0Lz6mK8IOHFI0G2I/8r1JvTqWp7Ic+ONtNZeMlUpeJXpyXjxS8h7UMPW Giag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :dkim-signature:arc-authentication-results; bh=u5BaUZzd9v1pgehA/lTKIrk9e7zTV/hj08an0/Fv4xc=; b=XhaG3nEtYENqxj+0usIxH/flIHOHcY2MtzylooAvoF3vp1IKz6B2+36G0qnvbP1yML F+HYI363WkcTKzfE3fd1wq/EixrWVadirsCemvx4xzY5Z3iweFaUhSgiBlbejrD97LYF 7xot7A46FUvZtU+l5pxT0fZZm76+dbzS67hkIJsLDyYMPh0jcbINVW2BVWJZUtM4ND9u pJBMgpe37Jup6czNel6zh3YluoWYnRSC3H9EjhbLp8nKCIubxeK02IU7xey9Jw+0HfoK EgRtrRCO14lj9iAIqY5lJrW8lSud9Yjhf6mjjMFwF96JxE7omGWB96GnMG8UpShT3cQ6 g3oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@raspberrypi.org header.s=pp header.b=qfC8fMSF; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=I48mnqsi; 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 k70si2378510pgc.622.2018.04.12.07.33.52; Thu, 12 Apr 2018 07:34:29 -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=fail header.i=@raspberrypi.org header.s=pp header.b=qfC8fMSF; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=I48mnqsi; 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 S1753181AbeDLOac (ORCPT + 99 others); Thu, 12 Apr 2018 10:30:32 -0400 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]:42340 "EHLO mx08-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753077AbeDLOa2 (ORCPT ); Thu, 12 Apr 2018 10:30:28 -0400 Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3CEPTrD031936 for ; Thu, 12 Apr 2018 15:30:27 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp; bh=u5BaUZzd9v1pgehA/lTKIrk9e7zTV/hj08an0/Fv4xc=; b=qfC8fMSF2cqkwPSOG2z5HNfNVJl9PTPlcuLWBQp6oxs8z2KmQIQLhGc6Ber2URjbd2JO LMWr8OOGX7uRG3XKjmVIywjO7OGq5oVOoa7WimvL9Uzqp6kD0g3nV6vebJ8w5sf9mCFT DAlo7983w6TwFWy7BOOryOJXf1pJZwHTjrAaTzKANu33lsWwmlI2ZlVbj3x5+H8hSyPH dT0F+paT+kOLE5Vrdw8X1F9ezHrp8Z+UD1wbSuI3+DD296lLbpYEHdcYXNQCL4GNz7Ix E9hRB4DtMYgTfeUy6HfBGLxpp+p1mNgaKCRvgoYk/cNMokfIzGEdDplPPB7j5xQiZohG lA== Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by mx08-00252a01.pphosted.com with ESMTP id 2h6trdtk91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Thu, 12 Apr 2018 15:30:27 +0100 Received: by mail-wm0-f70.google.com with SMTP id b23so2874607wme.3 for ; Thu, 12 Apr 2018 07:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=u5BaUZzd9v1pgehA/lTKIrk9e7zTV/hj08an0/Fv4xc=; b=I48mnqsiWw67VCJ1p0+RkYAqBoKq+CZ4uEbvu56MhD0Z1YJ4l2W63oR99eefnoCLcr Mv2dbQU8jxMrU2PhqMgST7NPNiydeQe+egVC9HylITfbNgbbtDAYCoJrKUFqwB47Fq6m HwCEcGb121/Ft+tGiTue7t6r6WZK5+i4zYGp+uZMiItY7nZUNokLtFWeq4GuFnm4jGAJ BEX7V0EpagQACriHu4do4TuwAp2Wriu5O4s1RN+qPKhDOoMCIptTqFOsPRkwY2fX+Fyx 24znl5M5Sk/RkKeADqQSs6mbdtDCFYGTPTkQ51IMEDxEH+fPf4vAU53K5RanyKYcrVDp sVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=u5BaUZzd9v1pgehA/lTKIrk9e7zTV/hj08an0/Fv4xc=; b=f7rE+ga6SjHdanVlaAxW45DWIlO2mTqc5KxeM/hmqLwTBDQSKcDI7YpawgRGzvYX96 +AYjHP7Sd6fFU2oQS+Z61gsG3VeIzeJf0+MoVuBA2UmlqqyZ7INp/7tfDmpI6GVoSQJf wTPjmmjHOx+5DtnucdtM4r47D1Vjp4gArDNSD5nkJ6qriRCOEtwWGzerPfpFtMMvPKTY 71Q83aKkiIM00P7fGoIW5QyABcSyeJLfBkrnZhp0BqdAbGa3ky4825W4xmgxKajR6kM8 RvrMnm7rKwHldTGA7yWaMYvMC0BD0QEAaeG94F+2YHzLP4NRN9IMC1z1Tc7x2Y2wPHXr 7Gwg== X-Gm-Message-State: ALQs6tCEc2sd4Qvr4l4OJ4LiScR9TR4qcHpwMW07wJlUCIPIejlpaQRv 7dBHmfvGZmXW6X1IWfH03001/g2ymRwFXg/IpGSK6iwTGgpXFdVh9ZHb+ouBtyBP/j5DPoHY0b/ G9NdixPrznwPS1a4YUIa2qbF/ X-Received: by 10.28.230.148 with SMTP id e20mr872672wmi.89.1523543426666; Thu, 12 Apr 2018 07:30:26 -0700 (PDT) X-Received: by 10.28.230.148 with SMTP id e20mr872651wmi.89.1523543426487; Thu, 12 Apr 2018 07:30:26 -0700 (PDT) Received: from ?IPv6:2a00:2381:fdf7:14:8da9:f6b6:f0c3:26ea? ([2a00:2381:fdf7:14:8da9:f6b6:f0c3:26ea]) by smtp.gmail.com with ESMTPSA id p14sm6755571wrc.30.2018.04.12.07.30.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 07:30:26 -0700 (PDT) Subject: Re: [PATCH 3/4] lan78xx: Read LED modes from Device Tree To: Andrew Lunn 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 References: <1523541336-145953-1-git-send-email-phil@raspberrypi.org> <1523541336-145953-4-git-send-email-phil@raspberrypi.org> <20180412142615.GO28963@lunn.ch> From: Phil Elwell Message-ID: <50bd418e-9f26-5d4f-f4bf-6355f08b22e1@raspberrypi.org> Date: Thu, 12 Apr 2018 15:30:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180412142615.GO28963@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-12_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On 12/04/2018 15:26, Andrew Lunn wrote: > 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. Good idea. > >> >> 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. Will do. Thanks, Phil