diff options
author | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-12-15 00:04:32 +0000 |
---|---|---|
committer | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-12-15 00:04:32 +0000 |
commit | 345bce368bc47c80003442a3f7c82181ddee7e42 (patch) | |
tree | 500dfa4593a960e3e1a43dff52513d6008a89a5f /target/linux | |
parent | 268d096b51e8650df8217bad04b7cdce47cd552b (diff) |
danube eeprom cleanup
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9762 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r-- | target/linux/danube/files/drivers/char/danube_eeprom.c | 97 |
1 files changed, 21 insertions, 76 deletions
diff --git a/target/linux/danube/files/drivers/char/danube_eeprom.c b/target/linux/danube/files/drivers/char/danube_eeprom.c index db0f610370..1835f2776e 100644 --- a/target/linux/danube/files/drivers/char/danube_eeprom.c +++ b/target/linux/danube/files/drivers/char/danube_eeprom.c @@ -61,15 +61,6 @@ /* allow the user to set the major device number */ static int danube_eeprom_maj = 0; -static ssize_t danube_eeprom_fops_read (struct file *, char *, size_t, loff_t *); -static ssize_t danube_eeprom_fops_write (struct file *, const char *, size_t, - loff_t *); -static int danube_eeprom_ioctl (struct inode *, struct file *, unsigned int, - unsigned long); -static int danube_eeprom_open (struct inode *, struct file *); -static int danube_eeprom_close (struct inode *, struct file *); - -//ifx_ssc.c extern int ifx_ssc_init (void); extern int ifx_ssc_open (struct inode *inode, struct file *filp); extern int ifx_ssc_close (struct inode *inode, struct file *filp); @@ -98,63 +89,30 @@ extern int ifx_ssc_rx (char *rx_buf, unsigned int rx_len); #define EEPROM_SIZE 512 static int -eeprom_rdsr (char *status) +eeprom_rdsr (void) { int ret = 0; unsigned char cmd = EEPROM_RDSR; unsigned long flag; + char status; local_irq_save(flag); - if ((ret = ifx_ssc_cs_low (EEPROM_CS))) - { - local_irq_restore(flag); - goto out; - } - - if ((ret = ifx_ssc_txrx (&cmd, 1, status, 1)) < 0) - { - ifx_ssc_cs_high(EEPROM_CS); - local_irq_restore(flag); - goto out; - } - - if ((ret = ifx_ssc_cs_high(EEPROM_CS))) - { - local_irq_restore(flag); - goto out; - } + if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0) + if ((ret = ifx_ssc_txrx(&cmd, 1, &status, 1)) >= 0) + ret = status & 1; + ifx_ssc_cs_high(EEPROM_CS); local_irq_restore(flag); -out: return ret; } -static inline int +void eeprom_wip_over (void) { - int ret = 0; - unsigned char status; - - while (1) - { - ret = eeprom_rdsr(&status); - printk("status %x \n", status); - - if (ret) - { - printk("read back status fails %d\n", ret); - break; - } - - if (((status) & 1) != 0) - printk("read back status not zero %x\n", status); - else - break; - } - - return ret; + while (eeprom_rdsr()) + printk("waiting for eeprom\n"); } static int @@ -165,29 +123,16 @@ eeprom_wren (void) unsigned long flag; local_irq_save(flag); - if ((ret = ifx_ssc_cs_low(EEPROM_CS))) - { - local_irq_restore(flag); - goto out; - } - - if ((ret = ifx_ssc_tx(&cmd, 1)) < 0) - { - ifx_ssc_cs_high(EEPROM_CS); - local_irq_restore(flag); - goto out; - } - - if ((ret = ifx_ssc_cs_high(EEPROM_CS))) - { - local_irq_restore(flag); - goto out; - } + if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0) + if ((ret = ifx_ssc_tx(&cmd, 1)) >= 0) + ret = 0; + ifx_ssc_cs_high(EEPROM_CS); local_irq_restore(flag); - eeprom_wip_over(); -out: + if (!ret) + eeprom_wip_over(); + return ret; } @@ -388,7 +333,7 @@ danube_eeprom_read (char *buf, size_t len, unsigned int addr) len = EEPROM_SIZE / 2; } - if ((ret = ifx_ssc_open ((struct inode *) 0, NULL))) + if ((ret = ifx_ssc_open((struct inode *) 0, NULL))) { printk("danube_eeprom_open fails\n"); goto out; @@ -396,26 +341,26 @@ danube_eeprom_read (char *buf, size_t len, unsigned int addr) data = (unsigned int)IFX_SSC_MODE_RXTX; - if ((ret = ifx_ssc_ioctl ((struct inode *) 0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data))) + if ((ret = ifx_ssc_ioctl((struct inode *) 0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data))) { printk("set RXTX mode fails\n"); goto out; } - if ((ret = eeprom_wrsr ())) + if ((ret = eeprom_wrsr())) { printk("EEPROM reset fails\n"); goto out; } - if ((ret = eeprom_read (addr, buf, len))) + if ((ret = eeprom_read(addr, buf, len))) { printk("eeprom read fails\n"); goto out; } out: - if (ifx_ssc_close ((struct inode *) 0, NULL)) + if (ifx_ssc_close((struct inode *) 0, NULL)) printk("danube_eeprom_close fails\n"); return len; |