From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] PATCH: hwmon-new-driver-ti-tmp401.patch
Date: Sun, 15 Jun 2008 19:17:07 +0000 [thread overview]
Message-ID: <20080615211707.41790348@hyperion.delvare> (raw)
In-Reply-To: <4853E081.1020109@hhs.nl>
Hi Ben,
On Sun, 15 Jun 2008 19:23:11 +0100, Ben Dooks wrote:
> On Sat, Jun 14, 2008 at 05:15:13PM +0200, Hans de Goede wrote:
> > Hi All,
> >
> > This is a new hwmon driver for TI's TMP401 temperature sensor IC. This
> > driver
> > was written on behalf of an embedded systems vendor under the
> > linuxdriverproject.
> >
> > It has been tested using a TI TMP401 sample attached to a i2c-tiny-usb
> > adapter.
> > Which was provided by Till Harbaum, many thanks to him for this!
> >
> > Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
> >
> > Regards,
> >
> > Hans
>
> > This is a new hwmon driver for TI's TMP401 temperature sensor IC. This driver
> > was written on behalf of an embedded systems vendor under the
> > linuxdriverproject.
> >
> > It has been tested using a TI TMP401 sample attached to a i2c-tiny-usb adapter.
> > Which was provided by Till Harbaum, many thanks to him for this!
> >
> > Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
> > (...)
> > +static struct i2c_driver tmp401_driver = {
> > + .driver = {
> > + .name = TMP401_NAME,
>
> the .owner field is missing, ie:
> .owner = THIS_MODULE,
It's optional (i2c_add_driver adds it anyway). I don't like it and I
might revert this behavior someday, but for now that's how things are,
so Hans' code is correct.
> > + },
> > + .attach_adapter = tmp401_attach_adapter,
> > + .detach_client = tmp401_detach_client,
> > +};
>
> you should be using the new method of attaching the clients, as the
> old driver methods are being removed as soon as possible.
If and only if the only users of this driver are embedded platforms. If
this chip is found on PCs or other systems where you can't instantiate
the I2C device, then the legacy methods must still be used. If both
types of users exist then you need two i2c_driver instances (for now;
I'm working on something better for 2.6.27.)
> > +
> > + if (data->status & mask)
> > + return sprintf(buf, "1\n");
> > + else
> > + return sprintf(buf, "0\n");
> > +}
>
> you should be using snprintf() or some other bounded printf method
> against PAGE_SIZE, the return should be the length of the buffer.
I doubt it. snprintf returns the number of bytes written (just like
sprintf), not the size of the buffer, and I fail to see why you would
want to return the buffer size. That would cause sysfs to pass
uninitialized data to user-space.
I agree that in theory we should be using snprintf in these functions,
but the fact is that no hwmon driver does this, and frankly this sounds
overkill. There's just no way PAGE_SIZE can be smaller than room it
takes to print an integer.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2008-06-15 19:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-14 15:15 [lm-sensors] PATCH: hwmon-new-driver-ti-tmp401.patch Hans de Goede
2008-06-15 18:23 ` Ben Dooks
2008-06-15 19:17 ` Jean Delvare [this message]
2008-08-20 11:20 ` Jean Delvare
2008-08-20 15:41 ` Jean Delvare
2008-08-22 18:04 ` Jean Delvare
2008-08-22 18:19 ` Hans de Goede
2008-10-23 20:13 ` Hans de Goede
2008-10-24 8:46 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080615211707.41790348@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.