From: Gary Bisson <gary.bisson@boundarydevices.com>
To: rtc-linux@googlegroups.com
Cc: linux-kernel@vger.kernel.org,
alexandre.belloni@free-electrons.com, a.zummo@towertech.it,
Gary Bisson <gary.bisson@boundarydevices.com>
Subject: [PATCH 3/4] rtc: m41t80: remove sqw sysfs entry
Date: Tue, 25 Apr 2017 16:45:16 +0200 [thread overview]
Message-ID: <20170425144517.15962-4-gary.bisson@boundarydevices.com> (raw)
In-Reply-To: <20170425144517.15962-1-gary.bisson@boundarydevices.com>
In order to use the proper clock framework to control this feature.
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
---
drivers/rtc/rtc-m41t80.c | 88 ------------------------------------------------
1 file changed, 88 deletions(-)
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 0c142653c309..2bdf494a9bd4 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -387,96 +387,8 @@ static ssize_t flags_show(struct device *dev,
}
static DEVICE_ATTR_RO(flags);
-static ssize_t sqwfreq_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct m41t80_data *clientdata = i2c_get_clientdata(client);
- int val, reg_sqw;
-
- if (!(clientdata->features & M41T80_FEATURE_SQ))
- return -EINVAL;
-
- reg_sqw = M41T80_REG_SQW;
- if (clientdata->features & M41T80_FEATURE_SQ_ALT)
- reg_sqw = M41T80_REG_WDAY;
- val = i2c_smbus_read_byte_data(client, reg_sqw);
- if (val < 0)
- return val;
- val = (val >> 4) & 0xf;
- switch (val) {
- case 0:
- break;
- case 1:
- val = 32768;
- break;
- default:
- val = 32768 >> val;
- }
- return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t sqwfreq_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct m41t80_data *clientdata = i2c_get_clientdata(client);
- int almon, sqw, reg_sqw, rc;
- unsigned long val;
-
- rc = kstrtoul(buf, 0, &val);
- if (rc < 0)
- return rc;
-
- if (!(clientdata->features & M41T80_FEATURE_SQ))
- return -EINVAL;
-
- if (val) {
- if (!is_power_of_2(val))
- return -EINVAL;
- val = ilog2(val);
- if (val == 15)
- val = 1;
- else if (val < 14)
- val = 15 - val;
- else
- return -EINVAL;
- }
- /* disable SQW, set SQW frequency & re-enable */
- almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
- if (almon < 0)
- return almon;
- reg_sqw = M41T80_REG_SQW;
- if (clientdata->features & M41T80_FEATURE_SQ_ALT)
- reg_sqw = M41T80_REG_WDAY;
- sqw = i2c_smbus_read_byte_data(client, reg_sqw);
- if (sqw < 0)
- return sqw;
- sqw = (sqw & 0x0f) | (val << 4);
-
- rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
- almon & ~M41T80_ALMON_SQWE);
- if (rc < 0)
- return rc;
-
- if (val) {
- rc = i2c_smbus_write_byte_data(client, reg_sqw, sqw);
- if (rc < 0)
- return rc;
-
- rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
- almon | M41T80_ALMON_SQWE);
- if (rc < 0)
- return rc;
- }
- return count;
-}
-static DEVICE_ATTR_RW(sqwfreq);
-
static struct attribute *attrs[] = {
&dev_attr_flags.attr,
- &dev_attr_sqwfreq.attr,
NULL,
};
--
2.11.0
next prev parent reply other threads:[~2017-04-25 14:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 14:45 [PATCH 0/4] rtc: m41t80: improve SQW support Gary Bisson
2017-04-25 14:45 ` [PATCH 1/4] rtc: m41t80: fix SQWE override when setting an alarm Gary Bisson
2017-04-25 14:45 ` [PATCH 2/4] rtc: m41t80: fix SQW dividers override when setting a date Gary Bisson
2017-04-25 14:45 ` Gary Bisson [this message]
2017-04-25 14:45 ` [PATCH 4/4] rtc: m41t80: add clock provider support Gary Bisson
2017-05-31 1:40 ` [PATCH 0/4] rtc: m41t80: improve SQW support Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170425144517.15962-4-gary.bisson@boundarydevices.com \
--to=gary.bisson@boundarydevices.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).