aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-11 17:14:09 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:45 -0400
commitb5ffc223e48417c2db0a4ce1beacdbab6503a472 (patch)
tree57295d30008091e4bd8477c5a608de3fba552319
parent7f53b35c2bc0324fb97008403e35073db7210353 (diff)
V4L/DVB (10536): saa6588: convert to v4l2-i2c-drv-legacy.h
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/saa6588.c82
1 files changed, 27 insertions, 55 deletions
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index f05024259f01..7c74ac4dd183 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -32,6 +32,8 @@
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34#include <media/rds.h> 34#include <media/rds.h>
35#include <media/v4l2-common.h>
36#include <media/v4l2-i2c-drv-legacy.h>
35 37
36/* Addresses to scan */ 38/* Addresses to scan */
37static unsigned short normal_i2c[] = { 39static unsigned short normal_i2c[] = {
@@ -72,7 +74,7 @@ MODULE_LICENSE("GPL");
72#define dprintk if (debug) printk 74#define dprintk if (debug) printk
73 75
74struct saa6588 { 76struct saa6588 {
75 struct i2c_client client; 77 struct i2c_client *client;
76 struct work_struct work; 78 struct work_struct work;
77 struct timer_list timer; 79 struct timer_list timer;
78 spinlock_t lock; 80 spinlock_t lock;
@@ -86,9 +88,6 @@ struct saa6588 {
86 int data_available_for_read; 88 int data_available_for_read;
87}; 89};
88 90
89static struct i2c_driver driver;
90static struct i2c_client client_template;
91
92/* ---------------------------------------------------------------------- */ 91/* ---------------------------------------------------------------------- */
93 92
94/* 93/*
@@ -265,7 +264,7 @@ static void saa6588_i2c_poll(struct saa6588 *s)
265 264
266 /* Although we only need 3 bytes, we have to read at least 6. 265 /* Although we only need 3 bytes, we have to read at least 6.
267 SAA6588 returns garbage otherwise */ 266 SAA6588 returns garbage otherwise */
268 if (6 != i2c_master_recv(&s->client, &tmpbuf[0], 6)) { 267 if (6 != i2c_master_recv(s->client, &tmpbuf[0], 6)) {
269 if (debug > 1) 268 if (debug > 1)
270 dprintk(PREFIX "read error!\n"); 269 dprintk(PREFIX "read error!\n");
271 return; 270 return;
@@ -380,7 +379,8 @@ static int saa6588_configure(struct saa6588 *s)
380 dprintk(PREFIX "writing: 0w=0x%02x 1w=0x%02x 2w=0x%02x\n", 379 dprintk(PREFIX "writing: 0w=0x%02x 1w=0x%02x 2w=0x%02x\n",
381 buf[0], buf[1], buf[2]); 380 buf[0], buf[1], buf[2]);
382 381
383 if (3 != (rc = i2c_master_send(&s->client, buf, 3))) 382 rc = i2c_master_send(s->client, buf, 3);
383 if (rc != 3)
384 printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc); 384 printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc);
385 385
386 return 0; 386 return 0;
@@ -388,33 +388,34 @@ static int saa6588_configure(struct saa6588 *s)
388 388
389/* ---------------------------------------------------------------------- */ 389/* ---------------------------------------------------------------------- */
390 390
391static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) 391static int saa6588_probe(struct i2c_client *client,
392 const struct i2c_device_id *id)
392{ 393{
393 struct saa6588 *s; 394 struct saa6588 *s;
394 client_template.adapter = adap;
395 client_template.addr = addr;
396 395
397 printk(PREFIX "chip found @ 0x%x\n", addr << 1); 396 v4l_info(client, "saa6588 found @ 0x%x (%s)\n",
397 client->addr << 1, client->adapter->name);
398 398
399 if (NULL == (s = kmalloc(sizeof(*s), GFP_KERNEL))) 399 s = kzalloc(sizeof(*s), GFP_KERNEL);
400 if (s == NULL)
400 return -ENOMEM; 401 return -ENOMEM;
401 402
403 s->client = client;
402 s->buf_size = bufblocks * 3; 404 s->buf_size = bufblocks * 3;
403 405
404 if (NULL == (s->buffer = kmalloc(s->buf_size, GFP_KERNEL))) { 406 s->buffer = kmalloc(s->buf_size, GFP_KERNEL);
407 if (s->buffer == NULL) {
405 kfree(s); 408 kfree(s);
406 return -ENOMEM; 409 return -ENOMEM;
407 } 410 }
408 spin_lock_init(&s->lock); 411 spin_lock_init(&s->lock);
409 s->client = client_template;
410 s->block_count = 0; 412 s->block_count = 0;
411 s->wr_index = 0; 413 s->wr_index = 0;
412 s->rd_index = 0; 414 s->rd_index = 0;
413 s->last_blocknum = 0xff; 415 s->last_blocknum = 0xff;
414 init_waitqueue_head(&s->read_queue); 416 init_waitqueue_head(&s->read_queue);
415 s->data_available_for_read = 0; 417 s->data_available_for_read = 0;
416 i2c_set_clientdata(&s->client, s); 418 i2c_set_clientdata(client, s);
417 i2c_attach_client(&s->client);
418 419
419 saa6588_configure(s); 420 saa6588_configure(s);
420 421
@@ -427,21 +428,13 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind)
427 return 0; 428 return 0;
428} 429}
429 430
430static int saa6588_probe(struct i2c_adapter *adap) 431static int saa6588_remove(struct i2c_client *client)
431{
432 if (adap->class & I2C_CLASS_TV_ANALOG)
433 return i2c_probe(adap, &addr_data, saa6588_attach);
434 return 0;
435}
436
437static int saa6588_detach(struct i2c_client *client)
438{ 432{
439 struct saa6588 *s = i2c_get_clientdata(client); 433 struct saa6588 *s = i2c_get_clientdata(client);
440 434
441 del_timer_sync(&s->timer); 435 del_timer_sync(&s->timer);
442 flush_scheduled_work(); 436 flush_scheduled_work();
443 437
444 i2c_detach_client(client);
445 kfree(s->buffer); 438 kfree(s->buffer);
446 kfree(s); 439 kfree(s);
447 return 0; 440 return 0;
@@ -486,38 +479,17 @@ static int saa6588_command(struct i2c_client *client, unsigned int cmd,
486 479
487/* ----------------------------------------------------------------------- */ 480/* ----------------------------------------------------------------------- */
488 481
489static struct i2c_driver driver = { 482static const struct i2c_device_id saa6588_id[] = {
490 .driver = { 483 { "saa6588", 0 },
491 .name = "saa6588", 484 { }
492 },
493 .id = -1, /* FIXME */
494 .attach_adapter = saa6588_probe,
495 .detach_client = saa6588_detach,
496 .command = saa6588_command,
497}; 485};
486MODULE_DEVICE_TABLE(i2c, saa6588_id);
498 487
499static struct i2c_client client_template = { 488static struct v4l2_i2c_driver_data v4l2_i2c_data = {
500 .name = "saa6588", 489 .name = "saa6588",
501 .driver = &driver, 490 .command = saa6588_command,
491 .probe = saa6588_probe,
492 .remove = saa6588_remove,
493 .legacy_class = I2C_CLASS_TV_ANALOG,
494 .id_table = saa6588_id,
502}; 495};
503
504static int __init saa6588_init_module(void)
505{
506 return i2c_add_driver(&driver);
507}
508
509static void __exit saa6588_cleanup_module(void)
510{
511 i2c_del_driver(&driver);
512}
513
514module_init(saa6588_init_module);
515module_exit(saa6588_cleanup_module);
516
517/*
518 * Overrides for Emacs so that we follow Linus's tabbing style.
519 * ---------------------------------------------------------------------------
520 * Local variables:
521 * c-basic-offset: 8
522 * End:
523 */