All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nishanth Menon <nm@ti.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	balbi@ti.com
Subject: Re: [PATCH V2 4/5] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
Date: Wed, 1 Jul 2015 14:54:04 +0200	[thread overview]
Message-ID: <20150701125404.GR485@piout.net> (raw)
In-Reply-To: <20150624162654.GA29259@kahuna>

Hi,

On 24/06/2015 at 11:26:54 -0500, Nishanth Menon wrote :
> I am wrong here - code just returns 0 and ignores err. So, how about
> the following patch instead: (Alexandre, please do let me know if the
> entire series needs to be reposted):

Can you resend just that one as v3? I'll take it right away. Thanks!

>  - improvement as suggested
>  - Picked up previous acks
>  - cleanup in probe does not need dev_pm_clear_wake_irq.
> -->8<---
> From 12367f8edffc25613f6f920d9bd7b69dfed57ce1 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Mon, 22 Jun 2015 14:13:19 -0500
> Subject: [PATCH V3] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt
>  source
> 
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
> 
> Let's add support for the optional second interrupt for wake-up using
> the generic wakeirq support added in commit 4990d4fe327b ("PM /
> Wakeirq: Add automated device wake IRQ handling")
> 
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
> 
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up") + ee83bd3b6483 ("serial: omap: Switch
> wake-up interrupt to generic wakeirq")
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>  drivers/rtc/rtc-ds1307.c |   36 +++++++++++++++++++++++++++++++++---
>  1 file changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index b03880fc32b5..e16989c48a90 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,9 @@
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/rtc/ds1307.h>
>  #include <linux/rtc.h>
>  #include <linux/slab.h>
> @@ -114,6 +117,7 @@ struct ds1307 {
>  #define HAS_ALARM	1		/* bit 1 == irq claimed */
>  	struct i2c_client	*client;
>  	struct rtc_device	*rtc;
> +	int			wakeirq;
>  	s32 (*read_block_data)(const struct i2c_client *client, u8 command,
>  			       u8 length, u8 *values);
>  	s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -1156,6 +1160,8 @@ read_rtc:
>  	}
>  
>  	if (want_irq) {
> +		struct device_node *node = client->dev.of_node;
> +
>  		err = devm_request_threaded_irq(&client->dev,
>  						client->irq, NULL, irq_handler,
>  						IRQF_SHARED | IRQF_ONESHOT,
> @@ -1163,13 +1169,34 @@ read_rtc:
>  		if (err) {
>  			client->irq = 0;
>  			dev_err(&client->dev, "unable to request IRQ!\n");
> -		} else {
> +			goto no_irq;
> +		}
>  
> -			set_bit(HAS_ALARM, &ds1307->flags);
> -			dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +		set_bit(HAS_ALARM, &ds1307->flags);
> +		dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +
> +		/* Currently supported by OF code only! */
> +		if (!node)
> +			goto no_irq;
> +
> +		err = of_irq_get(node, 1);
> +		if (err <= 0) {
> +			if (err == -EPROBE_DEFER)
> +				goto exit;
> +			goto no_irq;
> +		}
> +		ds1307->wakeirq = err;
> +
> +		err = dev_pm_set_dedicated_wake_irq(&client->dev,
> +						    ds1307->wakeirq);
> +		if (err) {
> +			dev_err(&client->dev, "unable to setup wakeIRQ %d!\n",
> +				err);
> +			goto exit;
>  		}
>  	}
>  
> +no_irq:
>  	if (chip->nvram_size) {
>  
>  		ds1307->nvram = devm_kzalloc(&client->dev,
> @@ -1213,6 +1240,9 @@ static int ds1307_remove(struct i2c_client *client)
>  {
>  	struct ds1307 *ds1307 = i2c_get_clientdata(client);
>  
> +	if (ds1307->wakeirq)
> +		dev_pm_clear_wake_irq(&client->dev);
> +
>  	if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
>  		sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
>  
> -- 
> 1.7.9.5
> 
> -- 
> Regards,
> Nishanth Menon

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nishanth Menon <nm@ti.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	balbi@ti.com
Subject: [rtc-linux] Re: [PATCH V2 4/5] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
Date: Wed, 1 Jul 2015 14:54:04 +0200	[thread overview]
Message-ID: <20150701125404.GR485@piout.net> (raw)
In-Reply-To: <20150624162654.GA29259@kahuna>

Hi,

On 24/06/2015 at 11:26:54 -0500, Nishanth Menon wrote :
> I am wrong here - code just returns 0 and ignores err. So, how about
> the following patch instead: (Alexandre, please do let me know if the
> entire series needs to be reposted):

Can you resend just that one as v3? I'll take it right away. Thanks!

>  - improvement as suggested
>  - Picked up previous acks
>  - cleanup in probe does not need dev_pm_clear_wake_irq.
> -->8<---
> From 12367f8edffc25613f6f920d9bd7b69dfed57ce1 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Mon, 22 Jun 2015 14:13:19 -0500
> Subject: [PATCH V3] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt
>  source
> 
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
> 
> Let's add support for the optional second interrupt for wake-up using
> the generic wakeirq support added in commit 4990d4fe327b ("PM /
> Wakeirq: Add automated device wake IRQ handling")
> 
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
> 
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up") + ee83bd3b6483 ("serial: omap: Switch
> wake-up interrupt to generic wakeirq")
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>  drivers/rtc/rtc-ds1307.c |   36 +++++++++++++++++++++++++++++++++---
>  1 file changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index b03880fc32b5..e16989c48a90 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,9 @@
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/rtc/ds1307.h>
>  #include <linux/rtc.h>
>  #include <linux/slab.h>
> @@ -114,6 +117,7 @@ struct ds1307 {
>  #define HAS_ALARM	1		/* bit 1 == irq claimed */
>  	struct i2c_client	*client;
>  	struct rtc_device	*rtc;
> +	int			wakeirq;
>  	s32 (*read_block_data)(const struct i2c_client *client, u8 command,
>  			       u8 length, u8 *values);
>  	s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -1156,6 +1160,8 @@ read_rtc:
>  	}
>  
>  	if (want_irq) {
> +		struct device_node *node = client->dev.of_node;
> +
>  		err = devm_request_threaded_irq(&client->dev,
>  						client->irq, NULL, irq_handler,
>  						IRQF_SHARED | IRQF_ONESHOT,
> @@ -1163,13 +1169,34 @@ read_rtc:
>  		if (err) {
>  			client->irq = 0;
>  			dev_err(&client->dev, "unable to request IRQ!\n");
> -		} else {
> +			goto no_irq;
> +		}
>  
> -			set_bit(HAS_ALARM, &ds1307->flags);
> -			dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +		set_bit(HAS_ALARM, &ds1307->flags);
> +		dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +
> +		/* Currently supported by OF code only! */
> +		if (!node)
> +			goto no_irq;
> +
> +		err = of_irq_get(node, 1);
> +		if (err <= 0) {
> +			if (err == -EPROBE_DEFER)
> +				goto exit;
> +			goto no_irq;
> +		}
> +		ds1307->wakeirq = err;
> +
> +		err = dev_pm_set_dedicated_wake_irq(&client->dev,
> +						    ds1307->wakeirq);
> +		if (err) {
> +			dev_err(&client->dev, "unable to setup wakeIRQ %d!\n",
> +				err);
> +			goto exit;
>  		}
>  	}
>  
> +no_irq:
>  	if (chip->nvram_size) {
>  
>  		ds1307->nvram = devm_kzalloc(&client->dev,
> @@ -1213,6 +1240,9 @@ static int ds1307_remove(struct i2c_client *client)
>  {
>  	struct ds1307 *ds1307 = i2c_get_clientdata(client);
>  
> +	if (ds1307->wakeirq)
> +		dev_pm_clear_wake_irq(&client->dev);
> +
>  	if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
>  		sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
>  
> -- 
> 1.7.9.5
> 
> -- 
> Regards,
> Nishanth Menon

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

WARNING: multiple messages have this Message-ID (diff)
From: alexandre.belloni@free-electrons.com (Alexandre Belloni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 4/5] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
Date: Wed, 1 Jul 2015 14:54:04 +0200	[thread overview]
Message-ID: <20150701125404.GR485@piout.net> (raw)
In-Reply-To: <20150624162654.GA29259@kahuna>

Hi,

On 24/06/2015 at 11:26:54 -0500, Nishanth Menon wrote :
> I am wrong here - code just returns 0 and ignores err. So, how about
> the following patch instead: (Alexandre, please do let me know if the
> entire series needs to be reposted):

Can you resend just that one as v3? I'll take it right away. Thanks!

>  - improvement as suggested
>  - Picked up previous acks
>  - cleanup in probe does not need dev_pm_clear_wake_irq.
> -->8<---
> From 12367f8edffc25613f6f920d9bd7b69dfed57ce1 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Mon, 22 Jun 2015 14:13:19 -0500
> Subject: [PATCH V3] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt
>  source
> 
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
> 
> Let's add support for the optional second interrupt for wake-up using
> the generic wakeirq support added in commit 4990d4fe327b ("PM /
> Wakeirq: Add automated device wake IRQ handling")
> 
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
> 
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up") + ee83bd3b6483 ("serial: omap: Switch
> wake-up interrupt to generic wakeirq")
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>  drivers/rtc/rtc-ds1307.c |   36 +++++++++++++++++++++++++++++++++---
>  1 file changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index b03880fc32b5..e16989c48a90 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,9 @@
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/rtc/ds1307.h>
>  #include <linux/rtc.h>
>  #include <linux/slab.h>
> @@ -114,6 +117,7 @@ struct ds1307 {
>  #define HAS_ALARM	1		/* bit 1 == irq claimed */
>  	struct i2c_client	*client;
>  	struct rtc_device	*rtc;
> +	int			wakeirq;
>  	s32 (*read_block_data)(const struct i2c_client *client, u8 command,
>  			       u8 length, u8 *values);
>  	s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -1156,6 +1160,8 @@ read_rtc:
>  	}
>  
>  	if (want_irq) {
> +		struct device_node *node = client->dev.of_node;
> +
>  		err = devm_request_threaded_irq(&client->dev,
>  						client->irq, NULL, irq_handler,
>  						IRQF_SHARED | IRQF_ONESHOT,
> @@ -1163,13 +1169,34 @@ read_rtc:
>  		if (err) {
>  			client->irq = 0;
>  			dev_err(&client->dev, "unable to request IRQ!\n");
> -		} else {
> +			goto no_irq;
> +		}
>  
> -			set_bit(HAS_ALARM, &ds1307->flags);
> -			dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +		set_bit(HAS_ALARM, &ds1307->flags);
> +		dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> +
> +		/* Currently supported by OF code only! */
> +		if (!node)
> +			goto no_irq;
> +
> +		err = of_irq_get(node, 1);
> +		if (err <= 0) {
> +			if (err == -EPROBE_DEFER)
> +				goto exit;
> +			goto no_irq;
> +		}
> +		ds1307->wakeirq = err;
> +
> +		err = dev_pm_set_dedicated_wake_irq(&client->dev,
> +						    ds1307->wakeirq);
> +		if (err) {
> +			dev_err(&client->dev, "unable to setup wakeIRQ %d!\n",
> +				err);
> +			goto exit;
>  		}
>  	}
>  
> +no_irq:
>  	if (chip->nvram_size) {
>  
>  		ds1307->nvram = devm_kzalloc(&client->dev,
> @@ -1213,6 +1240,9 @@ static int ds1307_remove(struct i2c_client *client)
>  {
>  	struct ds1307 *ds1307 = i2c_get_clientdata(client);
>  
> +	if (ds1307->wakeirq)
> +		dev_pm_clear_wake_irq(&client->dev);
> +
>  	if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
>  		sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
>  
> -- 
> 1.7.9.5
> 
> -- 
> Regards,
> Nishanth Menon

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  parent reply	other threads:[~2015-07-01 12:54 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 16:15 [PATCH V2 0/5] drivers/rtc/rtc-ds1307.c: Basic cleanups and support for wakeupirq Nishanth Menon
2015-06-23 16:15 ` Nishanth Menon
2015-06-23 16:15 ` Nishanth Menon
2015-06-23 16:15 ` [rtc-linux] " Nishanth Menon
2015-06-23 16:15 ` [PATCH V2 1/5] drivers/rtc/rtc-ds1307.c: Convert to threaded IRQ Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` [rtc-linux] " Nishanth Menon
2015-06-23 16:15 ` [PATCH V2 2/5] drivers/rtc/rtc-ds1307.c: Switch to managed irq allocation Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` [rtc-linux] " Nishanth Menon
2015-06-23 16:15 ` [PATCH V2 3/5] drivers/rtc/rtc-ds1307.c: Sort the headers Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` [rtc-linux] " Nishanth Menon
2015-06-23 16:15 ` [PATCH V2 4/5] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` [rtc-linux] " Nishanth Menon
2015-06-24 10:54   ` Tony Lindgren
2015-06-24 10:54     ` Tony Lindgren
2015-06-24 10:54     ` [rtc-linux] " Tony Lindgren
2015-06-24 15:36   ` Grygorii Strashko
2015-06-24 15:36     ` Grygorii Strashko
2015-06-24 15:36     ` Grygorii Strashko
2015-06-24 15:36     ` [rtc-linux] " Grygorii Strashko
2015-06-24 16:07     ` Nishanth Menon
2015-06-24 16:07       ` Nishanth Menon
2015-06-24 16:07       ` Nishanth Menon
2015-06-24 16:07       ` [rtc-linux] " Nishanth Menon
2015-06-24 16:25       ` Grygorii Strashko
2015-06-24 16:25         ` Grygorii Strashko
2015-06-24 16:25         ` Grygorii Strashko
2015-06-24 16:25         ` [rtc-linux] " Grygorii Strashko
2015-06-24 16:26       ` Nishanth Menon
2015-06-24 16:26         ` Nishanth Menon
2015-06-24 16:26         ` Nishanth Menon
2015-06-24 16:26         ` [rtc-linux] " Nishanth Menon
2015-06-25 17:23         ` Grygorii Strashko
2015-06-25 17:23           ` Grygorii Strashko
2015-06-25 17:23           ` Grygorii Strashko
2015-06-25 17:23           ` [rtc-linux] " Grygorii Strashko
2015-07-01 12:54         ` Alexandre Belloni [this message]
2015-07-01 12:54           ` Alexandre Belloni
2015-07-01 12:54           ` [rtc-linux] " Alexandre Belloni
2015-06-23 16:15 ` [TMP PATCH V2 5/5] ARM: dts: am57xx-beagle-x15: Add wakeup irq for mcp79410 Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` Nishanth Menon
2015-06-23 16:15   ` [rtc-linux] " Nishanth Menon
2015-06-24 14:34 ` [PATCH V2 0/5] drivers/rtc/rtc-ds1307.c: Basic cleanups and support for wakeupirq Felipe Balbi
2015-06-24 14:34   ` Felipe Balbi
2015-06-24 14:34   ` Felipe Balbi
2015-06-24 14:34   ` [rtc-linux] " Felipe Balbi
2015-06-24 15:37   ` Grygorii Strashko
2015-06-24 15:37     ` Grygorii Strashko
2015-06-24 15:37     ` Grygorii Strashko
2015-06-24 15:37     ` [rtc-linux] " Grygorii Strashko
2015-07-02 22:47 ` Alexandre Belloni
2015-07-02 22:47   ` Alexandre Belloni
2015-07-02 22:47   ` [rtc-linux] " 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=20150701125404.GR485@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=a.zummo@towertech.it \
    --cc=balbi@ti.com \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.