linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
@ 2010-03-11  0:55 Wolfram Sang
       [not found] ` <1268268932-23447-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2010-03-11  0:55 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Albrecht Dreß, Wolfram Sang, Eric W. Biederman, Jean Delvare

Commit 6992f5334995af474c2b58d010d08bc597f0f2fe introduced this requirement.

Reported-by: Albrecht Dreß <albrecht.dress-KvP5wT2u2U0@public.gmane.org>
Signed-off-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
---
 drivers/misc/eeprom/at24.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Depends on:

http://thread.gmane.org/gmane.linux.drivers.i2c/5496

([PATCH V2] at24: Fall back to byte or word reads if needed)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 88c20da..d2deea4 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -541,6 +541,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
 	at24->bin.read = at24_bin_read;
 	at24->bin.size = chip.byte_len;
+	sysfs_bin_attr_init(&at24->bin);
 
 	at24->macc.read = at24_macc_read;
 
-- 
1.7.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found] ` <1268268932-23447-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-03-11  7:58   ` Jean Delvare
       [not found]     ` <20100311085835.34c6cd51-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  2010-03-11 18:21   ` Albrecht Dreß
  1 sibling, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2010-03-11  7:58 UTC (permalink / raw)
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Wolfram Sang, Eric W. Biederman

Hi Wolfram,

On Thu, 11 Mar 2010 01:55:32 +0100, Wolfram Sang wrote:
> Commit 6992f5334995af474c2b58d010d08bc597f0f2fe introduced this requirement.
> 
> Reported-by: Albrecht Dreß <albrecht.dress-KvP5wT2u2U0@public.gmane.org>
> Signed-off-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> ---
>  drivers/misc/eeprom/at24.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> Depends on:
> 
> http://thread.gmane.org/gmane.linux.drivers.i2c/5496
> 
> ([PATCH V2] at24: Fall back to byte or word reads if needed)
> 
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 88c20da..d2deea4 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -541,6 +541,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
>  	at24->bin.read = at24_bin_read;
>  	at24->bin.size = chip.byte_len;
> +	sysfs_bin_attr_init(&at24->bin);

I think it would make more sense to move the initialization _before_
manually setting other struct members. You don't know what
sysfs_bin_attr_init does or will do in the future.

>  
>  	at24->macc.read = at24_macc_read;
>  

I presume the at25 driver needs the same fix?

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found]     ` <20100311085835.34c6cd51-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-03-11  8:03       ` Wolfram Sang
       [not found]         ` <20100311080347.GB16219-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2010-03-11  8:03 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Eric W. Biederman

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

Hi Jean,

> > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> > index 88c20da..d2deea4 100644
> > --- a/drivers/misc/eeprom/at24.c
> > +++ b/drivers/misc/eeprom/at24.c
> > @@ -541,6 +541,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
> >  	at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
> >  	at24->bin.read = at24_bin_read;
> >  	at24->bin.size = chip.byte_len;
> > +	sysfs_bin_attr_init(&at24->bin);
> 
> I think it would make more sense to move the initialization _before_
> manually setting other struct members. You don't know what
> sysfs_bin_attr_init does or will do in the future.

Okay.

> I presume the at25 driver needs the same fix?

Yes, sent it to the SPI-list sperately. I wasn't sure if a patch series would
ease or complicate things.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found]         ` <20100311080347.GB16219-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-03-11 10:54           ` Jean Delvare
       [not found]             ` <20100311115426.6440837c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2010-03-11 10:54 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Eric W. Biederman

On Thu, 11 Mar 2010 09:03:47 +0100, Wolfram Sang wrote:
> Hi Jean,
> 
> > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> > > index 88c20da..d2deea4 100644
> > > --- a/drivers/misc/eeprom/at24.c
> > > +++ b/drivers/misc/eeprom/at24.c
> > > @@ -541,6 +541,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
> > >  	at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
> > >  	at24->bin.read = at24_bin_read;
> > >  	at24->bin.size = chip.byte_len;
> > > +	sysfs_bin_attr_init(&at24->bin);
> > 
> > I think it would make more sense to move the initialization _before_
> > manually setting other struct members. You don't know what
> > sysfs_bin_attr_init does or will do in the future.
> 
> Okay.

OK, patch applied with this change, thanks.

> > I presume the at25 driver needs the same fix?
> 
> Yes, sent it to the SPI-list sperately. I wasn't sure if a patch series would
> ease or complicate things.

Fine with me, as long as it get fixed.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found]             ` <20100311115426.6440837c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-03-11 11:23               ` Wolfram Sang
       [not found]                 ` <20100311112321.GA28805-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2010-03-11 11:23 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Eric W. Biederman

[-- Attachment #1: Type: text/plain, Size: 487 bytes --]


> > > I presume the at25 driver needs the same fix?
> > 
> > Yes, sent it to the SPI-list sperately. I wasn't sure if a patch series would
> > ease or complicate things.
> 
> Fine with me, as long as it get fixed.

I am currently using my newly acquired coccinelle-fu to find further drivers in
need of such a fix :)

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found]                 ` <20100311112321.GA28805-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-03-11 14:57                   ` Jean Delvare
       [not found]                     ` <20100311155753.25fc9a5c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2010-03-11 14:57 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Eric W. Biederman

On Thu, 11 Mar 2010 12:23:21 +0100, Wolfram Sang wrote:
> 
> > > > I presume the at25 driver needs the same fix?
> > > 
> > > Yes, sent it to the SPI-list sperately. I wasn't sure if a patch series would
> > > ease or complicate things.
> > 
> > Fine with me, as long as it get fixed.
> 
> I am currently using my newly acquired coccinelle-fu to find further drivers in
> need of such a fix :)

A quick grep suggests that only 3 drivers need care:
arch/mips/txx9/generic/setup.c
drivers/misc/eeprom/at24.c
drivers/misc/eeprom/at25.c

I'm curious if coccinelle will find more...

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found] ` <1268268932-23447-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2010-03-11  7:58   ` Jean Delvare
@ 2010-03-11 18:21   ` Albrecht Dreß
  2010-03-12  0:12     ` Wolfram Sang
  1 sibling, 1 reply; 9+ messages in thread
From: Albrecht Dreß @ 2010-03-11 18:21 UTC (permalink / raw)
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, Eric W. Biederman,
	Jean Delvare

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

Hi Wolfram:

your patch completely fixes the issue on my 5200B board.

Just an other dumb question:  as I mentioned, the driver is loaded even if no chip is attached to the i2c bus.  Wouldn't it make sense to check if the chip is there (e.g. by reading the first byte), and eject with ENODEV if it isn't?

Thanks, Albrecht.

Tested-By: Albrecht Dreß <albrecht.dress-KvP5wT2u2U0@public.gmane.org>

Am 11.03.10 01:55 schrieb(en) Wolfram Sang:
> Commit 6992f5334995af474c2b58d010d08bc597f0f2fe introduced this requirement.
> 
> Reported-by: Albrecht Dreß <albrecht.dress-KvP5wT2u2U0@public.gmane.org>
> Signed-off-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> ---
>  drivers/misc/eeprom/at24.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> Depends on:
> 
> http://thread.gmane.org/gmane.linux.drivers.i2c/5496
> 
> ([PATCH V2] at24: Fall back to byte or word reads if needed)
> 
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 88c20da..d2deea4 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -541,6 +541,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
>  	at24->bin.read = at24_bin_read;
>  	at24->bin.size = chip.byte_len;
> +	sysfs_bin_attr_init(&at24->bin);
> 
>  	at24->macc.read = at24_macc_read;
> 
> --
> 1.7.0
> 
> 
> 
> 


[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
  2010-03-11 18:21   ` Albrecht Dreß
@ 2010-03-12  0:12     ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2010-03-12  0:12 UTC (permalink / raw)
  To: Albrecht Dreß
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Eric W. Biederman, Jean Delvare

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

> Just an other dumb question:  as I mentioned, the driver is loaded even if no
> chip is attached to the i2c bus.  Wouldn't it make sense to check if the chip
> is there (e.g. by reading the first byte), and eject with ENODEV if it isn't?

That would be part of a detect-callback. In probe() the device is already
considered to be present. But you can instantiate devices at runtime if you
want to add the eeprom dynamically (Documentation/i2c/instantiating-devices)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures
       [not found]                     ` <20100311155753.25fc9a5c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-03-12  7:12                       ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2010-03-12  7:12 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Albrecht Dreß,
	Eric W. Biederman

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

> A quick grep suggests that only 3 drivers need care:
> arch/mips/txx9/generic/setup.c
> drivers/misc/eeprom/at24.c
> drivers/misc/eeprom/at25.c
> 
> I'm curious if coccinelle will find more...

See kernel-janitors:

drivers/base/firmware_class.c
drivers/rtc/rtc-ds1742.c

needed a fix, too. At least those, I am not 100% sure I found all of them.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-03-12  7:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-11  0:55 [PATCH] misc/eeprom/at24: init dynamic bin_attribute structures Wolfram Sang
     [not found] ` <1268268932-23447-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-03-11  7:58   ` Jean Delvare
     [not found]     ` <20100311085835.34c6cd51-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-11  8:03       ` Wolfram Sang
     [not found]         ` <20100311080347.GB16219-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-03-11 10:54           ` Jean Delvare
     [not found]             ` <20100311115426.6440837c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-11 11:23               ` Wolfram Sang
     [not found]                 ` <20100311112321.GA28805-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-03-11 14:57                   ` Jean Delvare
     [not found]                     ` <20100311155753.25fc9a5c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-12  7:12                       ` Wolfram Sang
2010-03-11 18:21   ` Albrecht Dreß
2010-03-12  0:12     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).