diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-13 10:10:07 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:19 -0500 |
commit | 49457cc2792a63512112434534ecfdd3d4c66e93 (patch) | |
tree | ccc9d1f873d0051c830a75f4f589b0e096f45840 /drivers/media/video/wm8739.c | |
parent | d9a53aa9024e507df01f257494956e906a92c864 (diff) |
V4L/DVB (6453): wm8739: 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/wm8739.c')
-rw-r--r-- | drivers/media/video/wm8739.c | 71 |
1 files changed, 10 insertions, 61 deletions
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c index 1bf4cbec6a87..459228a5cf50 100644 --- a/drivers/media/video/wm8739.c +++ b/drivers/media/video/wm8739.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/videodev.h> | 30 | #include <linux/videodev.h> |
31 | #include <media/v4l2-common.h> | 31 | #include <media/v4l2-common.h> |
32 | #include <media/v4l2-chip-ident.h> | 32 | #include <media/v4l2-chip-ident.h> |
33 | #include <media/v4l2-i2c-drv-legacy.h> | ||
33 | 34 | ||
34 | MODULE_DESCRIPTION("wm8739 driver"); | 35 | MODULE_DESCRIPTION("wm8739 driver"); |
35 | MODULE_AUTHOR("T. Adachi, Hans Verkuil"); | 36 | MODULE_AUTHOR("T. Adachi, Hans Verkuil"); |
@@ -259,27 +260,11 @@ static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg | |||
259 | 260 | ||
260 | /* i2c implementation */ | 261 | /* i2c implementation */ |
261 | 262 | ||
262 | static struct i2c_driver i2c_driver; | 263 | static int wm8739_probe(struct i2c_client *client) |
263 | |||
264 | static int wm8739_attach(struct i2c_adapter *adapter, int address, int kind) | ||
265 | { | 264 | { |
266 | struct i2c_client *client; | ||
267 | struct wm8739_state *state; | 265 | struct wm8739_state *state; |
268 | 266 | ||
269 | /* Check if the adapter supports the needed features */ | 267 | v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); |
270 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
271 | return 0; | ||
272 | |||
273 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
274 | if (client == NULL) | ||
275 | return -ENOMEM; | ||
276 | |||
277 | client->addr = address; | ||
278 | client->adapter = adapter; | ||
279 | client->driver = &i2c_driver; | ||
280 | snprintf(client->name, sizeof(client->name) - 1, "wm8739"); | ||
281 | |||
282 | v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name); | ||
283 | 268 | ||
284 | state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); | 269 | state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); |
285 | if (state == NULL) { | 270 | if (state == NULL) { |
@@ -306,56 +291,20 @@ static int wm8739_attach(struct i2c_adapter *adapter, int address, int kind) | |||
306 | /* normal, 256fs, 48KHz sampling rate */ | 291 | /* normal, 256fs, 48KHz sampling rate */ |
307 | wm8739_write(client, R9, 0x001); /* activate */ | 292 | wm8739_write(client, R9, 0x001); /* activate */ |
308 | wm8739_set_audio(client); /* set volume/mute */ | 293 | wm8739_set_audio(client); /* set volume/mute */ |
309 | |||
310 | i2c_attach_client(client); | ||
311 | |||
312 | return 0; | 294 | return 0; |
313 | } | 295 | } |
314 | 296 | ||
315 | static int wm8739_probe(struct i2c_adapter *adapter) | 297 | static int wm8739_remove(struct i2c_client *client) |
316 | { | 298 | { |
317 | if (adapter->class & I2C_CLASS_TV_ANALOG) | 299 | kfree(i2c_get_clientdata(client)); |
318 | return i2c_probe(adapter, &addr_data, wm8739_attach); | ||
319 | return 0; | 300 | return 0; |
320 | } | 301 | } |
321 | 302 | ||
322 | static int wm8739_detach(struct i2c_client *client) | 303 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
323 | { | 304 | .name = "wm8739", |
324 | struct wm8739_state *state = i2c_get_clientdata(client); | 305 | .driverid = I2C_DRIVERID_WM8739, |
325 | int err; | ||
326 | |||
327 | err = i2c_detach_client(client); | ||
328 | if (err) | ||
329 | return err; | ||
330 | |||
331 | kfree(state); | ||
332 | kfree(client); | ||
333 | return 0; | ||
334 | } | ||
335 | |||
336 | /* ----------------------------------------------------------------------- */ | ||
337 | |||
338 | /* i2c implementation */ | ||
339 | static struct i2c_driver i2c_driver = { | ||
340 | .driver = { | ||
341 | .name = "wm8739", | ||
342 | }, | ||
343 | .id = I2C_DRIVERID_WM8739, | ||
344 | .attach_adapter = wm8739_probe, | ||
345 | .detach_client = wm8739_detach, | ||
346 | .command = wm8739_command, | 306 | .command = wm8739_command, |
307 | .probe = wm8739_probe, | ||
308 | .remove = wm8739_remove, | ||
347 | }; | 309 | }; |
348 | 310 | ||
349 | |||
350 | static int __init wm8739_init_module(void) | ||
351 | { | ||
352 | return i2c_add_driver(&i2c_driver); | ||
353 | } | ||
354 | |||
355 | static void __exit wm8739_cleanup_module(void) | ||
356 | { | ||
357 | i2c_del_driver(&i2c_driver); | ||
358 | } | ||
359 | |||
360 | module_init(wm8739_init_module); | ||
361 | module_exit(wm8739_cleanup_module); | ||