f



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 <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h> /* printk */
#include <linux/fs.h> /
#include <linux/errno.h> /* error codes */

#include <linux/types.h> /* size_t */
#include <linux/proc_fs.h> /* proc file system */
#include <linux/fcntl.h>
#include <asm/system.h> /* cli, flags */
#include <asm/uaccess.h> /* 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;cntr<64;cntr++)
{
rjurr[cntr]=0;
}
for(cntr=0;cntr<64;cntr++)
{
ccw[cntr] = cntr;
}
/* Register the device. */
result = register_chrdev(qadc_major, "qadc", &qadc_fops);
if (result < 0)
{
printk("<1>QADC: couldnt obtain major number %d\n",qadc_major);
return result;
}

printk("QADC driver is installed\n");

return 0;
}
/* Unload the module. */
void cleanup_module_qadc(void)
{
unregister_chrdev (qadc_major, "qadc");

}
/* Open the device file. */
int qadc_open(struct inode *inode, struct file *filp)
{
MOD_INC_USE_COUNT;
//printk("Executing qadc_open\n");
return 0;
}
/* Close the device file. */
int qadc_release(struct inode *inode, struct file *filp)
{
MOD_DEC_USE_COUNT;
//printk("Executing qadc_release\n");

return 0;
}

ssize_t qadc_read(struct file *filp, char *buf, size_t count, loff_t
*f_pos)
{
int cntr=0, adcntr, val;
*qacr1=0x1100; // Activate software triggered continous-scan mode
printk("Executing qadc_read");
while(cntr<8) //read only the 8 first channel
{
printk("Starting convertion");
if((*qasr1>>8) > 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<8;adcntr++)
{
values[cntr++] = rjurr[adcntr]; // Read a value off the queue and
increment }
}
}


val = (int) values[0];
*qacr1 = 0;
/* Move data to the user space */
if(copy_to_user (buf, &val, 4))
return -EFAULT;
*f_pos++;
return 1;
}
/* Write to the file. */
ssize_t qadc_write(struct file *filp, const char *buf, size_t count,
loff_t *fpos)
{
//QADC is read only, this funciton can be removed
return 1;
}

########################################################################################################################
Cheers

krish

0
12/30/2006 9:22:11 AM
comp.arch.embedded 20047 articles. 1 followers. Post Follow

13 Replies
4659 Views

Similar Articles

[PageSpeed] 51

techie.embedded@gmail.com wrote:
> 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]#
> ########################################################################################################################
> Cheers
> 
> krish
> 

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??
0
hs.chauhan (114)
12/30/2006 9:47:39 AM
Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
> In article <1167470530.933569.143970@v33g2000cwv.googlegroups.com>, 
> techie.embedded@gmail.com says...
>> 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]#
> <snip>
>> /* Structure to declare our file access functions. */
>> struct file_operations qadc_fops =
>> {
>> open: qadc_open,
>> read: qadc_read,
>> write: qadc_write,
>> release: qadc_release
>> };

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

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

---
******************************************************************
*  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************

-- 
Posted via a free Usenet account from http://www.teranews.com

0
ksi (21)
12/30/2006 10:57:24 PM
In article <1167470530.933569.143970@v33g2000cwv.googlegroups.com>, 
techie.embedded@gmail.com says...
> 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]#
<snip>
> /* Structure to declare our file access functions. */
> struct file_operations qadc_fops =
> {
> open: qadc_open,
> read: qadc_read,
> write: qadc_write,
> release: qadc_release
> };

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

Robert

-- 
Posted via a free Usenet account from http://www.teranews.com

0
12/30/2006 11:05:21 PM
In article <4596eed3$0$18582$88260bb3@free.teranews.com>, Sergey 
Kubushin says...
> Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
> > In article <1167470530.933569.143970@v33g2000cwv.googlegroups.com>, 
> > techie.embedded@gmail.com says...
> >> 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]#
> > <snip>
> >> /* Structure to declare our file access functions. */
> >> struct file_operations qadc_fops =
> >> {
> >> open: qadc_open,
> >> read: qadc_read,
> >> write: qadc_write,
> >> release: qadc_release
> >> };
> 
> > Well, the above isn't valid C so I'd start there.
> 
> It was some time back but now it's changed.

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

0
12/31/2006 12:41:20 AM
In article <MPG.2000d13782aaec369896b1@free.teranews.com>, Robert Adsett 
says...
> In article <4596eed3$0$18582$88260bb3@free.teranews.com>, Sergey 
> Kubushin says...
> > Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
> > > In article <1167470530.933569.143970@v33g2000cwv.googlegroups.com>, 
> > > techie.embedded@gmail.com says...
> > >> 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]#
> > > <snip>
> > >> /* Structure to declare our file access functions. */
> > >> struct file_operations qadc_fops =
> > >> {
> > >> open: qadc_open,
> > >> read: qadc_read,
> > >> write: qadc_write,
> > >> release: qadc_release
> > >> };
> > 
> > > Well, the above isn't valid C so I'd start there.
> > 
> > It was some time back but now it's changed.
> 
> 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. 

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

0
12/31/2006 12:49:32 AM
Sergey Kubushin wrote:
> Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
>> In article <1167470530.933569.143970@v33g2000cwv.googlegroups.com>, 
>> techie.embedded@gmail.com says...
>>> 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]#
>> <snip>
>>> /* Structure to declare our file access functions. */
>>> struct file_operations qadc_fops =
>>> {
>>> open: qadc_open,
>>> read: qadc_read,
>>> write: qadc_write,
>>> release: qadc_release
>>> };
> 
>> Well, the above isn't valid C so I'd start there.
> 
> It was some time back but now it's changed.
> 
> ---
> ******************************************************************
> *  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
> *  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
> ******************************************************************
> 
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.)
0
dennis4312 (19)
12/31/2006 4:11:01 AM
Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
> In article <MPG.2000d13782aaec369896b1@free.teranews.com>, Robert Adsett 
> says...

[dd]

>> > > <snip>
>> > >> /* Structure to declare our file access functions. */
>> > >> struct file_operations qadc_fops =
>> > >> {
>> > >> open: qadc_open,
>> > >> read: qadc_read,
>> > >> write: qadc_write,
>> > >> release: qadc_release
>> > >> };
>> > 
>> > > Well, the above isn't valid C so I'd start there.
>> > 
>> > It was some time back but now it's changed.
>> 
>> 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. 

> 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?

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.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************

-- 
Posted via a free Usenet account from http://www.teranews.com

0
ksi (21)
12/31/2006 4:11:58 AM
In article <4597388e$0$18638$88260bb3@free.teranews.com>, Sergey 
Kubushin says...
> Robert Adsett <subscriptions@aeolusdevelopment.com> wrote:
> > In article <MPG.2000d13782aaec369896b1@free.teranews.com>, Robert Adsett 
> > says...
> 
> [dd]
> 
> >> > > <snip>
> >> > >> /* Structure to declare our file access functions. */
> >> > >> struct file_operations qadc_fops =
> >> > >> {
> >> > >> open: qadc_open,
> >> > >> read: qadc_read,
> >> > >> write: qadc_write,
> >> > >> release: qadc_release
> >> > >> };
> >> > 
> >> > > Well, the above isn't valid C so I'd start there.
> >> > 
> >> > It was some time back but now it's changed.
> >> 
> >> 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. 
<snip>
> 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.

So not valid C, just an obsolete GCC extension. 

Robert

-- 
Posted via a free Usenet account from http://www.teranews.com

0
12/31/2006 5:21:24 AM
On 2006-12-31, Dennis <dennis@nowhere.net> wrote:

>>>> /* Structure to declare our file access functions. */
>>>> struct file_operations qadc_fops =
>>>> {
>>>> open: qadc_open,
>>>> read: qadc_read,
>>>> write: qadc_write,
>>>> release: qadc_release
>>>> };
>> 
>>> Well, the above isn't valid C so I'd start there.
>> 
>> It was some time back but now it's changed.
>
> 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.)

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               
                               visi.com            
0
grante (5416)
12/31/2006 4:40:04 PM
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:
> On 2006-12-31, Dennis <dennis@nowhere.net> wrote:
>
> >>>> /* Structure to declare our file access functions. */
> >>>> struct file_operations qadc_fops =
> >>>> {
> >>>> open: qadc_open,
> >>>> read: qadc_read,
> >>>> write: qadc_write,
> >>>> release: qadc_release
> >>>> };
> >>
> >>> Well, the above isn't valid C so I'd start there.
> >>
> >> It was some time back but now it's changed.
> >
> > 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.)
>
> 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
>                                visi.com

0
1/1/2007 8:40:54 AM
krish wrote:

> 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 ???

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...]

0
HBBroeker (925)
1/1/2007 2:38:28 PM
Hans-Bernhard Br�ker wrote:
> krish wrote:
> 
>> 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 ???
> 
> Not quite. It would be supported, but only if your GCC was run with
> extensions enabled.  In other words: lose that -ansi switch.

No, don't.  Revise the code to be standard compatible.

> 
> [and please consider bottom-posting and snipping quoted material...]

This I can heartily endorse.

-- 
Merry Christmas, Happy Hanukah, Happy New Year
        Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
     <http://cbfalconer.home.att.net>


0
cbfalconer (19194)
1/1/2007 3:45:50 PM
Hans-Bernhard Br=F6ker wrote:

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

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

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

Cheers

krish

0
1/2/2007 5:01:55 AM
Reply: