Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (5815): Cx88: i2c structure templates clean-up

Clean up the use of structure templates in cx88-i2c and cx88-vp3054-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 cx88-i2c.o by 33% and cx88-vp3054-i2c.o by 49%
(x86_64).

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Jean Delvare and committed by
Mauro Carvalho Chehab
7e520d09 4de7bb44

+10 -27
+7 -18
drivers/media/video/cx88/cx88-i2c.c
··· 160 160 i2c_clients_command(&core->i2c_adap, cmd, arg); 161 161 } 162 162 163 - static struct i2c_algo_bit_data cx8800_i2c_algo_template = { 163 + static const struct i2c_algo_bit_data cx8800_i2c_algo_template = { 164 164 .setsda = cx8800_bit_setsda, 165 165 .setscl = cx8800_bit_setscl, 166 166 .getsda = cx8800_bit_getsda, ··· 170 170 }; 171 171 172 172 /* ----------------------------------------------------------------------- */ 173 - 174 - static struct i2c_adapter cx8800_i2c_adap_template = { 175 - .name = "cx2388x", 176 - .owner = THIS_MODULE, 177 - .id = I2C_HW_B_CX2388x, 178 - .client_register = attach_inform, 179 - .client_unregister = detach_inform, 180 - }; 181 - 182 - static struct i2c_client cx8800_i2c_client_template = { 183 - .name = "cx88xx internal", 184 - }; 185 173 186 174 static char *i2c_devs[128] = { 187 175 [ 0x1c >> 1 ] = "lgdt330x", ··· 200 212 /* Prevents usage of invalid delay values */ 201 213 if (i2c_udelay<5) 202 214 i2c_udelay=5; 203 - cx8800_i2c_algo_template.udelay=i2c_udelay; 204 215 205 - memcpy(&core->i2c_adap, &cx8800_i2c_adap_template, 206 - sizeof(core->i2c_adap)); 207 216 memcpy(&core->i2c_algo, &cx8800_i2c_algo_template, 208 217 sizeof(core->i2c_algo)); 209 - memcpy(&core->i2c_client, &cx8800_i2c_client_template, 210 - sizeof(core->i2c_client)); 211 218 212 219 if (core->tuner_type != TUNER_ABSENT) 213 220 core->i2c_adap.class |= I2C_CLASS_TV_ANALOG; ··· 211 228 212 229 core->i2c_adap.dev.parent = &pci->dev; 213 230 strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name)); 231 + core->i2c_adap.owner = THIS_MODULE; 232 + core->i2c_adap.id = I2C_HW_B_CX2388x; 233 + core->i2c_adap.client_register = attach_inform; 234 + core->i2c_adap.client_unregister = detach_inform; 235 + core->i2c_algo.udelay = i2c_udelay; 214 236 core->i2c_algo.data = core; 215 237 i2c_set_adapdata(&core->i2c_adap,core); 216 238 core->i2c_adap.algo_data = &core->i2c_algo; 217 239 core->i2c_client.adapter = &core->i2c_adap; 240 + strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); 218 241 219 242 cx8800_bit_setscl(core,1); 220 243 cx8800_bit_setsda(core,1);
+3 -9
drivers/media/video/cx88/cx88-vp3054-i2c.c
··· 94 94 95 95 /* ----------------------------------------------------------------------- */ 96 96 97 - static struct i2c_algo_bit_data vp3054_i2c_algo_template = { 97 + static const struct i2c_algo_bit_data vp3054_i2c_algo_template = { 98 98 .setsda = vp3054_bit_setsda, 99 99 .setscl = vp3054_bit_setscl, 100 100 .getsda = vp3054_bit_getsda, ··· 104 104 }; 105 105 106 106 /* ----------------------------------------------------------------------- */ 107 - 108 - static struct i2c_adapter vp3054_i2c_adap_template = { 109 - .name = "cx2388x", 110 - .owner = THIS_MODULE, 111 - .id = I2C_HW_B_CX2388x, 112 - }; 113 107 114 108 int vp3054_i2c_probe(struct cx8802_dev *dev) 115 109 { ··· 119 125 return -ENOMEM; 120 126 vp3054_i2c = dev->card_priv; 121 127 122 - memcpy(&vp3054_i2c->adap, &vp3054_i2c_adap_template, 123 - sizeof(vp3054_i2c->adap)); 124 128 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, 125 129 sizeof(vp3054_i2c->algo)); 126 130 ··· 127 135 vp3054_i2c->adap.dev.parent = &dev->pci->dev; 128 136 strlcpy(vp3054_i2c->adap.name, core->name, 129 137 sizeof(vp3054_i2c->adap.name)); 138 + vp3054_i2c->adap.owner = THIS_MODULE; 139 + vp3054_i2c->adap.id = I2C_HW_B_CX2388x; 130 140 vp3054_i2c->algo.data = dev; 131 141 i2c_set_adapdata(&vp3054_i2c->adap, dev); 132 142 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;