linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo
@ 2015-06-03  4:51 Vaibhav Jain
  2015-06-03  5:34 ` Neelesh Gupta
  2015-07-08  3:25 ` Michael Neuling
  0 siblings, 2 replies; 3+ messages in thread
From: Vaibhav Jain @ 2015-06-03  4:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Neelesh Gupta, Vaibhav Jain

rtc-opal driver provides support for rtc alarms via
times-power-on(tpo). However some platforms like BML use a fake rtc
clock and don't support tpo. Such platforms are indicated by the missing
'has-tpo' property in the device tree.

Current implementation however enables callback for
rtc_class_ops.read/set alarm irrespective of the tpo support from the
platform. This results in a failed opal call when kernel tries to read
an existing alarms via opal_get_tpo_time during rtc device registration.

This patch fixes this issue by setting opal_rtc_ops.read/set_alarm
callback pointers only when tpo is supported.

Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
---
 drivers/rtc/rtc-opal.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
index 7061dca..1125641 100644
--- a/drivers/rtc/rtc-opal.c
+++ b/drivers/rtc/rtc-opal.c
@@ -190,11 +190,9 @@ exit:
 	return rc;
 }
 
-static const struct rtc_class_ops opal_rtc_ops = {
+static struct rtc_class_ops opal_rtc_ops = {
 	.read_time	= opal_get_rtc_time,
 	.set_time	= opal_set_rtc_time,
-	.read_alarm	= opal_get_tpo_time,
-	.set_alarm	= opal_set_tpo_time,
 };
 
 static int opal_rtc_probe(struct platform_device *pdev)
@@ -202,8 +200,11 @@ static int opal_rtc_probe(struct platform_device *pdev)
 	struct rtc_device *rtc;
 
 	if (pdev->dev.of_node && of_get_property(pdev->dev.of_node, "has-tpo",
-						 NULL))
+						 NULL)) {
 		device_set_wakeup_capable(&pdev->dev, true);
+		opal_rtc_ops.read_alarm	= opal_get_tpo_time;
+		opal_rtc_ops.set_alarm = opal_set_tpo_time;
+	}
 
 	rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,
 				       THIS_MODULE);
-- 
2.2.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo
  2015-06-03  4:51 [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo Vaibhav Jain
@ 2015-06-03  5:34 ` Neelesh Gupta
  2015-07-08  3:25 ` Michael Neuling
  1 sibling, 0 replies; 3+ messages in thread
From: Neelesh Gupta @ 2015-06-03  5:34 UTC (permalink / raw)
  To: Vaibhav Jain, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1926 bytes --]



On 06/03/2015 10:21 AM, Vaibhav Jain wrote:
> rtc-opal driver provides support for rtc alarms via
> times-power-on(tpo). However some platforms like BML use a fake rtc
> clock and don't support tpo. Such platforms are indicated by the missing
> 'has-tpo' property in the device tree.
>
> Current implementation however enables callback for
> rtc_class_ops.read/set alarm irrespective of the tpo support from the
> platform. This results in a failed opal call when kernel tries to read
> an existing alarms via opal_get_tpo_time during rtc device registration.
>
> This patch fixes this issue by setting opal_rtc_ops.read/set_alarm
> callback pointers only when tpo is supported.
>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>

Acked-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>

Thanks,
Neelesh.

> ---
>   drivers/rtc/rtc-opal.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
> index 7061dca..1125641 100644
> --- a/drivers/rtc/rtc-opal.c
> +++ b/drivers/rtc/rtc-opal.c
> @@ -190,11 +190,9 @@ exit:
>   	return rc;
>   }
>
> -static const struct rtc_class_ops opal_rtc_ops = {
> +static struct rtc_class_ops opal_rtc_ops = {
>   	.read_time	= opal_get_rtc_time,
>   	.set_time	= opal_set_rtc_time,
> -	.read_alarm	= opal_get_tpo_time,
> -	.set_alarm	= opal_set_tpo_time,
>   };
>
>   static int opal_rtc_probe(struct platform_device *pdev)
> @@ -202,8 +200,11 @@ static int opal_rtc_probe(struct platform_device *pdev)
>   	struct rtc_device *rtc;
>
>   	if (pdev->dev.of_node && of_get_property(pdev->dev.of_node, "has-tpo",
> -						 NULL))
> +						 NULL)) {
>   		device_set_wakeup_capable(&pdev->dev, true);
> +		opal_rtc_ops.read_alarm	= opal_get_tpo_time;
> +		opal_rtc_ops.set_alarm = opal_set_tpo_time;
> +	}
>
>   	rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,
>   				       THIS_MODULE);


[-- Attachment #2: Type: text/html, Size: 2682 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo
  2015-06-03  4:51 [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo Vaibhav Jain
  2015-06-03  5:34 ` Neelesh Gupta
@ 2015-07-08  3:25 ` Michael Neuling
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Neuling @ 2015-07-08  3:25 UTC (permalink / raw)
  To: Vaibhav Jain; +Cc: linuxppc-dev, Neelesh Gupta

> [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo

I'd prefer to avoid the double negative and extra words.  ie.

  rtc/opal: Enable alarms only when opal supports tpo

But looks good other than that.

Acked-by: Michael Neuling <mikey@neuling.org>


On Wed, 2015-06-03 at 10:21 +0530, Vaibhav Jain wrote:
> rtc-opal driver provides support for rtc alarms via
> times-power-on(tpo). However some platforms like BML use a fake rtc
> clock and don't support tpo. Such platforms are indicated by the missing
> 'has-tpo' property in the device tree.
>=20
> Current implementation however enables callback for
> rtc_class_ops.read/set alarm irrespective of the tpo support from the
> platform. This results in a failed opal call when kernel tries to read
> an existing alarms via opal_get_tpo_time during rtc device registration.
>=20
> This patch fixes this issue by setting opal_rtc_ops.read/set_alarm
> callback pointers only when tpo is supported.
>=20
> Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
> ---
>  drivers/rtc/rtc-opal.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>=20
> diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
> index 7061dca..1125641 100644
> --- a/drivers/rtc/rtc-opal.c
> +++ b/drivers/rtc/rtc-opal.c
> @@ -190,11 +190,9 @@ exit:
>  	return rc;
>  }
> =20
> -static const struct rtc_class_ops opal_rtc_ops =3D {
> +static struct rtc_class_ops opal_rtc_ops =3D {
>  	.read_time	=3D opal_get_rtc_time,
>  	.set_time	=3D opal_set_rtc_time,
> -	.read_alarm	=3D opal_get_tpo_time,
> -	.set_alarm	=3D opal_set_tpo_time,
>  };
> =20
>  static int opal_rtc_probe(struct platform_device *pdev)
> @@ -202,8 +200,11 @@ static int opal_rtc_probe(struct platform_device *pd=
ev)
>  	struct rtc_device *rtc;
> =20
>  	if (pdev->dev.of_node && of_get_property(pdev->dev.of_node, "has-tpo",
> -						 NULL))
> +						 NULL)) {
>  		device_set_wakeup_capable(&pdev->dev, true);
> +		opal_rtc_ops.read_alarm	=3D opal_get_tpo_time;
> +		opal_rtc_ops.set_alarm =3D opal_set_tpo_time;
> +	}
> =20
>  	rtc =3D devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,
>  				       THIS_MODULE);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-08  3:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03  4:51 [PATCH] rtc/rtc-opal: Disable rtc-alarms when opal doesn't support tpo Vaibhav Jain
2015-06-03  5:34 ` Neelesh Gupta
2015-07-08  3:25 ` Michael Neuling

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).