2 drivers/rtc/rtc-isl1208.c | 357 +++++++++++++++++++++-------------------------
3 1 file changed, 170 insertions(+), 187 deletions(-)
5 Index: linux-2.6.24.7/drivers/rtc/rtc-isl1208.c
6 ===================================================================
7 --- linux-2.6.24.7.orig/drivers/rtc/rtc-isl1208.c
8 +++ linux-2.6.24.7/drivers/rtc/rtc-isl1208.c
10 #include <linux/bcd.h>
11 #include <linux/rtc.h>
13 -#define DRV_NAME "isl1208"
14 -#define DRV_VERSION "0.2"
15 +#define DRV_VERSION "0.3"
19 #define ISL1208_REG_SC 0x00
20 #define ISL1208_REG_MN 0x01
21 #define ISL1208_REG_HR 0x02
22 -#define ISL1208_REG_HR_MIL (1<<7) /* 24h/12h mode */
23 -#define ISL1208_REG_HR_PM (1<<5) /* PM/AM bit in 12h mode */
24 +#define ISL1208_REG_HR_MIL (1<<7) /* 24h/12h mode */
25 +#define ISL1208_REG_HR_PM (1<<5) /* PM/AM bit in 12h mode */
26 #define ISL1208_REG_DT 0x03
27 #define ISL1208_REG_MO 0x04
28 #define ISL1208_REG_YR 0x05
31 /* control/status section */
32 #define ISL1208_REG_SR 0x07
33 -#define ISL1208_REG_SR_ARST (1<<7) /* auto reset */
34 -#define ISL1208_REG_SR_XTOSCB (1<<6) /* crystal oscillator */
35 -#define ISL1208_REG_SR_WRTC (1<<4) /* write rtc */
36 -#define ISL1208_REG_SR_ALM (1<<2) /* alarm */
37 -#define ISL1208_REG_SR_BAT (1<<1) /* battery */
38 -#define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */
39 +#define ISL1208_REG_SR_ARST (1<<7) /* auto reset */
40 +#define ISL1208_REG_SR_XTOSCB (1<<6) /* crystal oscillator */
41 +#define ISL1208_REG_SR_WRTC (1<<4) /* write rtc */
42 +#define ISL1208_REG_SR_ALM (1<<2) /* alarm */
43 +#define ISL1208_REG_SR_BAT (1<<1) /* battery */
44 +#define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */
45 #define ISL1208_REG_INT 0x08
46 -#define ISL1208_REG_09 0x09 /* reserved */
47 +#define ISL1208_REG_09 0x09 /* reserved */
48 #define ISL1208_REG_ATR 0x0a
49 #define ISL1208_REG_DTR 0x0b
52 #define ISL1208_REG_USR2 0x13
53 #define ISL1208_USR_SECTION_LEN 2
55 -/* i2c configuration */
56 -#define ISL1208_I2C_ADDR 0xde
58 -static unsigned short normal_i2c[] = {
59 - ISL1208_I2C_ADDR>>1, I2C_CLIENT_END
61 -I2C_CLIENT_INSMOD; /* defines addr_data */
63 -static int isl1208_attach_adapter(struct i2c_adapter *adapter);
64 -static int isl1208_detach_client(struct i2c_client *client);
66 -static struct i2c_driver isl1208_driver = {
70 - .id = I2C_DRIVERID_ISL1208,
71 - .attach_adapter = &isl1208_attach_adapter,
72 - .detach_client = &isl1208_detach_client,
74 +static struct i2c_driver isl1208_driver;
78 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
82 u8 reg_addr[1] = { reg };
83 struct i2c_msg msgs[2] = {
84 - { client->addr, client->flags, sizeof(reg_addr), reg_addr },
85 - { client->addr, client->flags | I2C_M_RD, len, buf }
86 + {client->addr, client->flags, sizeof(reg_addr), reg_addr}
88 + {client->addr, client->flags | I2C_M_RD, len, buf}
92 @@ -103,15 +85,14 @@ isl1208_i2c_read_regs(struct i2c_client
95 isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[],
99 u8 i2c_buf[ISL1208_REG_USR2 + 2];
100 struct i2c_msg msgs[1] = {
101 - { client->addr, client->flags, len + 1, i2c_buf }
102 + {client->addr, client->flags, len + 1, i2c_buf}
107 BUG_ON(reg > ISL1208_REG_USR2);
108 BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
110 @@ -125,7 +106,8 @@ isl1208_i2c_set_regs(struct i2c_client *
113 /* simple check to see wether we have a isl1208 */
114 -static int isl1208_i2c_validate_client(struct i2c_client *client)
116 +isl1208_i2c_validate_client(struct i2c_client *client)
118 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
119 u8 zero_mask[ISL1208_RTC_SECTION_LEN] = {
120 @@ -139,24 +121,29 @@ static int isl1208_i2c_validate_client(s
123 for (i = 0; i < ISL1208_RTC_SECTION_LEN; ++i) {
124 - if (regs[i] & zero_mask[i]) /* check if bits are cleared */
125 + if (regs[i] & zero_mask[i]) /* check if bits are cleared */
132 -static int isl1208_i2c_get_sr(struct i2c_client *client)
134 +isl1208_i2c_get_sr(struct i2c_client *client)
136 - return i2c_smbus_read_byte_data(client, ISL1208_REG_SR) == -1 ? -EIO:0;
137 + int sr = i2c_smbus_read_byte_data(client, ISL1208_REG_SR);
144 -static int isl1208_i2c_get_atr(struct i2c_client *client)
146 +isl1208_i2c_get_atr(struct i2c_client *client)
148 int atr = i2c_smbus_read_byte_data(client, ISL1208_REG_ATR);
154 /* The 6bit value in the ATR register controls the load
155 * capacitance C_load * in steps of 0.25pF
156 @@ -169,51 +156,54 @@ static int isl1208_i2c_get_atr(struct i2
160 - atr &= 0x3f; /* mask out lsb */
161 - atr ^= 1<<5; /* invert 6th bit */
162 - atr += 2*9; /* add offset of 4.5pF; unit[atr] = 0.25pF */
163 + atr &= 0x3f; /* mask out lsb */
164 + atr ^= 1 << 5; /* invert 6th bit */
165 + atr += 2 * 9; /* add offset of 4.5pF; unit[atr] = 0.25pF */
170 -static int isl1208_i2c_get_dtr(struct i2c_client *client)
172 +isl1208_i2c_get_dtr(struct i2c_client *client)
174 int dtr = i2c_smbus_read_byte_data(client, ISL1208_REG_DTR);
179 /* dtr encodes adjustments of {-60,-40,-20,0,20,40,60} ppm */
180 - dtr = ((dtr & 0x3) * 20) * (dtr & (1<<2) ? -1 : 1);
181 + dtr = ((dtr & 0x3) * 20) * (dtr & (1 << 2) ? -1 : 1);
186 -static int isl1208_i2c_get_usr(struct i2c_client *client)
188 +isl1208_i2c_get_usr(struct i2c_client *client)
190 u8 buf[ISL1208_USR_SECTION_LEN] = { 0, };
193 - ret = isl1208_i2c_read_regs (client, ISL1208_REG_USR1, buf,
194 - ISL1208_USR_SECTION_LEN);
195 + ret = isl1208_i2c_read_regs(client, ISL1208_REG_USR1, buf,
196 + ISL1208_USR_SECTION_LEN);
200 return (buf[1] << 8) | buf[0];
203 -static int isl1208_i2c_set_usr(struct i2c_client *client, u16 usr)
205 +isl1208_i2c_set_usr(struct i2c_client *client, u16 usr)
207 u8 buf[ISL1208_USR_SECTION_LEN];
210 buf[1] = (usr >> 8) & 0xff;
212 - return isl1208_i2c_set_regs (client, ISL1208_REG_USR1, buf,
213 - ISL1208_USR_SECTION_LEN);
214 + return isl1208_i2c_set_regs(client, ISL1208_REG_USR1, buf,
215 + ISL1208_USR_SECTION_LEN);
218 -static int isl1208_rtc_proc(struct device *dev, struct seq_file *seq)
220 +isl1208_rtc_proc(struct device *dev, struct seq_file *seq)
222 struct i2c_client *const client = to_i2c_client(dev);
223 int sr, dtr, atr, usr;
224 @@ -230,20 +220,19 @@ static int isl1208_rtc_proc(struct devic
225 (sr & ISL1208_REG_SR_ALM) ? " ALM" : "",
226 (sr & ISL1208_REG_SR_WRTC) ? " WRTC" : "",
227 (sr & ISL1208_REG_SR_XTOSCB) ? " XTOSCB" : "",
228 - (sr & ISL1208_REG_SR_ARST) ? " ARST" : "",
230 + (sr & ISL1208_REG_SR_ARST) ? " ARST" : "", sr);
232 seq_printf(seq, "batt_status\t: %s\n",
233 (sr & ISL1208_REG_SR_RTCF) ? "bad" : "okay");
235 dtr = isl1208_i2c_get_dtr(client);
238 seq_printf(seq, "digital_trim\t: %d ppm\n", dtr);
240 atr = isl1208_i2c_get_atr(client);
242 seq_printf(seq, "analog_trim\t: %d.%.2d pF\n",
243 - atr>>2, (atr&0x3)*25);
244 + atr >> 2, (atr & 0x3) * 25);
246 usr = isl1208_i2c_get_usr(client);
248 @@ -252,9 +241,8 @@ static int isl1208_rtc_proc(struct devic
253 -static int isl1208_i2c_read_time(struct i2c_client *client,
254 - struct rtc_time *tm)
256 +isl1208_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
259 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
260 @@ -274,27 +262,30 @@ static int isl1208_i2c_read_time(struct
262 tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SC]);
263 tm->tm_min = BCD2BIN(regs[ISL1208_REG_MN]);
264 - { /* HR field has a more complex interpretation */
266 + /* HR field has a more complex interpretation */
268 const u8 _hr = regs[ISL1208_REG_HR];
269 - if (_hr & ISL1208_REG_HR_MIL) /* 24h format */
270 + if (_hr & ISL1208_REG_HR_MIL) /* 24h format */
271 tm->tm_hour = BCD2BIN(_hr & 0x3f);
272 - else { // 12h format
275 tm->tm_hour = BCD2BIN(_hr & 0x1f);
276 - if (_hr & ISL1208_REG_HR_PM) /* PM flag set */
277 + if (_hr & ISL1208_REG_HR_PM) /* PM flag set */
282 tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DT]);
283 - tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */
284 + tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */
285 tm->tm_year = BCD2BIN(regs[ISL1208_REG_YR]) + 100;
286 tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DW]);
291 -static int isl1208_i2c_read_alarm(struct i2c_client *client,
292 - struct rtc_wkalrm *alarm)
294 +isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
296 struct rtc_time *const tm = &alarm->time;
297 u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, };
298 @@ -307,7 +298,7 @@ static int isl1208_i2c_read_alarm(struct
301 sr = isl1208_i2c_read_regs(client, ISL1208_REG_SCA, regs,
302 - ISL1208_ALARM_SECTION_LEN);
303 + ISL1208_ALARM_SECTION_LEN);
305 dev_err(&client->dev, "%s: reading alarm section failed\n",
307 @@ -315,23 +306,25 @@ static int isl1208_i2c_read_alarm(struct
310 /* MSB of each alarm register is an enable bit */
311 - tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA-ISL1208_REG_SCA] & 0x7f);
312 - tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA-ISL1208_REG_SCA] & 0x7f);
313 - tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA-ISL1208_REG_SCA] & 0x3f);
314 - tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA-ISL1208_REG_SCA] & 0x3f);
315 - tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MOA-ISL1208_REG_SCA] & 0x1f)-1;
316 - tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA-ISL1208_REG_SCA] & 0x03);
317 + tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f);
318 + tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f);
319 + tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f);
320 + tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f);
322 + BCD2BIN(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1;
323 + tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03);
328 -static int isl1208_rtc_read_time(struct device *dev, struct rtc_time *tm)
330 +isl1208_rtc_read_time(struct device *dev, struct rtc_time *tm)
332 return isl1208_i2c_read_time(to_i2c_client(dev), tm);
335 -static int isl1208_i2c_set_time(struct i2c_client *client,
336 - struct rtc_time const *tm)
338 +isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
341 u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
342 @@ -353,7 +346,7 @@ static int isl1208_i2c_set_time(struct i
346 - sr = i2c_smbus_write_byte_data (client, ISL1208_REG_SR,
347 + sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
348 sr | ISL1208_REG_SR_WRTC);
350 dev_err(&client->dev, "%s: writing SR failed\n", __func__);
351 @@ -369,7 +362,7 @@ static int isl1208_i2c_set_time(struct i
354 /* clear WRTC again */
355 - sr = i2c_smbus_write_byte_data (client, ISL1208_REG_SR,
356 + sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
357 sr & ~ISL1208_REG_SR_WRTC);
359 dev_err(&client->dev, "%s: writing SR failed\n", __func__);
360 @@ -380,70 +373,69 @@ static int isl1208_i2c_set_time(struct i
364 -static int isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm)
366 +isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm)
368 return isl1208_i2c_set_time(to_i2c_client(dev), tm);
371 -static int isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
373 +isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
375 return isl1208_i2c_read_alarm(to_i2c_client(dev), alarm);
378 static const struct rtc_class_ops isl1208_rtc_ops = {
379 - .proc = isl1208_rtc_proc,
380 - .read_time = isl1208_rtc_read_time,
381 - .set_time = isl1208_rtc_set_time,
382 - .read_alarm = isl1208_rtc_read_alarm,
383 - //.set_alarm = isl1208_rtc_set_alarm,
384 + .proc = isl1208_rtc_proc,
385 + .read_time = isl1208_rtc_read_time,
386 + .set_time = isl1208_rtc_set_time,
387 + .read_alarm = isl1208_rtc_read_alarm,
388 + /*.set_alarm = isl1208_rtc_set_alarm, */
391 /* sysfs interface */
393 -static ssize_t isl1208_sysfs_show_atrim(struct device *dev,
394 - struct device_attribute *attr,
397 +isl1208_sysfs_show_atrim(struct device *dev,
398 + struct device_attribute *attr, char *buf)
402 - atr = isl1208_i2c_get_atr(to_i2c_client(dev));
403 + int atr = isl1208_i2c_get_atr(to_i2c_client(dev));
407 - return sprintf(buf, "%d.%.2d pF\n", atr>>2, (atr&0x3)*25);
408 + return sprintf(buf, "%d.%.2d pF\n", atr >> 2, (atr & 0x3) * 25);
411 static DEVICE_ATTR(atrim, S_IRUGO, isl1208_sysfs_show_atrim, NULL);
413 -static ssize_t isl1208_sysfs_show_dtrim(struct device *dev,
414 - struct device_attribute *attr,
417 +isl1208_sysfs_show_dtrim(struct device *dev,
418 + struct device_attribute *attr, char *buf)
422 - dtr = isl1208_i2c_get_dtr(to_i2c_client(dev));
423 + int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev));
427 return sprintf(buf, "%d ppm\n", dtr);
430 static DEVICE_ATTR(dtrim, S_IRUGO, isl1208_sysfs_show_dtrim, NULL);
432 -static ssize_t isl1208_sysfs_show_usr(struct device *dev,
433 - struct device_attribute *attr,
436 +isl1208_sysfs_show_usr(struct device *dev,
437 + struct device_attribute *attr, char *buf)
441 - usr = isl1208_i2c_get_usr(to_i2c_client(dev));
442 + int usr = isl1208_i2c_get_usr(to_i2c_client(dev));
446 return sprintf(buf, "0x%.4x\n", usr);
449 -static ssize_t isl1208_sysfs_store_usr(struct device *dev,
450 - struct device_attribute *attr,
451 - const char *buf, size_t count)
453 +isl1208_sysfs_store_usr(struct device *dev,
454 + struct device_attribute *attr,
455 + const char *buf, size_t count)
459 @@ -460,124 +452,116 @@ static ssize_t isl1208_sysfs_store_usr(s
461 return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count;
464 static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
465 isl1208_sysfs_store_usr);
468 -isl1208_probe(struct i2c_adapter *adapter, int addr, int kind)
469 +isl1208_sysfs_register(struct device *dev)
472 - struct i2c_client *new_client = NULL;
473 - struct rtc_device *rtc = NULL;
476 + err = device_create_file(dev, &dev_attr_atrim);
480 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
483 + err = device_create_file(dev, &dev_attr_dtrim);
485 + device_remove_file(dev, &dev_attr_atrim);
489 - new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
490 - if (new_client == NULL) {
493 + err = device_create_file(dev, &dev_attr_usr);
495 + device_remove_file(dev, &dev_attr_atrim);
496 + device_remove_file(dev, &dev_attr_dtrim);
499 - new_client->addr = addr;
500 - new_client->adapter = adapter;
501 - new_client->driver = &isl1208_driver;
502 - new_client->flags = 0;
503 - strcpy(new_client->name, DRV_NAME);
508 - rc = isl1208_i2c_validate_client(new_client);
513 +isl1208_sysfs_unregister(struct device *dev)
515 + device_remove_file(dev, &dev_attr_atrim);
516 + device_remove_file(dev, &dev_attr_atrim);
517 + device_remove_file(dev, &dev_attr_usr);
523 +isl1208_probe(struct i2c_client *client)
526 + struct rtc_device *rtc;
528 - rc = i2c_attach_client(new_client);
531 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
534 - dev_info(&new_client->dev,
535 + if (isl1208_i2c_validate_client(client) < 0)
538 + dev_info(&client->dev,
539 "chip found, driver version " DRV_VERSION "\n");
541 rtc = rtc_device_register(isl1208_driver.driver.name,
543 - &isl1208_rtc_ops, THIS_MODULE);
547 - goto failout_detach;
549 + &client->dev, &isl1208_rtc_ops,
552 + return PTR_ERR(rtc);
554 - i2c_set_clientdata(new_client, rtc);
555 + i2c_set_clientdata(client, rtc);
557 - rc = isl1208_i2c_get_sr(new_client);
558 + rc = isl1208_i2c_get_sr(client);
560 - dev_err(&new_client->dev, "reading status failed\n");
561 - goto failout_unregister;
562 + dev_err(&client->dev, "reading status failed\n");
563 + goto exit_unregister;
566 if (rc & ISL1208_REG_SR_RTCF)
567 - dev_warn(&new_client->dev, "rtc power failure detected, "
568 + dev_warn(&client->dev, "rtc power failure detected, "
569 "please set clock.\n");
571 - rc = device_create_file(&new_client->dev, &dev_attr_atrim);
573 - goto failout_unregister;
574 - rc = device_create_file(&new_client->dev, &dev_attr_dtrim);
576 - goto failout_atrim;
577 - rc = device_create_file(&new_client->dev, &dev_attr_usr);
579 - goto failout_dtrim;
580 + rc = isl1208_sysfs_register(&client->dev);
582 + goto exit_unregister;
587 - device_remove_file(&new_client->dev, &dev_attr_dtrim);
589 - device_remove_file(&new_client->dev, &dev_attr_atrim);
590 - failout_unregister:
592 rtc_device_unregister(rtc);
594 - i2c_detach_client(new_client);
601 -isl1208_attach_adapter (struct i2c_adapter *adapter)
603 - return i2c_probe(adapter, &addr_data, isl1208_probe);
608 -isl1208_detach_client(struct i2c_client *client)
609 +isl1208_remove(struct i2c_client *client)
612 - struct rtc_device *const rtc = i2c_get_clientdata(client);
615 - rtc_device_unregister(rtc); /* do we need to kfree? */
617 - rc = i2c_detach_client(client);
620 + struct rtc_device *rtc = i2c_get_clientdata(client);
623 + isl1208_sysfs_unregister(&client->dev);
624 + rtc_device_unregister(rtc);
629 -/* module management */
630 +static struct i2c_driver isl1208_driver = {
632 + .name = "rtc-isl1208",
634 + .probe = isl1208_probe,
635 + .remove = isl1208_remove,
638 -static int __init isl1208_init(void)
642 return i2c_add_driver(&isl1208_driver);
645 -static void __exit isl1208_exit(void)
649 i2c_del_driver(&isl1208_driver);
651 Index: linux-2.6.24.7/drivers/rtc/rtc-pcf8563.c
652 ===================================================================
653 --- linux-2.6.24.7.orig/drivers/rtc/rtc-pcf8563.c
654 +++ linux-2.6.24.7/drivers/rtc/rtc-pcf8563.c
656 #include <linux/bcd.h>
657 #include <linux/rtc.h>
659 -#define DRV_VERSION "0.4.2"
661 -/* Addresses to scan: none
662 - * This chip cannot be reliably autodetected. An empty eeprom
663 - * located at 0x51 will pass the validation routine due to
664 - * the way the registers are implemented.
666 -static unsigned short normal_i2c[] = { I2C_CLIENT_END };
668 -/* Module parameters */
670 +#define DRV_VERSION "0.4.3"
672 #define PCF8563_REG_ST1 0x00 /* status */
673 #define PCF8563_REG_ST2 0x01
674 @@ -53,8 +43,10 @@ I2C_CLIENT_INSMOD;
675 #define PCF8563_SC_LV 0x80 /* low voltage */
676 #define PCF8563_MO_C 0x80 /* century */
678 +static struct i2c_driver pcf8563_driver;
681 - struct i2c_client client;
682 + struct rtc_device *rtc;
684 * The meaning of MO_C bit varies by the chip type.
685 * From PCF8563 datasheet: this bit is toggled when the years
686 @@ -72,16 +64,13 @@ struct pcf8563 {
687 int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
690 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
691 -static int pcf8563_detach(struct i2c_client *client);
694 * In the routines that deal directly with the pcf8563 hardware, we use
695 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
697 static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
699 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
700 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
701 unsigned char buf[13] = { PCF8563_REG_ST1 };
703 struct i2c_msg msgs[] = {
704 @@ -138,7 +127,7 @@ static int pcf8563_get_datetime(struct i
706 static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
708 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
709 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
711 unsigned char buf[9];
713 @@ -257,100 +246,66 @@ static const struct rtc_class_ops pcf856
714 .set_time = pcf8563_rtc_set_time,
717 -static int pcf8563_attach(struct i2c_adapter *adapter)
719 - return i2c_probe(adapter, &addr_data, pcf8563_probe);
722 -static struct i2c_driver pcf8563_driver = {
726 - .id = I2C_DRIVERID_PCF8563,
727 - .attach_adapter = &pcf8563_attach,
728 - .detach_client = &pcf8563_detach,
731 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
732 +static int pcf8563_probe(struct i2c_client *client)
734 struct pcf8563 *pcf8563;
735 - struct i2c_client *client;
736 - struct rtc_device *rtc;
740 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
741 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
743 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
747 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
750 - if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
755 - client = &pcf8563->client;
756 - client->addr = address;
757 - client->driver = &pcf8563_driver;
758 - client->adapter = adapter;
760 - strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
761 + if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL)))
764 /* Verify the chip is really an PCF8563 */
766 - if (pcf8563_validate_client(client) < 0) {
772 - /* Inform the i2c layer */
773 - if ((err = i2c_attach_client(client)))
774 + if (pcf8563_validate_client(client) < 0) {
779 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
781 - rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
782 + pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
783 &pcf8563_rtc_ops, THIS_MODULE);
786 - err = PTR_ERR(rtc);
788 + if (IS_ERR(pcf8563->rtc)) {
789 + err = PTR_ERR(pcf8563->rtc);
793 - i2c_set_clientdata(client, rtc);
794 + i2c_set_clientdata(client, pcf8563);
799 - i2c_detach_client(client);
808 -static int pcf8563_detach(struct i2c_client *client)
809 +static int pcf8563_remove(struct i2c_client *client)
811 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
813 - struct rtc_device *rtc = i2c_get_clientdata(client);
814 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
817 - rtc_device_unregister(rtc);
819 - if ((err = i2c_detach_client(client)))
822 + rtc_device_unregister(pcf8563->rtc);
829 +static struct i2c_driver pcf8563_driver = {
831 + .name = "rtc-pcf8563",
833 + .probe = pcf8563_probe,
834 + .remove = pcf8563_remove,
837 static int __init pcf8563_init(void)
839 return i2c_add_driver(&pcf8563_driver);
840 Index: linux-2.6.24.7/drivers/rtc/rtc-x1205.c
841 ===================================================================
842 --- linux-2.6.24.7.orig/drivers/rtc/rtc-x1205.c
843 +++ linux-2.6.24.7/drivers/rtc/rtc-x1205.c
845 #include <linux/rtc.h>
846 #include <linux/delay.h>
848 -#define DRV_VERSION "1.0.7"
850 -/* Addresses to scan: none. This chip is located at
851 - * 0x6f and uses a two bytes register addressing.
852 - * Two bytes need to be written to read a single register,
853 - * while most other chips just require one and take the second
854 - * one as the data to be written. To prevent corrupting
855 - * unknown chips, the user must explicitly set the probe parameter.
858 -static unsigned short normal_i2c[] = { I2C_CLIENT_END };
860 -/* Insmod parameters */
862 +#define DRV_VERSION "1.0.8"
864 /* offsets into CCR area */
866 @@ -91,19 +78,7 @@ I2C_CLIENT_INSMOD;
868 #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */
871 -static int x1205_attach(struct i2c_adapter *adapter);
872 -static int x1205_detach(struct i2c_client *client);
873 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind);
875 -static struct i2c_driver x1205_driver = {
879 - .id = I2C_DRIVERID_X1205,
880 - .attach_adapter = &x1205_attach,
881 - .detach_client = &x1205_detach,
883 +static struct i2c_driver x1205_driver;
886 * In the routines that deal directly with the x1205 hardware, we use
887 @@ -497,58 +472,51 @@ static ssize_t x1205_sysfs_show_dtrim(st
889 static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
891 -static int x1205_attach(struct i2c_adapter *adapter)
892 +static int x1205_sysfs_register(struct device *dev)
896 + err = device_create_file(dev, &dev_attr_atrim);
900 + err = device_create_file(dev, &dev_attr_dtrim);
902 + device_remove_file(dev, &dev_attr_atrim);
907 +static void x1205_sysfs_unregister(struct device *dev)
909 - return i2c_probe(adapter, &addr_data, x1205_probe);
910 + device_remove_file(dev, &dev_attr_atrim);
911 + device_remove_file(dev, &dev_attr_dtrim);
914 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
916 +static int x1205_probe(struct i2c_client *client)
920 - struct i2c_client *client;
921 struct rtc_device *rtc;
923 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
924 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
926 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
929 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
933 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
936 + if (x1205_validate_client(client) < 0) {
941 - client->addr = address;
942 - client->driver = &x1205_driver;
943 - client->adapter = adapter;
945 - strlcpy(client->name, x1205_driver.driver.name, I2C_NAME_SIZE);
947 - /* Verify the chip is really an X1205 */
949 - if (x1205_validate_client(client) < 0) {
955 - /* Inform the i2c layer */
956 - if ((err = i2c_attach_client(client)))
959 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
961 rtc = rtc_device_register(x1205_driver.driver.name, &client->dev,
962 &x1205_rtc_ops, THIS_MODULE);
965 - err = PTR_ERR(rtc);
969 + return PTR_ERR(rtc);
971 i2c_set_clientdata(client, rtc);
973 @@ -565,45 +533,35 @@ static int x1205_probe(struct i2c_adapte
975 dev_err(&client->dev, "couldn't read status\n");
977 - err = device_create_file(&client->dev, &dev_attr_atrim);
978 - if (err) goto exit_devreg;
979 - err = device_create_file(&client->dev, &dev_attr_dtrim);
980 - if (err) goto exit_atrim;
981 + err = x1205_sysfs_register(&client->dev);
988 - device_remove_file(&client->dev, &dev_attr_atrim);
991 rtc_device_unregister(rtc);
994 - i2c_detach_client(client);
1003 -static int x1205_detach(struct i2c_client *client)
1004 +static int x1205_remove(struct i2c_client *client)
1007 struct rtc_device *rtc = i2c_get_clientdata(client);
1010 - rtc_device_unregister(rtc);
1012 - if ((err = i2c_detach_client(client)))
1017 + rtc_device_unregister(rtc);
1018 + x1205_sysfs_unregister(&client->dev);
1022 +static struct i2c_driver x1205_driver = {
1024 + .name = "rtc-x1205",
1026 + .probe = x1205_probe,
1027 + .remove = x1205_remove,
1030 static int __init x1205_init(void)
1032 return i2c_add_driver(&x1205_driver);