From: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: timtimred-f/KTTADhmRsdnm+yROfE0A@public.gmane.org,
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: [patch 2.6.24-rc5-git] add i2c_new_dummy() utility
Date: Sat, 22 Dec 2007 21:08:50 -0800 [thread overview]
Message-ID: <200712222108.51292.david-b@pacbell.net> (raw)
In-Reply-To: <kOXVGr9s.1198344701.9162110.khali-IO4AeUl/lkuWVfeAwA7xHQ@public.gmane.org>
On Saturday 22 December 2007, Jean Delvare wrote:
> > +/**
> > + * i2c_new_dummy - return a new i2c device bound to a dummy driver
> > + * @adapter: the adapter managing the device
> > + * @address: seven bit address to be used
> > + * @type: optional label used for i2c_client.name
>
> Do you have a use case in mind for this feature?
You mean the "type" field? In the at24.c driver I posted, it's
the same name used with the "real" i2c_client node. That helps
make sense of just what the "dummy" is for; sysfs can show it.
Being tied to a "dummy" driver is not very explanatory.
> > + * This returns the new i2c client, which may be saved for later use with
> > + * i2c_unregister_device(); or NULL to indicate an error.
>
> I'd say it _should_ be saved. Calling i2c_unregister_device() is pretty
> much mandatory, unless the driver can't be built as a module.
OK by me, "which should be saved".
> > + */
> > +struct i2c_client *
> > +i2c_new_dummy(struct i2c_adapter *adapter, unsigned address, const char *type)
>
> The rest of i2c-core uses an unsigned short for addresses, maybe do the
> same here for consistency?
It's promoted by C! But no problem. I'll make it u16 to match
the SMBus calls and struct i2c_msg ... and be more concise, still
fitting on one line.
> > +{
> > + struct i2c_board_info info = {
> > + .driver_name = "dummy",
> > + .addr = address,
> > + };
> > +
> > + if (type)
> > + strncpy(info.type, type, sizeof info.type);
>
> Please use strlcpy() instead, strncpy() is error-prone.
OK.
> > @@ -848,11 +893,24 @@ static int __init i2c_init(void)
> > retval = bus_register(&i2c_bus_type);
> > if (retval)
> > return retval;
> > - return class_register(&i2c_adapter_class);
> > + retval = class_register(&i2c_adapter_class);
> > + if (retval)
> > + goto bus_err;
> > + retval = i2c_add_driver(&dummy_driver);
> > + if (retval)
> > + goto class_err;
> > + return 0;
> > +
> > +class_err:
> > + class_unregister(&i2c_adapter_class);
> > +bus_err:
> > + bus_unregister(&i2c_bus_type);
> > + return retval;
> > }
>
> Thanks for fixing a broken error path...
I could hardly avoid it! :)
> > --- a/include/linux/i2c.h 2007-12-15 20:57:54.000000000 -0800
> > +++ b/include/linux/i2c.h 2007-12-15 21:01:22.000000000 -0800
> > @@ -261,6 +261,12 @@ i2c_new_probed_device(struct i2c_adapter
> > struct i2c_board_info *info,
> > unsigned short const *addr_list);
> >
> > +/* For devices that use several addresses, use i2c_new_dummy() to make
> > + * client handles for the exta addresses.
>
> Typo: extra.
Glitchey keyboard. :(
> > + */
> > +extern struct i2c_client *
> > +i2c_new_dummy(struct i2c_adapter *adap, unsigned address, const char *type);
> > +
> > extern void i2c_unregister_device(struct i2c_client *);
> >
> > /* Mainboard arch_initcall() code should register all its I2C devices.
> >
>
> Other than that the patch looks just fine. Please respin it and I'll
> apply it.
Thanks. Update to follow.
- Dave
next prev parent reply other threads:[~2007-12-23 5:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-22 17:31 [patch 2.6.24-rc5-git] add i2c_new_dummy() utility Jean Delvare
[not found] ` <kOXVGr9s.1198344701.9162110.khali-IO4AeUl/lkuWVfeAwA7xHQ@public.gmane.org>
2007-12-23 5:08 ` David Brownell [this message]
[not found] ` <200712222108.51292.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2007-12-23 5:11 ` David Brownell
[not found] ` <200712222111.09471.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2007-12-23 9:03 ` Jean Delvare
[not found] <20071216052308.A0FB11668D7@adsl-69-226-248-13.dsl.pltn13.pacbell.net>
[not found] ` <20071216052308.A0FB11668D7-ZcXrCSuhvln6VZ3dlLfH/g4gEjPzgfUyLrfjE7I9kuVHxeISYlDBzl6hYfS7NtTn@public.gmane.org>
2007-12-27 20:58 ` Byron Bradley
[not found] ` <57e2b00712271258l6ea661ai2bfd6b9e099c71be-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-27 21:53 ` David Brownell
[not found] ` <200712271353.05857.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2007-12-27 22:09 ` Byron Bradley
[not found] ` <57e2b00712271409n6c98f76o45116cd92b01f396-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-27 23:06 ` David Brownell
[not found] ` <200712271506.43069.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2007-12-27 23:37 ` Byron Bradley
2007-12-27 23:59 ` David Brownell
[not found] ` <200712281230.17840.david-b@pacbell.net>
[not found] ` <57e2b00712281645y70f6ec74s57945dc53f113ec8@mail.gmail.com>
[not found] ` <57e2b00712281645y70f6ec74s57945dc53f113ec8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-30 3:05 ` David Brownell
[not found] ` <200712291905.15160.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-01-04 22:16 ` Jean Delvare
[not found] ` <20080104231633.135f2875-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-01-04 23:48 ` David Brownell
[not found] ` <200801041548.54825.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-01-06 9:57 ` Jean Delvare
2008-01-17 22:24 ` David Brownell
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=200712222108.51292.david-b@pacbell.net \
--to=david-b-ybekhbn/0ldr7s880joybq@public.gmane.org \
--cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=timtimred-f/KTTADhmRsdnm+yROfE0A@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox