From patchwork Mon Apr 12 18:05:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sensoray-dev X-Patchwork-Id: 92065 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3CICLgD018124 for ; Mon, 12 Apr 2010 18:12:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659Ab0DLSMU (ORCPT ); Mon, 12 Apr 2010 14:12:20 -0400 Received: from gateway05.websitewelcome.com ([67.18.14.14]:43733 "HELO gateway05.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750776Ab0DLSMT (ORCPT ); Mon, 12 Apr 2010 14:12:19 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 12 Apr 2010 18:12:21 +0000 (UTC) X-Greylist: delayed 398 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 Apr 2010 14:12:19 EDT Received: (qmail 1764 invoked from network); 12 Apr 2010 18:06:58 -0000 Received: from gator886.hostgator.com (174.120.40.226) by gateway05.websitewelcome.com with SMTP; 12 Apr 2010 18:06:58 -0000 Received: from [66.15.212.169] (port=18320 helo=user-desktop.local) by gator886.hostgator.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1O1O0z-0002ph-Bk; Mon, 12 Apr 2010 13:05:41 -0500 Date: Mon, 12 Apr 2010 11:05:37 -0700 (PDT) From: sensoray-dev Subject: [PATCH] s2255drv: firmware reload on timeout To: linux-media@vger.kernel.org Message-ID: MIME-Version: 1.0 Content-Disposition: INLINE X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator886.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sensoray.com Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -r 686a2330f4a6 -r 88db759d6bdf linux/drivers/media/video/s2255drv.c --- a/linux/drivers/media/video/s2255drv.c Mon Apr 12 10:15:23 2010 -0700 +++ b/linux/drivers/media/video/s2255drv.c Mon Apr 12 11:01:37 2010 -0700 @@ -58,7 +58,7 @@ #include "compat.h" #define S2255_MAJOR_VERSION 1 -#define S2255_MINOR_VERSION 19 +#define S2255_MINOR_VERSION 20 #define S2255_RELEASE 0 #define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \ S2255_MINOR_VERSION, \ @@ -1753,7 +1753,7 @@ == S2255_FW_SUCCESS) || (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING)), - msecs_to_jiffies(S2255_LOAD_TIMEOUT)); + msecs_to_jiffies(S2255_LOAD_TIMEOUT)); /* state may have changed, re-read */ state = atomic_read(&dev->fw_data->fw_state); break; @@ -1761,27 +1761,38 @@ default: break; } - mutex_unlock(&dev->open_lock); /* state may have changed in above switch statement */ switch (state) { case S2255_FW_SUCCESS: break; case S2255_FW_FAILED: printk(KERN_INFO "2255 firmware load failed.\n"); + mutex_unlock(&dev->open_lock); return -ENODEV; case S2255_FW_DISCONNECTING: printk(KERN_INFO "%s: disconnecting\n", __func__); + mutex_unlock(&dev->open_lock); return -ENODEV; case S2255_FW_LOADED_DSPWAIT: case S2255_FW_NOTLOADED: printk(KERN_INFO "%s: firmware not loaded yet" "please try again later\n", __func__); + /* + * Timeout on firmware load means device unusable. + * Set firmware failure state. + * On next s2255_open the firmware will be reloaded. + */ + atomic_set(&dev->fw_data->fw_state, + S2255_FW_FAILED); + mutex_unlock(&dev->open_lock); return -EAGAIN; default: printk(KERN_INFO "%s: unknown state\n", __func__); + mutex_unlock(&dev->open_lock); return -EFAULT; } + mutex_unlock(&dev->open_lock); /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh), GFP_KERNEL); if (NULL == fh) @@ -2074,7 +2085,6 @@ dprintk(5, "setmode ready %d\n", cc); break; case S2255_RESPONSE_FW: - dev->chn_ready |= (1 << cc); if ((dev->chn_ready & 0x0f) != 0x0f) break;