aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/upd64083.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-09-14 03:58:06 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:01:25 -0500
commit266669776c12b92bab6e0bba4b3124ae920df194 (patch)
tree4ca18d8a2a5cbb1e7050b8a0c16053312d6e8a1f /drivers/media/video/upd64083.c
parent08e140544029192a123cc2cbf28edeb5d5462ad2 (diff)
V4L/DVB (6462): upd64083: convert to bus-based I2C API
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/upd64083.c')
-rw-r--r--drivers/media/video/upd64083.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 401bd21f46eb..08d2d643c65e 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -27,6 +27,7 @@
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
29#include <media/v4l2-chip-ident.h> 29#include <media/v4l2-chip-ident.h>
30#include <media/v4l2-i2c-drv-legacy.h>
30#include <media/upd64083.h> 31#include <media/upd64083.h>
31 32
32MODULE_DESCRIPTION("uPD64083 driver"); 33MODULE_DESCRIPTION("uPD64083 driver");
@@ -171,32 +172,18 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a
171 172
172/* i2c implementation */ 173/* i2c implementation */
173 174
174static struct i2c_driver i2c_driver; 175static int upd64083_probe(struct i2c_client *client)
175
176static int upd64083_attach(struct i2c_adapter *adapter, int address, int kind)
177{ 176{
178 struct i2c_client *client;
179 struct upd64083_state *state; 177 struct upd64083_state *state;
180 int i; 178 int i;
181 179
182 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 180 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
183 return 0; 181 return 0;
184 182
185 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 183 v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name);
186 if (client == NULL) {
187 return -ENOMEM;
188 }
189
190 client->addr = address;
191 client->adapter = adapter;
192 client->driver = &i2c_driver;
193 snprintf(client->name, sizeof(client->name) - 1, "uPD64083");
194
195 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
196 184
197 state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL); 185 state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL);
198 if (state == NULL) { 186 if (state == NULL) {
199 kfree(client);
200 return -ENOMEM; 187 return -ENOMEM;
201 } 188 }
202 i2c_set_clientdata(client, state); 189 i2c_set_clientdata(client, state);
@@ -207,53 +194,22 @@ static int upd64083_attach(struct i2c_adapter *adapter, int address, int kind)
207 for (i = 0; i < TOT_REGS; i++) { 194 for (i = 0; i < TOT_REGS; i++) {
208 upd64083_write(client, i, state->regs[i]); 195 upd64083_write(client, i, state->regs[i]);
209 } 196 }
210 i2c_attach_client(client);
211
212 return 0; 197 return 0;
213} 198}
214 199
215static int upd64083_probe(struct i2c_adapter *adapter) 200static int upd64083_remove(struct i2c_client *client)
216{ 201{
217 if (adapter->class & I2C_CLASS_TV_ANALOG) 202 kfree(i2c_get_clientdata(client));
218 return i2c_probe(adapter, &addr_data, upd64083_attach);
219 return 0;
220}
221
222static int upd64083_detach(struct i2c_client *client)
223{
224 int err;
225
226 err = i2c_detach_client(client);
227 if (err)
228 return err;
229
230 kfree(client);
231 return 0; 203 return 0;
232} 204}
233 205
234/* ----------------------------------------------------------------------- */ 206/* ----------------------------------------------------------------------- */
235 207
236/* i2c implementation */ 208
237static struct i2c_driver i2c_driver = { 209static struct v4l2_i2c_driver_data v4l2_i2c_data = {
238 .driver = { 210 .name = "upd64083",
239 .name = "upd64083", 211 .driverid = I2C_DRIVERID_UPD64083,
240 },
241 .id = I2C_DRIVERID_UPD64083,
242 .attach_adapter = upd64083_probe,
243 .detach_client = upd64083_detach,
244 .command = upd64083_command, 212 .command = upd64083_command,
213 .probe = upd64083_probe,
214 .remove = upd64083_remove,
245}; 215};
246
247
248static int __init upd64083_init_module(void)
249{
250 return i2c_add_driver(&i2c_driver);
251}
252
253static void __exit upd64083_exit_module(void)
254{
255 i2c_del_driver(&i2c_driver);
256}
257
258module_init(upd64083_init_module);
259module_exit(upd64083_exit_module);