aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-abx80x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-abx80x.c')
-rw-r--r--drivers/rtc/rtc-abx80x.c43
1 files changed, 7 insertions, 36 deletions
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 6ddcad642d1e..73830670a41f 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * A driver for the I2C members of the Abracon AB x8xx RTC family, 3 * A driver for the I2C members of the Abracon AB x8xx RTC family,
3 * and compatible: AB 1805 and AB 0805 4 * and compatible: AB 1805 and AB 0805
@@ -7,10 +8,6 @@
7 * Author: Philippe De Muyter <phdm@macqel.be> 8 * Author: Philippe De Muyter <phdm@macqel.be>
8 * Author: Alexandre Belloni <alexandre.belloni@bootlin.com> 9 * Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */ 11 */
15 12
16#include <linux/bcd.h> 13#include <linux/bcd.h>
@@ -404,7 +401,7 @@ static ssize_t autocalibration_store(struct device *dev,
404 return -EINVAL; 401 return -EINVAL;
405 } 402 }
406 403
407 retval = abx80x_rtc_set_autocalibration(dev, autocalibration); 404 retval = abx80x_rtc_set_autocalibration(dev->parent, autocalibration);
408 405
409 return retval ? retval : count; 406 return retval ? retval : count;
410} 407}
@@ -414,7 +411,7 @@ static ssize_t autocalibration_show(struct device *dev,
414{ 411{
415 int autocalibration = 0; 412 int autocalibration = 0;
416 413
417 autocalibration = abx80x_rtc_get_autocalibration(dev); 414 autocalibration = abx80x_rtc_get_autocalibration(dev->parent);
418 if (autocalibration < 0) { 415 if (autocalibration < 0) {
419 dev_err(dev, "Failed to read RTC autocalibration\n"); 416 dev_err(dev, "Failed to read RTC autocalibration\n");
420 sprintf(buf, "0\n"); 417 sprintf(buf, "0\n");
@@ -430,7 +427,7 @@ static ssize_t oscillator_store(struct device *dev,
430 struct device_attribute *attr, 427 struct device_attribute *attr,
431 const char *buf, size_t count) 428 const char *buf, size_t count)
432{ 429{
433 struct i2c_client *client = to_i2c_client(dev); 430 struct i2c_client *client = to_i2c_client(dev->parent);
434 int retval, flags, rc_mode = 0; 431 int retval, flags, rc_mode = 0;
435 432
436 if (strncmp(buf, "rc", 2) == 0) { 433 if (strncmp(buf, "rc", 2) == 0) {
@@ -472,7 +469,7 @@ static ssize_t oscillator_show(struct device *dev,
472 struct device_attribute *attr, char *buf) 469 struct device_attribute *attr, char *buf)
473{ 470{
474 int rc_mode = 0; 471 int rc_mode = 0;
475 struct i2c_client *client = to_i2c_client(dev); 472 struct i2c_client *client = to_i2c_client(dev->parent);
476 473
477 rc_mode = abx80x_is_rc_mode(client); 474 rc_mode = abx80x_is_rc_mode(client);
478 475
@@ -592,13 +589,6 @@ static int abx80x_dt_trickle_cfg(struct device_node *np)
592 return (trickle_cfg | i); 589 return (trickle_cfg | i);
593} 590}
594 591
595static void rtc_calib_remove_sysfs_group(void *_dev)
596{
597 struct device *dev = _dev;
598
599 sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group);
600}
601
602#ifdef CONFIG_WATCHDOG 592#ifdef CONFIG_WATCHDOG
603 593
604static inline u8 timeout_bits(unsigned int timeout) 594static inline u8 timeout_bits(unsigned int timeout)
@@ -851,32 +841,14 @@ static int abx80x_probe(struct i2c_client *client,
851 } 841 }
852 } 842 }
853 843
854 /* Export sysfs entries */ 844 err = rtc_add_group(priv->rtc, &rtc_calib_attr_group);
855 err = sysfs_create_group(&(&client->dev)->kobj, &rtc_calib_attr_group);
856 if (err) { 845 if (err) {
857 dev_err(&client->dev, "Failed to create sysfs group: %d\n", 846 dev_err(&client->dev, "Failed to create sysfs group: %d\n",
858 err); 847 err);
859 return err; 848 return err;
860 } 849 }
861 850
862 err = devm_add_action_or_reset(&client->dev, 851 return rtc_register_device(priv->rtc);
863 rtc_calib_remove_sysfs_group,
864 &client->dev);
865 if (err) {
866 dev_err(&client->dev,
867 "Failed to add sysfs cleanup action: %d\n",
868 err);
869 return err;
870 }
871
872 err = rtc_register_device(priv->rtc);
873
874 return err;
875}
876
877static int abx80x_remove(struct i2c_client *client)
878{
879 return 0;
880} 852}
881 853
882static const struct i2c_device_id abx80x_id[] = { 854static const struct i2c_device_id abx80x_id[] = {
@@ -899,7 +871,6 @@ static struct i2c_driver abx80x_driver = {
899 .name = "rtc-abx80x", 871 .name = "rtc-abx80x",
900 }, 872 },
901 .probe = abx80x_probe, 873 .probe = abx80x_probe,
902 .remove = abx80x_remove,
903 .id_table = abx80x_id, 874 .id_table = abx80x_id,
904}; 875};
905 876