public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: tps65910: Handle clear-mask correctly desc
       [not found] <Marcus Folkesson <marcus.folkesson@gmail.com>
@ 2011-11-22 13:39 ` Marcus Folkesson
  2011-11-22 13:39   ` [PATCH] mfd: tps65910: Handle clear-mask correctly Marcus Folkesson
  2013-11-22  7:16 ` [PATCH RESEND] rtc: ds1511: add device-tree bindings Marcus Folkesson
  1 sibling, 1 reply; 7+ messages in thread
From: Marcus Folkesson @ 2011-11-22 13:39 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel

Clear the bitmask as the function says.

I was just wondering why my regulator did not turn off... :-)


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

* [PATCH] mfd: tps65910: Handle clear-mask correctly
  2011-11-22 13:39 ` [PATCH] mfd: tps65910: Handle clear-mask correctly desc Marcus Folkesson
@ 2011-11-22 13:39   ` Marcus Folkesson
  2011-12-12 14:30     ` Samuel Ortiz
  0 siblings, 1 reply; 7+ messages in thread
From: Marcus Folkesson @ 2011-11-22 13:39 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Marcus Folkesson

The function is not actually cleaing the bitmask.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/mfd/tps65910.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 6f5b8cf..c1da84b 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -120,7 +120,7 @@ int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask)
 		goto out;
 	}
 
-	data &= mask;
+	data &= ~mask;
 	err = tps65910_i2c_write(tps65910, reg, 1, &data);
 	if (err)
 		dev_err(tps65910->dev, "write to reg %x failed\n", reg);
-- 
1.7.5.4


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

* Re: [PATCH] mfd: tps65910: Handle clear-mask correctly
  2011-11-22 13:39   ` [PATCH] mfd: tps65910: Handle clear-mask correctly Marcus Folkesson
@ 2011-12-12 14:30     ` Samuel Ortiz
  2011-12-12 15:04       ` Graeme Gregory
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Ortiz @ 2011-12-12 14:30 UTC (permalink / raw)
  To: Marcus Folkesson, Graeme Gregory; +Cc: linux-kernel

Hi Marcus,

On Tue, Nov 22, 2011 at 02:39:51PM +0100, Marcus Folkesson wrote:
> The function is not actually cleaing the bitmask.

This looks like a valid fix, and all the tps65910_clear_bits() callers seem to
expect that behaviour. Graeme, I'm going to try to push this one for 3.2,
unless you object to it.

Cheers,
Samuel.

> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
>  drivers/mfd/tps65910.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
> index 6f5b8cf..c1da84b 100644
> --- a/drivers/mfd/tps65910.c
> +++ b/drivers/mfd/tps65910.c
> @@ -120,7 +120,7 @@ int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask)
>  		goto out;
>  	}
>  
> -	data &= mask;
> +	data &= ~mask;
>  	err = tps65910_i2c_write(tps65910, reg, 1, &data);
>  	if (err)
>  		dev_err(tps65910->dev, "write to reg %x failed\n", reg);
> -- 
> 1.7.5.4
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* Re: [PATCH] mfd: tps65910: Handle clear-mask correctly
  2011-12-12 14:30     ` Samuel Ortiz
@ 2011-12-12 15:04       ` Graeme Gregory
  0 siblings, 0 replies; 7+ messages in thread
From: Graeme Gregory @ 2011-12-12 15:04 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: Marcus Folkesson, linux-kernel

I missed the original mail, but yes it looks good to me please push.

Graeme

On 12/12/11 08:30, Samuel Ortiz wrote:
> Hi Marcus,
>
> On Tue, Nov 22, 2011 at 02:39:51PM +0100, Marcus Folkesson wrote:
>> The function is not actually cleaing the bitmask.
> This looks like a valid fix, and all the tps65910_clear_bits() callers seem to
> expect that behaviour. Graeme, I'm going to try to push this one for 3.2,
> unless you object to it.
>
> Cheers,
> Samuel.
>
>> Signed-off-by: Marcus Folkesson<marcus.folkesson@gmail.com>
>> ---
>>   drivers/mfd/tps65910.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
>> index 6f5b8cf..c1da84b 100644
>> --- a/drivers/mfd/tps65910.c
>> +++ b/drivers/mfd/tps65910.c
>> @@ -120,7 +120,7 @@ int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask)
>>   		goto out;
>>   	}
>>
>> -	data&= mask;
>> +	data&= ~mask;
>>   	err = tps65910_i2c_write(tps65910, reg, 1,&data);
>>   	if (err)
>>   		dev_err(tps65910->dev, "write to reg %x failed\n", reg);
>> -- 
>> 1.7.5.4
>>


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

* [PATCH RESEND] rtc: ds1511: add device-tree bindings
       [not found] <Marcus Folkesson <marcus.folkesson@gmail.com>
  2011-11-22 13:39 ` [PATCH] mfd: tps65910: Handle clear-mask correctly desc Marcus Folkesson
@ 2013-11-22  7:16 ` Marcus Folkesson
  2013-11-22  7:16   ` [PATCH] " Marcus Folkesson
  1 sibling, 1 reply; 7+ messages in thread
From: Marcus Folkesson @ 2013-11-22  7:16 UTC (permalink / raw)
  To: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, a.zummo, grant.likely
  Cc: devicetree, linux-doc, linux-kernel, rtc-linux

Resending patch.


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

* [PATCH] rtc: ds1511: add device-tree bindings
  2013-11-22  7:16 ` [PATCH RESEND] rtc: ds1511: add device-tree bindings Marcus Folkesson
@ 2013-11-22  7:16   ` Marcus Folkesson
  2013-11-22  9:26     ` Mark Rutland
  0 siblings, 1 reply; 7+ messages in thread
From: Marcus Folkesson @ 2013-11-22  7:16 UTC (permalink / raw)
  To: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, a.zummo, grant.likely
  Cc: devicetree, linux-doc, linux-kernel, rtc-linux, Marcus Folkesson

Compatible with ds1500, ds1501 and ds1511

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 .../devicetree/bindings/rtc/maxim-ds1511.txt       |   18 +++++
 drivers/rtc/rtc-ds1511.c                           |   85 +++++++++++++++++---
 2 files changed, 90 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/maxim-ds1511.txt

diff --git a/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt b/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt
new file mode 100644
index 0000000..17fa356
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt
@@ -0,0 +1,18 @@
+* Maxim Real Time Clock
+
+
+Support for Maxim DS1500, DS1501 and DS1511 RTC.
+
+Required properties:
+- compatible : Should be "maxim,ds1500-rtc", "maxim,ds1501-rtc" or "maxim,ds1511-rtc".
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: IRQ line for the RTC.
+
+Example:
+
+rtc@10300 {
+        compatible = "maxim,ds1511-rtc";
+        reg = <0xd0010300 0x20>;
+        interrupts = <50>;
+};
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 6a3fcfe..3778a8e 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -24,6 +24,9 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #define DRV_VERSION "0.6"
 
@@ -476,6 +479,52 @@ static struct bin_attribute ds1511_nvram_attr = {
 	.write = ds1511_nvram_write,
 };
 
+
+
+#ifdef CONFIG_OF
+static int ds1511_of_probe(struct platform_device *pdev,
+	 struct rtc_plat_data *pdata)
+{
+	struct device *dev = &pdev->dev;
+	u32 val;
+	int ret;
+	struct resource res;
+
+	ret = of_address_to_resource(&pdev->dev.of_node, 0, &res);
+	if (ret)
+		return -ENODEV;
+
+	pdata->size = resource_size(&res);
+
+	if (!devm_request_mem_region(&pdev->dev, res.start, pdata->size,
+			pdev->name))
+		return -EBUSY;
+
+	ds1511_base = devm_ioremap(&pdev->dev, res.start, pdata->size);
+	if (!ds1511_base)
+		return -ENOMEM;
+
+	pdata->ioaddr = ds1511_base;
+	pdata->irq = irq_of_parse_and_map(&pdev->dev.of_node, 0);
+
+	return 0;
+}
+
+static const struct of_device_id rtc_of_match[] = {
+	{ .compatible = "maxim,ds1500-rtc" },
+	{ .compatible = "maxim,ds1501-rtc" },
+	{ .compatible = "maxim,ds1511-rtc" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, rtc_of_match);
+
+#else
+static int ds1511_of_probe(struct platform_device *pdev, struct rtc_plat_data *pdata)
+{
+	return -ENODEV;
+}
+#endif
+
 static int ds1511_rtc_probe(struct platform_device *pdev)
 {
 	struct rtc_device *rtc;
@@ -483,22 +532,31 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
 	struct rtc_plat_data *pdata;
 	int ret = 0;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		return -ENODEV;
-	}
 	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
-	pdata->size = resource_size(res);
-	if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
-			pdev->name))
-		return -EBUSY;
-	ds1511_base = devm_ioremap(&pdev->dev, res->start, pdata->size);
-	if (!ds1511_base)
-		return -ENOMEM;
-	pdata->ioaddr = ds1511_base;
-	pdata->irq = platform_get_irq(pdev, 0);
+
+	if (pdev->dev.of_node) {
+		ret = ds1511_of_probe(pdev, pdata);
+		if (ret < 0)
+			return ret;
+	} else if (!pdev) {
+
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res) {
+			return -ENODEV;
+		}
+		pdata->size = resource_size(res);
+		if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
+				pdev->name))
+			return -EBUSY;
+		ds1511_base = devm_ioremap(&pdev->dev, res->start, pdata->size);
+		if (!ds1511_base)
+			return -ENOMEM;
+		pdata->ioaddr = ds1511_base;
+		pdata->irq = platform_get_irq(pdev, 0);
+	} else
+		return -ENODEV;
 
 	/*
 	 * turn on the clock and the crystal, etc.
@@ -575,6 +633,7 @@ static struct platform_driver ds1511_rtc_driver = {
 	.driver		= {
 		.name	= "ds1511",
 		.owner	= THIS_MODULE,
+		.of_match_table	= of_match_ptr(rtc_of_match),
 	},
 };
 
-- 
1.7.10.4


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

* Re: [PATCH] rtc: ds1511: add device-tree bindings
  2013-11-22  7:16   ` [PATCH] " Marcus Folkesson
@ 2013-11-22  9:26     ` Mark Rutland
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Rutland @ 2013-11-22  9:26 UTC (permalink / raw)
  To: Marcus Folkesson
  Cc: rob.herring@calxeda.com, Pawel Moll, swarren@wwwdotorg.org,
	ijc+devicetree@hellion.org.uk, rob@landley.net,
	a.zummo@towertech.it, grant.likely@linaro.org,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com

On Fri, Nov 22, 2013 at 07:16:39AM +0000, Marcus Folkesson wrote:
> Compatible with ds1500, ds1501 and ds1511
> 
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
>  .../devicetree/bindings/rtc/maxim-ds1511.txt       |   18 +++++
>  drivers/rtc/rtc-ds1511.c                           |   85 +++++++++++++++++---
>  2 files changed, 90 insertions(+), 13 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/rtc/maxim-ds1511.txt
> 
> diff --git a/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt b/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt
> new file mode 100644
> index 0000000..17fa356
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/maxim-ds1511.txt
> @@ -0,0 +1,18 @@
> +* Maxim Real Time Clock
> +
> +
> +Support for Maxim DS1500, DS1501 and DS1511 RTC.
> +
> +Required properties:
> +- compatible : Should be "maxim,ds1500-rtc", "maxim,ds1501-rtc" or "maxim,ds1511-rtc".

I'd prefer each of these on an individial line:

- compatible : Should contain one of:
   * "maxim,ds1500-rtc"
   * "maxim,ds1501-rtc"
   * "maxim,ds1511-rtc"

It would also be nice to have a description of how these differ, if
possible.

> +- reg: physical base address of the controller and length of memory mapped
> +  region.
> +- interrupts: IRQ line for the RTC.
> +
> +Example:
> +
> +rtc@10300 {
> +        compatible = "maxim,ds1511-rtc";
> +        reg = <0xd0010300 0x20>;
> +        interrupts = <50>;
> +};

Otherwise, the binding looks fine to me.

> diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
> index 6a3fcfe..3778a8e 100644
> --- a/drivers/rtc/rtc-ds1511.c
> +++ b/drivers/rtc/rtc-ds1511.c
> @@ -24,6 +24,9 @@
>  #include <linux/platform_device.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
>  
>  #define DRV_VERSION "0.6"
>  
> @@ -476,6 +479,52 @@ static struct bin_attribute ds1511_nvram_attr = {
>  	.write = ds1511_nvram_write,
>  };
>  
> +
> +
> +#ifdef CONFIG_OF
> +static int ds1511_of_probe(struct platform_device *pdev,
> +	 struct rtc_plat_data *pdata)
> +{
> +	struct device *dev = &pdev->dev;
> +	u32 val;
> +	int ret;
> +	struct resource res;
> +
> +	ret = of_address_to_resource(&pdev->dev.of_node, 0, &res);
> +	if (ret)
> +		return -ENODEV;
> +

You can use platform_get_resource(pdev, IORESOURCE_MEM, 0) here as the
platform bus OF code will have already parsed this out of the dt for
you.

> +	pdata->size = resource_size(&res);
> +
> +	if (!devm_request_mem_region(&pdev->dev, res.start, pdata->size,
> +			pdev->name))
> +		return -EBUSY;
> +
> +	ds1511_base = devm_ioremap(&pdev->dev, res.start, pdata->size);
> +	if (!ds1511_base)
> +		return -ENOMEM;
> +
> +	pdata->ioaddr = ds1511_base;
> +	pdata->irq = irq_of_parse_and_map(&pdev->dev.of_node, 0);

Similarly, platform_get_resource(pdev, IORESOURCE_IRQ, 0).

There's no need to parse the dt twice.

> +
> +	return 0;
> +}
> +
> +static const struct of_device_id rtc_of_match[] = {
> +	{ .compatible = "maxim,ds1500-rtc" },
> +	{ .compatible = "maxim,ds1501-rtc" },
> +	{ .compatible = "maxim,ds1511-rtc" },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, rtc_of_match);
> +
> +#else
> +static int ds1511_of_probe(struct platform_device *pdev, struct rtc_plat_data *pdata)
> +{
> +	return -ENODEV;
> +}
> +#endif
> +
>  static int ds1511_rtc_probe(struct platform_device *pdev)
>  {
>  	struct rtc_device *rtc;
> @@ -483,22 +532,31 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
>  	struct rtc_plat_data *pdata;
>  	int ret = 0;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		return -ENODEV;
> -	}
>  	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>  	if (!pdata)
>  		return -ENOMEM;
> -	pdata->size = resource_size(res);
> -	if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
> -			pdev->name))
> -		return -EBUSY;
> -	ds1511_base = devm_ioremap(&pdev->dev, res->start, pdata->size);
> -	if (!ds1511_base)
> -		return -ENOMEM;
> -	pdata->ioaddr = ds1511_base;
> -	pdata->irq = platform_get_irq(pdev, 0);

As the platform bus OF code parses everything for you, this should have
been sufficient (with the rtc_of_match table wired up).

> +
> +	if (pdev->dev.of_node) {
> +		ret = ds1511_of_probe(pdev, pdata);
> +		if (ret < 0)
> +			return ret;
> +	} else if (!pdev) {

You've already dereferenced pdev above, if this is necessary it's
broken.

How would this get called without a pdev? I believe it can't.

> +
> +		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +		if (!res) {
> +			return -ENODEV;
> +		}
> +		pdata->size = resource_size(res);
> +		if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
> +				pdev->name))
> +			return -EBUSY;
> +		ds1511_base = devm_ioremap(&pdev->dev, res->start, pdata->size);
> +		if (!ds1511_base)
> +			return -ENOMEM;
> +		pdata->ioaddr = ds1511_base;
> +		pdata->irq = platform_get_irq(pdev, 0);

This all relies on pdev despite only being called when pdev is NULL, so
it's broken.

Thanks,
Mark.

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

end of thread, other threads:[~2013-11-22  9:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Marcus Folkesson <marcus.folkesson@gmail.com>
2011-11-22 13:39 ` [PATCH] mfd: tps65910: Handle clear-mask correctly desc Marcus Folkesson
2011-11-22 13:39   ` [PATCH] mfd: tps65910: Handle clear-mask correctly Marcus Folkesson
2011-12-12 14:30     ` Samuel Ortiz
2011-12-12 15:04       ` Graeme Gregory
2013-11-22  7:16 ` [PATCH RESEND] rtc: ds1511: add device-tree bindings Marcus Folkesson
2013-11-22  7:16   ` [PATCH] " Marcus Folkesson
2013-11-22  9:26     ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox