Skip to contentSkip to conversation

mfd: tps65910: Handle clear-mask correctly desc

PATCH New Marcus Folkesson 4 participants 7 messages Nov 22, 2011 – Nov 22, 2013 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): Marcus Folkesson <[email protected]

#1 lore raw

PATCH 1/1 mfd: tps65910: Handle clear-mask correctly desc

Clear the bitmask as the function says.

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

#2 lore raw

PATCH 1/1 mfd: tps65910: Handle clear-mask correctly

The function is not actually cleaing the bitmask.

---
 drivers/mfd/tps65910.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/tps65910.c +1 -1
index 6f5b8cf..c1da84b 100644
@@ -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);
Signature · 1 line
1.7.5.4
#3 lore raw

Re: [PATCH] mfd: tps65910: Handle clear-mask correctly

Hi Marcus,

Quoted 1 line · Marcus Folkesson

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.

Quoted 21 lines
---
 drivers/mfd/tps65910.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/tps65910.c +1 -1
index 6f5b8cf..c1da84b 100644
@@ -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);
Signature · 1 line
1.7.5.4
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#4 lore raw

Re: [PATCH] mfd: tps65910: Handle clear-mask correctly

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

Graeme

Quoted 32 lines · Samuel Ortiz

Hi Marcus,

Quoted 1 line · Marcus Folkesson

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.

Quoted 21 lines
---
  drivers/mfd/tps65910.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/tps65910.c +1 -1
index 6f5b8cf..c1da84b 100644
@@ -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);
Signature · 1 line
1.7.5.4
#6 lore raw

PATCH 1/1 rtc: ds1511: add device-tree bindings

Compatible with ds1500, ds1501 and ds1511

---
 .../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
Documentation/devicetree/bindings/rtc/maxim-ds1511.txt new file +18 -0
new file mode 100644
index 0000000..17fa356
@@ -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>;
+};
drivers/rtc/rtc-ds1511.c +72 -13

112 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#7 lore raw

Re: [PATCH] rtc: ds1511: add device-tree bindings

Quoted 15 lines · Marcus Folkesson

Compatible with ds1500, ds1501 and ds1511

---
 .../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
Documentation/devicetree/bindings/rtc/maxim-ds1511.txt new file +0 -0
new file mode 100644
index 0000000..17fa356

Documentation/devicetree/bindings/rtc/maxim-ds1511.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/rtc/maxim-ds1511.txt new file +7 -0
@@ -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.

Documentation/devicetree/bindings/rtc/maxim-ds1511.txt line 18

Quoted 11 lines
Documentation/devicetree/bindings/rtc/maxim-ds1511.txt new file +11 -0
+- 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.

Quoted 23 lines
drivers/rtc/rtc-ds1511.c +8 -0
index 6a3fcfe..3778a8e 100644
@@ -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)

drivers/rtc/rtc-ds1511.c static struct bin_attribute ds1511_nvram_attr = { · line 496

Quoted 10 lines
drivers/rtc/rtc-ds1511.c +10 -0
+{
+	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.

drivers/rtc/rtc-ds1511.c static struct bin_attribute ds1511_nvram_attr = { · line 508

Quoted 12 lines
drivers/rtc/rtc-ds1511.c +12 -0
+	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.

Quoted 32 lines
drivers/rtc/rtc-ds1511.c +19 -4
+
+	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)

drivers/rtc/rtc-ds1511.c static int ds1511_rtc_probe(struct platform_device *pdev) · line 501

Quoted 10 lines
drivers/rtc/rtc-ds1511.c +0 -9
 		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).

drivers/rtc/rtc-ds1511.c static int ds1511_rtc_probe(struct platform_device *pdev) · line 543

Quoted 6 lines
drivers/rtc/rtc-ds1511.c +6 -0
+
+	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.

Quoted 4 lines
drivers/rtc/rtc-ds1511.c +4 -0
+
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res) {
+			return -ENODEV;

drivers/rtc/rtc-ds1511.c static int ds1511_rtc_probe(struct platform_device *pdev) · line 557

Quoted 10 lines
drivers/rtc/rtc-ds1511.c +10 -0
+		}
+		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.