git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git]
/
drivers
/
acorn
/
char
/
pcf8583.c
diff --git
a/drivers/acorn/char/pcf8583.c
b/drivers/acorn/char/pcf8583.c
index
ad7ae7a
..
9b49f31
100644
(file)
--- a/
drivers/acorn/char/pcf8583.c
+++ b/
drivers/acorn/char/pcf8583.c
@@
-9,6
+9,7
@@
*
* Driver for PCF8583 RTC & RAM chip
*/
*
* Driver for PCF8583 RTC & RAM chip
*/
+#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/string.h>
@@
-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 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,
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_addr,
- .normal_i2c_range = ignore,
.probe = ignore,
.probe = ignore,
- .probe_range = ignore,
.ignore = 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)
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] = {
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);
};
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)
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);
}
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] = {
{
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;
};
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;
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);
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;
if (ret == len)
ret = 0;
- buf[1] =
DAT
(client);
+ buf[1] =
get_ctrl
(client);
i2c_master_send(client, (char *)buf, 2);
return ret;
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)
{
static int
pcf8583_get_ctrl(struct i2c_client *client, unsigned char *ctrl)
{
- *ctrl =
DAT
(client);
+ *ctrl =
get_ctrl
(client);
return 0;
}
return 0;
}
@@
-151,7
+169,7
@@
pcf8583_set_ctrl(struct i2c_client *client, unsigned char *ctrl)
buf[0] = 0;
buf[1] = *ctrl;
buf[0] = 0;
buf[1] = *ctrl;
-
DAT(client) = *ctrl
;
+
set_ctrl(client, *ctrl)
;
return i2c_master_send(client, (char *)buf, 2);
}
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] = {
{
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;
};
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;
}
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] = {
{
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;
};
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;
}
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 = {
}
static struct i2c_driver pcf8583_driver = {
- .name = "PCF8583",
+ .driver = {
+ .name = "PCF8583",
+ },
.id = I2C_DRIVERID_PCF8583,
.id = I2C_DRIVERID_PCF8583,
- .flags = I2C_DF_NOTIFY,
.attach_adapter = pcf8583_probe,
.detach_client = pcf8583_detach,
.command = pcf8583_command
.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);
}
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");