aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/go7007/wis-uda1342.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-04-21 15:47:22 -0400
committerJean Delvare <khali@linux-fr.org>2009-04-21 15:47:22 -0400
commit7400516ab40d8fe55031dc8d614e2b365bd95f1c (patch)
tree33fc8410c9727ca32747ed84832bafb785285f79 /drivers/staging/go7007/wis-uda1342.c
parenta939b96cccdb65df80a52447ec8e4a6d79c56dbb (diff)
go7007: Convert to the new i2c device binding model
Move the go7007 driver away from the legacy i2c binding model, which is going away really soon now. The I2C addresses of the audio and video chips in s2250-board didn't look quite right, apparently they were left-aligned values when Linux wants right-aligned values, so I fixed them too. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/go7007/wis-uda1342.c')
-rw-r--r--drivers/staging/go7007/wis-uda1342.c52
1 files changed, 15 insertions, 37 deletions
diff --git a/drivers/staging/go7007/wis-uda1342.c b/drivers/staging/go7007/wis-uda1342.c
index 555645c0cc1..739c7ae8913 100644
--- a/drivers/staging/go7007/wis-uda1342.c
+++ b/drivers/staging/go7007/wis-uda1342.c
@@ -59,73 +59,51 @@ static int wis_uda1342_command(struct i2c_client *client,
59 return 0; 59 return 0;
60} 60}
61 61
62static struct i2c_driver wis_uda1342_driver; 62static int wis_uda1342_probe(struct i2c_client *client,
63 63 const struct i2c_device_id *id)
64static struct i2c_client wis_uda1342_client_templ = {
65 .name = "UDA1342 (WIS)",
66 .driver = &wis_uda1342_driver,
67};
68
69static int wis_uda1342_detect(struct i2c_adapter *adapter, int addr, int kind)
70{ 64{
71 struct i2c_client *client; 65 struct i2c_adapter *adapter = client->adapter;
72 66
73 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) 67 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
74 return 0; 68 return -ENODEV;
75
76 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
77 if (client == NULL)
78 return -ENOMEM;
79 memcpy(client, &wis_uda1342_client_templ,
80 sizeof(wis_uda1342_client_templ));
81 client->adapter = adapter;
82 client->addr = addr;
83 69
84 printk(KERN_DEBUG 70 printk(KERN_DEBUG
85 "wis-uda1342: initializing UDA1342 at address %d on %s\n", 71 "wis-uda1342: initializing UDA1342 at address %d on %s\n",
86 addr, adapter->name); 72 client->addr, adapter->name);
87 73
88 write_reg(client, 0x00, 0x8000); /* reset registers */ 74 write_reg(client, 0x00, 0x8000); /* reset registers */
89 write_reg(client, 0x00, 0x1241); /* select input 1 */ 75 write_reg(client, 0x00, 0x1241); /* select input 1 */
90 76
91 i2c_attach_client(client);
92 return 0; 77 return 0;
93} 78}
94 79
95static int wis_uda1342_detach(struct i2c_client *client) 80static int wis_uda1342_remove(struct i2c_client *client)
96{ 81{
97 int r;
98
99 r = i2c_detach_client(client);
100 if (r < 0)
101 return r;
102
103 kfree(client);
104 return 0; 82 return 0;
105} 83}
106 84
85static struct i2c_device_id wis_uda1342_id[] = {
86 { "wis_uda1342", 0 },
87 { }
88};
89
107static struct i2c_driver wis_uda1342_driver = { 90static struct i2c_driver wis_uda1342_driver = {
108 .driver = { 91 .driver = {
109 .name = "WIS UDA1342 I2C driver", 92 .name = "WIS UDA1342 I2C driver",
110 }, 93 },
111 .id = I2C_DRIVERID_WIS_UDA1342, 94 .probe = wis_uda1342_probe,
112 .detach_client = wis_uda1342_detach, 95 .remove = wis_uda1342_remove,
113 .command = wis_uda1342_command, 96 .command = wis_uda1342_command,
97 .id_table = wis_uda1342_id,
114}; 98};
115 99
116static int __init wis_uda1342_init(void) 100static int __init wis_uda1342_init(void)
117{ 101{
118 int r; 102 return i2c_add_driver(&wis_uda1342_driver);
119
120 r = i2c_add_driver(&wis_uda1342_driver);
121 if (r < 0)
122 return r;
123 return wis_i2c_add_driver(wis_uda1342_driver.id, wis_uda1342_detect);
124} 103}
125 104
126static void __exit wis_uda1342_cleanup(void) 105static void __exit wis_uda1342_cleanup(void)
127{ 106{
128 wis_i2c_del_driver(wis_uda1342_detect);
129 i2c_del_driver(&wis_uda1342_driver); 107 i2c_del_driver(&wis_uda1342_driver);
130} 108}
131 109