From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] revisiting __SENSOR_DEVICE_ATTR() and array
Date: Sat, 24 Dec 2005 15:46:20 +0000 [thread overview]
Message-ID: <20051224164620.6e274936.khali@linux-fr.org> (raw)
In-Reply-To: <439A7911.5020904@gmail.com>
Hi Jim,
> > I'm awaiting for your MAINTAINERS patch :)
>
> now included.
Thanks, however, this is a bit confusing as you are moving an entry
around while adding your own. Please send a separate patch (to Linus or
Andrew) reordering "PERSONALITY HANDLING" where it belongs. Then send a
separate patch to me adding your own entry for PC87360.
About the pc87360 patch itself:
> - struct i2c_client *new_client;
> + struct i2c_client *cli;
I wholeheartedly agree that "new_client" was a uselessly long
identifier (inherited from the first Linux hardware monitoring drivers
6 years ago!) However, "cli" might be a bit short now and possibly
confusing (makes one think of the "clear interrupt" assembly operand).
"client" would probably be a reasonable compromise.
Now I understand that one of the reasons beyind the choice of the new
variable name is to keep lines short and avoid repeated line breaks.
There are a few tricks you could use to achieve the same, while using
"client" instead of "cli":
1* Define the following inline function:
static inline int client_create_file(i2c_client *client, struct device_attribute *attr)
{
return device_create_file(&client->dev, attr):
}
Then you can create the files that way:
client_create_file(client, &sensor_dev_attr_in0_input.dev_attr);
2* Keep a pointer to client->dev handy, and use it everywhere is
possible:
struct device *dev = &client->dev;
device_create_file(dev, &sensor_dev_attr_in0_input.dev_attr);
This second option is probably better as it avoids repeated dereferences
of the same pointer, so I think it should be more efficient
performance-wise - although such a change doesn't seem to affect the
binary size; maybe gcc optimizes it on its own already.
This change might be a separate, preliminary patch to the SENSOR_ATTR()
one, at your option.
> - strcpy(new_client->name, name);
> + strcpy(cli->name, name);
While you're at it, strlcpy is prefered in this case.
> + for (i=0; i<11; i++) {
Please respect the coding style that was used for this file WRT spaces
around assignment and comparison symbols.
Thanks,
--
Jean Delvare
next prev parent reply other threads:[~2005-12-24 15:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-10 6:43 [lm-sensors] revisiting __SENSOR_DEVICE_ATTR() and array Jim Cromie
2005-12-10 10:21 ` Jean Delvare
2005-12-14 4:44 ` Jim Cromie
2005-12-16 4:39 ` Mark M. Hoffman
2005-12-16 17:28 ` Jim Cromie
2005-12-18 16:43 ` Jean Delvare
2005-12-18 17:33 ` Jean Delvare
2005-12-19 11:52 ` Jim Cromie
2005-12-19 16:52 ` Jim Cromie
2005-12-24 15:46 ` Jean Delvare [this message]
2005-12-24 16:04 ` 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=20051224164620.6e274936.khali@linux-fr.org \
--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.