From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755751AbcIMIE4 (ORCPT ); Tue, 13 Sep 2016 04:04:56 -0400 Received: from nbd.name ([46.4.11.11]:56920 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbcIMIEx (ORCPT ); Tue, 13 Sep 2016 04:04:53 -0400 Subject: Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family To: Andrew Lunn References: <1473669337-21221-1-git-send-email-john@phrozen.org> <1473669337-21221-4-git-send-email-john@phrozen.org> <20160913004047.GB3585@lunn.ch> Cc: "David S. Miller" , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, qsdk-review@qca.qualcomm.com From: John Crispin Message-ID: <7f9c1463-1cc0-e230-e7fe-dbb434427251@phrozen.org> Date: Tue, 13 Sep 2016 10:04:49 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160913004047.GB3585@lunn.ch> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/09/2016 02:40, Andrew Lunn wrote: >> > +static int >> > +qca8k_get_eee(struct dsa_switch *ds, int port, >> > + struct ethtool_eee *e) >> > +{ >> > + struct qca8k_priv *priv = qca8k_to_priv(ds); >> > + struct ethtool_eee *p = &priv->port_sts[qca8k_phy_to_port(port)].eee; >> > + u32 lp, adv, supported; >> > + u16 val; >> > + >> > + /* The switch has no way to tell the result of the AN so we need to >> > + * read the result directly from the PHYs MMD registers >> > + */ >> > + val = qca8k_phy_mmd_read(priv, port, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); >> > + supported = mmd_eee_cap_to_ethtool_sup_t(val); >> > + >> > + val = qca8k_phy_mmd_read(priv, port, MDIO_MMD_AN, MDIO_AN_EEE_ADV); >> > + adv = mmd_eee_adv_to_ethtool_adv_t(val); >> > + >> > + val = qca8k_phy_mmd_read(priv, port, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); >> > + lp = mmd_eee_adv_to_ethtool_adv_t(val); >> > + >> > + e->eee_enabled = p->eee_enabled; >> > + e->eee_active = !!(supported & adv & lp); >> > + >> > + return 0; >> > +} > Couldn't you just call phy_ethtool_get_eee(phydev)? Then you don't > need qca8k_phy_mmd_read()? Hi Andrew, this function does indeed duplicate the functionality of phy_ethtool_get_eee() with the small difference, that e->eee_active is also set which phy_ethtool_get_eee() does not set. dsa_slave_get_eee() will call phy_ethtool_get_eee() right after the get_eee() op has been called. would it be ok to move the code setting eee_active to phy_ethtool_get_eee(). if thats possible then we could just have a stub inside the dsa driver with a note saying that the dsa layer will do the magic for us. John