X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Facorn%2Fchar%2Fpcf8583.c;fp=drivers%2Facorn%2Fchar%2Fpcf8583.c;h=9b49f316ae923a6a46478bab22f7d376a940d783;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=ad7ae7ab8920434626690cd12a9c5be4c651547a;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index ad7ae7ab8..9b49f316a 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -9,6 +9,7 @@ * * Driver for PCF8583 RTC & RAM chip */ +#include #include #include #include @@ -23,18 +24,17 @@ static struct i2c_driver pcf8583_driver; static unsigned short ignore[] = { I2C_CLIENT_END }; static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END }; +static unsigned short *forces[] = { NULL }; static struct i2c_client_address_data addr_data = { .normal_i2c = normal_addr, - .normal_i2c_range = ignore, .probe = ignore, - .probe_range = ignore, .ignore = ignore, - .ignore_range = ignore, - .force = ignore, + .forces = forces, }; -#define DAT(x) ((unsigned int)(x->dev.driver_data)) +#define set_ctrl(x, v) i2c_set_clientdata(x, (void *)(unsigned int)(v)) +#define get_ctrl(x) ((unsigned int)i2c_get_clientdata(x)) static int pcf8583_attach(struct i2c_adapter *adap, int addr, int kind) @@ -42,8 +42,17 @@ pcf8583_attach(struct i2c_adapter *adap, int addr, int kind) struct i2c_client *c; unsigned char buf[1], ad[1] = { 0 }; struct i2c_msg msgs[2] = { - { addr, 0, 1, ad }, - { addr, I2C_M_RD, 1, buf } + { + .addr = addr, + .flags = 0, + .len = 1, + .buf = ad, + }, { + .addr = addr, + .flags = I2C_M_RD, + .len = 1, + .buf = buf, + } }; c = kmalloc(sizeof(*c), GFP_KERNEL); @@ -56,7 +65,7 @@ pcf8583_attach(struct i2c_adapter *adap, int addr, int kind) c->driver = &pcf8583_driver; if (i2c_transfer(c->adapter, msgs, 2) == 2) - DAT(c) = buf[0]; + set_ctrl(c, buf[0]); return i2c_attach_client(c); } @@ -80,8 +89,17 @@ pcf8583_get_datetime(struct i2c_client *client, struct rtc_tm *dt) { unsigned char buf[8], addr[1] = { 1 }; struct i2c_msg msgs[2] = { - { client->addr, 0, 1, addr }, - { client->addr, I2C_M_RD, 6, buf } + { + .addr = client->addr, + .flags = 0, + .len = 1, + .buf = addr, + }, { + .addr = client->addr, + .flags = I2C_M_RD, + .len = 6, + .buf = buf, + } }; int ret = -EIO; @@ -115,7 +133,7 @@ pcf8583_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo) int ret, len = 6; buf[0] = 0; - buf[1] = DAT(client) | 0x80; + buf[1] = get_ctrl(client) | 0x80; buf[2] = BIN_TO_BCD(dt->cs); buf[3] = BIN_TO_BCD(dt->secs); buf[4] = BIN_TO_BCD(dt->mins); @@ -131,7 +149,7 @@ pcf8583_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo) if (ret == len) ret = 0; - buf[1] = DAT(client); + buf[1] = get_ctrl(client); i2c_master_send(client, (char *)buf, 2); return ret; @@ -140,7 +158,7 @@ pcf8583_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo) static int pcf8583_get_ctrl(struct i2c_client *client, unsigned char *ctrl) { - *ctrl = DAT(client); + *ctrl = get_ctrl(client); return 0; } @@ -151,7 +169,7 @@ pcf8583_set_ctrl(struct i2c_client *client, unsigned char *ctrl) buf[0] = 0; buf[1] = *ctrl; - DAT(client) = *ctrl; + set_ctrl(client, *ctrl); return i2c_master_send(client, (char *)buf, 2); } @@ -161,15 +179,23 @@ pcf8583_read_mem(struct i2c_client *client, struct mem *mem) { unsigned char addr[1]; struct i2c_msg msgs[2] = { - { client->addr, 0, 1, addr }, - { client->addr, I2C_M_RD, 0, mem->data } + { + .addr = client->addr, + .flags = 0, + .len = 1, + .buf = addr, + }, { + .addr = client->addr, + .flags = I2C_M_RD, + .len = mem->nr, + .buf = mem->data, + } }; if (mem->loc < 8) return -EINVAL; addr[0] = mem->loc; - msgs[1].len = mem->nr; return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO; } @@ -179,15 +205,23 @@ pcf8583_write_mem(struct i2c_client *client, struct mem *mem) { unsigned char addr[1]; struct i2c_msg msgs[2] = { - { client->addr, 0, 1, addr }, - { client->addr, 0, 0, mem->data } + { + .addr = client->addr, + .flags = 0, + .len = 1, + .buf = addr, + }, { + .addr = client->addr, + .flags = I2C_M_NOSTART, + .len = mem->nr, + .buf = mem->data, + } }; if (mem->loc < 8) return -EINVAL; addr[0] = mem->loc; - msgs[1].len = mem->nr; return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO; } @@ -223,9 +257,10 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg) } static struct i2c_driver pcf8583_driver = { - .name = "PCF8583", + .driver = { + .name = "PCF8583", + }, .id = I2C_DRIVERID_PCF8583, - .flags = I2C_DF_NOTIFY, .attach_adapter = pcf8583_probe, .detach_client = pcf8583_detach, .command = pcf8583_command @@ -236,4 +271,14 @@ static __init int pcf8583_init(void) return i2c_add_driver(&pcf8583_driver); } -__initcall(pcf8583_init); +static __exit void pcf8583_exit(void) +{ + i2c_del_driver(&pcf8583_driver); +} + +module_init(pcf8583_init); +module_exit(pcf8583_exit); + +MODULE_AUTHOR("Russell King"); +MODULE_DESCRIPTION("PCF8583 I2C RTC driver"); +MODULE_LICENSE("GPL");