OSDN Git Service

[PATCH] i2c cleanup : c99 struct init
authorJean Delvare <khali@linux-fr.org>
Tue, 5 Dec 2006 08:22:51 +0000 (09:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 Dec 2006 08:22:51 +0000 (09:22 +0100)
Switch all i2c drivers to use the C99-style structure initialization,
as it is way safer.

Note that some hardcoded 100 are converted to HZ in the process,
as this was the true intent of the original code.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/i2c-algo-bit.c
drivers/i2c/i2c-algo-pcf.c
drivers/i2c/i2c-core.c
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-elektor.c
drivers/i2c/i2c-elv.c
drivers/i2c/i2c-philips-par.c
drivers/i2c/i2c-velleman.c

index f128f1e..0b1a039 100644 (file)
@@ -523,14 +523,11 @@ static u32 bit_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm i2c_bit_algo = {
-       "Bit-shift algorithm",
-       I2C_ALGO_BIT,
-       bit_xfer,
-       NULL,
-       NULL,                           /* slave_xmit           */
-       NULL,                           /* slave_recv           */
-       algo_control,                   /* ioctl                */
-       bit_func,                       /* functionality        */
+       .name           = "Bit-shift algorithm",
+       .id             = I2C_ALGO_BIT,
+       .master_xfer    = bit_xfer,
+       .algo_control   = algo_control,
+       .functionality  = bit_func,
 };
 
 /* 
index 559f59d..c289f48 100644 (file)
@@ -440,14 +440,11 @@ static u32 pcf_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm pcf_algo = {
-       "PCF8584 algorithm",
-       I2C_ALGO_PCF,
-       pcf_xfer,
-       NULL,
-       NULL,                           /* slave_xmit           */
-       NULL,                           /* slave_recv           */
-       algo_control,                   /* ioctl                */
-       pcf_func,                       /* functionality        */
+       .name           = "PCF8584 algorithm",
+       .id             = I2C_ALGO_PCF,
+       .master_xfer    = pcf_xfer,
+       .algo_control   = algo_control,
+       .functionality  = pcf_func,
 };
 
 /* 
index 5f6f101..86aeb32 100644 (file)
@@ -87,7 +87,7 @@ static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
 /* To implement the dynamic /proc/bus/i2c-? files, we need our own 
    implementation of the read hook */
 static struct file_operations i2cproc_operations = {
-       read:           i2cproc_bus_read,
+       .read           = i2cproc_bus_read,
 };
 
 static int i2cproc_initialized = 0;
index 7e3133f..b166da1 100644 (file)
@@ -80,13 +80,13 @@ extern
 static int i2cdev_cleanup(void);
 
 static struct file_operations i2cdev_fops = {
-       owner:          THIS_MODULE,
-       llseek:         no_llseek,
-       read:           i2cdev_read,
-       write:          i2cdev_write,
-       ioctl:          i2cdev_ioctl,
-       open:           i2cdev_open,
-       release:        i2cdev_release,
+       .owner          = THIS_MODULE,
+       .llseek         = no_llseek,
+       .read           = i2cdev_read,
+       .write          = i2cdev_write,
+       .ioctl          = i2cdev_ioctl,
+       .open           = i2cdev_open,
+       .release        = i2cdev_release,
 };
 
 #define I2CDEV_ADAPS_MAX I2C_ADAP_MAX
@@ -97,24 +97,20 @@ static devfs_handle_t devfs_handle = NULL;
 #endif
 
 static struct i2c_driver i2cdev_driver = {
-       name:           "i2c-dev dummy driver",
-       id:             I2C_DRIVERID_I2CDEV,
-       flags:          I2C_DF_DUMMY,
-       attach_adapter: i2cdev_attach_adapter,
-       detach_client:  i2cdev_detach_client,
-       command:        i2cdev_command,
-/*     inc_use:        NULL,
-       dec_use:        NULL, */
+       .name           = "i2c-dev dummy driver",
+       .id             = I2C_DRIVERID_I2CDEV,
+       .flags          = I2C_DF_DUMMY,
+       .attach_adapter = i2cdev_attach_adapter,
+       .detach_client  = i2cdev_detach_client,
+       .command        = i2cdev_command,
 };
 
 static struct i2c_client i2cdev_client_template = {
-       name:           "I2C /dev entry",
-       id:             1,
-       flags:          0,
-       addr:           -1,
-/*     adapter:        NULL, */
-       driver:         &i2cdev_driver,
-/*     data:           NULL */
+       .name           = "I2C /dev entry",
+       .id             = 1,
+       .flags          = 0,
+       .addr           = -1,
+       .driver         = &i2cdev_driver,
 };
 
 static int i2cdev_initialized;
index ea11e42..73f17de 100644 (file)
@@ -199,24 +199,24 @@ static void pcf_isa_dec_use(struct i2c_adapter *adap)
  * This is only done when more than one hardware adapter is supported.
  */
 static struct i2c_algo_pcf_data pcf_isa_data = {
-       NULL,
-       pcf_isa_setbyte,
-       pcf_isa_getbyte,
-       pcf_isa_getown,
-       pcf_isa_getclock,
-       pcf_isa_waitforpin,
-       10, 10, 100,            /*      waits, timeout */
+       .setpcf         = pcf_isa_setbyte,
+       .getpcf         = pcf_isa_getbyte,
+       .getown         = pcf_isa_getown,
+       .getclock       = pcf_isa_getclock,
+       .waitforpin     = pcf_isa_waitforpin,
+       .udelay         = 10,
+       .mdelay         = 10,
+       .timeout        = HZ,
 };
 
 static struct i2c_adapter pcf_isa_ops = {
-       "PCF8584 ISA adapter",
-       I2C_HW_P_ELEK,
-       NULL,
-       &pcf_isa_data,
-       pcf_isa_inc_use,
-       pcf_isa_dec_use,
-       pcf_isa_reg,
-       pcf_isa_unreg,
+       .name              = "PCF8584 ISA adapter",
+       .id                = I2C_HW_P_ELEK,
+       .algo_data         = &pcf_isa_data,
+       .inc_use           = pcf_isa_inc_use,
+       .dec_use           = pcf_isa_dec_use,
+       .client_register   = pcf_isa_reg,
+       .client_unregister = pcf_isa_unreg,
 };
 
 int __init i2c_pcfisa_init(void) 
index a8c951a..8ae6a0d 100644 (file)
@@ -145,23 +145,23 @@ static void bit_elv_dec_use(struct i2c_adapter *adap)
  * This is only done when more than one hardware adapter is supported.
  */
 static struct i2c_algo_bit_data bit_elv_data = {
-       NULL,
-       bit_elv_setsda,
-       bit_elv_setscl,
-       bit_elv_getsda,
-       bit_elv_getscl,
-       80, 80, 100,            /*      waits, timeout */
+       .setsda         = bit_elv_setsda,
+       .setscl         = bit_elv_setscl,
+       .getsda         = bit_elv_getsda,
+       .getscl         = bit_elv_getscl,
+       .udelay         = 80,
+       .mdelay         = 80,
+       .timeout        = HZ
 };
 
 static struct i2c_adapter bit_elv_ops = {
-       "ELV Parallel port adaptor",
-       I2C_HW_B_ELV,
-       NULL,
-       &bit_elv_data,
-       bit_elv_inc_use,
-       bit_elv_dec_use,
-       bit_elv_reg,
-       bit_elv_unreg,  
+       .name           = "ELV Parallel port adaptor",
+       .id             = I2C_HW_B_ELV,
+       .algo_data      = &bit_elv_data,
+       .inc_use        = bit_elv_inc_use,
+       .dec_use        = bit_elv_dec_use,
+       .client_register = bit_elv_reg,
+       .client_unregister = bit_elv_unreg,
 };
 
 int __init i2c_bitelv_init(void)
index 57531ba..880e206 100644 (file)
@@ -156,33 +156,31 @@ static void bit_lp_dec_use(struct i2c_adapter *adap)
  */
  
 static struct i2c_algo_bit_data bit_lp_data = {
-       NULL,
-       bit_lp_setsda,
-       bit_lp_setscl,
-       bit_lp_getsda,
-       bit_lp_getscl,
-       80, 80, 100,            /*      waits, timeout */
+       .setsda         = bit_lp_setsda,
+       .setscl         = bit_lp_setscl,
+       .getsda         = bit_lp_getsda,
+       .getscl         = bit_lp_getscl,
+       .udelay         = 80,
+       .mdelay         = 80,
+       .timeout        = HZ
 }; 
 
 static struct i2c_algo_bit_data bit_lp_data2 = {
-       NULL,
-       bit_lp_setsda2,
-       bit_lp_setscl2,
-       bit_lp_getsda2,
-       NULL,
-       80, 80, 100,            /*      waits, timeout */
+       .setsda         = bit_lp_setsda2,
+       .setscl         = bit_lp_setscl2,
+       .getsda         = bit_lp_getsda2,
+       .udelay         = 80,
+       .mdelay         = 80,
+       .timeout        = HZ
 }; 
 
 static struct i2c_adapter bit_lp_ops = {
-       "Philips Parallel port adapter",
-       I2C_HW_B_LP,
-       NULL,
-       NULL,
-       bit_lp_inc_use,
-       bit_lp_dec_use,
-       bit_lp_reg,
-
-       bit_lp_unreg,
+       .name           = "Philips Parallel port adapter",
+       .id             = I2C_HW_B_LP,
+       .inc_use        = bit_lp_inc_use,
+       .dec_use        = bit_lp_dec_use,
+       .client_register = bit_lp_reg,
+       .client_unregister = bit_lp_unreg,
 };
 
 static void i2c_parport_attach (struct parport *port)
index ff8bbdc..feb579b 100644 (file)
@@ -139,23 +139,23 @@ static void bit_velle_dec_use(struct i2c_adapter *adap)
  */
 
 static struct i2c_algo_bit_data bit_velle_data = {
-       NULL,
-       bit_velle_setsda,
-       bit_velle_setscl,
-       bit_velle_getsda,
-       bit_velle_getscl,
-       10, 10, 100,            /*      waits, timeout */
+       .setsda         = bit_velle_setsda,
+       .setscl         = bit_velle_setscl,
+       .getsda         = bit_velle_getsda,
+       .getscl         = bit_velle_getscl,
+       .udelay         = 10,
+       .mdelay         = 10,
+       .timeout        = HZ
 };
 
 static struct i2c_adapter bit_velle_ops = {
-       "Velleman K8000",
-       I2C_HW_B_VELLE,
-       NULL,
-       &bit_velle_data,
-       bit_velle_inc_use,
-       bit_velle_dec_use,
-       bit_velle_reg,
-       bit_velle_unreg,
+       .name           = "Velleman K8000",
+       .id             = I2C_HW_B_VELLE,
+       .algo_data      = &bit_velle_data,
+       .inc_use        = bit_velle_inc_use,
+       .dec_use        = bit_velle_dec_use,
+       .client_register = bit_velle_reg,
+       .client_unregister = bit_velle_unreg,
 };
 
 int __init  i2c_bitvelle_init(void)