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>
This commit is contained in:
parent
b7aff107f3
commit
af69f9a787
|
@ -94,6 +94,11 @@ static struct abx80x_cap abx80x_caps[] = {
|
|||
[ABX80X] = {.pn = 0}
|
||||
};
|
||||
|
||||
struct abx80x_priv {
|
||||
struct rtc_device *rtc;
|
||||
struct i2c_client *client;
|
||||
};
|
||||
|
||||
static int abx80x_is_rc_mode(struct i2c_client *client)
|
||||
{
|
||||
int flags = 0;
|
||||
|
@ -218,7 +223,8 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|||
static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct i2c_client *client = dev_id;
|
||||
struct rtc_device *rtc = i2c_get_clientdata(client);
|
||||
struct abx80x_priv *priv = i2c_get_clientdata(client);
|
||||
struct rtc_device *rtc = priv->rtc;
|
||||
int status;
|
||||
|
||||
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
|
||||
|
@ -533,7 +539,7 @@ static int abx80x_probe(struct i2c_client *client,
|
|||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct device_node *np = client->dev.of_node;
|
||||
struct rtc_device *rtc;
|
||||
struct abx80x_priv *priv;
|
||||
int i, data, err, trickle_cfg = -EINVAL;
|
||||
char buf[7];
|
||||
unsigned int part = id->driver_data;
|
||||
|
@ -610,13 +616,18 @@ static int abx80x_probe(struct i2c_client *client,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
rtc = devm_rtc_allocate_device(&client->dev);
|
||||
if (IS_ERR(rtc))
|
||||
return PTR_ERR(rtc);
|
||||
priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (priv == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
rtc->ops = &abx80x_rtc_ops;
|
||||
priv->rtc = devm_rtc_allocate_device(&client->dev);
|
||||
if (IS_ERR(priv->rtc))
|
||||
return PTR_ERR(priv->rtc);
|
||||
|
||||
i2c_set_clientdata(client, rtc);
|
||||
priv->rtc->ops = &abx80x_rtc_ops;
|
||||
priv->client = client;
|
||||
|
||||
i2c_set_clientdata(client, priv);
|
||||
|
||||
if (client->irq > 0) {
|
||||
dev_info(&client->dev, "IRQ %d supplied\n", client->irq);
|
||||
|
@ -649,7 +660,7 @@ static int abx80x_probe(struct i2c_client *client,
|
|||
return err;
|
||||
}
|
||||
|
||||
err = rtc_register_device(rtc);
|
||||
err = rtc_register_device(priv->rtc);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue