error: expected '=', ',', ';', 'asm' or '__attrib

Hi

I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same.

The Error is I get is :

qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]#

########################################################################### ADC Driver Code ###########################################################################

#define MODULE #define __KERNEL__ #include #include #include /* printk */ #include / #include /* error codes */

#include /* size_t */ #include /* proc file system */ #include #include /* cli, flags */ #include /* copy from/to user */

/*Registers to get qadc access*/ volatile unsigned short * qadcmcr = (unsigned short *)0x40190000; volatile unsigned short * qacr0 = (unsigned short *)0x4019000a; volatile unsigned short * qacr1 = (unsigned short *)0x4019000c; volatile unsigned short * qacr2 = (unsigned short *)0x4019000e; volatile unsigned short * qasr0 = (unsigned short *)0x40190010; volatile unsigned short * qasr1 = (unsigned short *)0x40190012; volatile unsigned short *ccw = (unsigned short *)0x40190200; volatile unsigned short *rjurr = (unsigned short *)0x40190280; /* Function prototypes required by qadc.c */ int qadc_open (struct inode *inode, struct file *filp);

int qadc_release (struct inode *inode, struct file *filp); ssize_t qadc_read(struct file *filp, char *buf, size_t count, loff_t

*f_pos); ssize_t qadc_write (struct file *filp, const char *buf, size_t count, loff_t *f_pos); void cleanup_module_qadc (void);

/* Structure to declare our file access functions. */ struct file_operations qadc_fops = { open: qadc_open, read: qadc_read, write: qadc_write, release: qadc_release };

/* Global driver variables. */ int qadc_major = 80; /* major number */ unsigned short values[64]; /* data buffer */ int init_module_qadc(void) { int cntr; //counter for loop; int result;

*qadcmcr= 0x40; //QADC operates normally *qacr0 = 0x7f; //QCLK, disable extern mux, set the trigger assignments *qacr1 = 0x1100; //disable interrupts, select operate mode *qacr2 = 0x11; //disable queue 2 *qasr0 = 0; for(cntr=0;cntr8) > 7) // When the queue is full, read it to RAM { printk("Data in queue"); *qacr1=0; // Deactivate software triggered continous-scan mode for(adcntr=0;adcntr
Reply to
techie.embedded
Loading thread data ...

########################################################################################################################

Are you sure, its a driver issue? None of the "Expected Error" show that... It should have been a driver issue if it compiled and still couldn't drive your system.

What about C programming experience??

Reply to
Himanshu Chauhan

It was some time back but now it's changed.

--
******************************************************************
*  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
 Click to see the full signature
Reply to
Sergey Kubushin

Well, the above isn't valid C so I'd start there.

Robert

--
Posted via a free Usenet account from http://www.teranews.com
Reply to
Robert Adsett

As of? AFAIR it isn't part of C89/90 and the more recent changes are not generally available. It's certainly the line the compiler is complaining about.

Robert

--
Posted via a free Usenet account from http://www.teranews.com
Reply to
Robert Adsett

I did a little checking, the only reference Ive found to member initialization in C uses the following syntax

struct point location = { .y = 13, .x = 10 };

No mention of the syntax above. Even that is only present in C99 and so far from widely available.

Do you have a reference for the validity of the syntax in the original post?

Robert

--
Posted via a free Usenet account from http://www.teranews.com
Reply to
Robert Adsett

The syntax was an extension in gcc to simplify Linux device drivers. If you are not using gcc the compiler doesn't recognize it. It has been years since I have written a Linux device driver so the construct could have changed an be no longer supported. (I know they made some changed in device drivers in the newer kernels.)

Reply to
Dennis

Look into any 2.4.xx Linux kernel source, e.g. in drivers/mtd/nand look for nand_base.c if I still remember those older kernels. Or nand_ids.c. There is a lot of this type structure initializations in there. Then everything changed to { .member = value } style that is, IMHO, not any better than that old GCC { member: value } style.

This was _GCC_ extension though you probably won't find it in C/C++ standards. Nowadays this style is considered obsolete and newer GCC uses C99 notation.

--
******************************************************************
*  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
 Click to see the full signature
Reply to
Sergey Kubushin

So not valid C, just an obsolete GCC extension.

Robert

--
Posted via a free Usenet account from http://www.teranews.com
Reply to
Robert Adsett

I was just using that the other day, so I know it's still supported in gcc 3.4. I don't know if it's been deprecated or removed in 4.1.

--
Grant Edwards                   grante             Yow!  I'm wet! I'm wild!
                                  at               
 Click to see the full signature
Reply to
Grant Edwards

Hello all

I'm using gcc-2.95 ( the m68k toolchain )....

So, what is the conslusion of the discussion ???? The Structure declaration is not supported by gcc-2.95 ???

thanks

krish Grant Edwards wrote:

Reply to
krish

Not quite. It would be supported, but only if your GCC was run with extensions enabled. In other words: lose that -ansi switch.

[and please consider bottom-posting and snipping quoted material...]
Reply to
Hans-Bernhard Bröker

Could you please clarify on how exactly I do that ???

That is, what are the extensions to be added or removed & where ????

Cheers

krish

Reply to
techie.embedded

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.