The patch number 8047 was added via Mauro Carvalho Chehab <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Jean Delvare  <[EMAIL PROTECTED]>
bt8xx: i2c structure templates clean-up


Clean up the use of structure templates in bttv-i2c. For one thing, a
real template is supposed to be read-only. And in some cases it's more
efficient to initialize the few fields we need individually.

This clean-up shrinks bttv-i2c.o by 29% (x86_64).

Signed-off-by: Jean Delvare <[EMAIL PROTECTED]>
Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>


---

 linux/drivers/media/video/bt8xx/bttv-i2c.c |   61 +++++----------------
 1 file changed, 17 insertions(+), 44 deletions(-)

diff -r ba0355dd8f63 -r 624ca7ca9809 linux/drivers/media/video/bt8xx/bttv-i2c.c
--- a/linux/drivers/media/video/bt8xx/bttv-i2c.c        Thu Jun 12 13:20:46 
2008 +0000
+++ b/linux/drivers/media/video/bt8xx/bttv-i2c.c        Sun Jun 15 09:20:18 
2008 -0300
@@ -37,11 +37,6 @@
 #include <linux/jiffies.h>
 #endif
 #include <asm/io.h>
-
-static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
-static struct i2c_adapter bttv_i2c_adap_sw_template;
-static struct i2c_adapter bttv_i2c_adap_hw_template;
-static struct i2c_client bttv_i2c_client_template;
 
 static int attach_inform(struct i2c_client *client);
 
@@ -106,25 +101,13 @@ static int bttv_bit_getsda(void *data)
        return state;
 }
 
-static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
+static struct i2c_algo_bit_data __devinitdata bttv_i2c_algo_bit_template = {
        .setsda  = bttv_bit_setsda,
        .setscl  = bttv_bit_setscl,
        .getsda  = bttv_bit_getsda,
        .getscl  = bttv_bit_getscl,
        .udelay  = 16,
        .timeout = 200,
-};
-
-static struct i2c_adapter bttv_i2c_adap_sw_template = {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-       .owner             = THIS_MODULE,
-#endif
-#ifdef I2C_CLASS_TV_ANALOG
-       .class             = I2C_CLASS_TV_ANALOG,
-#endif
-       .name              = "bttv",
-       .id                = I2C_HW_B_BT848,
-       .client_register   = attach_inform,
 };
 
 /* ----------------------------------------------------------------------- */
@@ -276,22 +259,9 @@ static int bttv_i2c_xfer(struct i2c_adap
        return retval;
 }
 
-static struct i2c_algorithm bttv_algo = {
+static const struct i2c_algorithm bttv_algo = {
        .master_xfer   = bttv_i2c_xfer,
        .functionality = functionality,
-};
-
-static struct i2c_adapter bttv_i2c_adap_hw_template = {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-       .owner             = THIS_MODULE,
-#endif
-#ifdef I2C_CLASS_TV_ANALOG
-       .class         = I2C_CLASS_TV_ANALOG,
-#endif
-       .name          = "bt878",
-       .id            = I2C_HW_B_BT848 /* FIXME */,
-       .algo          = &bttv_algo,
-       .client_register = attach_inform,
 };
 
 /* ----------------------------------------------------------------------- */
@@ -345,10 +315,6 @@ void bttv_call_i2c_clients(struct bttv *
                return;
        i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
 }
-
-static struct i2c_client bttv_i2c_client_template = {
-       .name   = "bttv internal",
-};
 
 
 /* read I2C */
@@ -431,29 +397,36 @@ static void do_i2c_scan(char *name, stru
 /* init + register i2c algo-bit adapter */
 int __devinit init_bttv_i2c(struct bttv *btv)
 {
-       memcpy(&btv->i2c_client, &bttv_i2c_client_template,
-              sizeof(bttv_i2c_client_template));
+       strlcpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE);
 
        if (i2c_hw)
                btv->use_i2c_hw = 1;
        if (btv->use_i2c_hw) {
                /* bt878 */
-               memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_hw_template,
-                      sizeof(bttv_i2c_adap_hw_template));
+               strlcpy(btv->c.i2c_adap.name, "bt878",
+                       sizeof(btv->c.i2c_adap.name));
+               btv->c.i2c_adap.id = I2C_HW_B_BT848;    /* FIXME */
+               btv->c.i2c_adap.algo = &bttv_algo;
        } else {
                /* bt848 */
        /* Prevents usage of invalid delay values */
                if (i2c_udelay<5)
                        i2c_udelay=5;
-               bttv_i2c_algo_bit_template.udelay=i2c_udelay;
-
-               memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template,
-                      sizeof(bttv_i2c_adap_sw_template));
+
+               strlcpy(btv->c.i2c_adap.name, "bttv",
+                       sizeof(btv->c.i2c_adap.name));
+               btv->c.i2c_adap.id = I2C_HW_B_BT848;
                memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
                       sizeof(bttv_i2c_algo_bit_template));
+               btv->i2c_algo.udelay = i2c_udelay;
                btv->i2c_algo.data = btv;
                btv->c.i2c_adap.algo_data = &btv->i2c_algo;
        }
+       btv->c.i2c_adap.owner = THIS_MODULE;
+#ifdef I2C_CLASS_TV_ANALOG
+       btv->c.i2c_adap.class = I2C_CLASS_TV_ANALOG;
+#endif
+       btv->c.i2c_adap.client_register = attach_inform;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,66)
        btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/624ca7ca980939d3dd374339cdf57d41607f24c1

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to