Skip to content

Commit

Permalink
rtc: ds1307: refactor chip_desc table
Browse files Browse the repository at this point in the history
The chip_desc table is suboptimal.  Currently it requires an entry for
every new chip type, even if it is empty.  This has already been
forgotten for the ds1388.  Refactor the code, so new entries are only
needed, when they chip type really needs a (non-empty) description.
Also make the table visually more appealing.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Austin Boyle <Austin.Boyle@aviatnet.com>
Cc: David Anders <danders.dev@gmail.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Wolfram Sang authored and Linus Torvalds committed Mar 23, 2012
1 parent fef931f commit 32d322b
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions drivers/rtc/rtc-ds1307.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum ds_type {
m41t00,
mcp7941x,
rx_8025,
last_ds_type /* always last */
// rs5c372 too? different address...
};

Expand Down Expand Up @@ -120,30 +121,23 @@ struct chip_desc {
unsigned alarm:1;
};

static const struct chip_desc chips[] = {
[ds_1307] = {
.nvram56 = 1,
},
[ds_1337] = {
.alarm = 1,
},
[ds_1338] = {
.nvram56 = 1,
},
[ds_1339] = {
.alarm = 1,
},
[ds_1340] = {
},
[ds_3231] = {
.alarm = 1,
},
[m41t00] = {
},
[mcp7941x] = {
},
[rx_8025] = {
}, };
static const struct chip_desc chips[last_ds_type] = {
[ds_1307] = {
.nvram56 = 1,
},
[ds_1337] = {
.alarm = 1,
},
[ds_1338] = {
.nvram56 = 1,
},
[ds_1339] = {
.alarm = 1,
},
[ds_3231] = {
.alarm = 1,
},
};

static const struct i2c_device_id ds1307_id[] = {
{ "ds1307", ds_1307 },
Expand Down Expand Up @@ -836,11 +830,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,
}

break;
case rx_8025:
case ds_1337:
case ds_1339:
case ds_1388:
case ds_3231:
default:
break;
}

Expand Down

0 comments on commit 32d322b

Please sign in to comment.