[i2c] [PATCH] i2c-parport: Optimize initialization for a smaller driver

Jean Delvare khali at linux-fr.org
Tue Feb 20 22:12:19 CET 2007


Initialize the fields of the i2c_adapter structure individually,
rather than copying a whole static template structure. This shaves
off 474 bytes or 14% (on i386) from the binary size.

Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
 drivers/i2c/busses/i2c-parport.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

--- linux-2.6.21-pre.orig/drivers/i2c/busses/i2c-parport.c	2007-02-20 11:05:37.000000000 +0100
+++ linux-2.6.21-pre/drivers/i2c/busses/i2c-parport.c	2007-02-20 21:46:25.000000000 +0100
@@ -143,13 +143,6 @@ static struct i2c_algo_bit_data parport_
 
 /* ----- I2c and parallel port call-back functions and structures --------- */
 
-static struct i2c_adapter parport_adapter = {
-	.owner		= THIS_MODULE,
-	.class		= I2C_CLASS_HWMON,
-	.id		= I2C_HW_B_LP,
-	.name		= "Parallel port adapter",
-};
-
 static void i2c_parport_attach (struct parport *port)
 {
 	struct i2c_par *adapter;
@@ -169,7 +162,10 @@ static void i2c_parport_attach (struct p
 	}
 
 	/* Fill the rest of the structure */
-	adapter->adapter = parport_adapter;
+	adapter->adapter.owner = THIS_MODULE;
+	adapter->adapter.class = I2C_CLASS_HWMON;
+	adapter->adapter.id = I2C_HW_B_LP;
+	strlcpy(adapter->adapter.name, "Parallel port adapter", I2C_NAME_SIZE);
 	adapter->algo_data = parport_algo_data;
 	if (!adapter_parm[type].getscl.val)
 		adapter->algo_data.getscl = NULL;


-- 
Jean Delvare



More information about the i2c mailing list