Show
Ignore:
Timestamp:
07/03/2009 04:48:37 PM (8 months ago)
Author:
BrainSlayer
Message:

fixes usb issues with some devices

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/linux/rt2880/linux-2.6.23/drivers/usb/dwc_otg/dwc_otg_attr.c

    r10741 r12433  
    11/* ========================================================================== 
    2  * $File: //dwh/usb_iip/dev/software/otg_ipmate/linux/drivers/dwc_otg_attr.c $ 
    3  * $Revision: 1.1
    4  * $Date: 2007-11-19 05:39:07
    5  * $Change: 537387
     2 * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_attr.c $ 
     3 * $Revision: 1.2
     4 * $Date: 2008-11-21 05:39:15
     5 * $Change: 1064918
    66 * 
    77 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter, 
     
    207207  
    208208 <tr> 
     209 <td> spramdump </td> 
     210 <td> Dumps the contents of core registers.</td> 
     211 <td> Read</td> 
     212 </tr> 
     213 
     214 <tr> 
    209215 <td> hcddump </td> 
    210216 <td> Dumps the current HCD state.</td> 
     
    255261#include <linux/types.h> 
    256262#include <linux/stat.h>  /* permission constants */ 
     263#include <linux/version.h> 
    257264 
    258265//#include <asm/sizes.h> 
     
    268275#include "dwc_otg_hcd.h" 
    269276 
     277#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
    270278/* 
    271279 * MACROs for defining sysfs attribute 
    272280 */ 
    273281#define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
    274 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 
     282static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \ 
    275283{ \ 
    276         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     284        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 
     285        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);             \ 
    277286        uint32_t val; \ 
    278287        val = dwc_read_reg32 (_addr_); \ 
     
    281290} 
    282291#define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
    283 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 
     292static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \ 
     293                                        const char *buf, size_t count) \ 
    284294{ \ 
    285         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     295        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 
     296        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 
    286297        uint32_t set = simple_strtoul(buf, NULL, 16); \ 
    287298        uint32_t clear = set; \ 
     
    293304} 
    294305 
     306/* 
     307 * MACROs for defining sysfs attribute for 32-bit registers 
     308 */ 
     309#define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 
     310static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \ 
     311{ \ 
     312        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 
     313        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 
     314        uint32_t val; \ 
     315        val = dwc_read_reg32 (_addr_); \ 
     316        return sprintf (buf, "%s = 0x%08x\n", _string_, val); \ 
     317} 
     318#define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \ 
     319static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \ 
     320                                        const char *buf, size_t count) \ 
     321{ \ 
     322        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 
     323        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 
     324        uint32_t val = simple_strtoul(buf, NULL, 16); \ 
     325        dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \ 
     326        dwc_write_reg32(_addr_, val); \ 
     327        return count; \ 
     328} 
     329 
     330#else 
     331 
     332/* 
     333 * MACROs for defining sysfs attribute 
     334 */ 
     335#define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
     336static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 
     337{ \ 
     338        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     339        uint32_t val; \ 
     340        val = dwc_read_reg32 (_addr_); \ 
     341        val = (val & (_mask_)) >> _shift_; \ 
     342        return sprintf (buf, "%s = 0x%x\n", _string_, val); \ 
     343} 
     344#define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
     345static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 
     346{ \ 
     347        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     348        uint32_t set = simple_strtoul(buf, NULL, 16); \ 
     349        uint32_t clear = set; \ 
     350        clear = ((~clear) << _shift_) & _mask_; \ 
     351        set = (set << _shift_) & _mask_; \ 
     352        dev_dbg(_dev, "Storing Address=0x%08x Set=0x%08x Clear=0x%08x\n", (uint32_t)_addr_, set, clear); \ 
     353        dwc_modify_reg32(_addr_, clear, set); \ 
     354        return count; \ 
     355} 
     356 
     357/* 
     358 * MACROs for defining sysfs attribute for 32-bit registers 
     359 */ 
     360#define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 
     361static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 
     362{ \ 
     363        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     364        uint32_t val; \ 
     365        val = dwc_read_reg32 (_addr_); \ 
     366        return sprintf (buf, "%s = 0x%08x\n", _string_, val); \ 
     367} 
     368#define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \ 
     369static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 
     370{ \ 
     371        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
     372        uint32_t val = simple_strtoul(buf, NULL, 16); \ 
     373        dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \ 
     374        dwc_write_reg32(_addr_, val); \ 
     375        return count; \ 
     376} 
     377 
     378#endif 
     379 
    295380#define DWC_OTG_DEVICE_ATTR_BITFIELD_RW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
    296381DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 
     
    302387DEVICE_ATTR(_otg_attr_name_,0444,_otg_attr_name_##_show,NULL); 
    303388 
    304 /* 
    305  * MACROs for defining sysfs attribute for 32-bit registers 
    306  */ 
    307 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 
    308 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 
    309 { \ 
    310         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
    311         uint32_t val; \ 
    312         val = dwc_read_reg32 (_addr_); \ 
    313         return sprintf (buf, "%s = 0x%08x\n", _string_, val); \ 
    314 } 
    315 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \ 
    316 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 
    317 { \ 
    318         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 
    319         uint32_t val = simple_strtoul(buf, NULL, 16); \ 
    320         dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \ 
    321         dwc_write_reg32(_addr_, val); \ 
    322         return count; \ 
    323 } 
    324  
    325389#define DWC_OTG_DEVICE_ATTR_REG32_RW(_otg_attr_name_,_addr_,_string_) \ 
    326390DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 
     
    339403 * Show the register offset of the Register Access. 
    340404 */ 
    341 static ssize_t regoffset_show( struct device *_dev, char *buf)  
    342 
    343         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     405static ssize_t regoffset_show( struct device *_dev, 
     406#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     407                               struct device_attribute *attr, 
     408#endif 
     409                               char *buf)  
     410
     411#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     412        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     413        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     414#else 
     415        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     416#endif 
    344417        return snprintf(buf, sizeof("0xFFFFFFFF\n")+1,"0x%08x\n", otg_dev->reg_offset); 
    345418} 
     
    348421 * Set the register offset for the next Register Access         Read/Write 
    349422 */ 
    350 static ssize_t regoffset_store( struct device *_dev, const char *buf,  
    351                                 size_t count )  
    352 
    353         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     423static ssize_t regoffset_store( struct device *_dev, 
     424#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     425                                struct device_attribute *attr, 
     426#endif 
     427                                const char *buf,  
     428                                size_t count )  
     429
     430#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     431        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     432        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     433#else 
     434        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     435#endif 
    354436        uint32_t offset = simple_strtoul(buf, NULL, 16); 
    355437        //dev_dbg(_dev, "Offset=0x%08x\n", offset); 
     
    363445        return count; 
    364446} 
    365 DEVICE_ATTR(regoffset, S_IRUGO|S_IWUSR, regoffset_show, regoffset_store); 
     447DEVICE_ATTR(regoffset, S_IRUGO|S_IWUSR, (void *)regoffset_show, regoffset_store); 
    366448 
    367449 
     
    370452 * attribute. 
    371453 */ 
    372 static ssize_t regvalue_show( struct device *_dev, char *buf)  
    373 
    374         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     454static ssize_t regvalue_show( struct device *_dev, 
     455#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     456                              struct device_attribute *attr, 
     457#endif 
     458                              char *buf)  
     459
     460#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     461        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     462        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     463#else 
     464        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     465#endif 
    375466        uint32_t val; 
    376467        volatile uint32_t *addr; 
     
    399490 *  
    400491 */ 
    401 static ssize_t regvalue_store( struct device *_dev, const char *buf,  
    402                                size_t count )  
    403 
    404         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     492static ssize_t regvalue_store( struct device *_dev, 
     493#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     494                               struct device_attribute *attr, 
     495#endif 
     496                               const char *buf,  
     497                               size_t count )  
     498
     499#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     500        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     501        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     502#else 
     503        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     504#endif 
    405505        volatile uint32_t * addr; 
    406506        uint32_t val = simple_strtoul(buf, NULL, 16); 
     
    453553 * Show the HNP status bit 
    454554 */ 
    455 static ssize_t hnp_show( struct device *_dev, char *buf)  
    456 
    457         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     555static ssize_t hnp_show( struct device *_dev, 
     556#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     557                         struct device_attribute *attr, 
     558#endif 
     559                         char *buf)  
     560
     561#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     562        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     563        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     564#else 
     565        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     566#endif 
    458567        gotgctl_data_t val; 
    459568        val.d32 = dwc_read_reg32 (&(otg_dev->core_if->core_global_regs->gotgctl)); 
     
    464573 * Set the HNP Request bit 
    465574 */ 
    466 static ssize_t hnp_store( struct device *_dev, const char *buf,  
     575static ssize_t hnp_store( struct device *_dev, 
     576#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     577                          struct device_attribute *attr, 
     578#endif 
     579                          const char *buf,  
    467580                          size_t count )  
    468581{ 
    469         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     582#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     583        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     584        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     585#else 
     586        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     587#endif 
    470588        uint32_t in = simple_strtoul(buf, NULL, 16); 
    471589        uint32_t *addr = (uint32_t *)&(otg_dev->core_if->core_global_regs->gotgctl); 
     
    485603 * Show the SRP status bit 
    486604 */ 
    487 static ssize_t srp_show( struct device *_dev, char *buf)  
     605static ssize_t srp_show( struct device *_dev, 
     606#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     607                         struct device_attribute *attr, 
     608#endif 
     609                         char *buf)  
    488610{ 
    489611#ifndef DWC_HOST_ONLY 
    490         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     612#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     613        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     614        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     615#else 
     616        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     617#endif 
    491618        gotgctl_data_t val; 
    492619        val.d32 = dwc_read_reg32 (&(otg_dev->core_if->core_global_regs->gotgctl)); 
     
    502629 * Set the SRP Request bit 
    503630 */ 
    504 static ssize_t srp_store( struct device *_dev, const char *buf,  
     631static ssize_t srp_store( struct device *_dev, 
     632#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     633                          struct device_attribute *attr, 
     634#endif 
     635                          const char *buf,  
    505636                          size_t count )  
    506637{ 
    507638#ifndef DWC_HOST_ONLY 
    508         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     639#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     640        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     641        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     642#else 
     643        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     644#endif 
    509645        dwc_otg_pcd_initiate_srp(otg_dev->pcd); 
    510646#endif 
     
    519655 * Show the Bus Power status 
    520656 */ 
    521 static ssize_t buspower_show( struct device *_dev, char *buf)  
    522 
    523         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     657static ssize_t buspower_show( struct device *_dev, 
     658#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     659                              struct device_attribute *attr, 
     660#endif 
     661                              char *buf)  
     662
     663#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     664        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     665        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     666#else 
     667        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     668#endif 
    524669        hprt0_data_t val; 
    525670        val.d32 = dwc_read_reg32 (otg_dev->core_if->host_if->hprt0); 
     
    531676 * Set the Bus Power status 
    532677 */ 
    533 static ssize_t buspower_store( struct device *_dev, const char *buf,  
    534                                size_t count )  
    535 
    536         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     678static ssize_t buspower_store( struct device *_dev, 
     679#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     680                               struct device_attribute *attr, 
     681#endif 
     682                               const char *buf,  
     683                               size_t count )  
     684
     685#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     686        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     687        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     688#else 
     689        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     690#endif 
    537691        uint32_t on = simple_strtoul(buf, NULL, 16); 
    538692        uint32_t *addr = (uint32_t *)otg_dev->core_if->host_if->hprt0; 
     
    555709 * Show the Bus Suspend status 
    556710 */ 
    557 static ssize_t bussuspend_show( struct device *_dev, char *buf)  
    558 
    559         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     711static ssize_t bussuspend_show( struct device *_dev, 
     712#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     713                                struct device_attribute *attr, 
     714#endif 
     715                                char *buf)  
     716
     717#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     718        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     719        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     720#else 
     721        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     722#endif 
    560723        hprt0_data_t val; 
    561724        val.d32 = dwc_read_reg32 (otg_dev->core_if->host_if->hprt0); 
     
    566729 * Set the Bus Suspend status 
    567730 */ 
    568 static ssize_t bussuspend_store( struct device *_dev, const char *buf,  
    569                                  size_t count )  
    570 
    571         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     731static ssize_t bussuspend_store( struct device *_dev, 
     732#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     733                                 struct device_attribute *attr, 
     734#endif 
     735                                 const char *buf,  
     736                                 size_t count )  
     737
     738#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     739        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     740        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     741#else 
     742        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     743#endif 
    572744        uint32_t in = simple_strtoul(buf, NULL, 16); 
    573745        uint32_t *addr = (uint32_t *)otg_dev->core_if->host_if->hprt0; 
     
    584756 * Show the status of Remote Wakeup. 
    585757 */ 
    586 static ssize_t remote_wakeup_show( struct device *_dev, char *buf)  
     758static ssize_t remote_wakeup_show( struct device *_dev, 
     759#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     760                                   struct device_attribute *attr, 
     761#endif 
     762                                   char *buf)  
    587763{ 
    588764#ifndef DWC_HOST_ONLY 
    589         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     765#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     766        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     767        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     768#else 
     769        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     770#endif 
    590771        dctl_data_t val; 
    591772        val.d32 =  
    592                 dwc_read_reg32( &otg_dev->core_if->dev_if->dev_global_regs->dctl); 
     773               dwc_read_reg32( &otg_dev->core_if->dev_if->dev_global_regs->dctl); 
    593774        return sprintf( buf, "Remote Wakeup = %d Enabled = %d\n",  
    594                         val.b.rmtwkupsig, otg_dev->pcd->remote_wakeup_enable); 
     775                       val.b.rmtwkupsig, otg_dev->pcd->remote_wakeup_enable); 
    595776#else 
    596777        return sprintf(buf, "Host Only Mode!\n"); 
     
    603784 *  
    604785 */ 
    605 static ssize_t remote_wakeup_store( struct device *_dev, const char *buf,  
    606                                     size_t count )  
     786static ssize_t remote_wakeup_store( struct device *_dev, 
     787#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     788                                    struct device_attribute *attr, 
     789#endif 
     790                                    const char *buf,  
     791                                    size_t count )  
    607792{ 
    608793#ifndef DWC_HOST_ONLY 
    609         uint32_t val = simple_strtoul(buf, NULL, 16);         
    610         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     794#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     795        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     796        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     797#else 
     798        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     799#endif 
     800        uint32_t val = simple_strtoul(buf, NULL, 16);         
    611801        if (val&1) { 
    612802                dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 1); 
     
    619809} 
    620810DEVICE_ATTR(remote_wakeup,  S_IRUGO|S_IWUSR, remote_wakeup_show,  
    621             remote_wakeup_store); 
     811           remote_wakeup_store); 
    622812 
    623813/** 
     
    625815 * current mode of the core). 
    626816 */ 
    627 static ssize_t regdump_show( struct device *_dev, char *buf)  
    628 
    629         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
    630  
     817static ssize_t regdump_show( struct device *_dev, 
     818#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     819                             struct device_attribute *attr, 
     820#endif 
     821                             char *buf)  
     822
     823#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     824        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     825        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     826#else 
     827        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     828#endif 
    631829        dwc_otg_dump_global_registers( otg_dev->core_if); 
    632830        if (dwc_otg_is_host_mode(otg_dev->core_if)) { 
     
    634832        } else { 
    635833                dwc_otg_dump_dev_registers( otg_dev->core_if); 
     834 
    636835        } 
    637836        return sprintf( buf, "Register Dump\n" ); 
     
    641840 
    642841/** 
     842 * Dump global registers and either host or device registers (depending on the 
     843 * current mode of the core). 
     844 */ 
     845static ssize_t spramdump_show( struct device *_dev, 
     846#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     847                               struct device_attribute *attr, 
     848#endif 
     849                               char *buf)  
     850{ 
     851#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     852        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     853        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     854#else 
     855        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     856#endif 
     857        dwc_otg_dump_spram( otg_dev->core_if); 
     858 
     859        return sprintf( buf, "SPRAM Dump\n" ); 
     860} 
     861 
     862DEVICE_ATTR(spramdump, S_IRUGO|S_IWUSR, spramdump_show, 0); 
     863 
     864/** 
    643865 * Dump the current hcd state. 
    644866 */ 
    645 static ssize_t hcddump_show( struct device *_dev, char *buf)  
     867static ssize_t hcddump_show( struct device *_dev, 
     868#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     869                             struct device_attribute *attr, 
     870#endif 
     871                             char *buf)  
    646872{ 
    647873#ifndef DWC_DEVICE_ONLY 
    648         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     874#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     875        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     876        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     877#else 
     878        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     879#endif 
    649880        dwc_otg_hcd_dump_state(otg_dev->hcd); 
    650881#endif 
     
    659890 * start transfer and two additional sample points. 
    660891 */ 
    661 static ssize_t hcd_frrem_show( struct device *_dev, char *buf)  
     892static ssize_t hcd_frrem_show( struct device *_dev, 
     893#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     894                               struct device_attribute *attr, 
     895#endif 
     896                               char *buf)  
    662897{ 
    663898#ifndef DWC_DEVICE_ONLY 
    664         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     899#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     900        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     901        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     902#else 
     903        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     904#endif 
    665905        dwc_otg_hcd_dump_frrem(otg_dev->hcd); 
    666906#endif 
     
    676916#define RW_REG_COUNT 10000000 
    677917#define MSEC_PER_JIFFIE 1000/HZ  
    678 static ssize_t rd_reg_test_show( struct device *_dev, char *buf)  
    679 
     918static ssize_t rd_reg_test_show( struct device *_dev, 
     919#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     920                                 struct device_attribute *attr, 
     921#endif 
     922                                 char *buf)  
     923
     924#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     925        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     926        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     927#else 
     928        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     929#endif 
    680930        int i; 
    681931        int time; 
    682932        int start_jiffies; 
    683         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
    684933 
    685934        printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", 
     
    700949 * output shows the number of times the register is written). 
    701950 */ 
    702 static ssize_t wr_reg_test_show( struct device *_dev, char *buf)  
    703 
     951static ssize_t wr_reg_test_show( struct device *_dev, 
     952#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     953                                 struct device_attribute *attr, 
     954#endif 
     955                                 char *buf)  
     956
     957#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     958        struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 
     959        dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 
     960#else 
     961        dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
     962#endif 
     963        uint32_t reg_val; 
    704964        int i; 
    705965        int time; 
    706966        int start_jiffies; 
    707         dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 
    708         uint32_t reg_val; 
    709967 
    710968        printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", 
     
    728986void dwc_otg_attr_create (struct lm_device *lmdev) 
    729987{ 
    730         device_create_file(&lmdev->dev, &dev_attr_regoffset); 
    731         device_create_file(&lmdev->dev, &dev_attr_regvalue); 
    732         device_create_file(&lmdev->dev, &dev_attr_mode); 
    733         device_create_file(&lmdev->dev, &dev_attr_hnpcapable); 
    734         device_create_file(&lmdev->dev, &dev_attr_srpcapable); 
    735         device_create_file(&lmdev->dev, &dev_attr_hnp); 
    736         device_create_file(&lmdev->dev, &dev_attr_srp); 
    737         device_create_file(&lmdev->dev, &dev_attr_buspower); 
    738         device_create_file(&lmdev->dev, &dev_attr_bussuspend); 
    739         device_create_file(&lmdev->dev, &dev_attr_busconnected); 
    740         device_create_file(&lmdev->dev, &dev_attr_gotgctl); 
    741         device_create_file(&lmdev->dev, &dev_attr_gusbcfg); 
    742         device_create_file(&lmdev->dev, &dev_attr_grxfsiz); 
    743         device_create_file(&lmdev->dev, &dev_attr_gnptxfsiz); 
    744         device_create_file(&lmdev->dev, &dev_attr_gpvndctl); 
    745         device_create_file(&lmdev->dev, &dev_attr_ggpio); 
    746         device_create_file(&lmdev->dev, &dev_attr_guid); 
    747         device_create_file(&lmdev->dev, &dev_attr_gsnpsid); 
    748         device_create_file(&lmdev->dev, &dev_attr_devspeed); 
    749         device_create_file(&lmdev->dev, &dev_attr_enumspeed); 
    750         device_create_file(&lmdev->dev, &dev_attr_hptxfsiz); 
    751         device_create_file(&lmdev->dev, &dev_attr_hprt0); 
    752         device_create_file(&lmdev->dev, &dev_attr_remote_wakeup); 
    753         device_create_file(&lmdev->dev, &dev_attr_regdump); 
    754         device_create_file(&lmdev->dev, &dev_attr_hcddump); 
    755         device_create_file(&lmdev->dev, &dev_attr_hcd_frrem); 
    756         device_create_file(&lmdev->dev, &dev_attr_rd_reg_test); 
    757         device_create_file(&lmdev->dev, &dev_attr_wr_reg_test); 
     988        int error; 
     989         
     990        error = device_create_file(&lmdev->dev, &dev_attr_regoffset); 
     991        error = device_create_file(&lmdev->dev, &dev_attr_regvalue); 
     992        error = device_create_file(&lmdev->dev, &dev_attr_mode); 
     993        error = device_create_file(&lmdev->dev, &dev_attr_hnpcapable); 
     994        error = device_create_file(&lmdev->dev, &dev_attr_srpcapable); 
     995        error = device_create_file(&lmdev->dev, &dev_attr_hnp); 
     996        error = device_create_file(&lmdev->dev, &dev_attr_srp); 
     997        error = device_create_file(&lmdev->dev, &dev_attr_buspower); 
     998        error = device_create_file(&lmdev->dev, &dev_attr_bussuspend); 
     999        error = device_create_file(&lmdev->dev, &dev_attr_busconnected); 
     1000        error = device_create_file(&lmdev->dev, &dev_attr_gotgctl); 
     1001        error = device_create_file(&lmdev->dev, &dev_attr_gusbcfg); 
     1002        error = device_create_file(&lmdev->dev, &dev_attr_grxfsiz); 
     1003        error = device_create_file(&lmdev->dev, &dev_attr_gnptxfsiz); 
     1004        error = device_create_file(&lmdev->dev, &dev_attr_gpvndctl); 
     1005        error = device_create_file(&lmdev->dev, &dev_attr_ggpio); 
     1006        error = device_create_file(&lmdev->dev, &dev_attr_guid); 
     1007        error = device_create_file(&lmdev->dev, &dev_attr_gsnpsid); 
     1008        error = device_create_file(&lmdev->dev, &dev_attr_devspeed); 
     1009        error = device_create_file(&lmdev->dev, &dev_attr_enumspeed); 
     1010        error = device_create_file(&lmdev->dev, &dev_attr_hptxfsiz); 
     1011        error = device_create_file(&lmdev->dev, &dev_attr_hprt0); 
     1012        error = device_create_file(&lmdev->dev, &dev_attr_remote_wakeup); 
     1013        error = device_create_file(&lmdev->dev, &dev_attr_regdump); 
     1014        error = device_create_file(&lmdev->dev, &dev_attr_spramdump); 
     1015        error = device_create_file(&lmdev->dev, &dev_attr_hcddump); 
     1016        error = device_create_file(&lmdev->dev, &dev_attr_hcd_frrem); 
     1017        error = device_create_file(&lmdev->dev, &dev_attr_rd_reg_test); 
     1018        error = device_create_file(&lmdev->dev, &dev_attr_wr_reg_test); 
    7581019} 
    7591020 
     
    7871048        device_remove_file(&lmdev->dev, &dev_attr_remote_wakeup);       
    7881049        device_remove_file(&lmdev->dev, &dev_attr_regdump); 
     1050        device_remove_file(&lmdev->dev, &dev_attr_spramdump); 
    7891051        device_remove_file(&lmdev->dev, &dev_attr_hcddump); 
    7901052        device_remove_file(&lmdev->dev, &dev_attr_hcd_frrem);