lkml.org 
[lkml]   [2020]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [net-next PATCH v2 04/14] net: phy: Introduce fwnode_get_phy_id()
On Tue, Dec 15, 2020 at 07:28:10PM +0200, Andy Shevchenko wrote:
> On Tue, Dec 15, 2020 at 6:44 PM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Extract phy_id from compatible string. This will be used by
> > fwnode_mdiobus_register_phy() to create phy device using the
> > phy_id.
>
> ...
>
> > + if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) {
> > + *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
> > + return 0;
> > + }
> > + return -EINVAL;
>
> Perhaps traditional pattern, i.e.
> if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2)
> return -EINVAL;
>
> *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
> return 0;
>
> And perhaps GENMASK() ?

Sure. Will rewrite accordingly.

Thanks
Calvin

\
 
 \ /
  Last update: 2020-12-17 09:31    [W:0.070 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site