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
techie
12/30/2006 9:21:51 AM
comp.os.linux.embedded 3347 articles. 0 followers. tvnaidu2 (4) is leader. Post Follow

0 Replies
2450 Views

Similar Articles

[PageSpeed] 13

Reply: