mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-14 06:35:12 +00:00
rtc: ds1307: factor out irq_handler to struct chip_desc
Factor out irq_handler to struct chip_desc and use ds1307_irq as default. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This commit is contained in:
parent
82e2d43f63
commit
4594712705
1 changed files with 7 additions and 8 deletions
|
@ -140,12 +140,15 @@ struct chip_desc {
|
||||||
u8 century_enable_bit;
|
u8 century_enable_bit;
|
||||||
u8 century_bit;
|
u8 century_bit;
|
||||||
u8 bbsqi_bit;
|
u8 bbsqi_bit;
|
||||||
|
irq_handler_t irq_handler;
|
||||||
u16 trickle_charger_reg;
|
u16 trickle_charger_reg;
|
||||||
u8 (*do_trickle_setup)(struct ds1307 *, uint32_t,
|
u8 (*do_trickle_setup)(struct ds1307 *, uint32_t,
|
||||||
bool);
|
bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
static u8 do_trickle_setup_ds1339(struct ds1307 *, uint32_t ohms, bool diode);
|
static u8 do_trickle_setup_ds1339(struct ds1307 *, uint32_t ohms, bool diode);
|
||||||
|
static irqreturn_t rx8130_irq(int irq, void *dev_id);
|
||||||
|
static irqreturn_t mcp794xx_irq(int irq, void *dev_id);
|
||||||
|
|
||||||
static const struct chip_desc chips[last_ds_type] = {
|
static const struct chip_desc chips[last_ds_type] = {
|
||||||
[ds_1307] = {
|
[ds_1307] = {
|
||||||
|
@ -193,12 +196,14 @@ static const struct chip_desc chips[last_ds_type] = {
|
||||||
/* this is battery backed SRAM */
|
/* this is battery backed SRAM */
|
||||||
.nvram_offset = 0x20,
|
.nvram_offset = 0x20,
|
||||||
.nvram_size = 4, /* 32bit (4 word x 8 bit) */
|
.nvram_size = 4, /* 32bit (4 word x 8 bit) */
|
||||||
|
.irq_handler = rx8130_irq,
|
||||||
},
|
},
|
||||||
[mcp794xx] = {
|
[mcp794xx] = {
|
||||||
.alarm = 1,
|
.alarm = 1,
|
||||||
/* this is battery backed SRAM */
|
/* this is battery backed SRAM */
|
||||||
.nvram_offset = 0x20,
|
.nvram_offset = 0x20,
|
||||||
.nvram_size = 0x40,
|
.nvram_size = 0x40,
|
||||||
|
.irq_handler = mcp794xx_irq,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1320,8 +1325,6 @@ static int ds1307_probe(struct i2c_client *client,
|
||||||
unsigned long timestamp;
|
unsigned long timestamp;
|
||||||
u8 trickle_charger_setup = 0;
|
u8 trickle_charger_setup = 0;
|
||||||
|
|
||||||
irq_handler_t irq_handler = ds1307_irq;
|
|
||||||
|
|
||||||
const struct rtc_class_ops *rtc_ops = &ds13xx_rtc_ops;
|
const struct rtc_class_ops *rtc_ops = &ds13xx_rtc_ops;
|
||||||
|
|
||||||
ds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL);
|
ds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL);
|
||||||
|
@ -1493,16 +1496,12 @@ static int ds1307_probe(struct i2c_client *client,
|
||||||
case rx_8130:
|
case rx_8130:
|
||||||
ds1307->offset = 0x10; /* Seconds starts at 0x10 */
|
ds1307->offset = 0x10; /* Seconds starts at 0x10 */
|
||||||
rtc_ops = &rx8130_rtc_ops;
|
rtc_ops = &rx8130_rtc_ops;
|
||||||
if (want_irq)
|
|
||||||
irq_handler = rx8130_irq;
|
|
||||||
break;
|
break;
|
||||||
case ds_1388:
|
case ds_1388:
|
||||||
ds1307->offset = 1; /* Seconds starts at 1 */
|
ds1307->offset = 1; /* Seconds starts at 1 */
|
||||||
break;
|
break;
|
||||||
case mcp794xx:
|
case mcp794xx:
|
||||||
rtc_ops = &mcp794xx_rtc_ops;
|
rtc_ops = &mcp794xx_rtc_ops;
|
||||||
if (want_irq || ds1307_can_wakeup_device)
|
|
||||||
irq_handler = mcp794xx_irq;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1652,8 +1651,8 @@ static int ds1307_probe(struct i2c_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_irq) {
|
if (want_irq) {
|
||||||
err = devm_request_threaded_irq(ds1307->dev,
|
err = devm_request_threaded_irq(ds1307->dev, client->irq, NULL,
|
||||||
client->irq, NULL, irq_handler,
|
chip->irq_handler ?: ds1307_irq,
|
||||||
IRQF_SHARED | IRQF_ONESHOT,
|
IRQF_SHARED | IRQF_ONESHOT,
|
||||||
ds1307->name, ds1307);
|
ds1307->name, ds1307);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in a new issue