From patchwork Mon Sep 4 16:30:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9937417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04AC5603F9 for ; Mon, 4 Sep 2017 16:33:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB37D287CB for ; Mon, 4 Sep 2017 16:33:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAA7128806; Mon, 4 Sep 2017 16:33:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2839287FF for ; Mon, 4 Sep 2017 16:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kKCbSgxJ5RJg7NhXaX468uTgToeQT9Q/vLmg2yR6b0w=; b=aKPt3yGUgeT/cp3HPV/S36iV1k zxEKVWcsH+eZKIucTYB1SQbDyu5x1wCPdZpfxqLurAGwcthXTCC9G6ttKYLYuutj2UnwI2T2sNtM1 vvNYbhTjp4qjl38Yive+bZo1HHYqCvkJ/ue1b0lEk/R2XtP4nIZdm3GGUjwEhnYYIvDewvUY7DOQ0 ns/JwrZkwJL1nxPyDOr6v8GnFRbncFydSzzFX2h8ZcJggfIx2UjJI1yQySgva3cGfvWNOoUdmf1EJ X8RzXzFjVJQudOfBXgZbbzKNIEQnWyhT11yxn9fBmhx22zlrneKTAUqJD3gnh4kEEDjOm/G4DqzeA cYXqDabw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1douJ7-000421-W6; Mon, 04 Sep 2017 16:33:06 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1douIo-0003jX-2J for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2017 16:32:47 +0000 Received: by mail-wm0-x244.google.com with SMTP id u26so753685wma.5 for ; Mon, 04 Sep 2017 09:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TJDON8TrGp6QwnVdJpWbxvP94B2L9qIH8bwds37uyN4=; b=CrwVVH06PCOF/3GJEYwvVQBxBJoehVaZcxqNNwju8mfs1Q6QgALqM4GW7qC6Ma2FUe fpqW5vDzSme4mhiPXHLclhIiO1OB/oXDZGc369IIZBsXsXG82KJqids9eQ1mcfGXw1Wq A3wX5otxi48NBmMPjX1C8SBqIHq+FmDN4p+mGzwep50eSsdjUgQVneSk4irL8CpYdHHb WPm39aMoydxyYdPaJKuTxNC+AfsQQurS2ls7uOinwoNGVXZ001EpgYGeGLBlajAWJqEx sqWKnDGY8p4oikOy1aWnPzIf4vEH/pScZXwfu/8T6XExxHOrJkxpd8l79suc5ibRgTFb D9IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TJDON8TrGp6QwnVdJpWbxvP94B2L9qIH8bwds37uyN4=; b=hh9piSegSRrtJku1U7BuXdptPpCkQ8Koj/8OrnhqRrzcVWMr3JDt8FNL6yFp0P4Ays fiHP3gL87URFU81B/NGAlWS9EyYFUHQfcI6DjMaZUe5QUJp42H5lmXJ+M3k7b+nZdXl9 KTFKnayz4kDSsaKwHP2rCUxvOpLK0iJUyf2xomftDwdkVcJhhLwSn/ycz8dyxJzD5tI4 7ZImw1C0SR3uawFV0TSE9irMHs+SADQURL0f4Cvy1pZs/F4bG+fYneOGpco6EXWEKm4w K4Pkbj0Jm6HS3nPW5F6idCLff1SRDh/u4bSrHyIMw9CQDDYQxqpF16lLZwuGKf+A4PkV G5QQ== X-Gm-Message-State: AHPjjUjdTY41Xgl64ny6oGkU7EuC+QsFjq88auyoUYj/ZnLaLR0vguwx +P5BcXasfEEkhw== X-Google-Smtp-Source: ADKCNb4DVeveDCN/qBk3LzMRoNL0Og82GHuSeTwew2x9UfeFn3430TMRDw5hLyR7loIfQEo86Pbctg== X-Received: by 10.28.134.4 with SMTP id i4mr548862wmd.37.1504542744344; Mon, 04 Sep 2017 09:32:24 -0700 (PDT) Received: from Red.local (LFbn-MAR-1-577-78.w90-118.abo.wanadoo.fr. [90.118.156.78]) by smtp.googlemail.com with ESMTPSA id c83sm870010wmd.38.2017.09.04.09.32.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Sep 2017 09:32:23 -0700 (PDT) From: Corentin Labbe To: andrew@lunn.ch, f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com, jonmason@broadcom.com Subject: [PATCH 1/1] net: mdio-mux: add mdio_mux parameter to mdio_mux_init() Date: Mon, 4 Sep 2017 18:30:14 +0200 Message-Id: <20170904163014.955-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170904163014.955-1-clabbe.montjoie@gmail.com> References: <20170904163014.955-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170904_093246_280776_07EC9690 X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Corentin Labbe , bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP mdio_mux_init() use the parameter dev for two distinct thing: 1) Have a device for all devm_ functions 2) Get device_node from it Since it is two distinct purpose, this patch add a parameter mdio_mux that is linked to task 2. This will also permit to register an of_node mdio-mux that lacks a direct owning device. For example a mdio-mux which is a subnode of a real device. Signed-off-by: Corentin Labbe --- drivers/net/phy/mdio-mux-bcm-iproc.c | 2 +- drivers/net/phy/mdio-mux-gpio.c | 2 +- drivers/net/phy/mdio-mux-mmioreg.c | 3 ++- drivers/net/phy/mdio-mux.c | 7 ++++--- include/linux/mdio-mux.h | 9 +++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c index 0a5f62e0efcc..0831b7142df7 100644 --- a/drivers/net/phy/mdio-mux-bcm-iproc.c +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c @@ -199,7 +199,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, md); - rc = mdio_mux_init(md->dev, mdio_mux_iproc_switch_fn, + rc = mdio_mux_init(md->dev, md->dev->of_node, mdio_mux_iproc_switch_fn, &md->mux_handle, md, md->mii_bus); if (rc) { dev_info(md->dev, "mdiomux initialization failed\n"); diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c index 919949960a10..082ffef0dec4 100644 --- a/drivers/net/phy/mdio-mux-gpio.c +++ b/drivers/net/phy/mdio-mux-gpio.c @@ -54,7 +54,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) if (IS_ERR(s->gpios)) return PTR_ERR(s->gpios); - r = mdio_mux_init(&pdev->dev, + r = mdio_mux_init(&pdev->dev, pdev->dev.of_node, mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL); if (r != 0) { diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c index c3825c7da038..2573ab012f16 100644 --- a/drivers/net/phy/mdio-mux-mmioreg.c +++ b/drivers/net/phy/mdio-mux-mmioreg.c @@ -159,7 +159,8 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev) } } - ret = mdio_mux_init(&pdev->dev, mdio_mux_mmioreg_switch_fn, + ret = mdio_mux_init(&pdev->dev, pdev->dev.of_node, + mdio_mux_mmioreg_switch_fn, &s->mux_handle, s, NULL); if (ret) { dev_err(&pdev->dev, "failed to register mdio-mux bus %pOF\n", diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c index 6f75e9f27fed..0a86f1e4c02f 100644 --- a/drivers/net/phy/mdio-mux.c +++ b/drivers/net/phy/mdio-mux.c @@ -86,6 +86,7 @@ static int mdio_mux_write(struct mii_bus *bus, int phy_id, static int parent_count; int mdio_mux_init(struct device *dev, + struct device_node *mux_node, int (*switch_fn)(int cur, int desired, void *data), void **mux_handle, void *data, @@ -98,11 +99,11 @@ int mdio_mux_init(struct device *dev, struct mdio_mux_parent_bus *pb; struct mdio_mux_child_bus *cb; - if (!dev->of_node) + if (!mux_node) return -ENODEV; if (!mux_bus) { - parent_bus_node = of_parse_phandle(dev->of_node, + parent_bus_node = of_parse_phandle(mux_node, "mdio-parent-bus", 0); if (!parent_bus_node) @@ -132,7 +133,7 @@ int mdio_mux_init(struct device *dev, pb->mii_bus = parent_bus; ret_val = -ENODEV; - for_each_available_child_of_node(dev->of_node, child_bus_node) { + for_each_available_child_of_node(mux_node, child_bus_node) { int v; r = of_property_read_u32(child_bus_node, "reg", &v); diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h index 61f5b21b31c7..a5d58f221939 100644 --- a/include/linux/mdio-mux.h +++ b/include/linux/mdio-mux.h @@ -12,7 +12,16 @@ #include #include +/* mdio_mux_init() - Initialize a MDIO mux + * @dev The device owning the MDIO mux + * @mux_node The device node of the MDIO mux + * @switch_fn The function called for switching target MDIO child + * mux_handle A pointer to a (void *) used internaly by mdio-mux + * @data Private data used by switch_fn() + * @mux_bus An optional parent bus (Other case are to use parent_bus property) + */ int mdio_mux_init(struct device *dev, + struct device_node *mux_node, int (*switch_fn) (int cur, int desired, void *data), void **mux_handle, void *data,