aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1307.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-04-29 17:11:40 -0400
committerJean Delvare <khali@hyperion.delvare>2008-04-29 17:11:40 -0400
commit3760f736716f74bdc62a4ba5406934338da93eb2 (patch)
treee28e22c6655dd62566f1b7a99f9354a31bf9d06e /drivers/rtc/rtc-ds1307.c
parentd2653e92732bd3911feff6bee5e23dbf959381db (diff)
i2c: Convert most new-style drivers to use module aliasing
Based on earlier work by Jon Smirl and Jochen Friedrich. Update most new-style i2c drivers to use standard module aliasing instead of the old driver_name/type driver matching scheme. I've left the video drivers apart (except for SoC camera drivers) as they're a bit more diffcult to deal with, they'll have their own patch later. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Jon Smirl <jonsmirl@gmail.com> Cc: Jochen Friedrich <jochen@scram.de>
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r--drivers/rtc/rtc-ds1307.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 67ba8ae3217c..bbf97e65202a 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -99,45 +99,38 @@ struct ds1307 {
99}; 99};
100 100
101struct chip_desc { 101struct chip_desc {
102 char name[9];
103 unsigned nvram56:1; 102 unsigned nvram56:1;
104 unsigned alarm:1; 103 unsigned alarm:1;
105 enum ds_type type;
106}; 104};
107 105
108static const struct chip_desc chips[] = { { 106static const struct chip_desc chips[] = {
109 .name = "ds1307", 107[ds_1307] = {
110 .type = ds_1307,
111 .nvram56 = 1, 108 .nvram56 = 1,
112}, { 109},
113 .name = "ds1337", 110[ds_1337] = {
114 .type = ds_1337,
115 .alarm = 1, 111 .alarm = 1,
116}, { 112},
117 .name = "ds1338", 113[ds_1338] = {
118 .type = ds_1338,
119 .nvram56 = 1, 114 .nvram56 = 1,
120}, { 115},
121 .name = "ds1339", 116[ds_1339] = {
122 .type = ds_1339,
123 .alarm = 1, 117 .alarm = 1,
124}, { 118},
125 .name = "ds1340", 119[ds_1340] = {
126 .type = ds_1340, 120},
127}, { 121[m41t00] = {
128 .name = "m41t00",
129 .type = m41t00,
130}, }; 122}, };
131 123
132static inline const struct chip_desc *find_chip(const char *s) 124static const struct i2c_device_id ds1307_id[] = {
133{ 125 { "ds1307", ds_1307 },
134 unsigned i; 126 { "ds1337", ds_1337 },
135 127 { "ds1338", ds_1338 },
136 for (i = 0; i < ARRAY_SIZE(chips); i++) 128 { "ds1339", ds_1339 },
137 if (strnicmp(s, chips[i].name, sizeof chips[i].name) == 0) 129 { "ds1340", ds_1340 },
138 return &chips[i]; 130 { "m41t00", m41t00 },
139 return NULL; 131 { }
140} 132};
133MODULE_DEVICE_TABLE(i2c, ds1307_id);
141 134
142static int ds1307_get_time(struct device *dev, struct rtc_time *t) 135static int ds1307_get_time(struct device *dev, struct rtc_time *t)
143{ 136{
@@ -332,16 +325,9 @@ static int __devinit ds1307_probe(struct i2c_client *client,
332 struct ds1307 *ds1307; 325 struct ds1307 *ds1307;
333 int err = -ENODEV; 326 int err = -ENODEV;
334 int tmp; 327 int tmp;
335 const struct chip_desc *chip; 328 const struct chip_desc *chip = &chips[id->driver_data];
336 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 329 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
337 330
338 chip = find_chip(client->name);
339 if (!chip) {
340 dev_err(&client->dev, "unknown chip type '%s'\n",
341 client->name);
342 return -ENODEV;
343 }
344
345 if (!i2c_check_functionality(adapter, 331 if (!i2c_check_functionality(adapter,
346 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 332 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
347 return -EIO; 333 return -EIO;
@@ -362,7 +348,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,
362 ds1307->msg[1].len = sizeof(ds1307->regs); 348 ds1307->msg[1].len = sizeof(ds1307->regs);
363 ds1307->msg[1].buf = ds1307->regs; 349 ds1307->msg[1].buf = ds1307->regs;
364 350
365 ds1307->type = chip->type; 351 ds1307->type = id->driver_data;
366 352
367 switch (ds1307->type) { 353 switch (ds1307->type) {
368 case ds_1337: 354 case ds_1337:
@@ -551,6 +537,7 @@ static struct i2c_driver ds1307_driver = {
551 }, 537 },
552 .probe = ds1307_probe, 538 .probe = ds1307_probe,
553 .remove = __devexit_p(ds1307_remove), 539 .remove = __devexit_p(ds1307_remove),
540 .id_table = ds1307_id,
554}; 541};
555 542
556static int __init ds1307_init(void) 543static int __init ds1307_init(void)