2 drivers/rtc/rtc-pcf8563.c | 109 +++++++++++++---------------------------------
3 1 file changed, 32 insertions(+), 77 deletions(-)
5 Index: linux-2.6.25.1/drivers/rtc/rtc-pcf8563.c
6 ===================================================================
7 --- linux-2.6.25.1.orig/drivers/rtc/rtc-pcf8563.c
8 +++ linux-2.6.25.1/drivers/rtc/rtc-pcf8563.c
10 #include <linux/bcd.h>
11 #include <linux/rtc.h>
13 -#define DRV_VERSION "0.4.2"
15 -/* Addresses to scan: none
16 - * This chip cannot be reliably autodetected. An empty eeprom
17 - * located at 0x51 will pass the validation routine due to
18 - * the way the registers are implemented.
20 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
22 -/* Module parameters */
24 +#define DRV_VERSION "0.4.3"
26 #define PCF8563_REG_ST1 0x00 /* status */
27 #define PCF8563_REG_ST2 0x01
28 @@ -53,8 +43,10 @@ I2C_CLIENT_INSMOD;
29 #define PCF8563_SC_LV 0x80 /* low voltage */
30 #define PCF8563_MO_C 0x80 /* century */
32 +static struct i2c_driver pcf8563_driver;
35 - struct i2c_client client;
36 + struct rtc_device *rtc;
38 * The meaning of MO_C bit varies by the chip type.
39 * From PCF8563 datasheet: this bit is toggled when the years
40 @@ -72,16 +64,13 @@ struct pcf8563 {
41 int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
44 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
45 -static int pcf8563_detach(struct i2c_client *client);
48 * In the routines that deal directly with the pcf8563 hardware, we use
49 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
51 static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
53 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
54 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
55 unsigned char buf[13] = { PCF8563_REG_ST1 };
57 struct i2c_msg msgs[] = {
58 @@ -138,7 +127,7 @@ static int pcf8563_get_datetime(struct i
60 static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
62 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
63 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
67 @@ -257,100 +246,66 @@ static const struct rtc_class_ops pcf856
68 .set_time = pcf8563_rtc_set_time,
71 -static int pcf8563_attach(struct i2c_adapter *adapter)
73 - return i2c_probe(adapter, &addr_data, pcf8563_probe);
76 -static struct i2c_driver pcf8563_driver = {
80 - .id = I2C_DRIVERID_PCF8563,
81 - .attach_adapter = &pcf8563_attach,
82 - .detach_client = &pcf8563_detach,
85 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
86 +static int pcf8563_probe(struct i2c_client *client)
88 struct pcf8563 *pcf8563;
89 - struct i2c_client *client;
90 - struct rtc_device *rtc;
94 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
95 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
97 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
101 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
104 - if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
109 - client = &pcf8563->client;
110 - client->addr = address;
111 - client->driver = &pcf8563_driver;
112 - client->adapter = adapter;
114 - strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
115 + if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL)))
118 /* Verify the chip is really an PCF8563 */
120 - if (pcf8563_validate_client(client) < 0) {
126 - /* Inform the i2c layer */
127 - if ((err = i2c_attach_client(client)))
128 + if (pcf8563_validate_client(client) < 0) {
133 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
135 - rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
136 + pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
137 &pcf8563_rtc_ops, THIS_MODULE);
140 - err = PTR_ERR(rtc);
142 + if (IS_ERR(pcf8563->rtc)) {
143 + err = PTR_ERR(pcf8563->rtc);
147 - i2c_set_clientdata(client, rtc);
148 + i2c_set_clientdata(client, pcf8563);
153 - i2c_detach_client(client);
162 -static int pcf8563_detach(struct i2c_client *client)
163 +static int pcf8563_remove(struct i2c_client *client)
165 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
167 - struct rtc_device *rtc = i2c_get_clientdata(client);
168 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
171 - rtc_device_unregister(rtc);
173 - if ((err = i2c_detach_client(client)))
176 + rtc_device_unregister(pcf8563->rtc);
183 +static struct i2c_driver pcf8563_driver = {
185 + .name = "rtc-pcf8563",
187 + .probe = pcf8563_probe,
188 + .remove = pcf8563_remove,
191 static int __init pcf8563_init(void)
193 return i2c_add_driver(&pcf8563_driver);