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

Florian Fainelli florian at openwrt.org
Tue Jul 31 11:12:39 EDT 2012


Hello Ian,

On Monday 30 July 2012 17:32:39 Ian Molton wrote:
> On 30/07/12 17:19, Amar Nath wrote:
> > Hi Ian,
> >
> > On Mon, Jul 30, 2012 at 8:45 PM, Ian Molton 
<ian.molton at codethink.co.uk>wrote:
> >
> >> -       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);

Do you really need an allocation in atomic context here? Is not GFP_KERNEL 
sufficient?

There was a second place like this where you used an atomic allocation that 
needs fixing.

> >> +               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
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



More information about the linux-arm-kernel mailing list