diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-07-01 17:37:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-18 13:24:34 -0400 |
commit | 7e520d09f1a4b3da1d09a4540e3f4fa852658a0d (patch) | |
tree | 5a0b57aa67417c030043c6225b0e3c7ee361293a /drivers/media | |
parent | 4de7bb44cc6aa6e0a74f80c628f600da5b8fcd47 (diff) |
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>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/cx88/cx88-i2c.c | 25 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-vp3054-i2c.c | 12 |
2 files changed, 10 insertions, 27 deletions
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 7919a1f9da06..78bbcfab9670 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c | |||
@@ -160,7 +160,7 @@ void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) | |||
160 | i2c_clients_command(&core->i2c_adap, cmd, arg); | 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 | .setsda = cx8800_bit_setsda, | 164 | .setsda = cx8800_bit_setsda, |
165 | .setscl = cx8800_bit_setscl, | 165 | .setscl = cx8800_bit_setscl, |
166 | .getsda = cx8800_bit_getsda, | 166 | .getsda = cx8800_bit_getsda, |
@@ -171,18 +171,6 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = { | |||
171 | 171 | ||
172 | /* ----------------------------------------------------------------------- */ | 172 | /* ----------------------------------------------------------------------- */ |
173 | 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 | |||
186 | static char *i2c_devs[128] = { | 174 | static char *i2c_devs[128] = { |
187 | [ 0x1c >> 1 ] = "lgdt330x", | 175 | [ 0x1c >> 1 ] = "lgdt330x", |
188 | [ 0x86 >> 1 ] = "tda9887/cx22702", | 176 | [ 0x86 >> 1 ] = "tda9887/cx22702", |
@@ -212,14 +200,9 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) | |||
212 | /* Prevents usage of invalid delay values */ | 200 | /* Prevents usage of invalid delay values */ |
213 | if (i2c_udelay<5) | 201 | if (i2c_udelay<5) |
214 | i2c_udelay=5; | 202 | i2c_udelay=5; |
215 | cx8800_i2c_algo_template.udelay=i2c_udelay; | ||
216 | 203 | ||
217 | memcpy(&core->i2c_adap, &cx8800_i2c_adap_template, | ||
218 | sizeof(core->i2c_adap)); | ||
219 | memcpy(&core->i2c_algo, &cx8800_i2c_algo_template, | 204 | memcpy(&core->i2c_algo, &cx8800_i2c_algo_template, |
220 | sizeof(core->i2c_algo)); | 205 | sizeof(core->i2c_algo)); |
221 | memcpy(&core->i2c_client, &cx8800_i2c_client_template, | ||
222 | sizeof(core->i2c_client)); | ||
223 | 206 | ||
224 | if (core->tuner_type != TUNER_ABSENT) | 207 | if (core->tuner_type != TUNER_ABSENT) |
225 | core->i2c_adap.class |= I2C_CLASS_TV_ANALOG; | 208 | core->i2c_adap.class |= I2C_CLASS_TV_ANALOG; |
@@ -228,10 +211,16 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) | |||
228 | 211 | ||
229 | core->i2c_adap.dev.parent = &pci->dev; | 212 | core->i2c_adap.dev.parent = &pci->dev; |
230 | strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name)); | 213 | strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name)); |
214 | core->i2c_adap.owner = THIS_MODULE; | ||
215 | core->i2c_adap.id = I2C_HW_B_CX2388x; | ||
216 | core->i2c_adap.client_register = attach_inform; | ||
217 | core->i2c_adap.client_unregister = detach_inform; | ||
218 | core->i2c_algo.udelay = i2c_udelay; | ||
231 | core->i2c_algo.data = core; | 219 | core->i2c_algo.data = core; |
232 | i2c_set_adapdata(&core->i2c_adap,core); | 220 | i2c_set_adapdata(&core->i2c_adap,core); |
233 | core->i2c_adap.algo_data = &core->i2c_algo; | 221 | core->i2c_adap.algo_data = &core->i2c_algo; |
234 | core->i2c_client.adapter = &core->i2c_adap; | 222 | core->i2c_client.adapter = &core->i2c_adap; |
223 | strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); | ||
235 | 224 | ||
236 | cx8800_bit_setscl(core,1); | 225 | cx8800_bit_setscl(core,1); |
237 | cx8800_bit_setsda(core,1); | 226 | cx8800_bit_setsda(core,1); |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c index 82bc3a28aa22..cd0877636a32 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c | |||
@@ -94,7 +94,7 @@ static int vp3054_bit_getsda(void *data) | |||
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 | .setsda = vp3054_bit_setsda, | 98 | .setsda = vp3054_bit_setsda, |
99 | .setscl = vp3054_bit_setscl, | 99 | .setscl = vp3054_bit_setscl, |
100 | .getsda = vp3054_bit_getsda, | 100 | .getsda = vp3054_bit_getsda, |
@@ -105,12 +105,6 @@ static struct i2c_algo_bit_data vp3054_i2c_algo_template = { | |||
105 | 105 | ||
106 | /* ----------------------------------------------------------------------- */ | 106 | /* ----------------------------------------------------------------------- */ |
107 | 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 | |||
114 | int vp3054_i2c_probe(struct cx8802_dev *dev) | 108 | int vp3054_i2c_probe(struct cx8802_dev *dev) |
115 | { | 109 | { |
116 | struct cx88_core *core = dev->core; | 110 | struct cx88_core *core = dev->core; |
@@ -125,8 +119,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
125 | return -ENOMEM; | 119 | return -ENOMEM; |
126 | vp3054_i2c = dev->card_priv; | 120 | vp3054_i2c = dev->card_priv; |
127 | 121 | ||
128 | memcpy(&vp3054_i2c->adap, &vp3054_i2c_adap_template, | ||
129 | sizeof(vp3054_i2c->adap)); | ||
130 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, | 122 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, |
131 | sizeof(vp3054_i2c->algo)); | 123 | sizeof(vp3054_i2c->algo)); |
132 | 124 | ||
@@ -135,6 +127,8 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
135 | vp3054_i2c->adap.dev.parent = &dev->pci->dev; | 127 | vp3054_i2c->adap.dev.parent = &dev->pci->dev; |
136 | strlcpy(vp3054_i2c->adap.name, core->name, | 128 | strlcpy(vp3054_i2c->adap.name, core->name, |
137 | sizeof(vp3054_i2c->adap.name)); | 129 | sizeof(vp3054_i2c->adap.name)); |
130 | vp3054_i2c->adap.owner = THIS_MODULE; | ||
131 | vp3054_i2c->adap.id = I2C_HW_B_CX2388x; | ||
138 | vp3054_i2c->algo.data = dev; | 132 | vp3054_i2c->algo.data = dev; |
139 | i2c_set_adapdata(&vp3054_i2c->adap, dev); | 133 | i2c_set_adapdata(&vp3054_i2c->adap, dev); |
140 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; | 134 | vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; |