diff options
author | Jeremy Gebben <jgebben@sweptlaser.com> | 2018-09-11 13:28:25 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2018-09-12 06:02:19 -0400 |
commit | af69f9a7878413ccdb47a28b024748fd0381a035 (patch) | |
tree | 097cd6605dcbf1d17f9f6bf6b32815cb53cda2ab | |
parent | b7aff107f34f007f32f45136c9a935912a481d32 (diff) |
rtc: abx80x: use a 'priv' struct for client data
This will allow additional data to be tracked, for future
improvements.
Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r-- | drivers/rtc/rtc-abx80x.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index 2cefa67a1132..9d49054a0a4a 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c | |||
@@ -94,6 +94,11 @@ static struct abx80x_cap abx80x_caps[] = { | |||
94 | [ABX80X] = {.pn = 0} | 94 | [ABX80X] = {.pn = 0} |
95 | }; | 95 | }; |
96 | 96 | ||
97 | struct abx80x_priv { | ||
98 | struct rtc_device *rtc; | ||
99 | struct i2c_client *client; | ||
100 | }; | ||
101 | |||
97 | static int abx80x_is_rc_mode(struct i2c_client *client) | 102 | static int abx80x_is_rc_mode(struct i2c_client *client) |
98 | { | 103 | { |
99 | int flags = 0; | 104 | int flags = 0; |
@@ -218,7 +223,8 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
218 | static irqreturn_t abx80x_handle_irq(int irq, void *dev_id) | 223 | static irqreturn_t abx80x_handle_irq(int irq, void *dev_id) |
219 | { | 224 | { |
220 | struct i2c_client *client = dev_id; | 225 | struct i2c_client *client = dev_id; |
221 | struct rtc_device *rtc = i2c_get_clientdata(client); | 226 | struct abx80x_priv *priv = i2c_get_clientdata(client); |
227 | struct rtc_device *rtc = priv->rtc; | ||
222 | int status; | 228 | int status; |
223 | 229 | ||
224 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); | 230 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); |
@@ -533,7 +539,7 @@ static int abx80x_probe(struct i2c_client *client, | |||
533 | const struct i2c_device_id *id) | 539 | const struct i2c_device_id *id) |
534 | { | 540 | { |
535 | struct device_node *np = client->dev.of_node; | 541 | struct device_node *np = client->dev.of_node; |
536 | struct rtc_device *rtc; | 542 | struct abx80x_priv *priv; |
537 | int i, data, err, trickle_cfg = -EINVAL; | 543 | int i, data, err, trickle_cfg = -EINVAL; |
538 | char buf[7]; | 544 | char buf[7]; |
539 | unsigned int part = id->driver_data; | 545 | unsigned int part = id->driver_data; |
@@ -610,13 +616,18 @@ static int abx80x_probe(struct i2c_client *client, | |||
610 | if (err) | 616 | if (err) |
611 | return err; | 617 | return err; |
612 | 618 | ||
613 | rtc = devm_rtc_allocate_device(&client->dev); | 619 | priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); |
614 | if (IS_ERR(rtc)) | 620 | if (priv == NULL) |
615 | return PTR_ERR(rtc); | 621 | return -ENOMEM; |
622 | |||
623 | priv->rtc = devm_rtc_allocate_device(&client->dev); | ||
624 | if (IS_ERR(priv->rtc)) | ||
625 | return PTR_ERR(priv->rtc); | ||
616 | 626 | ||
617 | rtc->ops = &abx80x_rtc_ops; | 627 | priv->rtc->ops = &abx80x_rtc_ops; |
628 | priv->client = client; | ||
618 | 629 | ||
619 | i2c_set_clientdata(client, rtc); | 630 | i2c_set_clientdata(client, priv); |
620 | 631 | ||
621 | if (client->irq > 0) { | 632 | if (client->irq > 0) { |
622 | dev_info(&client->dev, "IRQ %d supplied\n", client->irq); | 633 | dev_info(&client->dev, "IRQ %d supplied\n", client->irq); |
@@ -649,7 +660,7 @@ static int abx80x_probe(struct i2c_client *client, | |||
649 | return err; | 660 | return err; |
650 | } | 661 | } |
651 | 662 | ||
652 | err = rtc_register_device(rtc); | 663 | err = rtc_register_device(priv->rtc); |
653 | 664 | ||
654 | return err; | 665 | return err; |
655 | } | 666 | } |