Re: VAIO EEPROM support in at24

From: Jean Delvare
Date: Thu Aug 06 2020 - 13:51:02 EST


On Wed, 5 Aug 2020 20:14:28 +0200, Bartosz Golaszewski wrote:
> On Wed, Aug 5, 2020 at 4:36 PM Jean Delvare <jdelvare@xxxxxxx> wrote:
> > I finally found the time to give it a try. Here's what my (tested)
> > prototype looks like:
>
> Hi Jean,
>
> this looks good at first glance.
>
> > --- a/drivers/misc/eeprom/at24.c
> > +++ b/drivers/misc/eeprom/at24.c
> > (...)
> > @@ -427,6 +450,15 @@ static int at24_read(void *priv, unsigne
> >
> > pm_runtime_put(dev);
> >
> > + if ((at24->flags & AT24_FLAG_MASKED_RANGE) && !capable(CAP_SYS_ADMIN)) {
>
> Maybe use unlikely() here? It's not necessarily a hotpath but at least
> it would be obvious it's a corner case.

Sure.

> > (...)
> > 1* Do we actually need to use a struct resource? With the current
> > requirements, that looks overkill to me. We really only need the
> > start and end offsets of the masked area (or start and length). Or
> > do you plan to ever support multiple masked ranges, and
> > resource.child would be used to daisy-chain these ranges? Personally
> > I would wait until the need exists.
>
> Yes, since this change doesn't seem to commit to any stable ABI, I'd
> say we can drop the reference to struct resource and possibly add it
> in the future. This just was the first thing that came to mind when I
> suggested it.

OK, I changed it to simple integers for now.

> > Note that if we would just store mstart and mlen in struct
> > at24_chip_data then we could even get rid of AT24_FLAG_MASKED_RANGE,
> > as mlen > 0 would imply a masked range.
>
> Makes sense.

Done.

> > 2* I chose the name "eeprom-vaio" because "vaio" would be too generic.
> > I'm open to suggestions if you don't like that name.
>
> Are you sure there won't be any different models of vaio eeproms? How
> about '24c02-vaio' or 'eeprom-vaio-24c02'?

All I've seen were 24C02 but last time was a decade ago. I have no idea
if recent Vaio laptops still have this EEPROM, at this address, of that
size. 'eeprom-vaio-24c02' is too long to my taste, and kind of
redundant as '24c02' implies 'eeprom'. I like '24c02-vaio' very much
though, it is both concise and accurate, and is future-proof too. I'll
go for that, thanks for the suggestion.

> > 3* at24_read() was pretty elegant before my changes, but with the need
> > to remember the original value of many parameters, it no longer is.
> > I'm considering rewriting it in a way that does not modify the
> > parameters needed to process the masked range, either as part of
> > this patch or as a subsequent clean-up patch. That would hopefully
> > make the code elegant again.
>
> All clean-ups are welcome.

OK, I'll give it a try and see if I can tidy it up.

> > 4* I made the masking active only for non-root users as this is what
> > the legacy eeprom driver was doing. I hope that's OK with you.
> >
>
> Yes, it's fine with me. If more fine-grained control is needed we can
> probably extend it.

OK :-)

I have a patch almost ready, I'll submit v2 later today.

--
Jean Delvare
SUSE L3 Support