Thread (27 messages) 27 messages, 6 authors, 2012-07-31
STALE5174d

Revision v1 of 12 in this series.

Revisions (12)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v1 current
  5. v1 [diff vs current]
  6. v1 [diff vs current]
  7. v2 [diff vs current]
  8. v2 [diff vs current]
  9. v2 [diff vs current]
  10. v2 [diff vs current]
  11. v2 [diff vs current]
  12. v2 [diff vs current]

[PATCH 3/6] mv643xx.c: Add basic device tree support.

From: Ian Molton <hidden>
Date: 2012-07-30 16:32:39

On 30/07/12 17:19, Amar Nath wrote:
Hi Ian,

On Mon, Jul 30, 2012 at 8:45 PM, Ian Molton [off-list ref]wrote:
quoted
-       pd = pdev->dev.platform_data;
+       if (pdev->dev.of_node) {
+               struct device_node *np = NULL;
+
+               /* when all users of this driver use FDT, we can remove
this */
+               pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
+               if (!pd) {
+                       dev_dbg(&pdev->dev, "Could not allocate platform
data\n");
+                       return -ENOMEM;
+               }
+
+               of_property_read_u32(pdev->dev.of_node,
+                       "port_number", &pd->port_number);
+               of_property_read_u32(pdev->dev.of_node,
+                       "phy_addr", &pd->phy_addr);
+               np = of_parse_phandle(pdev->dev.of_node, "mdio", 0);
+               if (np) {
+                       pd->shared = of_find_device_by_node(np);
+               } else {
+                       kfree(pd);
+                       return -ENODEV;
+               }
+       } else {
+               pd = pdev->dev.platform_data;
+       }
+
        if (pd == NULL) {
                dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
                return -ENODEV;
Can this check for pd be moved in the else part above as well, as for the
pd allocation with kzalloc,
we have already made a check for memory allocation failure?
Yes, Folded in for v2.

-Ian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help