Thread (10 messages) 10 messages, 2 authors, 2011-10-31
STALE5375d
Revisions (7)
  1. v3 [diff vs current]
  2. v3 current
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v4 [diff vs current]
  6. v4 [diff vs current]
  7. v4 [diff vs current]

[PATCH 2/3] staging: nvec: add device tree support

From: Stephen Warren <hidden>
Date: 2011-10-31 20:18:13
Also in: linux-tegra

Marc Dietrich wrote at Monday, October 31, 2011 1:59 PM:
This adds device tree support to the nvec driver. By using this method
it is no longer necessary to specify platform data through a board
file.
...
quoted hunk ↗ jump to hunk
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
...
+	if (pdata) {
+		nvec->gpio = pdata->gpio;
+		nvec->i2c_addr = pdata->i2c_addr;
+	} else if (nvec->dev->of_node) {
+		nvec->gpio = of_get_named_gpio(nvec->dev->of_node, "request-gpios", 0);
+		if (nvec->gpio < 0) {
+			dev_err(&pdev->dev, "no gpio specified");
+			goto failed;
+		}
+		prop = of_get_property(nvec->dev->of_node, "slave-addr", NULL);
+		if (!prop) {
+			dev_err(&pdev->dev, "no i2c address specified");
+			goto failed;
+		}
+		nvec->i2c_addr = be32_to_cpup(prop);
----------==========----------==========----------==========----------==========
Don't you want to use of_property_read_u32() here to simplify the code
slightly? You can also get rid of at least one #include that way.
+	} else {
+		dev_err(&pdev->dev, "no platform data\n");
+		goto failed;
+	}
-- 
nvpublic
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help