linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: Minor fixes to upgrading-clients document
@ 2011-02-20 14:04 Jean Delvare
       [not found] ` <20110220150408.03e9a674-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2011-02-20 14:04 UTC (permalink / raw)
  To: Linux I2C; +Cc: Ben Dooks

* Typical legacy drivers implemented method .detach_client, not
  .detach_adapter.
* Drop all references to __devexit, as i2c drivers shouldn't use it.

Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
---
 Documentation/i2c/upgrading-clients |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--- linux-2.6.38-rc5.orig/Documentation/i2c/upgrading-clients	2010-08-02 00:11:14.000000000 +0200
+++ linux-2.6.38-rc5/Documentation/i2c/upgrading-clients	2011-02-20 14:57:57.000000000 +0100
@@ -61,7 +61,7 @@ static int example_attach(struct i2c_ada
 	return 0;
 }
 
-static int __devexit example_detach(struct i2c_client *client)
+static int example_detach(struct i2c_client *client)
 {
 	struct example_state *state = i2c_get_clientdata(client);
 
@@ -81,7 +81,7 @@ static struct i2c_driver example_driver
 		.name		= "example",
 	},
 	.attach_adapter = example_attach_adapter,
-	.detach_client	= __devexit_p(example_detach),
+	.detach_client	= example_detach,
 	.suspend	= example_suspend,
 	.resume		= example_resume,
 };
@@ -93,7 +93,7 @@ Updating the client
 The new style binding model will check against a list of supported
 devices and their associated address supplied by the code registering
 the busses. This means that the driver .attach_adapter and
-.detach_adapter methods can be removed, along with the addr_data,
+.detach_client methods can be removed, along with the addr_data,
 as follows:
 
 - static struct i2c_driver example_driver;
@@ -110,14 +110,14 @@ as follows:
 
  static struct i2c_driver example_driver = {
 -	.attach_adapter = example_attach_adapter,
--	.detach_client	= __devexit_p(example_detach),
+-	.detach_client	= example_detach,
  }
 
 Add the probe and remove methods to the i2c_driver, as so:
 
  static struct i2c_driver example_driver = {
 +	.probe		= example_probe,
-+	.remove		= __devexit_p(example_remove),
++	.remove		= example_remove,
  }
 
 Change the example_attach method to accept the new parameters
@@ -199,8 +199,8 @@ to delete the i2c_detach_client call. It
 can also remove the ret variable as it is not not needed for
 any of the core functions.
 
-- static int __devexit example_detach(struct i2c_client *client)
-+ static int __devexit example_remove(struct i2c_client *client)
+- static int example_detach(struct i2c_client *client)
++ static int example_remove(struct i2c_client *client)
 {
 	struct example_state *state = i2c_get_clientdata(client);
 
@@ -253,7 +253,7 @@ static int example_probe(struct i2c_clie
 	return 0;
 }
 
-static int __devexit example_remove(struct i2c_client *client)
+static int example_remove(struct i2c_client *client)
 {
 	struct example_state *state = i2c_get_clientdata(client);
 
@@ -275,7 +275,7 @@ static struct i2c_driver example_driver
 	},
 	.id_table	= example_idtable,
 	.probe		= example_probe,
-	.remove		= __devexit_p(example_remove),
+	.remove		= example_remove,
 	.suspend	= example_suspend,
 	.resume		= example_resume,
 };


-- 
Jean Delvare

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

* Re: [PATCH] i2c: Minor fixes to upgrading-clients document
       [not found] ` <20110220150408.03e9a674-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2011-02-20 14:08   ` Wolfram Sang
       [not found]     ` <20110220140837.GA14786-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2011-02-20 14:08 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Linux I2C, Ben Dooks

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On Sun, Feb 20, 2011 at 03:04:08PM +0100, Jean Delvare wrote:

> * Typical legacy drivers implemented method .detach_client, not
>   .detach_adapter.
> * Drop all references to __devexit, as i2c drivers shouldn't use it.

Even not in remove()? 40 out of 84 drivers are doing so.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] i2c: Minor fixes to upgrading-clients document
       [not found]     ` <20110220140837.GA14786-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2011-02-20 17:01       ` Jean Delvare
  0 siblings, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2011-02-20 17:01 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Linux I2C, Ben Dooks

On Sun, 20 Feb 2011 15:08:38 +0100, Wolfram Sang wrote:
> On Sun, Feb 20, 2011 at 03:04:08PM +0100, Jean Delvare wrote:
> 
> > * Typical legacy drivers implemented method .detach_client, not
> >   .detach_adapter.
> > * Drop all references to __devexit, as i2c drivers shouldn't use it.
> 
> Even not in remove()? 40 out of 84 drivers are doing so.

Well, unless I am seriously mistaken, this isn't always safe.

Consider the case where !CONFIG_HOTPLUG and your i2c device driver is
built into the kernel (not as a module). The __devexit function will be
stripped at link time. If the i2c _bus_ driver is built as a module, it
can be inserted and removed at any time. When the bus driver is
removed, the .remove() method of every I2C device on this bus should be
called, except that your driver won't have any, so the clean-up won't
happen and you end up with a half-registered device.

So __devexit on the remove function on an i2c device driver is only
safe if the i2c bus driver is built into the kernel. Unfortunately,
unless !CONFIG_MODULES, the i2c device drivers have no way to tell if
this will be the case.

-- 
Jean Delvare

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

end of thread, other threads:[~2011-02-20 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-20 14:04 [PATCH] i2c: Minor fixes to upgrading-clients document Jean Delvare
     [not found] ` <20110220150408.03e9a674-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-02-20 14:08   ` Wolfram Sang
     [not found]     ` <20110220140837.GA14786-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-02-20 17:01       ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).