diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-03-06 04:51:33 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-03-17 22:36:01 -0400 |
commit | 559e883e0f776855072d70001a4c68a0d07a68f4 (patch) | |
tree | 8387445b5ba9ab8659c52bcada84552aa4647df2 | |
parent | 2fcdf5fd7c1b66f283b16639682f0b5dd3474b0b (diff) |
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>
-rw-r--r-- | drivers/rtc/rtc-abx80x.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index 8e7eb08281f7..90f25ac78abc 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c | |||
@@ -401,7 +401,7 @@ static ssize_t autocalibration_store(struct device *dev, | |||
401 | return -EINVAL; | 401 | return -EINVAL; |
402 | } | 402 | } |
403 | 403 | ||
404 | retval = abx80x_rtc_set_autocalibration(dev, autocalibration); | 404 | retval = abx80x_rtc_set_autocalibration(dev->parent, autocalibration); |
405 | 405 | ||
406 | return retval ? retval : count; | 406 | return retval ? retval : count; |
407 | } | 407 | } |
@@ -411,7 +411,7 @@ static ssize_t autocalibration_show(struct device *dev, | |||
411 | { | 411 | { |
412 | int autocalibration = 0; | 412 | int autocalibration = 0; |
413 | 413 | ||
414 | autocalibration = abx80x_rtc_get_autocalibration(dev); | 414 | autocalibration = abx80x_rtc_get_autocalibration(dev->parent); |
415 | if (autocalibration < 0) { | 415 | if (autocalibration < 0) { |
416 | dev_err(dev, "Failed to read RTC autocalibration\n"); | 416 | dev_err(dev, "Failed to read RTC autocalibration\n"); |
417 | sprintf(buf, "0\n"); | 417 | sprintf(buf, "0\n"); |
@@ -427,7 +427,7 @@ static ssize_t oscillator_store(struct device *dev, | |||
427 | struct device_attribute *attr, | 427 | struct device_attribute *attr, |
428 | const char *buf, size_t count) | 428 | const char *buf, size_t count) |
429 | { | 429 | { |
430 | struct i2c_client *client = to_i2c_client(dev); | 430 | struct i2c_client *client = to_i2c_client(dev->parent); |
431 | int retval, flags, rc_mode = 0; | 431 | int retval, flags, rc_mode = 0; |
432 | 432 | ||
433 | if (strncmp(buf, "rc", 2) == 0) { | 433 | if (strncmp(buf, "rc", 2) == 0) { |
@@ -469,7 +469,7 @@ static ssize_t oscillator_show(struct device *dev, | |||
469 | struct device_attribute *attr, char *buf) | 469 | struct device_attribute *attr, char *buf) |
470 | { | 470 | { |
471 | int rc_mode = 0; | 471 | int rc_mode = 0; |
472 | struct i2c_client *client = to_i2c_client(dev); | 472 | struct i2c_client *client = to_i2c_client(dev->parent); |
473 | 473 | ||
474 | rc_mode = abx80x_is_rc_mode(client); | 474 | rc_mode = abx80x_is_rc_mode(client); |
475 | 475 | ||
@@ -589,13 +589,6 @@ static int abx80x_dt_trickle_cfg(struct device_node *np) | |||
589 | return (trickle_cfg | i); | 589 | return (trickle_cfg | i); |
590 | } | 590 | } |
591 | 591 | ||
592 | static void rtc_calib_remove_sysfs_group(void *_dev) | ||
593 | { | ||
594 | struct device *dev = _dev; | ||
595 | |||
596 | sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group); | ||
597 | } | ||
598 | |||
599 | #ifdef CONFIG_WATCHDOG | 592 | #ifdef CONFIG_WATCHDOG |
600 | 593 | ||
601 | static inline u8 timeout_bits(unsigned int timeout) | 594 | static inline u8 timeout_bits(unsigned int timeout) |
@@ -848,27 +841,14 @@ static int abx80x_probe(struct i2c_client *client, | |||
848 | } | 841 | } |
849 | } | 842 | } |
850 | 843 | ||
851 | /* Export sysfs entries */ | 844 | err = rtc_add_group(priv->rtc, &rtc_calib_attr_group); |
852 | err = sysfs_create_group(&(&client->dev)->kobj, &rtc_calib_attr_group); | ||
853 | if (err) { | 845 | if (err) { |
854 | dev_err(&client->dev, "Failed to create sysfs group: %d\n", | 846 | dev_err(&client->dev, "Failed to create sysfs group: %d\n", |
855 | err); | 847 | err); |
856 | return err; | 848 | return err; |
857 | } | 849 | } |
858 | 850 | ||
859 | err = devm_add_action_or_reset(&client->dev, | 851 | return rtc_register_device(priv->rtc); |
860 | rtc_calib_remove_sysfs_group, | ||
861 | &client->dev); | ||
862 | if (err) { | ||
863 | dev_err(&client->dev, | ||
864 | "Failed to add sysfs cleanup action: %d\n", | ||
865 | err); | ||
866 | return err; | ||
867 | } | ||
868 | |||
869 | err = rtc_register_device(priv->rtc); | ||
870 | |||
871 | return err; | ||
872 | } | 852 | } |
873 | 853 | ||
874 | static int abx80x_remove(struct i2c_client *client) | 854 | static int abx80x_remove(struct i2c_client *client) |