Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9213167rwd; Wed, 21 Jun 2023 04:44:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Dz4bS+eVu8nYXgIFQgcIZFASEVfcneRL8oTh8u7MJv7EFfaCtYbKnTuL0mDNC8LKkGxn2 X-Received: by 2002:a17:90a:1908:b0:256:5dec:50ed with SMTP id 8-20020a17090a190800b002565dec50edmr11229596pjg.7.1687347859351; Wed, 21 Jun 2023 04:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687347859; cv=none; d=google.com; s=arc-20160816; b=opm49yIpoELjMqC/HSj1gxfCepVg1YhUaRYYOIoY5rFmtO7MoFgLO0xposkaW4QOpJ C4iuM9vRxQHu8Oy4fWFJBvhTeJsi++knCXjD/cN1XO9M/CN2T2wRQtnGXaPdjVO03clM YUMB1V1oa+4n9I2G/5hlOXGKMpTgwubdO4zYcbzDF89yCVtrNFJRZ3dLXFZWGe2eU2aL VMIn2q1zktJsndxMydcQdrp5BXRX398hpeXs5VoV8GA6D+u5HLvNwkdOBp90gk2Xtix+ oM4tAjiIZtxqMulu5NATF1H0Znlldo+xKPp09CkrejbXDWvNN/iEej2n5QjazEybZQ5G UgJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=h8uv74kexe5fPURtPC3MGLhbCOaTFswZcPNFTDqEOFc=; b=TlinfW3Ipl09iLBnAmfASClBxQyDawnxvVrbMUaLu9TAx5wmoQZYz+Pf7tXsIDxseh kAhby5+Y5ctX+XrQJS15jYidmyfx+b/oO8Cn3SC3KZxVaa4lZa7QWs0uM+n6VMUlg+7S lF6y2Qbv7iirYkyxfkRynNT8Y2Le2RR3MwkiIMEPXsPcqbHkTPu0d9nlBFoIzvP/yFls it65bnUfL3gWYBmflIX2+NVWwTswRylYxkKBAJjQG773SoPeeFGC/5t5b2ZsJEMX7T9q PxsKPsmIHLC/dQx8IvJ/X++KBvgPbJapIwUoVVDgiOKGIjyL6EAQFq79JaGsPRo/vvMZ a3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nG3Lb+8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a6546c3000000b0053424040bb7si2519756pgr.298.2023.06.21.04.44.05; Wed, 21 Jun 2023 04:44:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nG3Lb+8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232643AbjFUKwL (ORCPT + 99 others); Wed, 21 Jun 2023 06:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbjFUKvn (ORCPT ); Wed, 21 Jun 2023 06:51:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD4271BE6; Wed, 21 Jun 2023 03:50:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1062614E9; Wed, 21 Jun 2023 10:50:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB37BC433C8; Wed, 21 Jun 2023 10:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687344627; bh=cGQrS2SFrCOw8DMVAnIO4+fl2u2O+y02ZnnotmrAlDI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nG3Lb+8ZRwlReRXhUe9bnlJ/cH3779QLwSAvm9T8c0eCnkcx0Tp29YPVxvc0e7ep1 CuuFRPqzXv9l6vDxBjyCHtNmW28F5Dcn0MDwAjKYv9PH4EFcwyeuoj+LSrcv45HeIx NYwy3qlt8J6UPcvqCfVQbyLjQigXKA94bB9yCJYc= Date: Wed, 21 Jun 2023 12:50:21 +0200 From: Greg KH To: Benjamin Tissoires Cc: Filipe =?iso-8859-1?Q?La=EDns?= , Bastien Nocera , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] HID: logitech-hidpp: rework one more time the retries attempts Message-ID: <2023062156-trespass-pandemic-7f4f@gregkh> References: <20230621-logitech-fixes-v1-1-32e70933c0b0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230621-logitech-fixes-v1-1-32e70933c0b0@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 21, 2023 at 11:42:30AM +0200, Benjamin Tissoires wrote: > Make the code looks less like Pascal. > > Extract the internal code inside a helper function, fix the > initialization of the parameters used in the helper function > (`hidpp->answer_available` was not reset and `*response` wasn't too), > and use a `do {...} while();` loop. > > Fixes: 586e8fede795 ("HID: logitech-hidpp: Retry commands when device is busy") > Cc: stable@vger.kernel.org > Signed-off-by: Benjamin Tissoires > --- > as requested by https://lore.kernel.org/all/CAHk-=wiMbF38KCNhPFiargenpSBoecSXTLQACKS2UMyo_Vu2ww@mail.gmail.com/ > This is a rewrite of that particular piece of code. > --- > drivers/hid/hid-logitech-hidpp.c | 102 +++++++++++++++++++++++---------------- > 1 file changed, 61 insertions(+), 41 deletions(-) > > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c > index dfe8e09a18de..3d1ffe199f08 100644 > --- a/drivers/hid/hid-logitech-hidpp.c > +++ b/drivers/hid/hid-logitech-hidpp.c > @@ -275,21 +275,20 @@ static int __hidpp_send_report(struct hid_device *hdev, > } > > /* > - * hidpp_send_message_sync() returns 0 in case of success, and something else > - * in case of a failure. > - * - If ' something else' is positive, that means that an error has been raised > - * by the protocol itself. > - * - If ' something else' is negative, that means that we had a classic error > - * (-ENOMEM, -EPIPE, etc...) > + * Effectively send the message to the device, waiting for its answer. > + * > + * Must be called with hidpp->send_mutex locked > + * > + * Same return protocol than hidpp_send_message_sync(): > + * - success on 0 > + * - negative error means transport error > + * - positive value means protocol error > */ > -static int hidpp_send_message_sync(struct hidpp_device *hidpp, > +static int __do_hidpp_send_message_sync(struct hidpp_device *hidpp, > struct hidpp_report *message, > struct hidpp_report *response) __must_hold(&hidpp->send_mutex) ?