From patchwork Sat Jun 18 00:07:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivien Didelot X-Patchwork-Id: 637344 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rWct36g1nz9syq for ; Sat, 18 Jun 2016 10:08:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161057AbcFRAIi (ORCPT ); Fri, 17 Jun 2016 20:08:38 -0400 Received: from mail.savoirfairelinux.com ([208.88.110.44]:39231 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933199AbcFRAI0 (ORCPT ); Fri, 17 Jun 2016 20:08:26 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 6FA75620E3C; Fri, 17 Jun 2016 20:08:24 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id S_4YNeWXqTS1; Fri, 17 Jun 2016 20:08:15 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B5838620E47; Fri, 17 Jun 2016 20:08:12 -0400 (EDT) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qfLm1zTtAhPM; Fri, 17 Jun 2016 20:08:12 -0400 (EDT) Received: from ketchup.mtl.sfl (unknown [192.168.48.170]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 5178E620E86; Fri, 17 Jun 2016 20:08:12 -0400 (EDT) From: Vivien Didelot To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Andrew Lunn , Florian Fainelli , Ben Dooks , Sergei Shtylyov , Vivien Didelot Subject: [PATCH v3 net-next v3 12/14] net: dsa: mv88e6xxx: pass compatible info Date: Fri, 17 Jun 2016 20:07:34 -0400 Message-Id: <20160618000736.5598-13-vivien.didelot@savoirfairelinux.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160618000736.5598-1-vivien.didelot@savoirfairelinux.com> References: <20160618000736.5598-1-vivien.didelot@savoirfairelinux.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org After allocating the chip structure, pass it a compatible info pointer. The compatible info structure will be used later to describe how to access the switch registers and where to read the switch ID. For the standard MDIO probe, get it from the device node data. For the legacy DSA driver probing, pass it the 88E6085 info. Signed-off-by: Vivien Didelot Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index de92add..cadd1e3 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -3617,6 +3618,7 @@ static int mv88e6xxx_detect(struct mv88e6xxx_priv_state *ps) if (!info) return -ENODEV; + /* Update the compatible info with the probed one */ ps->info = info; dev_info(ps->dev, "switch 0x%x detected: %s, revision %u\n", @@ -3669,6 +3671,9 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, if (!ps) return NULL; + /* Legacy SMI probing will only support chips similar to 88E6085 */ + ps->info = &mv88e6xxx_table[MV88E6085]; + err = mv88e6xxx_smi_init(ps, bus, sw_addr); if (err) goto free; @@ -3754,14 +3759,21 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) { struct device *dev = &mdiodev->dev; struct device_node *np = dev->of_node; + const struct mv88e6xxx_info *compat_info; struct mv88e6xxx_priv_state *ps; u32 eeprom_len; int err; + compat_info = of_device_get_match_data(dev); + if (!compat_info) + return -EINVAL; + ps = mv88e6xxx_alloc_chip(dev); if (!ps) return -ENOMEM; + ps->info = compat_info; + err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr); if (err) return err; @@ -3801,7 +3813,10 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev) } static const struct of_device_id mv88e6xxx_of_match[] = { - { .compatible = "marvell,mv88e6085" }, + { + .compatible = "marvell,mv88e6085", + .data = &mv88e6xxx_table[MV88E6085], + }, { /* sentinel */ }, };