Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2886523pxb; Sun, 28 Feb 2021 17:19:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwH4ui5Fi/yRUjTaWyl03k7R2lujiJHOOBe/YtS874EWDvOqKw8kPUkSafr3JAyfXagXgY7 X-Received: by 2002:a05:6402:5250:: with SMTP id t16mr14038532edd.302.1614561583664; Sun, 28 Feb 2021 17:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614561583; cv=none; d=google.com; s=arc-20160816; b=HwUi+YawLspUbvVmxxL/RZgfe1s2/cwowMtL8GE6+nlBdTTjEHQKsLGDobijAFAyo0 TUTeq3JZ7e9UMBR7z6gFGyLobIfoXPWCAB6P7BmHocZOz+We2nCI+lR6GbzyV9VE6Nwk j6Iks9LfY9rXIwpSOx9lLPVVlbMOKGEsf8yA/8PqJiK30WOyXqvtQLOWGN5Ms41JtgQm vaBAXRgTbW6kleZHX0tHAvwRlqaRqiiuD8NvVlS5+4O0Jl6kMXUVzxqZpMn/cfXEYmGT eGN+3Sa3pNwjY90e0u2+qsyaAMBht1Kv/p1n6OoFPss9A7WS+aoemwUEeXo8gSJB9NXG IAHw== 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:dkim-signature:dkim-filter :date; bh=mbPn0neLZcgRJejMJaMjct0DkzF3tnCRvFCGemkflVg=; b=iyBQpvR9QggtbGn0AFmNyuLZCmu3xI5OnGEa3MK1G/aX7eozHqRMMyfRJ8PD16qqVH RZ/XKZEN+RsIiRbYkm+fK5aGOl//I3FUBBOHyOfvopSQYf/USfXE4BV0+NL88nDcXGH4 3RTfJr5xMJTWNEnKoW6FgQhDn3xtnBxYW8qnXKS2HuYKDyydGLLJOsv5pfJme/LxlefN WZxV9+8sRBS5TYCBTELxsvdwC/R7WEgtjZwNJD6OgCxmz+mtFddI7Pecz3NEgYLs4l1f lUuXzjxrG2BJZIk0rG/JGkTbBgdcwvYf+A6wVo27WrJwi+Emr3wNclRSuqDORmKYjjUk W8vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@innovation.ch header.s=default header.b=WVhY98tL; 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=QUARANTINE dis=NONE) header.from=innovation.ch Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si10125177edr.95.2021.02.28.17.19.21; Sun, 28 Feb 2021 17:19:43 -0800 (PST) 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=@innovation.ch header.s=default header.b=WVhY98tL; 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=QUARANTINE dis=NONE) header.from=innovation.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbhCAAFN (ORCPT + 99 others); Sun, 28 Feb 2021 19:05:13 -0500 Received: from ec2-44-228-98-151.us-west-2.compute.amazonaws.com ([44.228.98.151]:54128 "EHLO chill.innovation.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbhCAAFL (ORCPT ); Sun, 28 Feb 2021 19:05:11 -0500 Received: from localhost (localhost [127.0.0.1]) by chill.innovation.ch (Postfix) with ESMTP id EBF7B1B5ACE; Mon, 1 Mar 2021 00:04:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at innovation.ch Received: from chill.innovation.ch ([127.0.0.1]) by localhost (chill.innovation.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0jlRjtn27m3V; Mon, 1 Mar 2021 00:04:30 +0000 (UTC) Date: Mon, 1 Mar 2021 00:04:30 +0000 DKIM-Filter: OpenDKIM Filter v2.11.0 chill.innovation.ch 78F081B6455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=innovation.ch; s=default; t=1614557070; bh=mbPn0neLZcgRJejMJaMjct0DkzF3tnCRvFCGemkflVg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WVhY98tLOyzCz4G0i3Co0sjUrs1QLKzRChFXwi9co8ncAXusTmGS5xLttk78YAQFu 6jLSG3c9sYC5CgICV4ixEQ14/xnUOgHeT8MDDKNaaRsXnR4vpdTkSTnJH2CtF7gNNR 2G1BQM55j02tCgATdepgTYAoosJYfsxoi0Ft26BTvwKtQDKtepIvuhs4h8Yzb6qbyE P2BnivEJv+wJr8BOa5mtFVgRlOLwSnL/OsAFLNH5fbmOuy/a9tAz7v+yd4hDrl76+N P4+sWPiDRPiaEgZEOLlW6RVbQO9YLhYZfLvUPAGL/xkstRfHJujMcAxaQmkxEFMxVY bKP+T1WAtC/Rw== From: "Life is hard, and then you die" To: Jonathan Cameron Cc: Jiri Kosina , Benjamin Tissoires , Jonathan Cameron , Srinivas Pandruvada , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH 4/5] HID: apple-ibridge: Add Apple iBridge HID driver for T1 chip. Message-ID: <20210301000430.GA754582@innovation.ch> References: <20210228012643.69944-1-ronald@innovation.ch> <20210228012643.69944-5-ronald@innovation.ch> <20210228150239.00007d34@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20210228150239.00007d34@Huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, On Sun, Feb 28, 2021 at 03:02:39PM +0000, Jonathan Cameron wrote: > On Sat, 27 Feb 2021 17:26:42 -0800 > Ronald Tschal?r wrote: [snip] > > +#ifdef CONFIG_PM > > +/** > > + * appleib_forward_int_op() - Forward a hid-driver callback to all drivers on > > + * all virtual HID devices attached to the given real HID device. > > + * @hdev the real hid-device > > + * @forward a function that calls the callback on the given driver > > + * @args arguments for the forward function > > + * > > + * This is for callbacks that return a status as an int. > > + * > > + * Returns: 0 on success, or the first error returned by the @forward function. > > + */ > > +static int appleib_forward_int_op(struct hid_device *hdev, > > + int (*forward)(struct hid_driver *, > > + struct hid_device *, void *), > > + void *args) > > +{ > > + struct appleib_hid_dev_info *hdev_info = hid_get_drvdata(hdev); > > + struct hid_device *sub_hdev; > > + int rc = 0; > > + int i; > > + > > + for (i = 0; i < ARRAY_SIZE(hdev_info->sub_hdevs); i++) { > > + sub_hdev = hdev_info->sub_hdevs[i]; > > + if (sub_hdev->driver) { > > + rc = forward(sub_hdev->driver, sub_hdev, args); > > + if (rc) > > + break; > > return rc; here would be cleaner. > > > + } > > + > > + break; > > This is unusual. It's a for loop but as far as I can see only first iteration > can ever run as we exit the loop at this break if we haven't done so earlier. > What is the intent here? > > > + } > > + > > + return rc; > > +} Ho boy, good catch! This is simply a mistake. As you say, it should (and does now) read: for (i = 0; i < ARRAY_SIZE(hdev_info->sub_hdevs); i++) { sub_hdev = hdev_info->sub_hdevs[i]; if (sub_hdev->driver) { rc = forward(sub_hdev->driver, sub_hdev, args); if (rc) return rc; } } return rc; Thanks. Cheers, Ronald