Matthieu CASTET wrote:
> 
> 
> Daniel Drake wrote:
> 
>> Matthieu CASTET wrote:
>>
>>> Waiting for a clean solution I found a way to solve my problem : I read
>>> the
>>> start of the firmware in order to see if it is already loaded.
>>
>>
>>
>> This approach looks acceptable (although the actual implementation needs
>> cleaning a little) - thanks for investigating!
> 
> Here a more clean patch.
> There still a problem if a wrong firmware was loaded by another driver
> (windows or vendor driver) : we won't reload the one supported by our
> driver.
> 
>>
>> Have you been able to tell why the vendor driver does not suffer the same
>> problem? It would be good if we had more than one approach to choose from
>> :)
> 
> The vendor driver doesn't recover a rmmod of the rw driver.
> 
> 

I try to you patch for use in vendor version driver as following;

diff -c zd1211b-0613-org/zdusb.c zd1211b/zdusb.c
*** zd1211b-0613-org/zdusb.c    Wed Jun 13 17:23:51 2007
--- zd1211b/zdusb.c     Thu Jun 14 16:31:39 2007
***************
*** 106,111 ****
--- 109,172 ----


  MODULE_DEVICE_TABLE(usb, zd1211_ids);
+
+ #if 1
+
+ #define LOAD_VEC_START_OFFSET 0xfff7
+
+ static int
+ is_firmware_loaded (struct zd1205_private *macp)
+ {
+   int r;
+   u16 reset_vector;
+   int cache_size ;
+   u8 *pbuf, *ptr;
+
+   printk ("is_firmware_loaded-\n");
+   cache_size = dma_get_cache_alignment();
+   pbuf = kmalloc(cache_size * 2, GFP_KERNEL);
+
+   if (pbuf == NULL)
+     {
+       printk(KERN_ERR "zd1211(is_firmware_loaded): can't allocate
memory\n");
+       goto exit;
+   }
+
+   ptr = (u8 *)((u32)(pbuf + cache_size - 1) & ~((u32)(cache_size - 1)));
+   r = usb_control_msg
+     (macp->usb,
+      usb_rcvctrlpipe(macp->usb, 0),
+      FIRMWARE_READ_DATA,
+      USB_DIR_IN | 0x40,
+      LOAD_VEC_START_OFFSET,
+      0,
+      ptr,
+      sizeof(reset_vector),
+      1000 * HZ);
+     if (r != sizeof(reset_vector))
+       {
+       printk(KERN_ERR,
+ "zd1211(is_firmware_loaded)* usb_rcvctripipe 1 fail,\n  control request
firme\
ware read.  Return value %d\n", r);
+       goto exit;
+       }
+   reset_vector = *((u16*) ptr);
+   /* If a firware is loaded the reset_vector is the start of the
+    * firmware */
+   kfree (pbuf);
+   printk ("is_firmware_loaeded+, 0x%x(0x%x)\n",
+         reset_vector, cFIRMWARE_START_ADDR);
+   ZD1211DEBUG(0, "is_firmware_loaded: vector = %x, START_ADDR = %x\n",
+             reset_vector, cFIRMWARE_START_ADDR);
+   return reset_vector == cFIRMWARE_START_ADDR;
+
+  exit:
+   if (pbuf != NULL)
+     kfree(pbuf);
+   return -1;
+ }
+
+
+ #else /* !0 */
  int zd1211_FirstLoad = 1;
  #if 1
  #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
***************
*** 113,119 ****
  #else
  MODULE_PARM(zd1211_FirstLoad, "i");
  #endif
! #endif

  extern struct net_device *g_dev;
  #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
--- 174,181 ----
  #else
  MODULE_PARM(zd1211_FirstLoad, "i");
  #endif
! #endif /* 1 */
! #endif /* 0 */

  extern struct net_device *g_dev;
  #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
***************
*** 267,274 ****
--- 334,347 ----
      //If the driver was removed and reinstall without unplug the device.
      //You can tell the driver not to download the firmware again by issing
      //insmod zd1211b zd1211_FirstDown=0. Redownload causes device crash
+       printk ("before is_firmware_loaded\n");
+ #if 1
+     if (!is_firmware_loaded (macp))
+ #else
      if(zd1211_FirstLoad)
+ #endif
      {
+       ZD1211DEBUG(0, "!firmware_loaded and try to download\n");
          if (zd1211_Download_IncludeFile(macp) != 0){
              printk(KERN_ERR "zd1211_Download_IncludeFile failed\n");
              result = -EIO;


-- [EMAIL PROTECTED]    SRA




-- 
View this message in context: 
http://www.nabble.com/-zd1211rw--Driver-leaving-device-in-bugged-state---tf2288772.html#a11341388
Sent from the zd1211-devs mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Zd1211-devs mailing list - http://zd1211.wiki.sourceforge.net/
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/zd1211-devs

Reply via email to