On Sat, Sep 01, 2012 at 02:36:28PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > This will allow to detect the amba device and use the right driver for it at > runtime. > > The code is base on linux 3.5. > > + > +int amba_driver_register(struct amba_driver *drv) > +{ > + drv->drv.bus = &amba_bustype; > +#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn > + SETFN(probe); > + SETFN(remove);
Can we please drop this SETFN and just open code it? Being able to grep for amba_probe and finding its users is quite convenient. No, I don't care that in Linux it's also done like this. > +struct amba_device *amba_device_alloc(const char *name, int id, > resource_size_t base, > + size_t size) > +{ > + struct amba_device *dev; > + > + dev = xzalloc(sizeof(*dev)); > + if (dev) { xzalloc always returns a valid pointer. > + strcpy(dev->dev.name, name); > + dev->dev.id = id; > + dev->res.start = base; > + dev->res.end = base + size - 1; > + dev->res.flags = IORESOURCE_MEM; > + } > + > + return dev; > +} > + > +/** > + * struct amba_id - identifies a device on an AMBA bus > + * @id: The significant bits if the hardware device ID > + * @mask: Bitmask specifying which bits of the id field are significant when > + * matching. A driver binds to a device when ((hardware device ID) & mask) > + * == id. > + * @data: Private data used by the driver. > + */ > +struct amba_id { > + unsigned int id; > + unsigned int mask; > +#ifndef __KERNEL__ > + kernel_ulong_t data; > +#else > + void *data; > +#endif Drop this ifdef. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox