lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v2 1/4] net: mdio: Introduce a regmap-based mdio driver
Hello Russell,

On Thu, 25 May 2023 12:11:38 +0100
"Russell King (Oracle)" <linux@armlinux.org.uk> wrote:

> On Thu, May 25, 2023 at 12:11:23PM +0200, Maxime Chevallier wrote:
> > +struct mii_bus *devm_mdio_regmap_register(struct device *dev,
> > + const struct
> > mdio_regmap_config *config) +{
> > + struct mdio_regmap_config *mrc;
> > + struct mii_bus *mii;
> > + int rc;
> > +
> > + if (!config->parent)
> > + return ERR_PTR(-EINVAL);
> > +
> > + mii = devm_mdiobus_alloc_size(config->parent,
> > sizeof(*mrc));
> > + if (!mii)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + mrc = mii->priv;
> > + memcpy(mrc, config, sizeof(*mrc));
> > +
> > + mrc->regmap = config->regmap;
> > + mrc->valid_addr = config->valid_addr;
>
> You have just memcpy'd everything from config into mrc. Doesn't this
> already include "regmap" and "valid_addr" ?

Oh right... good catch, thanks !

> However, these are the only two things used, so does it really make
> sense to allocate the full mdio_regmap_config structure, or would a
> smaller data structure (of one pointer and one u8) be more
> appropriate?
>

You are correct, other fields are unused so I'll use a new struct for
the mii->priv field.

Thank you for reviewing,

Best regards,

Maxime

\
 
 \ /
  Last update: 2023-05-25 14:42    [W:0.067 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site