From patchwork Sun Feb 25 12:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129517 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2580634lja; Sun, 25 Feb 2018 04:54:02 -0800 (PST) X-Google-Smtp-Source: AH8x227eHaROcxCMbacoGd34drmdFNmFOddsePs0Ig10uXv/Sbnm2kszRvsMARhlSriI3RJxwP/n X-Received: by 2002:a17:902:8491:: with SMTP id c17-v6mr7514055plo.105.1519563242176; Sun, 25 Feb 2018 04:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519563242; cv=none; d=google.com; s=arc-20160816; b=zM1BZYvAFkdN1KdKJhtVjk/Y++SmkJ0yEjv06NhvJfYlyvBMr/f0+9U2Kzs6N6Ko3P CGrpb2aEqu3SP/WOvyN2ZX4mWQitJaAFOd1Po8v5qOxvn4i9XwCEeuBGo3ScueN+ESlf SdV69p/rDDzSq9pF4oA8Q2Zx8+X41ffHE6r230xO8CcCsndtv/Hm2ULEGKi0ccuo3bOd seREp5j7tHuv4F9j0GKOlLL44OI+AedcH1VghHEsVptgSc1ES+AdeGZDx44nD2QnM8Hp 1gBicJ3YPeSPbjuAd2kFINc2691QKvtIPKhoQ4nOnYNLy/BSVj6eePEbEiLXjuI7O5Rz 5P5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kEoXE/W2Mv8ccnkEU8aHbIt+tk4gMKYZKb3t5ezbSnk=; b=XBVAPHAs1PHUvPKVs4Gjwq0pSKp6Jqe5UEnUunUoaMDE4FczyuOAEraej4nfptC3q7 7LZ9BdNwax7EJXhXAJ8WgLlfMBE0Z+WURHCmwEm+doc9kvvfi8C+6EDE7pS1p7Wjtvu3 EO8TSSsecnFwTz86syTKmLS+RZoDR/xT3tRNhK0nsK//Si1FT4oLbjAhNiXj1s0/BzN5 waVGq43NDOPVC/wh3hmNpH0rW/3e1KMqi9MJkQhqf/do5WHfrXZnCMp8ZxiKExDi3oyc gAnzct4Bi//HcCf3Q2P3LFfITg6JR3X2d6NSVMm+E7/OVjEYTa+KjUv0kTTWck/udM78 h3LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MfIkVxvf; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si4218252pgf.390.2018.02.25.04.54.01; Sun, 25 Feb 2018 04:54:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MfIkVxvf; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751745AbeBYMx6 (ORCPT + 8 others); Sun, 25 Feb 2018 07:53:58 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40147 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbeBYMx4 (ORCPT ); Sun, 25 Feb 2018 07:53:56 -0500 Received: by mail-lf0-f68.google.com with SMTP id 37so18420486lfs.7 for ; Sun, 25 Feb 2018 04:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kEoXE/W2Mv8ccnkEU8aHbIt+tk4gMKYZKb3t5ezbSnk=; b=MfIkVxvfFvOhDi5+h346rQJoRJR4zZ9wHXAvPxEQhbsRrWWiWwnixRQvc0VWtA52Br WXIohBwneN1RYraPSJFsQ6d81oHHRe++iYt++wBcTryUOJA1zVKtSqZFo4EFtvKcR8yp TFOVjMV4Huu2n0wAs814+8QP7c2+ajE0owXww= 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=kEoXE/W2Mv8ccnkEU8aHbIt+tk4gMKYZKb3t5ezbSnk=; b=m64Xa0TJNqG8BPaYOcbLkXQg4m5oJRngsWNuMRHyLl8yTTnuvXnUjB6epwd9jtdiOE bvnyWko3VmdZWMXw+iTtmC00EKd7FKrwmkCoE8CQZTzWj5M4GDsIl7hWPtEE2zyqkU+7 wOc4zbIZTlMq08i+VhsCLJ8y7+qq+V/lzOBG7x1dGkHl+zIyRsIQAFmjekkeceqUGqLy pg11hMoBwiK7OOnDVk5+xHZf5k4WJ+gnyS1rTD0f09kSaEsxYo94mIC/mipMFWoubx6q ZQ5h7Jttrvbc8PwENrmBwx6va0/irrXqa27iFJ79B9wm6s3+RN8ILujs1J+kVBbZdWeX KnIg== X-Gm-Message-State: APf1xPDoE43aDPlxtSeszSEI237AVic4trIcoMML0LG169ctgaXru0Ch J7FjwCcPYdW35hepC+SpQLj0Cw== X-Received: by 10.46.65.211 with SMTP id d80mr5036547ljf.109.1519563234851; Sun, 25 Feb 2018 04:53:54 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 5sm1456574lfp.17.2018.02.25.04.53.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Feb 2018 04:53:54 -0800 (PST) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH net-next 1/5] net: mdio-gpio: Localize platform data Date: Sun, 25 Feb 2018 13:51:28 +0100 Message-Id: <20180225125132.25275-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180225125132.25275-1-linus.walleij@linaro.org> References: <20180225125132.25275-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org It is late on the day for platforms using platform data to pass information to drivers. As of today, the only thing in the kernel including the file is the MDIO GPIO driver itself. Essentially it is exposing a kernel-internal interface unused by any in-kernel code. Let's decomission this and make the MDIO GPIO driver more self-contained by starting to move this struct into the driver. Signed-off-by: Linus Walleij --- MAINTAINERS | 1 - drivers/net/phy/mdio-gpio.c | 19 ++++++++++++++++++- include/linux/platform_data/mdio-gpio.h | 33 --------------------------------- 3 files changed, 18 insertions(+), 35 deletions(-) delete mode 100644 include/linux/platform_data/mdio-gpio.h -- 2.14.3 diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260e36b7..e5a1a06c09e8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5333,7 +5333,6 @@ F: include/linux/*mdio*.h F: include/linux/of_net.h F: include/linux/phy.h F: include/linux/phy_fixed.h -F: include/linux/platform_data/mdio-gpio.h F: include/linux/platform_data/mdio-bcm-unimac.h F: include/trace/events/mdio.h F: include/uapi/linux/mdio.h diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 4333c6e14742..6d669f24c0e6 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -24,12 +24,29 @@ #include #include #include +#include #include -#include #include #include +struct mdio_gpio_platform_data { + /* GPIO numbers for bus pins */ + unsigned int mdc; + unsigned int mdio; + unsigned int mdo; + + bool mdc_active_low; + bool mdio_active_low; + bool mdo_active_low; + + u32 phy_mask; + u32 phy_ignore_ta_mask; + int irqs[PHY_MAX_ADDR]; + /* reset callback */ + int (*reset)(struct mii_bus *bus); +}; + struct mdio_gpio_info { struct mdiobb_ctrl ctrl; struct gpio_desc *mdc, *mdio, *mdo; diff --git a/include/linux/platform_data/mdio-gpio.h b/include/linux/platform_data/mdio-gpio.h deleted file mode 100644 index 11f00cdabe3d..000000000000 --- a/include/linux/platform_data/mdio-gpio.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MDIO-GPIO bus platform data structures - * - * Copyright (C) 2008, Paulius Zaleckas - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - */ - -#ifndef __LINUX_MDIO_GPIO_H -#define __LINUX_MDIO_GPIO_H - -#include - -struct mdio_gpio_platform_data { - /* GPIO numbers for bus pins */ - unsigned int mdc; - unsigned int mdio; - unsigned int mdo; - - bool mdc_active_low; - bool mdio_active_low; - bool mdo_active_low; - - u32 phy_mask; - u32 phy_ignore_ta_mask; - int irqs[PHY_MAX_ADDR]; - /* reset callback */ - int (*reset)(struct mii_bus *bus); -}; - -#endif /* __LINUX_MDIO_GPIO_H */ From patchwork Sun Feb 25 12:51:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129518 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2580649lja; Sun, 25 Feb 2018 04:54:04 -0800 (PST) X-Google-Smtp-Source: AH8x225dhcgx7jQjw8geI3A46e1pfXYc6rmDyh1cToKSnxInLCh5NIm12WgklploQ5AtqjEwtO0m X-Received: by 10.101.101.78 with SMTP id a14mr5939486pgw.368.1519563243938; Sun, 25 Feb 2018 04:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519563243; cv=none; d=google.com; s=arc-20160816; b=SCADZVlU1xjVISIxsnhwOSmEVw/8zjS+wm28JqBou7fMbOxYcN5+SRxfKj1Z/IXzhV NPf2tdYxC3EHlch21rRWPWsjjY4YAN860bHf+xtUYaKzxAar6eu2Jl8Rl+mTVtM6AAwb xUisa6FwxrN2KjfgkHxWTDmYj6DAaS5CwpZY46n09SL7Chp7dQCHXg5TsVBcW888qdGL cBOq0NQITl6zUSj9FuKs2e1FgnLOAsWeVJXo2zTgx4R4KRfec8vjawJH4z17VMroWPpK MEmfSQMh7Y548Z7qtJE8rcM1Szk33nqAAoXRmSFPHS8xtedN2kONWdpgYaakbjXQ9IRg kZeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3yrUy3EnPsdo/7mgRKoHBojWTaDXFqAwhxxVWfcVdac=; b=uO75BQCB0SJwEraBzv/m1kEdHonCYU3farZMiUpLXT9FORuTFa8zSlQpjCNwDp4B9k 3Td7zcz53q1FDHH+fXoLF205bx3V9fzTh8vtaHFNSt5UWPl6yauFA8kgFF2JmJRF6pt2 dfStmSFBPuIMZk/uN7gsbVICa914Ak1q+WtX8Pv1F8nFZhd2YNpKfrox1UrNMsR9Tj+Q Aj0O6keOEo2FNxLmG6LAn4QyF9tU9Gntsfa8BtQLn5XWuvEjD4+HQEwwHnU2yguerYyO hCoeCovd3lUbXMJTx3tQCcITlBKhKIcLle9ntpNePQQ4o6LBbs8tP7TQpFIXmUNm3Uad 6hZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jaHAcH8w; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si4218252pgf.390.2018.02.25.04.54.03; Sun, 25 Feb 2018 04:54:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jaHAcH8w; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751761AbeBYMyA (ORCPT + 8 others); Sun, 25 Feb 2018 07:54:00 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38944 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbeBYMx6 (ORCPT ); Sun, 25 Feb 2018 07:53:58 -0500 Received: by mail-lf0-f67.google.com with SMTP id f75so13409979lfg.6 for ; Sun, 25 Feb 2018 04:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3yrUy3EnPsdo/7mgRKoHBojWTaDXFqAwhxxVWfcVdac=; b=jaHAcH8wumM+D4FjIn2DhhKFPE2oi1+At5s9gBe3ZLk13DQgftewHdcjizjtBN8Pr0 H2CRFNJkasO8jHQSnP17ZVHSfA7dLvuOTgnkF3H2lj8a7DVJHq7PBnloCtlH/GYN7163 C/kNkiGgqBw4drvG8NBvQHDWNPwHbQiYy+dQE= 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=3yrUy3EnPsdo/7mgRKoHBojWTaDXFqAwhxxVWfcVdac=; b=k8rfTyrM1YYhduF5EwWaVcLajKV8/3d+ro0h3fKDZllaI9lZrqgvfwQh3aAMiJDoqv 3Z3W9gaOIu9tVtt7jC+cJHMuEigU2lYPQ3XBiGWMlcQKFu2Ni9YZ20TYRO8zy9BILfkX rgfWKwDeVqbxMOloXBtTQ1V8IjJtgjhIN7dtTr9yqCsxzPAtIXyig4+puFf01/bj0qQl LiGTRDWfBl1IxXF8K7l9EKkAsZu+yso+XH9fRTi+27e937K6b2byvanhvqCHCm1BXxks UVIs8bMXaaPkdBbZRCORaWC49Ax9O1TnBKjZEESYV6FD5rMpPTAHMAm3EG/bJmAjYeHP 0Pdg== X-Gm-Message-State: APf1xPDze9kdOoEUpRf5ppbemZLVI9EjBVnxWSRjXra0yi5Pv1dII1b8 28Y6UrjRyhEId0Av5uNJPeBMyA== X-Received: by 10.46.58.2 with SMTP id h2mr5571223lja.95.1519563237079; Sun, 25 Feb 2018 04:53:57 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 5sm1456574lfp.17.2018.02.25.04.53.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Feb 2018 04:53:56 -0800 (PST) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH net-next 2/5] net: mdio-gpio: Allocate state in probe() Date: Sun, 25 Feb 2018 13:51:29 +0100 Message-Id: <20180225125132.25275-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180225125132.25275-1-linus.walleij@linaro.org> References: <20180225125132.25275-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allocate the state container for the driver, struct mdio_gpio_info inside the probe() function instead of in the mdio_gpio_bus_init() function. Create the local struct device *dev variable in probe() and pass that around instead of constantly dereferencing the struct platform_data. Signed-off-by: Linus Walleij --- drivers/net/phy/mdio-gpio.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) -- 2.14.3 diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 6d669f24c0e6..d95bb45eb67b 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -52,14 +52,14 @@ struct mdio_gpio_info { struct gpio_desc *mdc, *mdio, *mdo; }; -static void *mdio_gpio_of_get_data(struct platform_device *pdev) +static void *mdio_gpio_of_get_data(struct device *dev) { - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; struct mdio_gpio_platform_data *pdata; enum of_gpio_flags flags; int ret; - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; @@ -142,21 +142,17 @@ static const struct mdiobb_ops mdio_gpio_ops = { }; static struct mii_bus *mdio_gpio_bus_init(struct device *dev, + struct mdio_gpio_info *bitbang, struct mdio_gpio_platform_data *pdata, int bus_id) { struct mii_bus *new_bus; - struct mdio_gpio_info *bitbang; int i; int mdc, mdio, mdo; unsigned long mdc_flags = GPIOF_OUT_INIT_LOW; unsigned long mdio_flags = GPIOF_DIR_IN; unsigned long mdo_flags = GPIOF_OUT_INIT_HIGH; - bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL); - if (!bitbang) - goto out; - bitbang->ctrl.ops = &mdio_gpio_ops; bitbang->ctrl.reset = pdata->reset; mdc = pdata->mdc; @@ -234,35 +230,41 @@ static void mdio_gpio_bus_destroy(struct device *dev) static int mdio_gpio_probe(struct platform_device *pdev) { struct mdio_gpio_platform_data *pdata; + struct device *dev = &pdev->dev; + struct mdio_gpio_info *bitbang; struct mii_bus *new_bus; int ret, bus_id; + bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL); + if (!bitbang) + return -ENOMEM; + if (pdev->dev.of_node) { - pdata = mdio_gpio_of_get_data(pdev); - bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); + pdata = mdio_gpio_of_get_data(dev); + bus_id = of_alias_get_id(dev->of_node, "mdio-gpio"); if (bus_id < 0) { - dev_warn(&pdev->dev, "failed to get alias id\n"); + dev_warn(dev, "failed to get alias id\n"); bus_id = 0; } } else { - pdata = dev_get_platdata(&pdev->dev); + pdata = dev_get_platdata(dev); bus_id = pdev->id; } if (!pdata) return -ENODEV; - new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id); + new_bus = mdio_gpio_bus_init(dev, bitbang, pdata, bus_id); if (!new_bus) return -ENODEV; - if (pdev->dev.of_node) - ret = of_mdiobus_register(new_bus, pdev->dev.of_node); + if (dev->of_node) + ret = of_mdiobus_register(new_bus, dev->of_node); else ret = mdiobus_register(new_bus); if (ret) - mdio_gpio_bus_deinit(&pdev->dev); + mdio_gpio_bus_deinit(dev); return ret; } From patchwork Sun Feb 25 12:51:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129519 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2580694lja; Sun, 25 Feb 2018 04:54:08 -0800 (PST) X-Google-Smtp-Source: AH8x225HwxVrkxt7uOyjvh36ICxSgMCD5dO/vzCJfuysfA9VBPtqscdHXRNZ6oRJK1WYDPP60Ngo X-Received: by 2002:a17:902:6bc3:: with SMTP id m3-v6mr7521585plt.442.1519563248834; Sun, 25 Feb 2018 04:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519563248; cv=none; d=google.com; s=arc-20160816; b=dc6NXOVSgax5e5YflJd0P1A7bIAQfyGzmxTJXvzFsdgLLrZr0Ik52FsXMgqMGpeM37 ygt4XIoyM8fv17DJ6+B2urR+qRvpTuisG1qIlK/CFPSluMWk6QsF9PALgUxRWQ91V/W5 EEUighY7KQQHw9y7n/X/jkmP5OvIKJftlZbM5MELfth8cI4jIb+rPSAGFAgqqZ0BxyTt HTeCcvmJGs+kfN8a7QRXOJohNDK+X4lyYeafoDAAu1nO+4IkjXNrebFGPM2e3wB+Lamv A9MdzLqS72y0MF0kgRAGLMiUD0VrbKGkQo7qp6+QmnUzse5M1TmCJRyCLh/ah8Fu09bv cIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=s+xwm/kbc8rRTq9uL8pkicVwwPFUY7Q1PsQcpHuE8A0=; b=HceRGjLDcvl21ykZdGnV/4A0WpGz2Q53rJOHAd+xzDolFGrloOWjj0vcLO9gaLoqv+ BpU/W+J8ads93PCHxliL2QzirQta9PTPKH/LAhtvui5OudoGv6kCDVdkKO/AcG+fIO/y Qbzf2XaRR4UN5LV/o/6V3tC9JZCDIb5mLoTQpX/yC8qL3XIF/KxscQqoHf07kKqNwneh VJ7ygohhSy5fPjgjZkfMjlguGfMgUAW6V46+YtBqSnNjkjQmZVOEN3RqxXR05hm75bVt wFPqgndNa71xYQjlUt4WvL7HBjrNZ3uw20n/KVBwGKIhcMDzxgRESDzPbrWlWLbRzGZ5 Alkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j8HzbMoa; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si5081812pfe.411.2018.02.25.04.54.08; Sun, 25 Feb 2018 04:54:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j8HzbMoa; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbeBYMyG (ORCPT + 8 others); Sun, 25 Feb 2018 07:54:06 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:43391 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751746AbeBYMyA (ORCPT ); Sun, 25 Feb 2018 07:54:00 -0500 Received: by mail-lf0-f68.google.com with SMTP id q69so18420694lfi.10 for ; Sun, 25 Feb 2018 04:53:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s+xwm/kbc8rRTq9uL8pkicVwwPFUY7Q1PsQcpHuE8A0=; b=j8HzbMoa/+YntaV/wfMeVJI/Smmiw7LyAexqkfFZibIYKX+B99LzFtlNVhFNQrkH69 eWhIe5hs59PtnLlVENc1R/EQ0Ls0SMPZUhz6ZZ2kqCanmDJI6Mh9W1D+v4a0Ljhz5ZVW 7dKzN77i/kavn6QlRGzFV/pXgeIKH9sAB7Sfk= 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=s+xwm/kbc8rRTq9uL8pkicVwwPFUY7Q1PsQcpHuE8A0=; b=EJZkE3GA5aLiDdzL/hR6UkUQBt7zS5ktRL3FujNMVW6i77fFsGBfgPWWYADP9QN2Yk 2P0Nw1ktP/yRR43fIdK8F3uNeJo8TKfD0jKX4mlevR86071S+7JNleQJsAfhnnEucmyP Dku5m+wA9wQwX6lLBr8LExrwVfJkTYfxcnTHBSKNMs/o02BdRQTizsbZHMxECGURPcxY EAhvvcQW2QMx9deuhtT+sb+zpWMkK1K3CO0ha1bgliFapVf62gTbyuUC92j4bXrQ4hdP duZdI0oxOIcVrdxTIsUz9xKpCsk1f6nK225WJEG8DzlhSx/Fs3/ls3W0DzMP5Amt6PET ESxg== X-Gm-Message-State: APf1xPBUr+dz6WfJynFXKzCM4L976TDt4XpouuYstSiI/qvJq83SwiLs N8qUFGlD6J/WkWHpSvpdlg6PlaQ0uKA= X-Received: by 10.46.13.10 with SMTP id 10mr5701603ljn.8.1519563238824; Sun, 25 Feb 2018 04:53:58 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 5sm1456574lfp.17.2018.02.25.04.53.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Feb 2018 04:53:58 -0800 (PST) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH net-next 3/5] net: mdio-gpio: Remove non-DT probe path Date: Sun, 25 Feb 2018 13:51:30 +0100 Message-Id: <20180225125132.25275-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180225125132.25275-1-linus.walleij@linaro.org> References: <20180225125132.25275-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This driver can now only be created using the device tree. Remove the platform data probe path and require OF_MDIO in Kconfig. Signed-off-by: Linus Walleij --- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/mdio-gpio.c | 21 ++++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) -- 2.14.3 diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index bdfbabb86ee0..27efc5d6fbe2 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -92,7 +92,7 @@ config MDIO_CAVIUM config MDIO_GPIO tristate "GPIO lib-based bitbanged MDIO buses" - depends on MDIO_BITBANG && GPIOLIB + depends on MDIO_BITBANG && GPIOLIB && OF_MDIO ---help--- Supports GPIO lib-based MDIO busses. diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index d95bb45eb67b..96c953d086c6 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -239,16 +239,11 @@ static int mdio_gpio_probe(struct platform_device *pdev) if (!bitbang) return -ENOMEM; - if (pdev->dev.of_node) { - pdata = mdio_gpio_of_get_data(dev); - bus_id = of_alias_get_id(dev->of_node, "mdio-gpio"); - if (bus_id < 0) { - dev_warn(dev, "failed to get alias id\n"); - bus_id = 0; - } - } else { - pdata = dev_get_platdata(dev); - bus_id = pdev->id; + pdata = mdio_gpio_of_get_data(dev); + bus_id = of_alias_get_id(dev->of_node, "mdio-gpio"); + if (bus_id < 0) { + dev_warn(dev, "failed to get alias id\n"); + bus_id = 0; } if (!pdata) @@ -258,11 +253,7 @@ static int mdio_gpio_probe(struct platform_device *pdev) if (!new_bus) return -ENODEV; - if (dev->of_node) - ret = of_mdiobus_register(new_bus, dev->of_node); - else - ret = mdiobus_register(new_bus); - + ret = of_mdiobus_register(new_bus, dev->of_node); if (ret) mdio_gpio_bus_deinit(dev); From patchwork Sun Feb 25 12:51:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129520 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2580737lja; Sun, 25 Feb 2018 04:54:12 -0800 (PST) X-Google-Smtp-Source: AH8x224a5l6jpSfNYrm43MMAnO9VmDIdjyfB4SB4LtLDy9XKQgGha3Vm2LeezYnon97ixYR3NphQ X-Received: by 10.98.68.26 with SMTP id r26mr7424316pfa.231.1519563252859; Sun, 25 Feb 2018 04:54:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519563252; cv=none; d=google.com; s=arc-20160816; b=waFaRWt6irVMDLG0S/zxybNGHYzF/xCsKBdsp8cjPA6JXop2FFpsn0/6u7tkq9v3Ly 3vD/kH2Z70R4qf90hqOWO0lvULqUt0bUy0Q77JWeAlE3qnela+lrXR949IpDaFdkKIIW DTzVqEHgMUaWR1kYYn7hJHOQd5/mH3mTpkgQlg+e9KiED+KseW02+q9mhA6l32DlPeO4 l7S3iP9Obc+YiTUXUaUEIuSvdpBSjwjAu4pcZEMn0DlDyhdP96FvaAxIz6eTf2Rtdc4l 6mgSXmY2Piy54wyROIIA2myY1Jo2U4ZxSDrUBaj1FRkbz/kjnOJsk/MOlzBOO1sh+WvV g1ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5NWpbaJZNfkvovM/6EoOL5lO72kWKJcjmS5LCc37VG4=; b=R5OHAaMCAxQtKcxND9ZBM3i4lQHNbiOnXmYyIa2fJTPgVJVGnjZ1NLkyPXfD/mDdo3 n0FjxlP11mCnaFxQrc4Yv/zA9HaxnGrnBkwop1j2D9/hLLWhdLM2piTshjlvpXAB75qu nxUABAgU+cR+mjEbQ8ZlQGy3oW7+i3tfOQccObGBv1RZlvGd9fe/q+Fz3x9NHqlinT7o o0dLKPoTJvU0CMrUsw0mXObU4l58EhO48ET94+7R1fBRom09Z4BbmwQrYVCacvt3L6+1 40IqP5gEBCiF3NsUDTJ2sIDpgSWfqq8ieptS2Ir3vsa6kTFWTluT4UW1nKb9ST+m3VQD xxJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6RlWtL8; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l77si5131892pfk.210.2018.02.25.04.54.12; Sun, 25 Feb 2018 04:54:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6RlWtL8; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751784AbeBYMyK (ORCPT + 8 others); Sun, 25 Feb 2018 07:54:10 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:46160 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbeBYMyC (ORCPT ); Sun, 25 Feb 2018 07:54:02 -0500 Received: by mail-lf0-f65.google.com with SMTP id r80so18426022lfe.13 for ; Sun, 25 Feb 2018 04:54:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5NWpbaJZNfkvovM/6EoOL5lO72kWKJcjmS5LCc37VG4=; b=W6RlWtL85nHDSCgATwFAiG/038n7vr2+K72p4evU5H/UYc9Bu1mq4N2WUP9xPIr1+B ++Vcyejjuw8Gh+Hn7qiUgzB/TB8BWGOawHtbfLDb0OZCU9W0VKfMV5xGXMRRWhQbO7RS vt2NEHPBfO35AGi0XPIgURlj+ufRp7FzJtykI= 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=5NWpbaJZNfkvovM/6EoOL5lO72kWKJcjmS5LCc37VG4=; b=qNcqPieq28XUxdQXeV5OowzRFTEqkBRF+G0xp2L75bhpYJAyLLGo0ObqQy6x3N3rPB QojBXcU6hC3f3ogJME88t6NEY2wq3Ve+De/rJyPGAJ5FxeDOmPup2PIZSKzQv3RUuWzd 0lpGvBgGlTO3FcCkogyxPzxdw/ohQO8tl6A3BqJMHiZoqHRSQerMYwf/DiFkPt1dXse4 LfETaowlJ8GgzwJ5yM8TRHiUfWMubueaAg+vXyG/R6eroTCrJ8ZUtHugeHRQPviiV5uj t2iDWLAxnAJCeC5ZRw5UTo0l8FojxNVdjxNbQBt4RQylB2Nl6HC7hnF2cExZJThr79j6 wDPw== X-Gm-Message-State: APf1xPDWvuPPpvaqjllACDfzv5i2GnjTDPJlm/uH3zzIZ+O015+S9/Gy GOZEfhb1oJLaRyDieBCzPRKpYg== X-Received: by 10.46.73.81 with SMTP id b17mr5169162ljd.144.1519563240827; Sun, 25 Feb 2018 04:54:00 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 5sm1456574lfp.17.2018.02.25.04.53.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Feb 2018 04:54:00 -0800 (PST) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH net-next 4/5] net: mdio-gpio: Merge platform data into state Date: Sun, 25 Feb 2018 13:51:31 +0100 Message-Id: <20180225125132.25275-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180225125132.25275-1-linus.walleij@linaro.org> References: <20180225125132.25275-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is no instantiation without DT data, we can now move to a single state container and merge the DT property retrieveal into mdio_gpio_bus_init(). We decomission the phy_mask, phy_ignore_ta_mask and irqs array and the reset() callback that were all just sitting unused and taking up space. If bitbanged GPIOs need to set up reset() callbacks these should be done in the device tree using proper bindings. If bitbanged GPIOs need to handle IRQs, these should be done in the device tree using the proper bindings. Signed-off-by: Linus Walleij --- drivers/net/phy/mdio-gpio.c | 130 ++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 82 deletions(-) -- 2.14.3 diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 96c953d086c6..9146077b5278 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -30,61 +30,11 @@ #include #include -struct mdio_gpio_platform_data { - /* GPIO numbers for bus pins */ - unsigned int mdc; - unsigned int mdio; - unsigned int mdo; - - bool mdc_active_low; - bool mdio_active_low; - bool mdo_active_low; - - u32 phy_mask; - u32 phy_ignore_ta_mask; - int irqs[PHY_MAX_ADDR]; - /* reset callback */ - int (*reset)(struct mii_bus *bus); -}; - struct mdio_gpio_info { struct mdiobb_ctrl ctrl; struct gpio_desc *mdc, *mdio, *mdo; }; -static void *mdio_gpio_of_get_data(struct device *dev) -{ - struct device_node *np = dev->of_node; - struct mdio_gpio_platform_data *pdata; - enum of_gpio_flags flags; - int ret; - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return NULL; - - ret = of_get_gpio_flags(np, 0, &flags); - if (ret < 0) - return NULL; - - pdata->mdc = ret; - pdata->mdc_active_low = flags & OF_GPIO_ACTIVE_LOW; - - ret = of_get_gpio_flags(np, 1, &flags); - if (ret < 0) - return NULL; - pdata->mdio = ret; - pdata->mdio_active_low = flags & OF_GPIO_ACTIVE_LOW; - - ret = of_get_gpio_flags(np, 2, &flags); - if (ret > 0) { - pdata->mdo = ret; - pdata->mdo_active_low = flags & OF_GPIO_ACTIVE_LOW; - } - - return pdata; -} - static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir) { struct mdio_gpio_info *bitbang = @@ -142,31 +92,60 @@ static const struct mdiobb_ops mdio_gpio_ops = { }; static struct mii_bus *mdio_gpio_bus_init(struct device *dev, - struct mdio_gpio_info *bitbang, - struct mdio_gpio_platform_data *pdata, - int bus_id) + struct mdio_gpio_info *bitbang) { - struct mii_bus *new_bus; - int i; - int mdc, mdio, mdo; + unsigned long mdo_flags = GPIOF_OUT_INIT_HIGH; unsigned long mdc_flags = GPIOF_OUT_INIT_LOW; unsigned long mdio_flags = GPIOF_DIR_IN; - unsigned long mdo_flags = GPIOF_OUT_INIT_HIGH; + struct device_node *np = dev->of_node; + enum of_gpio_flags flags; + struct mii_bus *new_bus; + bool mdio_active_low; + bool mdc_active_low; + bool mdo_active_low; + unsigned int mdio; + unsigned int mdc; + unsigned int mdo; + int bus_id; + int ret, i; + + ret = of_get_gpio_flags(np, 0, &flags); + if (ret < 0) + return NULL; + + mdc = ret; + mdc_active_low = flags & OF_GPIO_ACTIVE_LOW; + + ret = of_get_gpio_flags(np, 1, &flags); + if (ret < 0) + return NULL; + mdio = ret; + mdio_active_low = flags & OF_GPIO_ACTIVE_LOW; + + ret = of_get_gpio_flags(np, 2, &flags); + if (ret > 0) { + mdo = ret; + mdo_active_low = flags & OF_GPIO_ACTIVE_LOW; + } else { + mdo = 0; + } + + bus_id = of_alias_get_id(np, "mdio-gpio"); + if (bus_id < 0) { + dev_warn(dev, "failed to get alias id\n"); + bus_id = 0; + } bitbang->ctrl.ops = &mdio_gpio_ops; - bitbang->ctrl.reset = pdata->reset; - mdc = pdata->mdc; bitbang->mdc = gpio_to_desc(mdc); - if (pdata->mdc_active_low) + if (mdc_active_low) mdc_flags = GPIOF_OUT_INIT_HIGH | GPIOF_ACTIVE_LOW; - mdio = pdata->mdio; bitbang->mdio = gpio_to_desc(mdio); - if (pdata->mdio_active_low) + if (mdio_active_low) mdio_flags |= GPIOF_ACTIVE_LOW; - mdo = pdata->mdo; if (mdo) { bitbang->mdo = gpio_to_desc(mdo); - if (pdata->mdo_active_low) + if (mdo_active_low) mdo_flags = GPIOF_OUT_INIT_LOW | GPIOF_ACTIVE_LOW; } @@ -175,10 +154,6 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, goto out; new_bus->name = "GPIO Bitbanged MDIO", - - new_bus->phy_mask = pdata->phy_mask; - new_bus->phy_ignore_ta_mask = pdata->phy_ignore_ta_mask; - memcpy(new_bus->irq, pdata->irqs, sizeof(new_bus->irq)); new_bus->parent = dev; if (new_bus->phy_mask == ~0) @@ -229,31 +204,22 @@ static void mdio_gpio_bus_destroy(struct device *dev) static int mdio_gpio_probe(struct platform_device *pdev) { - struct mdio_gpio_platform_data *pdata; struct device *dev = &pdev->dev; struct mdio_gpio_info *bitbang; struct mii_bus *new_bus; - int ret, bus_id; + struct device_node *np; + int ret; + np = dev->of_node; bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL); if (!bitbang) return -ENOMEM; - pdata = mdio_gpio_of_get_data(dev); - bus_id = of_alias_get_id(dev->of_node, "mdio-gpio"); - if (bus_id < 0) { - dev_warn(dev, "failed to get alias id\n"); - bus_id = 0; - } - - if (!pdata) - return -ENODEV; - - new_bus = mdio_gpio_bus_init(dev, bitbang, pdata, bus_id); + new_bus = mdio_gpio_bus_init(dev, bitbang); if (!new_bus) return -ENODEV; - ret = of_mdiobus_register(new_bus, dev->of_node); + ret = of_mdiobus_register(new_bus, np); if (ret) mdio_gpio_bus_deinit(dev); From patchwork Sun Feb 25 12:51:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129521 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2580802lja; Sun, 25 Feb 2018 04:54:20 -0800 (PST) X-Google-Smtp-Source: AH8x226M9vGvtvI3FBZsWhoV7HZInpYpOud0Zo2RnstrHYkm/ozDQdZvHW41MB27QrJgrxSbtJnA X-Received: by 10.101.72.2 with SMTP id h2mr5922561pgs.240.1519563259943; Sun, 25 Feb 2018 04:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519563259; cv=none; d=google.com; s=arc-20160816; b=DgxphI3Vl1BNOxtdxEeEUwX70fBjspZ898LEhZF76ppk4wjxkdc7Y03Ez7qHubyBvM 4kGslIyug+CRBhKb94hr72I1J2DJOIe5CW5DeRNRyctxFqsbiOsCWoD24NKiH3l22x1X D9Ry5LQI/GtgKWh7a+hzLBNDMNsvYbvnTcXa32TUUFhdxEVBOg1Hcu1aD9L6IBNHgHz7 DOnBC+OoHLCpxo2UFZbo5z3heKe809VJuYWP9WvXg/ISbIGFMyHWYd/Uc7GOatg9xOMb QA497qTeGq01w2sioBv207Bu0me8Om2M1VPxG9mMUFrlImnGHOpzXIWeBWn48K1ivdHJ u6Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kcn0wdf0t5kx0IG2eQWcThYyZ3bGMuy3GTXTGN05orU=; b=O/3LELkRgRqarH2+fz9ex/Ksm2XtuzKjlaSSW/yFpiaDRBlKBz1nKW54Y9AhbdMfo5 zdWz/TYQDH9kb3NH+ps14lNdZ+L8IuPl1Ml24Q6vpqtu4rLPzXCg2hJor2EijprSO0ES zN4Yr8LVAQMQLjXioehxdyS4LMRwpkBHiv80nagK+HVb4nLIqIrOXvKW79lynwVQO/DM j9wusjLmyU6lYd6JA+lfAAmTn1eAcOaKKPckgwpFDufyDgvcQg9PpLcPOf5OIhORuV9F MVZ6xoht+pJVh0tPnIu+osdvyn1KZzcDMJondyDf5aEqzIi3RIVVopXB4c0J1bgdBqFx HkEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RHOeLXN6; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l77si5131892pfk.210.2018.02.25.04.54.19; Sun, 25 Feb 2018 04:54:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RHOeLXN6; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793AbeBYMyR (ORCPT + 8 others); Sun, 25 Feb 2018 07:54:17 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34926 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeBYMyE (ORCPT ); Sun, 25 Feb 2018 07:54:04 -0500 Received: by mail-lf0-f68.google.com with SMTP id 70so18438972lfw.2 for ; Sun, 25 Feb 2018 04:54:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kcn0wdf0t5kx0IG2eQWcThYyZ3bGMuy3GTXTGN05orU=; b=RHOeLXN6+VB80Zd+6XRl3MNsfYRIAH4zr+UxTC4yq7+6DcA9hiqPKxm+2wALlkoN40 wX2Kltl4rRd5vi0E/lGb7iPo06adXOPlWmPkrMAigiD3LxgKvZfZDAkbeGwF1ONkXzB/ LLLRoLMm8jTV9CK1mBFGYcNRYkaWGUDysakso= 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=kcn0wdf0t5kx0IG2eQWcThYyZ3bGMuy3GTXTGN05orU=; b=NHJVDLOwnbhk+Kc1nF2cVakgYr/lP0KuexWg0COsQPUQavYIpGAevqzZuTOrTTh5Cb sziQZ7EVusoMjXPdRdUJBVHeFcy1gm3uMqxCSaz05V0+inxlVUa+GSJOWyP2fa7yErhQ c9YlpbZ/Z1veHLGKirVSeqmGUwqRg/nO0TCq2RtZBETPrUwllzgDxXVcrfIgKERerk3+ 7m8Y2Q54ZEW1xbQ9VkeCn9cpltZYmcRviiy/eHiG9Zwymo0PPVZD1xDPMFpMzeDRlPWa GUfMxpuD45MvGwI5SipeRE2oaprPo5n9chDtFpyXnIXlo6m4WwAIy0EQqzknd2KMMffy DVXQ== X-Gm-Message-State: APf1xPC8hLeDF11X6J0Fi1lzUL39RdpjZnhruRkeyGJSQeGxSd9OcPPl L6PWO4STCtUDnvyLoaQlULfDBg== X-Received: by 10.46.21.13 with SMTP id s13mr5460180ljd.58.1519563242703; Sun, 25 Feb 2018 04:54:02 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id 5sm1456574lfp.17.2018.02.25.04.54.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Feb 2018 04:54:01 -0800 (PST) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH net-next 5/5] net: mdio-gpio: Move to gpiod API Date: Sun, 25 Feb 2018 13:51:32 +0100 Message-Id: <20180225125132.25275-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180225125132.25275-1-linus.walleij@linaro.org> References: <20180225125132.25275-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the bitbanged GPIO based MDIO driver over to using the gpiolib GPIO descriptors and transfer the line inversion and optional MDO handling semantics to gpiolib. The driver has been parsing the device tree to handle GPIO semantics on its own, but this is completely unnecessary as the gpiolib can handle all inversion and optional line semantics. This cuts down the code a lot and makes the driver simpler. Switch mdio_gpio_bus_init() to return an error pointer and handle this in probe() so we can back out of e.g. -EPROBE_DEFER properly if we need to. After this the GPIO MDIO driver only use GPIO descriptors and is completely decoupled from the old GPIO API. Signed-off-by: Linus Walleij --- drivers/net/phy/mdio-gpio.c | 81 +++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 58 deletions(-) -- 2.14.3 diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 9146077b5278..5740f16a0f30 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -25,9 +25,7 @@ #include #include #include -#include - -#include +#include #include struct mdio_gpio_info { @@ -94,41 +92,23 @@ static const struct mdiobb_ops mdio_gpio_ops = { static struct mii_bus *mdio_gpio_bus_init(struct device *dev, struct mdio_gpio_info *bitbang) { - unsigned long mdo_flags = GPIOF_OUT_INIT_HIGH; - unsigned long mdc_flags = GPIOF_OUT_INIT_LOW; - unsigned long mdio_flags = GPIOF_DIR_IN; struct device_node *np = dev->of_node; - enum of_gpio_flags flags; struct mii_bus *new_bus; - bool mdio_active_low; - bool mdc_active_low; - bool mdo_active_low; - unsigned int mdio; - unsigned int mdc; - unsigned int mdo; int bus_id; int ret, i; - ret = of_get_gpio_flags(np, 0, &flags); - if (ret < 0) - return NULL; - - mdc = ret; - mdc_active_low = flags & OF_GPIO_ACTIVE_LOW; - - ret = of_get_gpio_flags(np, 1, &flags); - if (ret < 0) - return NULL; - mdio = ret; - mdio_active_low = flags & OF_GPIO_ACTIVE_LOW; - - ret = of_get_gpio_flags(np, 2, &flags); - if (ret > 0) { - mdo = ret; - mdo_active_low = flags & OF_GPIO_ACTIVE_LOW; - } else { - mdo = 0; - } + bitbang->mdc = + devm_gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW); + if (IS_ERR(bitbang->mdc)) + return ERR_CAST(bitbang->mdc); + bitbang->mdio = + devm_gpiod_get_index(dev, NULL, 1, GPIOD_IN); + if (IS_ERR(bitbang->mdio)) + return ERR_CAST(bitbang->mdio); + bitbang->mdo = + devm_gpiod_get_index_optional(dev, NULL, 2, GPIOD_OUT_HIGH); + if (IS_ERR(bitbang->mdo)) + return ERR_CAST(bitbang->mdo); bus_id = of_alias_get_id(np, "mdio-gpio"); if (bus_id < 0) { @@ -137,27 +117,21 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, } bitbang->ctrl.ops = &mdio_gpio_ops; - bitbang->mdc = gpio_to_desc(mdc); - if (mdc_active_low) - mdc_flags = GPIOF_OUT_INIT_HIGH | GPIOF_ACTIVE_LOW; - bitbang->mdio = gpio_to_desc(mdio); - if (mdio_active_low) - mdio_flags |= GPIOF_ACTIVE_LOW; - if (mdo) { - bitbang->mdo = gpio_to_desc(mdo); - if (mdo_active_low) - mdo_flags = GPIOF_OUT_INIT_LOW | GPIOF_ACTIVE_LOW; - } new_bus = alloc_mdio_bitbang(&bitbang->ctrl); - if (!new_bus) + if (!new_bus) { + ret = -ENOMEM; goto out; + } new_bus->name = "GPIO Bitbanged MDIO", new_bus->parent = dev; - if (new_bus->phy_mask == ~0) + if (new_bus->phy_mask == ~0) { + dev_err(dev, "no PHY in mask\n"); + ret = -ENODEV; goto out_free_bus; + } for (i = 0; i < PHY_MAX_ADDR; i++) if (!new_bus->irq[i]) @@ -168,15 +142,6 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, else strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE); - if (devm_gpio_request_one(dev, mdc, mdc_flags, "mdc")) - goto out_free_bus; - - if (devm_gpio_request_one(dev, mdio, mdio_flags, "mdio")) - goto out_free_bus; - - if (mdo && devm_gpio_request_one(dev, mdo, mdo_flags, "mdo")) - goto out_free_bus; - dev_set_drvdata(dev, new_bus); return new_bus; @@ -184,7 +149,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, out_free_bus: free_mdio_bitbang(new_bus); out: - return NULL; + return ERR_PTR(ret); } static void mdio_gpio_bus_deinit(struct device *dev) @@ -216,8 +181,8 @@ static int mdio_gpio_probe(struct platform_device *pdev) return -ENOMEM; new_bus = mdio_gpio_bus_init(dev, bitbang); - if (!new_bus) - return -ENODEV; + if (IS_ERR(new_bus)) + return PTR_ERR(new_bus); ret = of_mdiobus_register(new_bus, np); if (ret)