From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: rtc-linux@googlegroups.com
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
linux-kernel@vger.kernel.org, cphealy@gmail.com
Subject: [PATCH v2 10/17] RTC: ds1307: Constify struct ds1307 where possible
Date: Tue, 21 Jun 2016 00:22:43 -0700 [thread overview]
Message-ID: <1466493770-11895-9-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1466493770-11895-1-git-send-email-andrew.smirnov@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/rtc/rtc-ds1307.c | 50 ++++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 66e7168..67907f1 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -333,7 +333,7 @@ static s32 ds1307_native_smbus_read_block_data(const struct i2c_client *client,
static irqreturn_t ds1307_irq(int irq, void *dev_id)
{
struct i2c_client *client = dev_id;
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
struct mutex *lock = &ds1307->rtc->ops_lock;
int stat, control;
@@ -367,8 +367,8 @@ out:
static int ds1307_get_time(struct device *dev, struct rtc_time *t)
{
u8 regs[DS1307_REG_COUNT];
- struct ds1307 *ds1307 = dev_get_drvdata(dev);
int tmp;
+ const struct ds1307 *ds1307 = dev_get_drvdata(dev);
/* read the RTC date and time registers all at once */
tmp = ds1307->read_block_data(ds1307->client,
@@ -404,7 +404,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
static int ds1307_set_time(struct device *dev, struct rtc_time *t)
{
- struct ds1307 *ds1307 = dev_get_drvdata(dev);
+ const struct ds1307 *ds1307 = dev_get_drvdata(dev);
int result;
int tmp;
u8 regs[DS1307_REG_COUNT];
@@ -464,7 +464,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
int ret;
u8 regs[DS1307_REG_COUNT];
@@ -512,7 +512,7 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
u8 regs[DS1307_REG_COUNT];
u8 control, status;
int ret;
@@ -574,7 +574,7 @@ static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
int ret;
if (!test_bit(HAS_ALARM, &ds1307->flags))
@@ -629,7 +629,7 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
static irqreturn_t mcp794xx_irq(int irq, void *dev_id)
{
struct i2c_client *client = dev_id;
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
struct mutex *lock = &ds1307->rtc->ops_lock;
int reg, ret;
@@ -666,7 +666,7 @@ out:
static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
u8 regs[DS1307_REG_COUNT];
int ret;
@@ -705,7 +705,7 @@ static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t)
static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
u8 regs[DS1307_REG_COUNT];
int ret;
@@ -751,7 +751,7 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled)
{
struct i2c_client *client = to_i2c_client(dev);
- struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ const struct ds1307 *ds1307 = i2c_get_clientdata(client);
int reg;
if (!test_bit(HAS_ALARM, &ds1307->flags))
@@ -785,7 +785,7 @@ ds1307_nvram_read(struct file *filp, struct kobject *kobj,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client;
- struct ds1307 *ds1307;
+ const struct ds1307 *ds1307;
int result;
client = kobj_to_i2c_client(kobj);
@@ -804,7 +804,7 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client;
- struct ds1307 *ds1307;
+ const struct ds1307 *ds1307;
int result;
client = kobj_to_i2c_client(kobj);
@@ -880,7 +880,7 @@ out:
*/
static int ds3231_hwmon_read_temp(struct device *dev, s32 *mC)
{
- struct ds1307 *ds1307 = dev_get_drvdata(dev);
+ const struct ds1307 *ds1307 = dev_get_drvdata(dev);
u8 temp_buf[2];
s16 temp;
int ret;
@@ -973,7 +973,7 @@ static int ds3231_clk_sqw_rates[] = {
8192,
};
-static int ds1337_write_control(struct ds1307 *ds1307, u8 mask, u8 value)
+static int ds1337_write_control(const struct ds1307 *ds1307, u8 mask, u8 value)
{
struct i2c_client *client = ds1307->client;
struct mutex *lock = &ds1307->rtc->ops_lock;
@@ -1001,7 +1001,7 @@ out:
static unsigned long ds3231_clk_sqw_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
- struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
int control;
int rate_sel = 0;
@@ -1032,7 +1032,7 @@ static long ds3231_clk_sqw_round_rate(struct clk_hw *hw, unsigned long rate,
static int ds3231_clk_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
- struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
int control = 0;
int rate_sel;
@@ -1056,21 +1056,21 @@ static int ds3231_clk_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
static int ds3231_clk_sqw_prepare(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
return ds1337_write_control(ds1307, DS1337_BIT_INTCN, 0);
}
static void ds3231_clk_sqw_unprepare(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
ds1337_write_control(ds1307, DS1337_BIT_INTCN, DS1337_BIT_INTCN);
}
static int ds3231_clk_sqw_is_prepared(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_sqw_to_ds1307(hw);
int control;
control = i2c_smbus_read_byte_data(ds1307->client, DS1337_REG_CONTROL);
@@ -1095,7 +1095,7 @@ static unsigned long ds3231_clk_32khz_recalc_rate(struct clk_hw *hw,
return 32768;
}
-static int ds3231_clk_32khz_control(struct ds1307 *ds1307, bool enable)
+static int ds3231_clk_32khz_control(const struct ds1307 *ds1307, bool enable)
{
struct i2c_client *client = ds1307->client;
struct mutex *lock = &ds1307->rtc->ops_lock;
@@ -1124,21 +1124,21 @@ out:
static int ds3231_clk_32khz_prepare(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
return ds3231_clk_32khz_control(ds1307, true);
}
static void ds3231_clk_32khz_unprepare(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
ds3231_clk_32khz_control(ds1307, false);
}
static int ds3231_clk_32khz_is_prepared(struct clk_hw *hw)
{
- struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
+ const struct ds1307 *ds1307 = clk_32khz_to_ds1307(hw);
int status;
status = i2c_smbus_read_byte_data(ds1307->client, DS1337_REG_STATUS);
@@ -1273,7 +1273,7 @@ static bool ds1307_want_irq(const struct ds1307 *ds1307,
return false;
}
-static int ds1307_chip_configure(struct ds1307 *ds1307)
+static int ds1307_chip_configure(const struct ds1307 *ds1307)
{
int tmp;
u8 regs[DS1307_REG_COUNT];
@@ -1422,7 +1422,7 @@ static int ds1307_chip_configure(struct ds1307 *ds1307)
return 0;
}
-static int ds1307_chip_sanity_check(struct ds1307 *ds1307)
+static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
{
int tmp;
u8 regs[DS1307_REG_COUNT];
--
2.5.5
next prev parent reply other threads:[~2016-06-21 7:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 7:22 [PATCH v2 02/17] RTC: ds1307: Disable square wave and timers as default Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 03/17] RTC: ds1307: Add devicetree bindings for DS1341 Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 04/17] RTC: ds1307: Add DS1341 specific power-saving options Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 05/17] RTC: ds1307: Convert ds1307_can_wakeup_device into a predicate Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 06/17] RTC: ds1307: Convert want_irq " Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 07/17] RTC: ds1307: Move chip configuration into a separate routine Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 08/17] RTC: ds1307: Move chip sanity checking " Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 09/17] RTC: ds1307: Remove register "cache" Andrey Smirnov
2016-06-21 7:22 ` Andrey Smirnov [this message]
2016-06-21 7:22 ` [PATCH v2 11/17] RTC: ds1307: Convert goto to a loop Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 12/17] RTC: ds1307: Redefine RX8025_REG_* to minimize extra code Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 13/17] RTC: ds1307: Report oscillator problems more intelligently Andrey Smirnov
2016-06-21 21:22 ` Alexandre Belloni
2016-06-21 23:06 ` Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 14/17] RTC: ds1307: Move last bits of sanity checking out of chip_configure Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 15/17] RTC: rtctest: Change alarm IRQ support detection Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 16/17] RTC: rtctest: Change no IRQ detection for RTC_IRQP_READ Andrey Smirnov
2016-06-21 7:22 ` [PATCH v2 17/17] RTC: rtctest: Change no IRQ detection for RTC_IRQP_SET Andrey Smirnov
2016-06-21 21:17 ` [PATCH v2 02/17] RTC: ds1307: Disable square wave and timers as default Alexandre Belloni
2016-06-21 23:43 ` Andrey Smirnov
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=1466493770-11895-9-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=cphealy@gmail.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
all inboxes | Powered by JetHome®