diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-13 10:28:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:21 -0500 |
commit | 79518dafd59a812bb390f201c6f18a8f875fcffb (patch) | |
tree | 9103f258e9c37b6ac73608ba5aba5cd9db3e8495 /drivers/media/video/msp3400-driver.c | |
parent | 77566dd724f118b332b5dbf62eedc869f1263f22 (diff) |
V4L/DVB (6457): msp3400: 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/msp3400-driver.c')
-rw-r--r-- | drivers/media/video/msp3400-driver.c | 69 |
1 files changed, 11 insertions, 58 deletions
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c index c0c87e06259b..f2946aca1299 100644 --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/videodev.h> | 53 | #include <linux/videodev.h> |
54 | #include <linux/videodev2.h> | 54 | #include <linux/videodev2.h> |
55 | #include <media/v4l2-common.h> | 55 | #include <media/v4l2-common.h> |
56 | #include <media/v4l2-i2c-drv-legacy.h> | ||
56 | #include <media/tvaudio.h> | 57 | #include <media/tvaudio.h> |
57 | #include <media/msp3400.h> | 58 | #include <media/msp3400.h> |
58 | #include <linux/kthread.h> | 59 | #include <linux/kthread.h> |
@@ -783,7 +784,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
783 | 784 | ||
784 | static int msp_suspend(struct i2c_client *client, pm_message_t state) | 785 | static int msp_suspend(struct i2c_client *client, pm_message_t state) |
785 | { | 786 | { |
786 | |||
787 | v4l_dbg(1, msp_debug, client, "suspend\n"); | 787 | v4l_dbg(1, msp_debug, client, "suspend\n"); |
788 | msp_reset(client); | 788 | msp_reset(client); |
789 | return 0; | 789 | return 0; |
@@ -791,7 +791,6 @@ static int msp_suspend(struct i2c_client *client, pm_message_t state) | |||
791 | 791 | ||
792 | static int msp_resume(struct i2c_client *client) | 792 | static int msp_resume(struct i2c_client *client) |
793 | { | 793 | { |
794 | |||
795 | v4l_dbg(1, msp_debug, client, "resume\n"); | 794 | v4l_dbg(1, msp_debug, client, "resume\n"); |
796 | msp_wake_thread(client); | 795 | msp_wake_thread(client); |
797 | return 0; | 796 | return 0; |
@@ -799,11 +798,8 @@ static int msp_resume(struct i2c_client *client) | |||
799 | 798 | ||
800 | /* ----------------------------------------------------------------------- */ | 799 | /* ----------------------------------------------------------------------- */ |
801 | 800 | ||
802 | static struct i2c_driver i2c_driver; | 801 | static int msp_probe(struct i2c_client *client) |
803 | |||
804 | static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | ||
805 | { | 802 | { |
806 | struct i2c_client *client; | ||
807 | struct msp_state *state; | 803 | struct msp_state *state; |
808 | int (*thread_func)(void *data) = NULL; | 804 | int (*thread_func)(void *data) = NULL; |
809 | int msp_hard; | 805 | int msp_hard; |
@@ -812,24 +808,15 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | |||
812 | int msp_product, msp_prod_hi, msp_prod_lo; | 808 | int msp_product, msp_prod_hi, msp_prod_lo; |
813 | int msp_rom; | 809 | int msp_rom; |
814 | 810 | ||
815 | client = kzalloc(sizeof(*client), GFP_KERNEL); | ||
816 | if (!client) | ||
817 | return -ENOMEM; | ||
818 | |||
819 | client->addr = address; | ||
820 | client->adapter = adapter; | ||
821 | client->driver = &i2c_driver; | ||
822 | snprintf(client->name, sizeof(client->name) - 1, "msp3400"); | 811 | snprintf(client->name, sizeof(client->name) - 1, "msp3400"); |
823 | 812 | ||
824 | if (msp_reset(client) == -1) { | 813 | if (msp_reset(client) == -1) { |
825 | v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); | 814 | v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); |
826 | kfree(client); | ||
827 | return 0; | 815 | return 0; |
828 | } | 816 | } |
829 | 817 | ||
830 | state = kzalloc(sizeof(*state), GFP_KERNEL); | 818 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
831 | if (!state) { | 819 | if (!state) { |
832 | kfree(client); | ||
833 | return -ENOMEM; | 820 | return -ENOMEM; |
834 | } | 821 | } |
835 | 822 | ||
@@ -857,7 +844,6 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | |||
857 | if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { | 844 | if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { |
858 | v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); | 845 | v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); |
859 | kfree(state); | 846 | kfree(state); |
860 | kfree(client); | ||
861 | return 0; | 847 | return 0; |
862 | } | 848 | } |
863 | 849 | ||
@@ -919,7 +905,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | |||
919 | } | 905 | } |
920 | 906 | ||
921 | /* hello world :-) */ | 907 | /* hello world :-) */ |
922 | v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, address << 1, adapter->name); | 908 | v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, client->addr << 1, client->adapter->name); |
923 | v4l_info(client, "%s ", client->name); | 909 | v4l_info(client, "%s ", client->name); |
924 | if (state->has_nicam && state->has_radio) | 910 | if (state->has_nicam && state->has_radio) |
925 | printk("supports nicam and radio, "); | 911 | printk("supports nicam and radio, "); |
@@ -954,24 +940,12 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | |||
954 | v4l_warn(client, "kernel_thread() failed\n"); | 940 | v4l_warn(client, "kernel_thread() failed\n"); |
955 | msp_wake_thread(client); | 941 | msp_wake_thread(client); |
956 | } | 942 | } |
957 | |||
958 | /* done */ | ||
959 | i2c_attach_client(client); | ||
960 | |||
961 | return 0; | ||
962 | } | ||
963 | |||
964 | static int msp_probe(struct i2c_adapter *adapter) | ||
965 | { | ||
966 | if (adapter->class & I2C_CLASS_TV_ANALOG) | ||
967 | return i2c_probe(adapter, &addr_data, msp_attach); | ||
968 | return 0; | 943 | return 0; |
969 | } | 944 | } |
970 | 945 | ||
971 | static int msp_detach(struct i2c_client *client) | 946 | static int msp_remove(struct i2c_client *client) |
972 | { | 947 | { |
973 | struct msp_state *state = i2c_get_clientdata(client); | 948 | struct msp_state *state = i2c_get_clientdata(client); |
974 | int err; | ||
975 | 949 | ||
976 | /* shutdown control thread */ | 950 | /* shutdown control thread */ |
977 | if (state->kthread) { | 951 | if (state->kthread) { |
@@ -980,43 +954,22 @@ static int msp_detach(struct i2c_client *client) | |||
980 | } | 954 | } |
981 | msp_reset(client); | 955 | msp_reset(client); |
982 | 956 | ||
983 | err = i2c_detach_client(client); | ||
984 | if (err) { | ||
985 | return err; | ||
986 | } | ||
987 | |||
988 | kfree(state); | 957 | kfree(state); |
989 | kfree(client); | ||
990 | return 0; | 958 | return 0; |
991 | } | 959 | } |
992 | 960 | ||
993 | /* ----------------------------------------------------------------------- */ | 961 | /* ----------------------------------------------------------------------- */ |
994 | 962 | ||
995 | /* i2c implementation */ | 963 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
996 | static struct i2c_driver i2c_driver = { | 964 | .name = "msp3400", |
997 | .id = I2C_DRIVERID_MSP3400, | 965 | .driverid = I2C_DRIVERID_MSP3400, |
998 | .attach_adapter = msp_probe, | 966 | .command = msp_command, |
999 | .detach_client = msp_detach, | 967 | .probe = msp_probe, |
968 | .remove = msp_remove, | ||
1000 | .suspend = msp_suspend, | 969 | .suspend = msp_suspend, |
1001 | .resume = msp_resume, | 970 | .resume = msp_resume, |
1002 | .command = msp_command, | ||
1003 | .driver = { | ||
1004 | .name = "msp3400", | ||
1005 | }, | ||
1006 | }; | 971 | }; |
1007 | 972 | ||
1008 | static int __init msp3400_init_module(void) | ||
1009 | { | ||
1010 | return i2c_add_driver(&i2c_driver); | ||
1011 | } | ||
1012 | |||
1013 | static void __exit msp3400_cleanup_module(void) | ||
1014 | { | ||
1015 | i2c_del_driver(&i2c_driver); | ||
1016 | } | ||
1017 | |||
1018 | module_init(msp3400_init_module); | ||
1019 | module_exit(msp3400_cleanup_module); | ||
1020 | 973 | ||
1021 | /* | 974 | /* |
1022 | * Overrides for Emacs so that we follow Linus's tabbing style. | 975 | * Overrides for Emacs so that we follow Linus's tabbing style. |