2 ?local function read_fn;
3 ?local function write_fn;
4 ?local function write_block_fn;
11 - read_fn(T *dev, unsigned char subaddr) {
33 - write_fn(T *dev, unsigned char subaddr, unsigned char data) {
36 - <ooo WHEN != i2c_readbyte(...)
49 - write_block_fn(T *dev, unsigned char *data, unsigned int len) {
50 - <ooo WHEN != i2c_readbyte(...)
52 - <ooo WHEN != i2c_readbyte(...)
59 !local function attach_fn, detach_fn, command_fn;
60 expression E, E1, E2, E3, E4;
64 ooo WHEN !<= I.{attach,detach,command} = E;
65 struct i2c_driver i2c_driver_struct = {
66 E1, E2, E3, E4, attach_fn, detach_fn, command_fn
71 !local function init_fn, exit_fn;
79 !identifier i2c_driver_struct;
84 i2c_register_driver(&i2c_driver_struct);
89 fresh identifier A##_probe;
90 fresh identifier normal_i2c, normal_i2c_range, probe, probe_range, ignore,
91 ignore_range, force, addr_data, client_template;
97 -! #include <linux/i2c-old.h>
98 + #include <linux/i2c.h>
100 + static unsigned short normal_i2c[] = {34>>1, I2C_CLIENT_END };
101 + static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
102 + static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
103 + static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
104 + static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
105 + static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
106 + static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
108 + static struct i2c_client_address_data addr_data = {
109 + normal_i2c, normal_i2c_range,
110 + probe, probe_range,
111 + ignore, ignore_range,
114 + static struct i2c_client client_template;
122 !- struct i2c_bus *bus;
123 + struct i2c_client *client;
125 + struct semaphore lock;
132 ! static struct i2c_driver i2c_driver_struct = {
134 - I2C_DRIVERID_VIDEODECODER,
135 - I2C_##A/u, I2C_##A/u + 1,
136 + I2C_DRIVERID_##A/u,
143 + static struct i2c_client client_template = {
144 + "##A##_client", -1, 0, 0, NULL, &i2c_driver_struct
151 - C[i2c_register_driver(&i2c_driver_struct)]
152 + C[i2c_add_driver(&i2c_driver_struct)]
161 - C[i2c_unregister_driver(&i2c_driver_struct)]
162 + C[i2c_del_driver(&i2c_driver_struct)]
166 error words = [i2c_register_driver, i2c_unregister_driver]
170 fresh identifier adap, addr, flags, kind;
171 fresh identifier client;
173 error expression error_code;
176 - attach_fn(struct i2c_device *device)
177 + attach_fn(struct i2c_adapter *adap, int addr, unsigned long flags, int kind)
179 + struct i2c_client *client;
181 + client = kmalloc(sizeof(*client), GFP_KERNEL);
182 + if(client == NULL) return -ENOMEM;
183 + client_template.adapter = adap;
184 + client_template.addr = addr;
185 + memcpy(client, &client_template, sizeof(*client));
192 + init_MUTEX(&coder->lock);
193 + i2c_attach_client(client);
212 - device->data = coder;
221 + client->data = coder;
222 coder->bus = device->bus;
250 error words = [attach_fn: device->data]
253 fresh identifier client;
257 attach_fn(struct i2c_device *device) {
259 command_fn(struct i2c_device *device, ...) {
262 device_fn(device,...)
269 - device_fn(struct i2c_device *device, ...) {
270 + device_fn(struct i2c_client *client, ...) {
277 fresh identifier adap;
280 + static int A##_probe(struct i2c_adapter *adap) {
281 + return i2c_probe(adap, &addr_data, A##_attach);
285 fresh identifier client;
288 - detach_fn(struct i2c_device *device)
289 + detach_fn(struct i2c_client *client)
297 + i2c_detach_client(client);
305 fresh identifier client;
308 - command_fn(struct i2c_device *device, ...) {
309 + command_fn(struct i2c_client *client, ...) {
318 expression X1, Y1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, X5, Y5, Z5, X6, Y6, Z6;
323 struct i2c_client *client;
325 fn(..., struct i2c_client *client, ...) {
330 + i2c_smbus_read_byte(client)
335 + i2c_smbus_write_byte(client,Y2,Z2)
339 - write_block_fn(X3,Y3,Z3)
340 + i2c_master_send(client,Y3,Z3)
349 + i2c_smbus_read_byte(X4->client)
354 + i2c_smbus_write_byte(X5->client,Y5,Z5)
358 - write_block_fn(X6,Y6,Z6)
359 + i2c_master_send(X6->client,Y6,Z6)