aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-09-13 10:30:38 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:01:21 -0500
commite8e6b99184aa8cf72c5a28bf2a64f6d81473b1ca (patch)
tree67bc51a71c0d60902ff88ea1292d4c72d4c92bf0
parent79518dafd59a812bb390f201c6f18a8f875fcffb (diff)
V4L/DVB (6458): cs53l23a: convert to bus-based I2C API
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/cs53l32a.c70
1 files changed, 9 insertions, 61 deletions
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index a73e285af730..e43febb9d161 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -29,6 +29,7 @@
29#include <linux/videodev.h> 29#include <linux/videodev.h>
30#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
31#include <media/v4l2-chip-ident.h> 31#include <media/v4l2-chip-ident.h>
32#include <media/v4l2-i2c-drv-legacy.h>
32 33
33MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC"); 34MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC");
34MODULE_AUTHOR("Martin Vaughan"); 35MODULE_AUTHOR("Martin Vaughan");
@@ -57,8 +58,7 @@ static int cs53l32a_read(struct i2c_client *client, u8 reg)
57 return i2c_smbus_read_byte_data(client, reg); 58 return i2c_smbus_read_byte_data(client, reg);
58} 59}
59 60
60static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, 61static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, void *arg)
61 void *arg)
62{ 62{
63 struct v4l2_routing *route = arg; 63 struct v4l2_routing *route = arg;
64 struct v4l2_control *ctrl = arg; 64 struct v4l2_control *ctrl = arg;
@@ -134,27 +134,17 @@ static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,
134 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 134 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
135 */ 135 */
136 136
137static struct i2c_driver i2c_driver; 137static int cs53l32a_probe(struct i2c_client *client)
138
139static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
140{ 138{
141 struct i2c_client *client;
142 int i; 139 int i;
143 140
144 /* Check if the adapter supports the needed features */ 141 /* Check if the adapter supports the needed features */
145 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 142 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
146 return 0; 143 return 0;
147 144
148 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
149 if (client == 0)
150 return -ENOMEM;
151
152 client->addr = address;
153 client->adapter = adapter;
154 client->driver = &i2c_driver;
155 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); 145 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a");
156 146
157 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name); 147 v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name);
158 148
159 for (i = 1; i <= 7; i++) { 149 for (i = 1; i <= 7; i++) {
160 u8 v = cs53l32a_read(client, i); 150 u8 v = cs53l32a_read(client, i);
@@ -179,55 +169,13 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
179 169
180 v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v); 170 v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v);
181 } 171 }
182
183 i2c_attach_client(client);
184
185 return 0; 172 return 0;
186} 173}
187 174
188static int cs53l32a_probe(struct i2c_adapter *adapter) 175static struct v4l2_i2c_driver_data v4l2_i2c_data = {
189{ 176 .name = "cs53l32a",
190 if (adapter->class & I2C_CLASS_TV_ANALOG) 177 .driverid = I2C_DRIVERID_CS53L32A,
191 return i2c_probe(adapter, &addr_data, cs53l32a_attach);
192 return 0;
193}
194
195static int cs53l32a_detach(struct i2c_client *client)
196{
197 int err;
198
199 err = i2c_detach_client(client);
200 if (err) {
201 return err;
202 }
203 kfree(client);
204
205 return 0;
206}
207
208/* ----------------------------------------------------------------------- */
209
210/* i2c implementation */
211static struct i2c_driver i2c_driver = {
212 .driver = {
213 .name = "cs53l32a",
214 },
215 .id = I2C_DRIVERID_CS53L32A,
216 .attach_adapter = cs53l32a_probe,
217 .detach_client = cs53l32a_detach,
218 .command = cs53l32a_command, 178 .command = cs53l32a_command,
179 .probe = cs53l32a_probe,
219}; 180};
220 181
221
222static int __init cs53l32a_init_module(void)
223{
224 return i2c_add_driver(&i2c_driver);
225}
226
227static void __exit cs53l32a_cleanup_module(void)
228{
229 i2c_del_driver(&i2c_driver);
230}
231
232module_init(cs53l32a_init_module);
233module_exit(cs53l32a_cleanup_module);