Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1d643a372259749ce2029e386ed5760d5d7f8b89
Commit:     1d643a372259749ce2029e386ed5760d5d7f8b89
Parent:     4db666cc3d199a8b837174bb0ad00d6b8f6115d6
Author:     Mike Isely <[EMAIL PROTECTED]>
AuthorDate: Sat Sep 8 22:18:50 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 22:14:34 2007 -0300

    V4L/DVB (6209): pvrusb2: Better discriminate among device types
    
    This is a bunch of cleanup in various places to improve behavior based
    on actual device type being driven.  While this doesn't actually
    affect operation with existing devices, it cleans things up so that it
    will be easier / more deterministic when other devices are added.
    Ideally we should make stuff like this table-driven, but for now this
    is just a series of small incremental (read: safe) improvements.
    
    Signed-off-by: Mike Isely <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/pvrusb2/pvrusb2-hdw.c |   82 +++++++++++++++++++----------
 1 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 7172f66..c8ee379 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1143,6 +1143,13 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
                        fw_files_24xxx, ARRAY_SIZE(fw_files_24xxx)
                },
        };
+
+       if ((hdw->hdw_type >= ARRAY_SIZE(fw_file_defs)) ||
+           (!fw_file_defs[hdw->hdw_type].lst)) {
+               hdw->fw1_state = FW1_STATE_OK;
+               return 0;
+       }
+
        hdw->fw1_state = FW1_STATE_FAILED; // default result
 
        trace_firmware("pvr2_upload_firmware1");
@@ -1224,6 +1231,11 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
                CX2341X_FIRM_ENC_FILENAME,
        };
 
+       if ((hdw->hdw_type != PVR2_HDW_TYPE_29XXX) &&
+           (hdw->hdw_type != PVR2_HDW_TYPE_24XXX)) {
+               return 0;
+       }
+
        trace_firmware("pvr2_upload_firmware2");
 
        ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder",
@@ -1742,29 +1754,35 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
        unsigned int idx;
        struct pvr2_ctrl *cptr;
        int reloadFl = 0;
-       if (!reloadFl) {
-               reloadFl = (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints
-                           == 0);
-               if (reloadFl) {
-                       pvr2_trace(PVR2_TRACE_INIT,
-                                  "USB endpoint config looks strange"
-                                  "; possibly firmware needs to be loaded");
+       if ((hdw->hdw_type == PVR2_HDW_TYPE_29XXX) ||
+           (hdw->hdw_type == PVR2_HDW_TYPE_24XXX)) {
+               if (!reloadFl) {
+                       reloadFl =
+                               
(hdw->usb_intf->cur_altsetting->desc.bNumEndpoints
+                                == 0);
+                       if (reloadFl) {
+                               pvr2_trace(PVR2_TRACE_INIT,
+                                          "USB endpoint config looks strange"
+                                          "; possibly firmware needs to be"
+                                          " loaded");
+                       }
                }
-       }
-       if (!reloadFl) {
-               reloadFl = !pvr2_hdw_check_firmware(hdw);
-               if (reloadFl) {
-                       pvr2_trace(PVR2_TRACE_INIT,
-                                  "Check for FX2 firmware failed"
-                                  "; possibly firmware needs to be loaded");
+               if (!reloadFl) {
+                       reloadFl = !pvr2_hdw_check_firmware(hdw);
+                       if (reloadFl) {
+                               pvr2_trace(PVR2_TRACE_INIT,
+                                          "Check for FX2 firmware failed"
+                                          "; possibly firmware needs to be"
+                                          " loaded");
+                       }
                }
-       }
-       if (reloadFl) {
-               if (pvr2_upload_firmware1(hdw) != 0) {
-                       pvr2_trace(PVR2_TRACE_ERROR_LEGS,
-                                  "Failure uploading firmware1");
+               if (reloadFl) {
+                       if (pvr2_upload_firmware1(hdw) != 0) {
+                               pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+                                          "Failure uploading firmware1");
+                       }
+                       return;
                }
-               return;
        }
        hdw->fw1_state = FW1_STATE_OK;
 
@@ -1773,17 +1791,25 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
        }
        if (!pvr2_hdw_dev_ok(hdw)) return;
 
-       for (idx = 0; idx < pvr2_client_lists[hdw->hdw_type].cnt; idx++) {
-               request_module(pvr2_client_lists[hdw->hdw_type].lst[idx]);
+       if (hdw->hdw_type < ARRAY_SIZE(pvr2_client_lists)) {
+               for (idx = 0;
+                    idx < pvr2_client_lists[hdw->hdw_type].cnt;
+                    idx++) {
+                       request_module(
+                               pvr2_client_lists[hdw->hdw_type].lst[idx]);
+               }
        }
 
-       pvr2_hdw_cmd_powerup(hdw);
-       if (!pvr2_hdw_dev_ok(hdw)) return;
+       if ((hdw->hdw_type == PVR2_HDW_TYPE_29XXX) ||
+           (hdw->hdw_type == PVR2_HDW_TYPE_24XXX)) {
+               pvr2_hdw_cmd_powerup(hdw);
+               if (!pvr2_hdw_dev_ok(hdw)) return;
 
-       if (pvr2_upload_firmware2(hdw)){
-               pvr2_trace(PVR2_TRACE_ERROR_LEGS,"device unstable!!");
-               pvr2_hdw_render_useless(hdw);
-               return;
+               if (pvr2_upload_firmware2(hdw)){
+                       pvr2_trace(PVR2_TRACE_ERROR_LEGS,"device unstable!!");
+                       pvr2_hdw_render_useless(hdw);
+                       return;
+               }
        }
 
        // This step MUST happen after the earlier powerup step.
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to