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

 

_______________________________________________
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