Hi Erwin,

        The value of the errno after the write fails is 9.

Thanks, Ramón

-----Mensaje original-----
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
En nombre de Erwin Authried
Enviado el: viernes, 22 de junio de 2007 13:00
Para: uClinux development list
Asunto: Re: [uClinux-dev] function write in char driver (ARM - AT91)

Hi Ramon,
could you tell us the value of "errno" after the write fails?

Regards,
Erwin

Am Freitag, den 22.06.2007, 12:46 +0200 schrieb rflores:
> Hi all,
> 
>  
> 
> I’m writing a char driver, my platform is an arm nommu (AT91).
> 
>  
> 
> The init function executes correctly in the uClinux startup. In the
> application the device is opened and closed correctly, but when I try
> to use the write function, the kernel doesn’t execute my write
> function and the function write in the application returns -1.
> 
>  
> 
> The code in the driver side is:
> 
>  
> 
> static int openflag_spi = 0;
> 
>  
> 
> static struct file_operations swspi_fops = {
> 
>   read: spi_read,
> 
>   write: spi_write,
> 
>   open: spi_open,
> 
>   release: spi_release,
> 
> }
> 
>  
> 
> static ssize_t spi_write (struct file *filp, const char *buf, ssize_t
> count, loff_t *f_pos)
> 
> {
> 
>   printk(“spi_write: %s\n”,buf);
> 
>   return(count);
> 
> }
> 
>  
> 
> static int spi_open (struct inode *inode,struct file *filp)
> 
> {
> 
>   if (openflag_spi )
> 
>     return –EBUSY;
> 
>  
> 
>   MOD_INC_USE_COUNT;
> 
>   printk(“SWSPI: Open\n”);
> 
>   openflag_spi = 1;
> 
>   return 0;
> 
> }
> 
>  
> 
> static int spi_release  (struct inode *inode,struct file *filp)
> 
> {
> 
>   printk(“SWSPI: Close\n”);
> 
>   openflag_spi = 0;
> 
>   MOD_DEC_USE_COUNT;
> 
>   return 0;
> 
> }
> 
>  
> 
> The code in the application side is:
> 
>  
> 
> int fd;
> 
> char buf[80];
> 
> fd = open (“/dev/swspi”,”rw”);
> 
> if (fd == -1){
> 
>   printf(“\nUnable to open device\n”);
> 
>   return (-1);
> 
> }
> 
> printf(“\nSpi device descriptor = %d\n”,fd);
> 
> strcpy(buf,”\nSWPI write function\n”);
> 
> printf(“write return = %d”,write(fd,buf,sizeof(buf)));
> 
>  
> 
>  
> 
> And the execution is:
> 
>  
> 
> Sash command shell (version 1.1.1)
> 
> /> 
> 
> /> 
> 
> /> llaccess test
> 
> SWSPI: Open
> 
>  
> 
> Spi  device descriptor = 3
> 
>  
> 
> write return = -1
> 
> SWSPI: Close
> 
> />
> 
>  
> 
> Where is the problem? Why doesn’t the kernel call to spi_write when
> the application invokes the write function?
> 
>  
> 
> Thanks in advance
> 
>  
> 
> Ramón Flores
> 
>  
> 
-- 
Dipl.-Ing. Erwin Authried
Softwareentwicklung und Systemdesign

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

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

Reply via email to