Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3790424pxb; Mon, 4 Oct 2021 09:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHYBi7/Ss42N34wckIxZ7qStJNT+iqmUxhrCSJMjYXp8kECR0RZrccp5Kq6UQPG8y17f8I X-Received: by 2002:a17:906:3913:: with SMTP id f19mr18282756eje.357.1633365546863; Mon, 04 Oct 2021 09:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633365546; cv=none; d=google.com; s=arc-20160816; b=ecUAnbqQ39hOGEOM4CU4q17qrDNl6k1T4rKqjhol0Sc0ihjS8SlTRHDVxQVwZqH2Z1 NXecXzucT7VyBHfomC1/XEqCMElal0ZFuCsmTWjgubS5KeLAxlvCHQvTVoZWJF8vUIO2 qO3zxBkzD3wGQvr14rgqTGjXJLaRLuJnKWSG5WvZEAxSuIUv+xB5A4/REcEqQspWjIkN 0gVRjfOf9KIeJmQwe5k4Fkq2DHGMG7tJ7zynHO3fs7yq794ZL1P+KpoN2v3g7Wiyzqxw h6xOrxfmTgcjhSRhqiOzsDzama7f8uuPu2CLrthDLRO6u7+lxEWQdjzbaM7kNL6wqX5c Ob0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i7JHzbHnDH+XYXTkdDqnTpUenk61Qbtb48ldAMM5ll8=; b=C5DuE98MNW+181rgJLycxYx86L3BJ37rm9ejySgToUSKyAv9a+kaqS4m0yr3FE5k+i coMujjdTMPoIqw5lQqu7yFuWJZmSnUArIHC+nMtej6VEmOgknqlI3wOnEmTfaRVWrrg1 wConCKOndoiXXh+2hRndgNYbW6aNuZ0pSx1aRDLRlUNty2IhubzAQZuXdxUmNIpmIkZ+ 53Pbe6mQDvAritFWvcg5ATyDu1S0lSiTEivyUG+W5WLLzVoGqVWIcNg2zTvXi03TLIMx 2i0LK40oOsCYu3L5tZrZQKkcyC1j0VV1ZY/29++WfdiQKs9XZ1zGMPAbv9xuKVwSNQoC DOaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J2BolHZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si25002417ede.314.2021.10.04.09.38.43; Mon, 04 Oct 2021 09:39:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J2BolHZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238158AbhJDNhJ (ORCPT + 99 others); Mon, 4 Oct 2021 09:37:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:47354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237433AbhJDNfQ (ORCPT ); Mon, 4 Oct 2021 09:35:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A88A63234; Mon, 4 Oct 2021 13:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353353; bh=32F6x39IuP+xV2Coi3AfhZCg5iYWqEXEbn+cTJ3EV5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2BolHZSQ7qK2DDVsQVttqSOAv0BvFfZ7qQvvXol8VKySpB5LbDjg3C8VktYZrzRl r6iC6g0gxtD/w1pA+CHP74dWNdbWrKt/SGjWUbDLRC3YHsUkQbtgV7bgTQiOMVedaW gYiIBwYmYmA3XnQBTqWg+8/0IhUfkSBCNWm74DAE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Young , Mauro Carvalho Chehab Subject: [PATCH 5.14 063/172] media: ir_toy: prevent device from hanging during transmit Date: Mon, 4 Oct 2021 14:51:53 +0200 Message-Id: <20211004125047.025237923@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Young commit f0c15b360fb65ee39849afe987c16eb3d0175d0d upstream. If the IR Toy is receiving IR while a transmit is done, it may end up hanging. We can prevent this from happening by re-entering sample mode just before issuing the transmit command. Link: https://github.com/bengtmartensson/HarcHardware/discussions/25 Cc: stable@vger.kernel.org Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/rc/ir_toy.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -24,6 +24,7 @@ static const u8 COMMAND_VERSION[] = { 'v // End transmit and repeat reset command so we exit sump mode static const u8 COMMAND_RESET[] = { 0xff, 0xff, 0, 0, 0, 0, 0 }; static const u8 COMMAND_SMODE_ENTER[] = { 's' }; +static const u8 COMMAND_SMODE_EXIT[] = { 0 }; static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 }; #define REPLY_XMITCOUNT 't' @@ -309,12 +310,30 @@ static int irtoy_tx(struct rc_dev *rc, u buf[i] = cpu_to_be16(v); } - buf[count] = cpu_to_be16(0xffff); + buf[count] = 0xffff; irtoy->tx_buf = buf; irtoy->tx_len = size; irtoy->emitted = 0; + // There is an issue where if the unit is receiving IR while the + // first TXSTART command is sent, the device might end up hanging + // with its led on. It does not respond to any command when this + // happens. To work around this, re-enter sample mode. + err = irtoy_command(irtoy, COMMAND_SMODE_EXIT, + sizeof(COMMAND_SMODE_EXIT), STATE_RESET); + if (err) { + dev_err(irtoy->dev, "exit sample mode: %d\n", err); + return err; + } + + err = irtoy_command(irtoy, COMMAND_SMODE_ENTER, + sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND); + if (err) { + dev_err(irtoy->dev, "enter sample mode: %d\n", err); + return err; + } + err = irtoy_command(irtoy, COMMAND_TXSTART, sizeof(COMMAND_TXSTART), STATE_TX); kfree(buf);