From patchwork Sun Jan 6 17:19:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 1937821 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8611940AFD for ; Sun, 6 Jan 2013 17:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756053Ab3AFRTu (ORCPT ); Sun, 6 Jan 2013 12:19:50 -0500 Received: from pequod.mess.org ([46.65.169.142]:55138 "EHLO pequod.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755774Ab3AFRTs (ORCPT ); Sun, 6 Jan 2013 12:19:48 -0500 Received: by pequod.mess.org (Postfix, from userid 1000) id CF9FE15FE1; Sun, 6 Jan 2013 17:19:45 +0000 (GMT) From: Sean Young To: Mauro Carvalho Chehab , =?UTF-8?q?David=20H=C3=A4rdeman?= Cc: linux-media@vger.kernel.org Subject: [PATCH 3/3] [media] iguanair: intermittent initialization failure Date: Sun, 6 Jan 2013 17:19:45 +0000 Message-Id: <1357492785-30966-3-git-send-email-sean@mess.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1357492785-30966-1-git-send-email-sean@mess.org> References: <1357492785-30966-1-git-send-email-sean@mess.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sometimes the first version request is sent before the device has fully initialized. This seems to happen on some hardware during boot when the iguanair is plugged into a root hub. Signed-off-by: Sean Young --- drivers/media/rc/iguanair.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c index a569c69..bc3557b 100644 --- a/drivers/media/rc/iguanair.c +++ b/drivers/media/rc/iguanair.c @@ -224,6 +224,14 @@ static int iguanair_get_features(struct iguanair *ir) ir->packet->header.cmd = CMD_GET_VERSION; rc = iguanair_send(ir, sizeof(ir->packet->header)); + + /* + * We might have sent the command before the device had time to + * initialize. Retry if we got no response. + */ + if (rc == -ETIMEDOUT) + rc = iguanair_send(ir, sizeof(ir->packet->header)); + if (rc) { dev_info(ir->dev, "failed to get version\n"); goto out; @@ -255,19 +263,14 @@ static int iguanair_get_features(struct iguanair *ir) ir->packet->header.cmd = CMD_GET_FEATURES; rc = iguanair_send(ir, sizeof(ir->packet->header)); - if (rc) { + if (rc) dev_info(ir->dev, "failed to get features\n"); - goto out; - } - out: return rc; } static int iguanair_receiver(struct iguanair *ir, bool enable) { - int rc; - ir->packet->header.start = 0; ir->packet->header.direction = DIR_OUT; ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF; @@ -275,9 +278,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable) if (enable) ir_raw_event_reset(ir->rc); - rc = iguanair_send(ir, sizeof(ir->packet->header)); - - return rc; + return iguanair_send(ir, sizeof(ir->packet->header)); } /*