Hi Daniel,

On Sat, 23 Sep 2006 16:24:46 -0400, Daniel Drake wrote:

> Matthieu CASTET wrote:
>> Daniel, Ulrich is it possible to know if the firmware is already loaded ?
>> I wanted to use zd_ioread16_locked(chip, &version, FW_FIRMWARE_VER);, but
>> it need context that aren't available at firmware_upload time.
> 
> I don't know, and we generally don't get to know fine details of the 
> hardware like this.
> 
> In my opinion you are looking in the wrong place. Instead you should be 
> comparing our driver to the vendor driver and see what is done 
> differently. There's works, ours has this bug.
I don't like the hackish way of the vendor driver.
I try to play with the vendor driver, and didn't find what's the problem.


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.


Matthieu

PS : i attach the patch, but it is not realy clean (I don't check 
is_firmware_loaded error case ...)

diff -ru /tmp/zd1211_2006-09-23/zd_usb.c ./zd_usb.c
--- /tmp/zd1211_2006-09-23/zd_usb.c     2006-09-09 12:14:14.000000000 +0200
+++ ./zd_usb.c  2006-09-23 23:19:55.000000000 +0200
@@ -1008,6 +1008,26 @@
        return 0;
 }
 
+static int is_firmware_loaded(struct usb_device *udev)
+{
+       u32 ret;
+       int r;
+
+       r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+                       USB_REQ_FIRMWARE_READ_DATA,
+                       USB_DIR_IN | USB_TYPE_VENDOR,
+                       /*offset */ FW_START_OFFSET, 0, &ret, sizeof(ret), 5000 
/* ms */);
+       if (r != sizeof(ret)) {
+               dev_err(&udev->dev,
+                               "control request firmeware confirmation failed."
+                               " Return value %d\n", r);
+               if (r >= 0)
+                       return -ENODEV;
+       }
+       /* it is the begining of uph firmware */
+       return ret == 0xedff9108;
+}
+
 static int probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
        int r;
@@ -1036,11 +1056,13 @@
                goto error;
        }
 
-       r = upload_firmware(udev, id->driver_info);
-       if (r) {
-               dev_err(&intf->dev,
-                      "couldn't load firmware. Error number %d\n", r);
-               goto error;
+       if (!is_firmware_loaded(udev)) {
+               r = upload_firmware(udev, id->driver_info);
+               if (r) {
+                       dev_err(&intf->dev,
+                                       "couldn't load firmware. Error number 
%d\n", r);
+                       goto error;
+               }
        }
 
        r = usb_reset_configuration(udev);
@@ -1073,7 +1095,7 @@
        dev_info(&intf->dev,"%s\n", netdev->name);
        return 0;
 error:
-       usb_reset_device(interface_to_usbdev(intf));
+       //usb_reset_device(interface_to_usbdev(intf));
        zd_netdev_free(netdev);
        return r;
 }
@@ -1102,7 +1124,7 @@
         * reset will not be executed here, the upload of the firmware in the
         * probe function caused by the reloading of the driver will fail.
         */
-       usb_reset_device(interface_to_usbdev(intf));
+       //usb_reset_device(interface_to_usbdev(intf));
 
        zd_netdev_free(netdev);
        dev_dbg(&intf->dev, "disconnected\n");


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Zd1211-devs mailing list - http://zd1211.ath.cx/
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/zd1211-devs

Reply via email to