forked from Minki/linux
rtc: abx80x: use rtc_add_group
Use rtc_add_group to add the sysfs group in a race free manner. This has the side effect of moving the files to their proper location. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
2fcdf5fd7c
commit
559e883e0f
@ -401,7 +401,7 @@ static ssize_t autocalibration_store(struct device *dev,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = abx80x_rtc_set_autocalibration(dev, autocalibration);
|
retval = abx80x_rtc_set_autocalibration(dev->parent, autocalibration);
|
||||||
|
|
||||||
return retval ? retval : count;
|
return retval ? retval : count;
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ static ssize_t autocalibration_show(struct device *dev,
|
|||||||
{
|
{
|
||||||
int autocalibration = 0;
|
int autocalibration = 0;
|
||||||
|
|
||||||
autocalibration = abx80x_rtc_get_autocalibration(dev);
|
autocalibration = abx80x_rtc_get_autocalibration(dev->parent);
|
||||||
if (autocalibration < 0) {
|
if (autocalibration < 0) {
|
||||||
dev_err(dev, "Failed to read RTC autocalibration\n");
|
dev_err(dev, "Failed to read RTC autocalibration\n");
|
||||||
sprintf(buf, "0\n");
|
sprintf(buf, "0\n");
|
||||||
@ -427,7 +427,7 @@ static ssize_t oscillator_store(struct device *dev,
|
|||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = to_i2c_client(dev);
|
struct i2c_client *client = to_i2c_client(dev->parent);
|
||||||
int retval, flags, rc_mode = 0;
|
int retval, flags, rc_mode = 0;
|
||||||
|
|
||||||
if (strncmp(buf, "rc", 2) == 0) {
|
if (strncmp(buf, "rc", 2) == 0) {
|
||||||
@ -469,7 +469,7 @@ static ssize_t oscillator_show(struct device *dev,
|
|||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int rc_mode = 0;
|
int rc_mode = 0;
|
||||||
struct i2c_client *client = to_i2c_client(dev);
|
struct i2c_client *client = to_i2c_client(dev->parent);
|
||||||
|
|
||||||
rc_mode = abx80x_is_rc_mode(client);
|
rc_mode = abx80x_is_rc_mode(client);
|
||||||
|
|
||||||
@ -589,13 +589,6 @@ static int abx80x_dt_trickle_cfg(struct device_node *np)
|
|||||||
return (trickle_cfg | i);
|
return (trickle_cfg | i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtc_calib_remove_sysfs_group(void *_dev)
|
|
||||||
{
|
|
||||||
struct device *dev = _dev;
|
|
||||||
|
|
||||||
sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_WATCHDOG
|
#ifdef CONFIG_WATCHDOG
|
||||||
|
|
||||||
static inline u8 timeout_bits(unsigned int timeout)
|
static inline u8 timeout_bits(unsigned int timeout)
|
||||||
@ -848,27 +841,14 @@ static int abx80x_probe(struct i2c_client *client,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Export sysfs entries */
|
err = rtc_add_group(priv->rtc, &rtc_calib_attr_group);
|
||||||
err = sysfs_create_group(&(&client->dev)->kobj, &rtc_calib_attr_group);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&client->dev, "Failed to create sysfs group: %d\n",
|
dev_err(&client->dev, "Failed to create sysfs group: %d\n",
|
||||||
err);
|
err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = devm_add_action_or_reset(&client->dev,
|
return rtc_register_device(priv->rtc);
|
||||||
rtc_calib_remove_sysfs_group,
|
|
||||||
&client->dev);
|
|
||||||
if (err) {
|
|
||||||
dev_err(&client->dev,
|
|
||||||
"Failed to add sysfs cleanup action: %d\n",
|
|
||||||
err);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = rtc_register_device(priv->rtc);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int abx80x_remove(struct i2c_client *client)
|
static int abx80x_remove(struct i2c_client *client)
|
||||||
|
Loading…
Reference in New Issue
Block a user