From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS 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 87B6DC4360F for ; Wed, 3 Apr 2019 21:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EAD8206B8 for ; Wed, 3 Apr 2019 21:15:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pw6sRnor" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbfDCVP3 (ORCPT ); Wed, 3 Apr 2019 17:15:29 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42505 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbfDCVP3 (ORCPT ); Wed, 3 Apr 2019 17:15:29 -0400 Received: by mail-wr1-f65.google.com with SMTP id g3so680319wrx.9 for ; Wed, 03 Apr 2019 14:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rIJ14JNN8rt59s7EeIqZTgNPqKSd1oM7YOdOP8IpGa0=; b=pw6sRnorVmrsaxqgJLFL6jJ15UU8pIW5eEosLRCrChemUlGOtXmC/oCKUmg2DoIydK cqHI6laOFs8JZyAb00yCErFDGTVU1N2jYI49znXqkU5yU73XWgBBUErWJ4CIxw4IYNEy +/AAhcDDXJT8WtZY3hq3JjW4tX+lvTiCeQI9GFjEd6V7y0io97exUIlHMwti34MgPaVR liOrVZn991A+OTnCFikCHDkI05Hr7AUi45yIURDN5eH8R/TIhFMS8oqZTqcnmh1Gl4lY zcyKI3bwN63QlFxsIuAGFuFVQG6VoDKNpK9VW3ryaeJXThKpg9fcnJgrQoY7bHxJFUYl UUUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rIJ14JNN8rt59s7EeIqZTgNPqKSd1oM7YOdOP8IpGa0=; b=CrgmImWPYMij8QzXaRaComv96cZg7kw5u3oxDq2qQK1xtVOJW2qSySr3jtPxXOaTCd Iw2x0bYTpBtYGhloyNlcrAlQHhxzIWNfXLejdkb1cECmHVOc64IA7Bisy3u7Pruqni/S ZNE47Yv1G1fYAzNucj60sd3xiEq4Sh7B4r6uvsOW3r7JcSTQlDRieTXxDeDmYPaAVcCG HYbhs2wWDOHs0/PDwQ5kgS0VtrvJdcJEZI+VAOW6XVkZ+QeI6C/do2AE4Irxpy2/84bg x9OO7e+HfAk1DU1gm+dX2oDBLVfs5yPMcWENTLasDkV6Llnno/4slLMHzIuBd5xO8cWL se/w== X-Gm-Message-State: APjAAAWwE/S8udUVXGtGw8l+LkjLZvMijI/gU/LvUccCIg1jugKcyAS6 1K3vb6IXLHWz0nod/0mtDpBMsfPV X-Google-Smtp-Source: APXvYqzvTDTBwQvKpvayKc1addW1/gkHY0lFe4Hc9ERqQ2OiNJkX+637OJZl8CcEgtzBaQw1w3Kf1w== X-Received: by 2002:adf:f30a:: with SMTP id i10mr1156700wro.111.1554326127593; Wed, 03 Apr 2019 14:15:27 -0700 (PDT) Received: from ?IPv6:2003:ea:8be1:dd00:ed2b:516:5ae8:487f? (p200300EA8BE1DD00ED2B05165AE8487F.dip0.t-ipconnect.de. [2003:ea:8be1:dd00:ed2b:516:5ae8:487f]) by smtp.googlemail.com with ESMTPSA id z84sm26982495wmg.24.2019.04.03.14.15.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 14:15:26 -0700 (PDT) Subject: [PATCH net-next v2 1/2] net: phy: allow a PHY driver to define neither features nor get_features From: Heiner Kallweit To: Andrew Lunn , Florian Fainelli , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <584beb62-1b0c-ebfa-c460-b1b378bf49bb@gmail.com> Date: Wed, 3 Apr 2019 23:14:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Meanwhile we have generic functions for reading the abilities of Clause 22 / 45 PHY's. This allows to use them as fallback in case callback get_features isn't set. Benefit is the reduction of boilerplate code in PHY drivers. v2: - adjust the comment in phy_driver_register to match the code Signed-off-by: Heiner Kallweit --- drivers/net/phy/phy_device.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 72fc714c9..f7a6d0ffb 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2143,12 +2143,17 @@ static int phy_probe(struct device *dev) */ if (phydrv->features) { linkmode_copy(phydev->supported, phydrv->features); - } else { + } else if (phydrv->get_features) { err = phydrv->get_features(phydev); - if (err) - goto out; + } else if (phydev->is_c45) { + err = genphy_c45_pma_read_abilities(phydev); + } else { + err = genphy_read_abilities(phydev); } + if (err) + goto out; + of_set_phy_supported(phydev); linkmode_copy(phydev->advertising, phydev->supported); @@ -2216,11 +2221,11 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) int retval; /* Either the features are hard coded, or dynamically - * determine. It cannot be both or neither + * determined. It cannot be both. */ - if (WARN_ON((!new_driver->features && !new_driver->get_features) || - (new_driver->features && new_driver->get_features))) { - pr_err("%s: Driver features are missing\n", new_driver->name); + if (WARN_ON(new_driver->features && new_driver->get_features)) { + pr_err("%s: features and get_features must not both be set\n", + new_driver->name); return -EINVAL; } -- 2.21.0