PPC driver - generic bus width

Michael Ellerman michael at ellerman.id.au
Thu Aug 27 00:22:45 EST 2009


On Wed, 2009-08-26 at 10:25 -0300, Alemao wrote:
> Hi all,
> 
> Im trying to develop a driver for my device, and its data bus can be 8, 16
> or 32 bits. This information is passed through the device tree source.
> My code is like this:
> 
> struct device_info_t {
> 	void (*read)();
> 	void (*write)();
> };
> 
> static int __devinit device_probe()
> {
> 	prop = of_get_property(ofdev->node, "bus-width", &size);
> 
> 	device->bus_width = *prop;
> 
> 	switch (device->bus_width) {
> 	case 8:
> 		device->read  = in_8;
> 		device->write = out_8;
> 		break;
> 	case 16:
> 		device->read  = in_be16;
> 		device->write = out_be16;
> 		break;
> 	case 32:
> 		device->read  = in_be32;
> 		device->write = out_be32;
> 		break;
> 	default:
> 		break;
> 	}
> }
> 
> Can someone point me some driver that is doing something similar to the
> ideia shown above?
> 
> Or what Im doing wrong in my code? Cause Im getting erros (warnings) like:
> 
> cc1: warnings being treated as errors
> drivers/dev_test.c:37: warning: function declaration isn't a prototype
> drivers/dev_test.c:38: warning: function declaration isn't a prototype
> drivers/dev_test.c: In function 'device_probe':
> drivers/dev_test.c:113: warning: assignment from incompatible pointer
> type

I'm not sure about the first two, you don't seem to have pasted all the
source, and you haven't given the line numbers.

The 3rd is probably because the prototype for in_8 etc. doesn't match
your structure.

cheers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20090827/33ec3ec9/attachment-0002.pgp>


More information about the Linuxppc-dev mailing list