From: Heiner Kallweit <hkallweit1@gmail.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: linux-rtc@vger.kernel.org
Subject: [PATCH 5/9] rtc: ds1307: improve irq setup
Date: Wed, 12 Jul 2017 07:49:37 +0200 [thread overview]
Message-ID: <e0f12929-cd91-7a78-222d-836e1f00ec0b@gmail.com> (raw)
In-Reply-To: <aded2895-cf4b-12f0-5525-c4389ccf3650@gmail.com>
Change the usage of variable want_irq to reflect its name. Don't set
it to true in case wakeup is enabled but no interrupt number is given.
In addition set variable ds1307_can_wakeup_device if chip->alarm
is set only.
This allows to simplify the code and make it better understandable.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/rtc/rtc-ds1307.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 115fe1c5..5aec1761 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1312,7 +1312,7 @@ static int ds1307_probe(struct i2c_client *client,
int err = -ENODEV;
int tmp, wday;
const struct chip_desc *chip;
- bool want_irq = false;
+ bool want_irq;
bool ds1307_can_wakeup_device = false;
unsigned char *buf;
struct ds1307_platform_data *pdata = dev_get_platdata(&client->dev);
@@ -1358,6 +1358,8 @@ static int ds1307_probe(struct i2c_client *client,
ds1307->type = acpi_id->driver_data;
}
+ want_irq = client->irq > 0 && chip->alarm;
+
if (!pdata)
trickle_charger_setup = ds1307_trickle_init(ds1307, chip);
else if (pdata->trickle_charger_setup)
@@ -1383,7 +1385,8 @@ static int ds1307_probe(struct i2c_client *client,
* This will guarantee the 'wakealarm' sysfs entry is available on the device,
* if supported by the RTC.
*/
- if (of_property_read_bool(client->dev.of_node, "wakeup-source"))
+ if (chip->alarm && of_property_read_bool(client->dev.of_node,
+ "wakeup-source"))
ds1307_can_wakeup_device = true;
#endif
@@ -1409,12 +1412,9 @@ static int ds1307_probe(struct i2c_client *client,
* For some variants, be sure alarms can trigger when we're
* running on Vbackup (BBSQI/BBSQW)
*/
- if (chip->alarm && (client->irq > 0 ||
- ds1307_can_wakeup_device)) {
+ if (want_irq || ds1307_can_wakeup_device) {
ds1307->regs[0] |= DS1337_BIT_INTCN | chip->bbsqi_bit;
ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE);
-
- want_irq = true;
}
regmap_write(ds1307->regmap, DS1337_REG_CONTROL,
@@ -1493,21 +1493,16 @@ static int ds1307_probe(struct i2c_client *client,
case rx_8130:
ds1307->offset = 0x10; /* Seconds starts at 0x10 */
rtc_ops = &rx8130_rtc_ops;
- if (chip->alarm && client->irq > 0) {
+ if (want_irq)
irq_handler = rx8130_irq;
- want_irq = true;
- }
break;
case ds_1388:
ds1307->offset = 1; /* Seconds starts at 1 */
break;
case mcp794xx:
rtc_ops = &mcp794xx_rtc_ops;
- if (chip->alarm && (client->irq > 0 ||
- ds1307_can_wakeup_device)) {
+ if (want_irq || ds1307_can_wakeup_device)
irq_handler = mcp794xx_irq;
- want_irq = true;
- }
break;
default:
break;
@@ -1639,7 +1634,7 @@ static int ds1307_probe(struct i2c_client *client,
MCP794XX_REG_WEEKDAY_WDAY_MASK,
tm.tm_wday + 1);
- if (want_irq) {
+ if (want_irq || ds1307_can_wakeup_device) {
device_set_wakeup_capable(ds1307->dev, true);
set_bit(HAS_ALARM, &ds1307->flags);
}
@@ -1649,9 +1644,7 @@ static int ds1307_probe(struct i2c_client *client,
return PTR_ERR(ds1307->rtc);
}
- if (ds1307_can_wakeup_device && client->irq <= 0) {
- /* Disable request for an IRQ */
- want_irq = false;
+ if (ds1307_can_wakeup_device && !want_irq) {
dev_info(ds1307->dev,
"'wakeup-source' is set, request for an IRQ is disabled!\n");
/* We cannot support UIE mode if we do not have an IRQ line */
--
2.13.2
next prev parent reply other threads:[~2017-07-12 5:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 5:23 [PATCH 0/9] rtc: ds1307: series with refactorings / improvements Heiner Kallweit
2017-07-12 5:49 ` [PATCH 1/9] rtc: ds1307: remove member irq from struct ds1307 Heiner Kallweit
2017-07-12 5:49 ` [PATCH 2/9] rtc: ds1307: factor out bbsqi bit to struct chip_desc Heiner Kallweit
2017-07-12 5:49 ` [PATCH 3/9] rtc: ds1307: improve trickle charger initialization Heiner Kallweit
2017-07-12 5:49 ` [PATCH 4/9] rtc: ds1307: constify struct chip_desc variables Heiner Kallweit
2017-07-12 5:49 ` Heiner Kallweit [this message]
2017-07-12 5:49 ` [PATCH 6/9] rtc: ds1307: factor out irq_handler to struct chip_desc Heiner Kallweit
2017-07-12 5:49 ` [PATCH 7/9] rtc: ds1307: factor out rtc_ops " Heiner Kallweit
2017-07-12 5:49 ` [PATCH 8/9] rtc: ds1307: factor out offset " Heiner Kallweit
2017-07-12 5:49 ` [PATCH 9/9] rtc: ds1307: remove member nvram_offset from struct ds1307 Heiner Kallweit
2017-08-24 21:04 ` [PATCH 0/9] rtc: ds1307: series with refactorings / improvements 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=e0f12929-cd91-7a78-222d-836e1f00ec0b@gmail.com \
--to=hkallweit1@gmail.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=linux-rtc@vger.kernel.org \
/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).