linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* PPC driver - generic bus width
@ 2009-08-26 13:25 Alemao
  2009-08-26 14:22 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Alemao @ 2009-08-26 13:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: linuxppc-dev, linuxppc-embedded

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

PS: Im using a MPC8349, linux kernel 2.6.26

Cheers,

--
Alemao

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PPC driver - generic bus width
  2009-08-26 13:25 PPC driver - generic bus width Alemao
@ 2009-08-26 14:22 ` Michael Ellerman
  2009-08-27  0:04   ` Stephen Rothwell
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2009-08-26 14:22 UTC (permalink / raw)
  To: Alemao; +Cc: linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PPC driver - generic bus width
  2009-08-26 14:22 ` Michael Ellerman
@ 2009-08-27  0:04   ` Stephen Rothwell
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Rothwell @ 2009-08-27  0:04 UTC (permalink / raw)
  To: michael; +Cc: linuxppc-dev, Alemao, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

On Thu, 27 Aug 2009 00:22:45 +1000 Michael Ellerman <michael@ellerman.id.au> wrote:
>
> > struct device_info_t {
> > 	void (*read)();
> > 	void (*write)();

These are not prototypes because there is no parameter list (use "void" for empty).

> > };
> > 
> > static int __devinit device_probe()

This isn't a prototype either.

> > 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
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-27  0:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 13:25 PPC driver - generic bus width Alemao
2009-08-26 14:22 ` Michael Ellerman
2009-08-27  0:04   ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).