Received: by 10.223.185.116 with SMTP id b49csp6387720wrg; Wed, 28 Feb 2018 08:35:12 -0800 (PST) X-Google-Smtp-Source: AG47ELsYZkhLB4JbfWlBEgzTwDgMMJxqYK59SapDWqbXLBtZ0OBBJlA0Bz/1LK3iBlD0TP2DgsA/ X-Received: by 2002:a17:902:467:: with SMTP id 94-v6mr3363638ple.57.1519835712671; Wed, 28 Feb 2018 08:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519835712; cv=none; d=google.com; s=arc-20160816; b=eWM7DGXtXSRRsLvpVnZGxM9sUpEZZ8A0aD9Ye19R2Mo30/FRDf3aI9PfSEPbQqUK2j nElXCSeCQngpvL7t+sVcZvchr2Td3eIBUHEW+vCA7lLe7WUkccogSYHAO/qlpkMRQ1p9 gDjTmn4OeQCKbg8cpZ4Wvq/A8+10dwb4PnzPsOlAij/l63L5ebVVBlUgEgDu787Y18cn mM2IVlbWFVriFoAgpceQGhw14OyJ5Hi5KygJ5bs+nz9k43SOZwsDl8FDBQ2wQ50qY92Q zyzTiaKiAMiwYUjoam3M/75j/cA0burXjJMyaS5HIzWPzvBgq6xgxUnqz9mD27s3skle DI6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=RpqR5mtAhNF4bEPEnm98coaorJNHuraxSjDYRT2+h6s=; b=bUVhGu0g2AhB10KNN0edJw+ejdaoNpz1jkDG8bOXPdPz4Y+JlB5xljywFFGMil21SB +/84TXTnf+Um+AcHAWbS7sG4pLBrgxiB28a6GRZy6k6U9mLUHJoakp0u9cpI2pqTW1vc vATYRSGBmoDb92ud7hK6Tf2yYycxbmXVYnMZLpA7p7xx1eHE2Vl06HrAUSRp3W2qxVKz NPQ0Ogripf1LAxI8qEgyoAyucNibXnziUbO0uzQ7fj+b8r7vRSQd8FcBCWs9Eyvd6eOA dVYCx0k0wBQnpy7Ntaliu+ebC1e69JcymL0ZhMdYgEgeabldTsyu9Rxf7yZMPomGK1zf /YIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TrwHz4Rc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12si1205469pgq.491.2018.02.28.08.34.57; Wed, 28 Feb 2018 08:35:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TrwHz4Rc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934662AbeB1QOB (ORCPT + 99 others); Wed, 28 Feb 2018 11:14:01 -0500 Received: from mail-qt0-f181.google.com ([209.85.216.181]:35192 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932268AbeB1QN5 (ORCPT ); Wed, 28 Feb 2018 11:13:57 -0500 Received: by mail-qt0-f181.google.com with SMTP id z14so3632744qti.2; Wed, 28 Feb 2018 08:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=RpqR5mtAhNF4bEPEnm98coaorJNHuraxSjDYRT2+h6s=; b=TrwHz4RcFYBOf7EKiUgRHe8cRIq7Ic88Cm8c4WjANo8Jgjg3ON+tmgP8xAB+Zo9HMD 6/qMGJDq2SdJ6BcdgPqm46aarEuQ7juGTFo8gfDUm5f6yOn7XQ/TVfzm5NixrcjZLBvS LvYfEd3GsJlMvk7LqVcI26ykipfAQo+xb0tYoS/v+vfBtx+5rEfyd38/hIufYHn7zt5X xuivq6kO+kLIdajVSWveH6cLjQmger7CwFuivX3RpFHoZPCi7X8V8MH6XmA6c8+Fn2RJ tQXkMJjA70sdb764kF1DS8F8U2CzSX3BH+jdp5jd00RVnEH6wXSDYgRw4VHcErPo9R1f bN7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=RpqR5mtAhNF4bEPEnm98coaorJNHuraxSjDYRT2+h6s=; b=PCMvXGAWJsQI3ZG0xdoWMHgVuQelqZP0dzno16OZ+JApnONJtc0guMmFy6nKAhj9vb 37FBoTsSvilA+9VcjqrL1ME7Y413nKJ8rhn6w2lfd0Qn5sbnsjAxBAyzfxZOT13+HzIx Epe6KXoWcJQk0fC6IcZyz/u9m4W8tLgAvNDJhP5PH3P7AG8vvVXvR8vPWgX4POk03Kk8 Jzy7WV0OQazelJC9FnovkpT8TaNUe1tab/2bLwINYNVlu79ALbllA5aH7Oprq3lPnKTn 3jHkUZQ+goswQ4+Y0OzK4q7934LFRGCOBuuyQ6rei7o0ngpFM6zwMEBBZmkZKzYtC4Hg YDDg== X-Gm-Message-State: APf1xPApsESbxeBQj1itAJA8Hziw0+kEQ/k2zsaAw6Mbc/E2poZb55jD gc89NNL41KPWn5rfgj1z4eOyDpmZMEWy/mB7r/9i5qLG X-Received: by 10.237.48.229 with SMTP id 92mr19171524qtf.39.1519834436291; Wed, 28 Feb 2018 08:13:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Wed, 28 Feb 2018 08:13:55 -0800 (PST) In-Reply-To: <20180227211539.5708-7-kernel@kempniu.pl> References: <20180227211539.5708-1-kernel@kempniu.pl> <20180227211539.5708-7-kernel@kempniu.pl> From: Andy Shevchenko Date: Wed, 28 Feb 2018 18:13:55 +0200 Message-ID: Subject: Re: [PATCH 6/7] platform/x86: fujitsu-laptop: More accurately represent the hotkey ring buffer managed by firmware To: =?UTF-8?B?TWljaGHFgiBLxJlwaWXFhA==?= Cc: Jonathan Woithe , Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 27, 2018 at 11:15 PM, Micha=C5=82 K=C4=99pie=C5=84 wrote: > The MAX_HOTKEY_RINGBUFFER_SIZE constant is set to 100, which allows up > to 100 hotkey events to be drained from the firmware ring buffer upon > module load. However, no known firmware is capable of holding more than > 16 hotkey events in its internal ring buffer: > The RINGBUFFERSIZE constant is set to 40, which allows the module to > queue up to 40 hotkey events for delivery to user space. As this value > seems arbitrarily chosen and 16 should be more than enough for any > practical use case, merge the two aforementioned constants into one > (HOTKEY_RINGBUFFER_SIZE) in order to simplify code and more accurately > represent the underlying data structure. > +#define HOTKEY_RINGBUFFER_SIZE 16 This need the comment or a BUILD_BUG_ON(!is_power_of_2(...)); > - ret =3D kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), > + ret =3D kfifo_alloc(&priv->fifo, HOTKEY_RINGBUFFER_SIZE * sizeof(= int), > GFP_KERNEL); > while (call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENTS, > 0x0, 0x0) !=3D 0 && > - i++ < MAX_HOTKEY_RINGBUFFER_SIZE) > + i++ < HOTKEY_RINGBUFFER_SIZE) > ; /* No action, result is discarded */ This looks horrible. Can it be redone do { if (call...() =3D=3D 0) break; } while (i++ < ...); ? > while ((irb =3D call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENT= S, > 0x0, 0x0)) !=3D 0 && > - i++ < MAX_HOTKEY_RINGBUFFER_SIZE) { > + i++ < HOTKEY_RINGBUFFER_SIZE) { Ditto. > scancode =3D irb & 0x4ff; > if (sparse_keymap_entry_from_scancode(priv->input, scanco= de)) > acpi_fujitsu_laptop_press(device, scancode); --=20 With Best Regards, Andy Shevchenko