[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclinux-dev
Subject:    [uClinux-dev] =?windows-1252?q?error=3A_expected_=91=3D=92=2C_?=
From:       "techie embedded" <techie.embedded () gmail ! com>
Date:       2006-12-30 9:28:16
Message-ID: 30f3d1370612300116i219ea7f7x1171346360c7592c () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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


[Attachment #5 (text/html)]

Hi<br><br>I&#39;m trying to compile an ADC Driver &amp; come acrosss the following \
error. I&#39;ve no experience writing drivers before, and hence have no clue how to \
fix it.<br>Hope someone out there has encountered the problem &amp; suggesst a fix \
for the same. <br><br>The Error is I get is :<br><br>qadc.c: At top \
level:<br>qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before \
'qadc_read'<br>make: *** [qadc.o] Error 1<br>[root@localhost qadc]#&nbsp;&nbsp;&nbsp; \
<br><br>########################################################################### \
<br>ADC Driver Code <br>###########################################################################<br><br>#define \
MODULE<br>#define __KERNEL__<br>#include &lt;linux/config.h&gt;<br>#include \
&lt;linux/module.h&gt;<br>#include &lt;linux/kernel.h&gt; /* printk */ <br>#include \
&lt;linux/fs.h&gt; /<br>#include &lt;linux/errno.h&gt; /* error codes \
*/<br><br>#include &lt;linux/types.h&gt; /* size_t */<br>#include \
&lt;linux/proc_fs.h&gt; /* proc file system */<br>#include &lt;linux/fcntl.h&gt;  \
<br>#include &lt;asm/system.h&gt; /* cli, flags */<br>#include &lt;asm/uaccess.h&gt; \
/* copy from/to user */<br><br>/*Registers to get qadc access*/<br>volatile unsigned \
short * qadcmcr = (unsigned short *)0x40190000;<br> volatile unsigned short * qacr0 = \
(unsigned short *)0x4019000a;<br>volatile unsigned short * qacr1 = (unsigned short \
*)0x4019000c;<br>volatile unsigned short * qacr2 = (unsigned short \
*)0x4019000e;<br>volatile unsigned short * qasr0 = (unsigned short *)0x40190010; \
<br>volatile unsigned short * qasr1 = (unsigned short *)0x40190012;<br>volatile \
unsigned short *ccw = (unsigned short *)0x40190200;<br>volatile unsigned short *rjurr \
= (unsigned short *)0x40190280;<br>/* Function prototypes required by  qadc.c \
*/<br>int qadc_open (struct inode *inode, struct file *filp);<br><br><br>int \
qadc_release (struct inode *inode, struct file *filp);<br>ssize_t qadc_read(struct \
file *filp, char *buf, size_t count, loff_t *f_pos);<br> ssize_t qadc_write (struct \
file *filp, const char *buf, size_t count, loff_t *f_pos);<br>void \
cleanup_module_qadc (void);<br><br>/* Structure to declare our file access functions. \
*/<br>struct file_operations qadc_fops =<br> {<br>open: qadc_open,<br>read: \
qadc_read,<br>write: qadc_write,<br>release: qadc_release<br>};<br><br>/* Global \
driver variables. */<br>int qadc_major = 80; /* major number */<br>unsigned short \
values[64]; /* data buffer */ <br>int init_module_qadc(void)<br>{<br>int cntr; \
//counter for loop;<br>int result;<br><br>*qadcmcr= 0x40; //QADC operates \
normally<br>*qacr0 = 0x7f; //QCLK, disable extern mux, set the trigger \
assignments<br>*qacr1 = 0x1100; //disable interrupts, select operate mode <br>*qacr2 \
= 0x11; //disable queue 2<br>*qasr0 = \
0;<br>for(cntr=0;cntr&lt;64;cntr++)<br>{<br>rjurr[cntr]=0;<br>}<br>for(cntr=0;cntr&lt;64;cntr++)<br>{<br>ccw[cntr] \
= cntr;<br>}<br>/* Register the device. */<br>result = register_chrdev(qadc_major, \
&quot;qadc&quot;, &amp;qadc_fops); <br>if (result &lt; \
0)<br>{<br>printk(&quot;&lt;1&gt;QADC: couldnt obtain major number \
%d\n&quot;,qadc_major);<br>return result;<br>}<br><br>printk(&quot;QADC driver is \
installed\n&quot;);<br><br>return 0;<br>}<br>/* Unload the module. */ <br>void \
cleanup_module_qadc(void)<br>{<br>unregister_chrdev (qadc_major, \
&quot;qadc&quot;);<br><br>}<br>/* Open the device file. */<br>int qadc_open(struct \
inode *inode, struct file \
*filp)<br>{<br>MOD_INC_USE_COUNT;<br>//printk(&quot;Executing qadc_open\n&quot;); \
<br>return 0;<br>}<br>/* Close the device file. */<br>int qadc_release(struct inode \
*inode, struct file *filp)<br>{<br>MOD_DEC_USE_COUNT;<br>//printk(&quot;Executing \
qadc_release\n&quot;);<br><br>return 0;<br>}<br><br>ssize_t qadc_read(struct file \
*filp, char *buf, size_t count, loff_t *f_pos) <br>{<br>int cntr=0, adcntr, \
val;<br>*qacr1=0x1100; // Activate software triggered continous-scan \
mode<br>printk(&quot;Executing qadc_read&quot;);<br>while(cntr&lt;8) //read only the \
8 first channel<br>{<br>printk(&quot;Starting convertion&quot;); \
<br>if((*qasr1&gt;&gt;8) &gt; 7) // When the queue is full, read it to \
RAM<br>{<br>printk(&quot;Data in queue&quot;);<br>*qacr1=0; // Deactivate software \
triggered continous-scan mode<br>for(adcntr=0;adcntr&lt;8;adcntr++) \
<br>{<br>values[cntr++] = rjurr[adcntr]; // Read a value off the queue and increment \
}<br>}<br>}<br><br><br>val = (int) values[0];<br>*qacr1 = 0;<br>/* Move data to the \
user space */<br>if(copy_to_user (buf, &amp;val, 4)) <br>return \
-EFAULT;<br>*f_pos++;<br>return 1;<br>}<br>/* Write to the file. */<br>ssize_t \
qadc_write(struct file *filp, const char *buf, size_t count, loff_t \
*fpos)<br>{<br>//QADC is read only, this funciton can be removed <br>return \
1;<br>}<br><br>########################################################################################################################<br>Cheers<br><br>krish<br>




_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic