Re: [PATCH v3] rtc: ds1307: generalise ram size and offset

From: Austin Boyle
Date: Wed Feb 01 2012 - 19:54:07 EST


Hi Wolfram,

I'm sorry about the slow response - I was away at linux.conf.au and then
haven't found enough time since I got back.

On Thu, 2012-01-19 at 20:45 +0100, Wolfram Sang wrote:
> Sorry, found another thing.
>
> > + if (chip) {
> > + if (chip->nvram_size)
> > + ds1307->nvram_size = chip->nvram_size;
> > + if (chip->nvram_offset)
> > + ds1307->nvram_offset = chip->nvram_offset;
> > + }
>
> I moved only the assignments...
>
> >
> > buf = ds1307->regs;
> > if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
> > @@ -893,11 +907,12 @@ read_rtc:
> > dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> > }
> >
> > - if (chip && chip->nvram56) {
> > + if (chip && chip->nvram_size) {
>
> .. to here when I saw...
>
> > + nvram.size = ds1307->nvram_size;
>
> ... that nvram is static and we are changing it. Yeah, it is very unlikely but
> if we have two RTC with different nvram sizes, one of them will not work correctly.
I see the issue. Am I right that it would only occur when you have two
I2C buses, each with one of the RTC chips supported by this driver?

The fix I thought of would be to add a 'struct bin_attribute' pointer to
'struct ds1307' and then in the probe function allocate the structure,
set the size & callbacks, and pass it as an argument to
sysfs_create_bin_file. Do you think this is viable?

It looks like Andrew Morton has already added this patch to the -mm
tree. Has he also grabbed the patches that this depends on?

Thanks,
Austin.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/