Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a994755 authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman
Browse files

[PATCH] i2c: Drop i2c_driver.flags, 2 of 3



Just about every i2c chip driver sets the I2C_DF_NOTIFY flag, so we
can simply make it the default and drop the flag. If any driver really
doesn't want to be notified when i2c adapters are added, that driver
can simply omit to set .attach_adapter. This approach is also more
robust as it prevents accidental NULL pointer dereferences.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ff179c8c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ Technical changes:
  there is a MODULE_LICENSE() line, at the bottom of the file
  (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this order).

* [Driver] The flags field of the i2c_driver structure is gone.
  I2C_DF_NOTIFY is now the default behavior.

Coding policy:

* [Copyright] Use (C), not (c), for copyright.
+0 −5
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ address.
static struct i2c_driver foo_driver = {
	.owner		= THIS_MODULE,
	.name		= "Foo version 2.3 driver",
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= &foo_attach_adapter,
	.detach_client	= &foo_detach_client,
	.command	= &foo_command /* may be NULL */
@@ -36,10 +35,6 @@ static struct i2c_driver foo_driver = {
The name field must match the driver name, including the case. It must not
contain spaces, and may be up to 31 characters long.

Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
means that your driver will be notified when new adapters are found.
This is almost always what you want.

All other fields are for call-back functions which will be explained 
below.

+0 −1
Original line number Diff line number Diff line
@@ -127,7 +127,6 @@ static struct i2c_driver max7310_i2c_driver = {
	.owner		= THIS_MODULE,
	.name		= "akita-max7310",
	.id		= I2C_DRIVERID_AKITAIOEXP,
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= max7310_attach_adapter,
	.detach_client	= max7310_detach_client,
};
+0 −1
Original line number Diff line number Diff line
@@ -259,7 +259,6 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg)
static struct i2c_driver pcf8583_driver = {
	.name		= "PCF8583",
	.id		= I2C_DRIVERID_PCF8583,
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= pcf8583_probe,
	.detach_client	= pcf8583_detach,
	.command	= pcf8583_command
+0 −1
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@ static struct i2c_driver adm1021_driver = {
	.owner		= THIS_MODULE,
	.name		= "adm1021",
	.id		= I2C_DRIVERID_ADM1021,
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= adm1021_attach_adapter,
	.detach_client	= adm1021_detach_client,
};
Loading