All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] i2c: Documentation update
@ 2005-10-29  1:28 Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2005-10-29  1:28 UTC (permalink / raw)
  To: lm-sensors

[PATCH] i2c: Documentation update

Update the i2c documentation: kzalloc should be used instead of
kmalloc.

I also fixed a couple other things nearby in writing-clients, as several
past changes had never been reported there.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 2445eb62e98250f1ec8cbc8cf7c4be9cfafe88e5
tree d378cbfddb05c37d09cf03c71f070b02aed7a9cc
parent deb875c7ff2ef417a2daff41ee4b357098b7ab10
author Jean Delvare <khali@linux-fr.org> Mon, 17 Oct 2005 23:16:25 +0200
committer Greg Kroah-Hartman <gregkh@suse.de> Fri, 28 Oct 2005 14:02:12 -0700

 Documentation/i2c/porting-clients |    2 +-
 Documentation/i2c/writing-clients |   16 +++++-----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index 4849dfd..184fac2 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -82,7 +82,7 @@ Technical changes:
   exit and exit_free. For i2c+isa drivers, labels should be named
   ERROR0, ERROR1 and ERROR2. Don't forget to properly set err before
   jumping to error labels. By the way, labels should be left-aligned.
-  Use memset to fill the client and data area with 0x00.
+  Use kzalloc instead of kmalloc.
   Use i2c_set_clientdata to set the client data (as opposed to
   a direct access to client->data).
   Use strlcpy instead of strcpy to copy the client name.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 1882811..e94d9c6 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -55,6 +55,7 @@ be very useful.
 An example structure is below.
 
   struct foo_data {
+    struct i2c_client client;
     struct semaphore lock; /* For ISA access in `sensors' drivers. */
     int sysctl_id;         /* To keep the /proc directory entry for 
                               `sensors' drivers. */
@@ -307,22 +308,15 @@ For now, you can ignore the `flags' para
        client structure, even though we cannot fill it completely yet.
        But it allows us to access several i2c functions safely */
     
-    /* Note that we reserve some space for foo_data too. If you don't
-       need it, remove it. We do it here to help to lessen memory
-       fragmentation. */
-    if (! (new_client = kmalloc(sizeof(struct i2c_client) + 
-                                sizeof(struct foo_data),
-                                GFP_KERNEL))) {
+    if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) {
       err = -ENOMEM;
       goto ERROR0;
     }
 
-    /* This is tricky, but it will set the data to the right value. */
-    client->data = new_client + 1;
-    data = (struct foo_data *) (client->data);
+    new_client = &data->client;
+    i2c_set_clientdata(new_client, data);
 
     new_client->addr = address;
-    new_client->data = data;
     new_client->adapter = adapter;
     new_client->driver = &foo_driver;
     new_client->flags = 0;
@@ -448,7 +442,7 @@ much simpler than the attachment code, f
       release_region(client->addr,LM78_EXTENT);
     /* HYBRID SENSORS CHIP ONLY END */
 
-    kfree(client); /* Frees client data too, if allocated at the same time */
+    kfree(data);
     return 0;
   }
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [lm-sensors] [PATCH] i2c: Documentation update
@ 2006-01-06 22:07 Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2006-01-06 22:07 UTC (permalink / raw)
  To: lm-sensors

[PATCH] i2c: Documentation update

Update the i2c documentation to reflect the recent change to
i2c_add_driver.

Signed-off-by: Jean Delvare <khali at linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>

---
commit d82c0bf88fa97c1993ea9d6051488e7cb012b440
tree 60ecbf9971ee125f84f063d153328f9d7ec5ea98
parent 2b48716d1d2f2edb1e7cbc5ecf1cb2cb39373e33
author Jean Delvare <khali at linux-fr.org> Wed, 07 Dec 2005 21:54:26 +0100
committer Greg Kroah-Hartman <gregkh at suse.de> Thu, 05 Jan 2006 22:16:25 -0800

 Documentation/i2c/porting-clients |    5 ++---
 Documentation/i2c/writing-clients |    1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index f997c72..f03c2a0 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -126,9 +126,8 @@ Technical changes:
 * [Driver] The flags field of the i2c_driver structure is gone.
   I2C_DF_NOTIFY is now the default behavior.
   The i2c_driver structure has a driver member, which is itself a
-  structure, those owner and name members should be initialized to
-  THIS_MODULE and a driver name string, respectively. i2c_driver
-  itself has no name member anymore.
+  structure, those name member should be initialized to a driver name
+  string. i2c_driver itself has no name member anymore.
 
 Coding policy:
 
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 95eed2b..27c425a 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -26,7 +26,6 @@ address.
 
 static struct i2c_driver foo_driver = {
 	.driver = {
-		.owner	= THIS_MODULE,
 		.name	= "foo",
 	},
 	.attach_adapter	= &foo_attach_adapter,



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-06 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-06 22:07 [lm-sensors] [PATCH] i2c: Documentation update Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2005-10-29  1:28 Greg KH

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.