Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0339C169C4 for ; Wed, 30 Jan 2019 00:41:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7AEE21473 for ; Wed, 30 Jan 2019 00:41:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="ZNKruN2h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbfA3All (ORCPT ); Tue, 29 Jan 2019 19:41:41 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:60011 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbfA3All (ORCPT ); Tue, 29 Jan 2019 19:41:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TYMV9Tz8GaBESVueH9hjhnXMxTdr/7smvjlveGTGVvE=; b=ZNKruN2h83KvpmWKa0HcFO4Aq8 HxvBbPzBKPzChopHpHZZm/SKPZfniMH+YjCpGkUWQ5AobgXETFwUZUSXZT3Rebnt6RnCa22VlIQcl co9pYM1CUF0+bu3c+qgzrHxYZI6qm0693lwHb5FWKOwXmPzfExxNaDLfF9GKZaZEWnw0=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1godtb-0006Dm-18; Wed, 30 Jan 2019 01:38:27 +0100 From: Andrew Lunn To: netdev Cc: Vivien Didelot , Florian Fainelli , Pavel Machek , Andrew Lunn Subject: [PATCH RFC RFT net-next 02/10] net: dsa: mv88e6060: Replace ds with priv Date: Wed, 30 Jan 2019 01:37:50 +0100 Message-Id: <20190130003758.23852-3-andrew@lunn.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190130003758.23852-1-andrew@lunn.ch> References: <20190130003758.23852-1-andrew@lunn.ch> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass around priv, not ds. This will help with changing to an mdio driver, and makes this driver more like mv88e6xxx. Signed-off-by: Andrew Lunn --- drivers/net/dsa/mv88e6060.c | 43 +++++++++++++++++++------------------ drivers/net/dsa/mv88e6060.h | 1 + 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c index 0b3e51f248c2..631358bf3d6b 100644 --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c @@ -18,10 +18,8 @@ #include #include "mv88e6060.h" -static int reg_read(struct dsa_switch *ds, int addr, int reg) +static int reg_read(struct mv88e6060_priv *priv, int addr, int reg) { - struct mv88e6060_priv *priv = ds->priv; - return mdiobus_read_nested(priv->bus, priv->sw_addr + addr, reg); } @@ -29,17 +27,15 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) ({ \ int __ret; \ \ - __ret = reg_read(ds, addr, reg); \ + __ret = reg_read(priv, addr, reg); \ if (__ret < 0) \ return __ret; \ __ret; \ }) -static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) +static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val) { - struct mv88e6060_priv *priv = ds->priv; - return mdiobus_write_nested(priv->bus, priv->sw_addr + addr, reg, val); } @@ -47,7 +43,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) ({ \ int __ret; \ \ - __ret = reg_write(ds, addr, reg, val); \ + __ret = reg_write(priv, addr, reg, val); \ if (__ret < 0) \ return __ret; \ }) @@ -97,7 +93,7 @@ static const char *mv88e6060_drv_probe(struct device *dsa_dev, return name; } -static int mv88e6060_switch_reset(struct dsa_switch *ds) +static int mv88e6060_switch_reset(struct mv88e6060_priv *priv) { int i; int ret; @@ -133,7 +129,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) return 0; } -static int mv88e6060_setup_global(struct dsa_switch *ds) +static int mv88e6060_setup_global(struct mv88e6060_priv *priv) { /* Disable discarding of frames with excessive collisions, * set the maximum frame size to 1536 bytes, and mask all @@ -149,7 +145,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds) return 0; } -static int mv88e6060_setup_port(struct dsa_switch *ds, int p) +static int mv88e6060_setup_port(struct mv88e6060_priv *priv, int p) { int addr = REG_PORT(p); @@ -159,7 +155,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) * port, enable Ingress and Egress Trailer tagging mode. */ REG_WRITE(addr, PORT_CONTROL, - dsa_is_cpu_port(ds, p) ? + dsa_is_cpu_port(priv->ds, p) ? PORT_CONTROL_TRAILER | PORT_CONTROL_INGRESS_MODE | PORT_CONTROL_STATE_FORWARDING : @@ -172,8 +168,8 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) */ REG_WRITE(addr, PORT_VLAN_MAP, ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) | - (dsa_is_cpu_port(ds, p) ? dsa_user_ports(ds) : - BIT(dsa_to_port(ds, p)->cpu_dp->index))); + (dsa_is_cpu_port(priv->ds, p) ? dsa_user_ports(priv->ds) : + BIT(dsa_to_port(priv->ds, p)->cpu_dp->index))); /* Port Association Vector: when learning source addresses * of packets, add the address to the address database using @@ -185,7 +181,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) return 0; } -static int mv88e6060_setup_addr(struct dsa_switch *ds) +static int mv88e6060_setup_addr(struct mv88e6060_priv *priv) { u8 addr[ETH_ALEN]; u16 val; @@ -208,25 +204,28 @@ static int mv88e6060_setup_addr(struct dsa_switch *ds) static int mv88e6060_setup(struct dsa_switch *ds) { + struct mv88e6060_priv *priv = ds->priv; int ret; int i; - ret = mv88e6060_switch_reset(ds); + priv->ds = ds; + + ret = mv88e6060_switch_reset(priv); if (ret < 0) return ret; /* @@@ initialise atu */ - ret = mv88e6060_setup_global(ds); + ret = mv88e6060_setup_global(priv); if (ret < 0) return ret; - ret = mv88e6060_setup_addr(ds); + ret = mv88e6060_setup_addr(priv); if (ret < 0) return ret; for (i = 0; i < MV88E6060_PORTS; i++) { - ret = mv88e6060_setup_port(ds, i); + ret = mv88e6060_setup_port(priv, i); if (ret < 0) return ret; } @@ -243,25 +242,27 @@ static int mv88e6060_port_to_phy_addr(int port) static int mv88e6060_phy_read(struct dsa_switch *ds, int port, int regnum) { + struct mv88e6060_priv *priv = ds->priv; int addr; addr = mv88e6060_port_to_phy_addr(port); if (addr == -1) return 0xffff; - return reg_read(ds, addr, regnum); + return reg_read(priv, addr, regnum); } static int mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val) { + struct mv88e6060_priv *priv = ds->priv; int addr; addr = mv88e6060_port_to_phy_addr(port); if (addr == -1) return 0xffff; - return reg_write(ds, addr, regnum, val); + return reg_write(priv, addr, regnum, val); } static const struct dsa_switch_ops mv88e6060_switch_ops = { diff --git a/drivers/net/dsa/mv88e6060.h b/drivers/net/dsa/mv88e6060.h index 10249bd16292..c0e7a0f2fb6a 100644 --- a/drivers/net/dsa/mv88e6060.h +++ b/drivers/net/dsa/mv88e6060.h @@ -117,6 +117,7 @@ struct mv88e6060_priv { */ struct mii_bus *bus; int sw_addr; + struct dsa_switch *ds; }; #endif -- 2.20.1