On Monday 31 October 2011 13:18:13 Stephen Warren wrote:
> 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.
> 
> ...
> 
> > 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.

Ok, I somehow didn't found it during my quick search.

> > +   } else {
> > +           dev_err(&pdev->dev, "no platform data\n");
> > +           goto failed;
> > +   }
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to