From patchwork Mon Sep 4 17:00:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9937433 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 425CA6035F for ; Mon, 4 Sep 2017 17:01:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30B3428796 for ; Mon, 4 Sep 2017 17:01:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24D37287F9; Mon, 4 Sep 2017 17:01:26 +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 B86C528796 for ; Mon, 4 Sep 2017 17:01:25 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=We3pL04voRAERuVrWB3RvO4Q4P0QVqKhTl7E0BL6SGc=; b=gIilAMozq7wwWD b2nOadlFHoR+T6s5ww8sofWbAyin0VgjS2jncmtucOlzvoDCRCVK7ZWYaXImpb8aYShU+mMWgUTQh FTsmNW+vU7WT+j/tmf0yTHjZzc8zFKQa4zOL8i/kZZkkkbK72kFUjMZr1DF0c+1Xj4opD4iciqegw xElNLr13Eg8hkCGBa7aiDk+VgPI8M9G9DwsvCJUa3pmkH7x9n+NI0RlvykPQHJxiAI1LcDs2gXp6q TXoBQDUNb/hxK7kWKZ78Sh4vR82bmJBgyl1P9wdLQo8tdt7qpcIGSVkBQk0V3z1WD2glmJmek3ZGA /CptJWqmDigqUPzrqrXw==; 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 1doukS-0001ir-Me; Mon, 04 Sep 2017 17:01:20 +0000 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1douk9-0001Rl-Ir for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2017 17:01:07 +0000 Received: by mail-oi0-x242.google.com with SMTP id g15so719533oib.3 for ; Mon, 04 Sep 2017 10:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/QDqOueKyfHOaN3ZDf9pTgbJyuc6hGHAX1skAgvaACI=; b=PRTWOBAVHxpF04Z6kuUwjt2UgdgxnuKWcOtPZiUIjg/HPEIHxJR6OhA5G2af9aomqH PXX+MJkP9CKrXURNgjG4n0zMejpjg+w7mc2XaMtv+Guy8nL+wSSPDMg9TOnL7UBdsLLO 8jJMdfukLtk6mTtiiArdoSR6bNjHkqIUu3aDTxPHyvshPg+yRk75PICKLJ+w0mg86FPc 0Gg2LmNw/71V4szRMyX4tfMArZ4OTSDsYuLOFiJdfj3wOxcBqzPxGqAk7ibm9BpK0mQR OmSIWIrOUr8AvH+WS3UkY+/haFFJgKOjN99nIHr2cQ81jTQ+fiYd41fcR5wTQ2JUeDsY Pi1g== 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=/QDqOueKyfHOaN3ZDf9pTgbJyuc6hGHAX1skAgvaACI=; b=qrZhepX+Ix7Dh1WWNH2GvmMJWwy2vNvCalPKCArKPCKi5WfjnkKYdOrzWNW6V/E2Ty lKd3sgCYquxDsHlTZ8dXjCzs70Ipa9Yt9WD3opiEIYTBWu0FyfG/ph1uXp6aYadOn0S7 ErHk2Rev+Kx9tUx3jTxeCqZf8NiiAnnlyUldWfTDpZnlcYHQoq7t8Nm+SJf4zb/Mh5M8 tbFQRCSitfwixa2kLJj3+HN3/6hg5fQWABybvUp9T7n446KqlqS5u7QJ1BohZ6ApBWtn i/aN/0MSUWcgQvk5osfStYLypwLnCoTtL+UErDa2EmgB55xEfkHAfmmNLmCav74eLOlp X/qw== X-Gm-Message-State: AHPjjUgwdc2Bznyu2oNjqEsPQKO5Tfj6TH0Ox1Y6rvFpM94CQQOT8PHM HZ0zoG7pi9MBMQ== X-Google-Smtp-Source: ADKCNb5n5Hn/F9w+9e0YGZw5YT735TuFMhL817ji1LK0uohzi2G5Gz8DoGSUNRvgr+GicEtuLbWWjg== X-Received: by 10.202.196.5 with SMTP id u5mr1236424oif.314.1504544440297; Mon, 04 Sep 2017 10:00:40 -0700 (PDT) Received: from ?IPv6:2001:470:d:73f:11be:5071:741:2eeb? ([2001:470:d:73f:11be:5071:741:2eeb]) by smtp.gmail.com with ESMTPSA id h76sm15890385oig.28.2017.09.04.10.00.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 10:00:39 -0700 (PDT) Subject: Re: [PATCH 1/1] net: mdio-mux: add mdio_mux parameter to mdio_mux_init() To: Corentin Labbe , andrew@lunn.ch, rjui@broadcom.com, sbranden@broadcom.com, jonmason@broadcom.com References: <20170904163014.955-1-clabbe.montjoie@gmail.com> <20170904163014.955-2-clabbe.montjoie@gmail.com> From: Florian Fainelli Message-ID: Date: Mon, 4 Sep 2017 10:00:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170904163014.955-2-clabbe.montjoie@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170904_100101_737344_8398C374 X-CRM114-Status: GOOD ( 21.72 ) 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, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 On 09/04/2017 09:30 AM, Corentin Labbe wrote: > 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. This looks fine, I was going to suggest introducing a wrapper around mdio_mux_init() which does something along the lines below, but considering the number of users of mdio_mux_init() within the kernel tree, it's reasonably easy to audit those, therefore: Reviewed-by: Florian Fainelli > 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, > diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h index 61f5b21b31c7..0316186c91b5 100644 --- a/include/linux/mdio-mux.h +++ b/include/linux/mdio-mux.h @@ -12,11 +12,19 @@ #include #include -int mdio_mux_init(struct device *dev, - int (*switch_fn) (int cur, int desired, void *data), - void **mux_handle, - void *data, - struct mii_bus *mux_bus); +int mdio_mux_init_dn(struct device *dev, struct device_node *mux_node, + int (*switch_fn)(int cur, int desired, void *data), + void **mux_handle, void *data, + struct mii_bus *mux_bus); + +static inline int mdio_mux_init(struct device *dev, + int (*switch_fn)(int cur, int desired, void *data), + void **mux_handle, void *data, + struct mii_bus *mux_bus) +{ + return mdio_mux_init_dn(dev, dev->of_node, switch_fn, + mux_handle, data, mux_bus); +} >