From: Grant Likely <grant.likely@secretlab.ca>
To: Jean Delvare <khali@linux-fr.org>,
i2c@lm-sensors.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] Eliminate references to new_client in i2c documentation
Date: Thu, 10 May 2007 15:04:16 -0600 [thread overview]
Message-ID: <20070510210409.11678.5134.stgit@trillian.secretlab.ca> (raw)
The use of 'new_client' in i2c device allocation has been refered to as
a 'disease'. Replace all occurances of 'struct i2c_client *new_client'
in documentation examples with 'struct i2c_client *client'.
Also remove unnecessary zero initializtion of .flags since kzalloc is used.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
Documentation/i2c/writing-clients | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index fbcff96..bd61480 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -260,7 +260,7 @@ For now, you can ignore the `flags' parameter. It is there for future use.
{
int err = 0;
int i;
- struct i2c_client *new_client;
+ struct i2c_client *client;
struct foo_data *data;
const char *client_name = ""; /* For non-`sensors' drivers, put the real
name here! */
@@ -323,13 +323,12 @@ For now, you can ignore the `flags' parameter. It is there for future use.
goto ERROR0;
}
- new_client = &data->client;
- i2c_set_clientdata(new_client, data);
+ client = &data->client;
+ i2c_set_clientdata(client, data);
- new_client->addr = address;
- new_client->adapter = adapter;
- new_client->driver = &foo_driver;
- new_client->flags = 0;
+ client->addr = address;
+ client->adapter = adapter;
+ client->driver = &foo_driver;
/* Now, we do the remaining detection. If no `force' parameter is used. */
@@ -337,7 +336,7 @@ For now, you can ignore the `flags' parameter. It is there for future use.
parameter was used. */
if (kind < 0) {
/* The below is of course bogus */
- if (foo_read(new_client,FOO_REG_GENERIC) != FOO_GENERIC_VALUE)
+ if (foo_read(client,FOO_REG_GENERIC) != FOO_GENERIC_VALUE)
goto ERROR1;
}
@@ -349,7 +348,7 @@ For now, you can ignore the `flags' parameter. It is there for future use.
/* Determine the chip type. Not needed if a `force_CHIPTYPE' parameter
was used. */
if (kind <= 0) {
- i = foo_read(new_client,FOO_REG_CHIPTYPE);
+ i = foo_read(client,FOO_REG_CHIPTYPE);
if (i == FOO_TYPE_1)
kind = chip1; /* As defined in the enum */
else if (i == FOO_TYPE_2)
@@ -377,7 +376,7 @@ For now, you can ignore the `flags' parameter. It is there for future use.
/* SENSORS ONLY END */
/* Fill in the remaining client fields. */
- strcpy(new_client->name,client_name);
+ strcpy(client->name,client_name);
/* SENSORS ONLY BEGIN */
data->type = kind;
@@ -389,14 +388,14 @@ For now, you can ignore the `flags' parameter. It is there for future use.
/* Any other initializations in data must be done here too. */
/* Tell the i2c layer a new client has arrived */
- if ((err = i2c_attach_client(new_client)))
+ if ((err = i2c_attach_client(client)))
goto ERROR3;
/* SENSORS ONLY BEGIN */
/* Register a new directory entry with module sensors. See below for
the `template' structure. */
- if ((i = i2c_register_entry(new_client, type_name,
- foo_dir_table_template,THIS_MODULE)) < 0) {
+ if ((i = i2c_register_entry(client, type_name,
+ foo_dir_table_template,THIS_MODULE)) < 0) {
err = i;
goto ERROR4;
}
@@ -406,14 +405,14 @@ For now, you can ignore the `flags' parameter. It is there for future use.
/* This function can write default values to the client registers, if
needed. */
- foo_init_client(new_client);
+ foo_init_client(client);
return 0;
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
ERROR4:
- i2c_detach_client(new_client);
+ i2c_detach_client(client);
ERROR3:
ERROR2:
/* SENSORS ONLY START */
next reply other threads:[~2007-05-10 21:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-10 21:04 Grant Likely [this message]
2007-05-10 21:06 ` [PATCH 2/2] Add driver for Dallas DS1682 elapsed time recorder Grant Likely
2007-05-11 8:01 ` [PATCH 1/2] Eliminate references to new_client in i2c documentation Jean Delvare
2007-05-11 13:32 ` Grant Likely
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=20070510210409.11678.5134.stgit@trillian.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=i2c@lm-sensors.org \
--cc=khali@linux-fr.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox