lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 2 Oct 2020 08:14:07 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Grant Likely <grant.likely@....com>,
        Calvin Johnson <calvin.johnson@....nxp.com>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Jeremy Linton <jeremy.linton@....com>,
        Andrew Lunn <andrew@...n.ch>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        Russell King - ARM Linux admin <linux@...linux.org.uk>,
        Cristi Sovaiala <cristian.sovaiala@....com>,
        Florin Laurentiu Chiculita <florinlaurentiu.chiculita@....com>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Madalin Bucur <madalin.bucur@....nxp.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     linux-kernel@...r.kernel.org, linux.cj@...il.com,
        netdev@...r.kernel.org, linux-acpi@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        Diana Madalina Craciun <diana.craciun@....com>,
        Laurentiu Tudor <laurentiu.tudor@....com>,
        "David S. Miller" <davem@...emloft.net>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Jakub Kicinski <kuba@...nel.org>, nd <nd@....com>
Subject: Re: [net-next PATCH v1 3/7] net: phy: Introduce fwnode_get_phy_id()



On 10/2/2020 4:05 AM, Grant Likely wrote:
> 
> 
> On 30/09/2020 17:04, Calvin Johnson wrote:
>> Extract phy_id from compatible string. This will be used by
>> fwnode_mdiobus_register_phy() to create phy device using the
>> phy_id.
>>
>> Signed-off-by: Calvin Johnson <calvin.johnson@....nxp.com>
>> ---
>>
>>   drivers/net/phy/phy_device.c | 32 +++++++++++++++++++++++++++++++-
>>   include/linux/phy.h          |  5 +++++
>>   2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index c4aec56d0a95..162abde6223d 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -9,6 +9,7 @@
>>   #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>> +#include <linux/acpi.h>
>>   #include <linux/bitmap.h>
>>   #include <linux/delay.h>
>>   #include <linux/errno.h>
>> @@ -845,6 +846,27 @@ static int get_phy_c22_id(struct mii_bus *bus, 
>> int addr, u32 *phy_id)
>>       return 0;
>>   }
>> +/* Extract the phy ID from the compatible string of the form
>> + * ethernet-phy-idAAAA.BBBB.
>> + */
>> +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
>> +{
>> +    unsigned int upper, lower;
>> +    const char *cp;
>> +    int ret;
>> +
>> +    ret = fwnode_property_read_string(fwnode, "compatible", &cp);
>> +    if (ret)
>> +        return ret;
>> +
>> +    if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) {
>> +        *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
>> +        return 0;
>> +    }
>> +    return -EINVAL;
>> +}
>> +EXPORT_SYMBOL(fwnode_get_phy_id);
> 
> This block, and the changes in patch 4 duplicate functions from 
> drivers/of/of_mdio.c, but it doesn't refactor anything in 
> drivers/of/of_mdio.c to use the new path. Is your intent to bring all of 
> the parsing in these functions of "compatible" into the ACPI code path?
> 
> If so, then the existing code path needs to be refactored to work with 
> fwnode_handle instead of device_node.
> 
> If not, then the DT path in these functions should call out to of_mdio, 
> while the ACPI path only does what is necessary.

Rob has been asking before to have drivers/of/of_mdio.c be merged or at 
least relocated within drivers/net/phy where it would naturally belong. 
As a preliminary step towards ACPI support that would seem reasonable to do.

Then, as Grant suggests you can start re-factoring as much as possible 
with using fwnode_handle.
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ