From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B9F8C4332F for ; Thu, 9 Nov 2023 18:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345039AbjKISzA (ORCPT ); Thu, 9 Nov 2023 13:55:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbjKISy6 (ORCPT ); Thu, 9 Nov 2023 13:54:58 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805F23C13 for ; Thu, 9 Nov 2023 10:54:56 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6bcbfecf314so288014b3a.1 for ; Thu, 09 Nov 2023 10:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556096; x=1700160896; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gOp+xpHlmwwJHpuAsntREKGWWkLs/V8YPmUbdNBBy0c=; b=fB6A8KUBkT3NPcrLeZkwztwcU9nMqgap2PNJgV9JTkqPKouNwkWQk4ycVOSqHdRFdg VodBkRQlmAdEKl7BDW0gtSVIiDo/2sFNiOpxavgg/YIk6aJbX5puqwBawctrOcQT4nAz cZ1CVR5dM4C0QNyFpyQ4AH2tn2qQKmukE6AsfaU8LLg1wW5tXXORNwNIqp0UrRyJEAOW 7+hd2oO9Yxx66FUVKToJw7rMvFyfBhaP/c1bvmgmEaQy6Kr0mxrLVv9OJvTBMahnragA jjWsxyEJPh9M2zzvMhhUfpOwGGnVysNjrMSN5FiXl+vWfDxSL7xEEhpfLIQHbGDiZGdy 6LQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556096; x=1700160896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gOp+xpHlmwwJHpuAsntREKGWWkLs/V8YPmUbdNBBy0c=; b=N1KJz7iyufQESVLaIzrfW2fs8yJmn50mV/V5RRD6MKwLqAXhFu+hl2Q7i9UbZ+Hznw Wo7W/vXax2xrH8abpisG0l6NLf6veBbuptcva6vj7z6w/L3vvUm4zNtCWlzJm3czpEBt RCLN220ljfw0IKXui3i7wkckZhIO8fsORXbSzihie1KFPqYN70oD30h6aWLSw3R3II0v 3s7mnYszlLi9G2CGmoROQe3YCJqrfuX/nsAv6BEcr4PZJ1L0TfV5tCIgT/UaPKmI4ZJW 5hwGroFdXwagnGcbNlRYEvwAVrMa9N7zzvbpU/xZjWh3I8rsk8Xp84bLUSg6cHjYzlnK 0m6Q== X-Gm-Message-State: AOJu0Yw5T3o8gJyvDn0ydADVNEyanZ/3vTvNyDp3hOHgYfYNEwrd0i4H P0YJYYkYWvURin28LQ6cCOw= X-Google-Smtp-Source: AGHT+IE+IJZS1sqYktLsiPaL1df4ka4ANEDD9qXqEAzn3MA5xqXj0C0RPxKP+lsVDxfLH5oDuT8zSg== X-Received: by 2002:a05:6a20:4304:b0:16e:26fd:7c02 with SMTP id h4-20020a056a20430400b0016e26fd7c02mr6287408pzk.2.1699556096014; Thu, 09 Nov 2023 10:54:56 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:54:55 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 1/7] platform/chrome: Fix typo 'preceeds' in comment Date: Fri, 10 Nov 2023 02:54:33 +0800 Message-Id: <20231109185439.1535962-2-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'preceeds' with 'precedes' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 71948dade0e2..568bbb64a389 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -511,7 +511,7 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensor= hub *sensorhub, * ringbuffer. * * This is the new spreading code, assumes every sample's timestamp - * preceeds the sample. Run if tight_timestamps =3D=3D true. + * precedes the sample. Run if tight_timestamps =3D=3D true. * * Sometimes the EC receives only one interrupt (hence timestamp) for * a batch of samples. Only the first sample will have the correct --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7397C4332F for ; Thu, 9 Nov 2023 18:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345057AbjKISzG (ORCPT ); Thu, 9 Nov 2023 13:55:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234641AbjKISzC (ORCPT ); Thu, 9 Nov 2023 13:55:02 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E5513C1F for ; Thu, 9 Nov 2023 10:55:00 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1cc55bcd51eso1939805ad.0 for ; Thu, 09 Nov 2023 10:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556100; x=1700160900; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oc8XKB87wQbvVWG32n2t+Y4HWDVG4F2xfYYjT2VaS4U=; b=d4voFKKNHmwa3kR4Rkw2u/8RWQW/IfOhw9/G6sQZXy5iWzRYQosXqIdFeljA9hR4ln jB8WioG8Kzcqtj+K124kNiPFtclFB/5VsdBIqdjd+Jh8Zu4xePatHoyg/5OGAkXwP81b AeeRgn5v+/d1t2mc0C4kDdPoffLzJmsWVrvO36/VvHXCzCx8xX/bhXThO0a91vOBrB8y QsG/+HJm6nSgRkdWCKiM1oVL1cTom7T5XdVU5VNEGQYIhU/LU3nHLlZg9LNZ31EuYB6p Fv/ngeymDqPLf2+eh6igssGrerJ8nbfP68ZPnUa/XjqSznVR5V4wiVDzdPe8Sv9sD/j2 Yk3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556100; x=1700160900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oc8XKB87wQbvVWG32n2t+Y4HWDVG4F2xfYYjT2VaS4U=; b=NDjs6zyOpGKglG5fBKqDpzq5kdYb3C5ceE9YFWlTpxIuu1tVDWI51EY2TBdtPx99pV IQXy1P378utpKQ6ZmFFwHtVUROjaJbm+g9a3/of/ZpbvwEAzRQ5HbTuD02HSJENeAKie GyAhh2tkMjGhXokg+C9Tp4My/SIc9Ahhw8HnEBEcq0tYhu6jetYDexQsTKZghDMUmfd/ qvAg5xLquh4hq0Uad20RGl3w2jo7MxN1jxzygVA3A6O4mydQ4AF0FiZE9VJ+v3dB8+mp FKIgeMMdg3aAszz4Y8FnZJK+v0SAL0ZSFPQSIbgFXpOuYZJfPMENHFD71+k+ibCxrZWq Z2Gg== X-Gm-Message-State: AOJu0YzStt/U/VhszBDzSj5gdoiL6sD/nMR9Ovk+Fj6fowkMb0Hsvwzt DNbe0pmEtdFMUusnOprQ/bI= X-Google-Smtp-Source: AGHT+IEpztjQzljXdJINa8TiA3AV4M8Z9qXo4fdBCG4xuIsFgmcJhHYl+Z7UYu0PyuQnE8wyfFehig== X-Received: by 2002:a17:903:2281:b0:1cc:2b68:40ec with SMTP id b1-20020a170903228100b001cc2b6840ecmr6475275plh.4.1699556099887; Thu, 09 Nov 2023 10:54:59 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:54:59 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 2/7] platform/chrome: Fix typo 'perod' in comment Date: Fri, 10 Nov 2023 02:54:34 +0800 Message-Id: <20231109185439.1535962-3-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'porod' with 'period' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 568bbb64a389..ee1c3124d31a 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -701,7 +701,7 @@ cros_ec_sensor_ring_spread_add(struct cros_ec_sensorhub= *sensorhub, * last_out --> * * - * We spread time for the samples using perod p =3D (current - TS1)/4. + * We spread time for the samples using period p =3D (current - TS1)/4. * between TS1 and TS2: [TS1+p/4, TS1+2p/4, TS1+3p/4, current_timestamp]. * */ --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BF87C4332F for ; Thu, 9 Nov 2023 18:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345060AbjKISzJ (ORCPT ); Thu, 9 Nov 2023 13:55:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234702AbjKISzG (ORCPT ); Thu, 9 Nov 2023 13:55:06 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C94322D57 for ; Thu, 9 Nov 2023 10:55:03 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6bb744262caso295018b3a.0 for ; Thu, 09 Nov 2023 10:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556103; x=1700160903; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/asJ9Dj+3Cx6KmENE4+zs0bPzpX4pHWbGWWiop9m2C8=; b=Kmu8gqFJEzPv8rm3FO7iehzUCYeFU9Ud0rLFmXNmGg6Z5G3lvBB2rPFFbXgW4U5+h7 f5hTEu4Y4X4GBM6zlQf4ZT8U5yf7n0s9r0wBt6e1Ge4hOnjEUjoxCbNS1CQdi6ZOOZEK fbbJeqo8gNa6RhAkZWG2FEY+EU1osP3SvIPMZrSTh6wjCLfL0WWSo4KIJGxO3DPHbprH p1eVdTSZ6AYdHoZyvzP+8Saq6FIzZqJ4VBnhYh/EBzeYeKBggXGDuV8ECVGoaN9l0bXi A+0NI4PwKz6+FgQsROIkjimvhhVM7m0FC28UWe0cv/E9Q48BQr1Xk8Rno/mUUa50xmiD YQMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556103; x=1700160903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/asJ9Dj+3Cx6KmENE4+zs0bPzpX4pHWbGWWiop9m2C8=; b=RlhnaLw3fjkrA9BEkv99kHrmfFB3/1nVVJn/z5YP0Lmwn4Uy6RCuLBhJOcU7xqVxAC t6dAciHWjbbJqKQr/MrQ2G3e6pGpOmKb44RiyGd0q8gLCGUtaKDlo6moJ4CKVzZi+0qd 9J6yRh1/I5ygSnAaQBDQ0DkKVU1DARVo20IF8q2EJeOvZoY8Pd7lwcSMVlw/NYBbSOq9 YxaZjntNnCN1X1te5A2LU/zN31NSB8JRK8ufBvvWzRvtlt2HQWMDjdsHgHQvSEi00pRh vwMEoPQpDZAghu3d5FjTm+zgiUhoEI5F4mmAkIU62A0hdBnkliq7+0r6Cic7PcYh8I9O z6sA== X-Gm-Message-State: AOJu0YwFQWzRanASY/GYz539pemBMHrXON+vhOg5MvfKUl7h1NUhX8GY LMEIiye+aRJbtu3yZ2qAFhw= X-Google-Smtp-Source: AGHT+IEBJK90gDyvFSF15Zd7y9xNPqkhfxe80VneNX35DCeNzc+cf8p1xhimbg9FPPlfKaG3sC+8mA== X-Received: by 2002:a05:6a21:329b:b0:133:6e3d:68cd with SMTP id yt27-20020a056a21329b00b001336e3d68cdmr7081305pzb.3.1699556103276; Thu, 09 Nov 2023 10:55:03 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:55:02 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 3/7] platform/chrome: Fix typo 'noone' in comment Date: Fri, 10 Nov 2023 02:54:35 +0800 Message-Id: <20231109185439.1535962-4-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'noone' with 'no one' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index ee1c3124d31a..85764e62cbe4 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -103,7 +103,7 @@ EXPORT_SYMBOL_GPL(cros_ec_sensorhub_unregister_push_dat= a); * @sensorhub: Sensor Hub object * @on: true when events are requested. * - * To be called before sleeping or when noone is listening. + * To be called before sleeping or when no one is listening. * Return: 0 on success, or an error when we can not communicate with the = EC. * */ --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64452C4167B for ; Thu, 9 Nov 2023 18:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345033AbjKISzL (ORCPT ); Thu, 9 Nov 2023 13:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345074AbjKISzJ (ORCPT ); Thu, 9 Nov 2023 13:55:09 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBDB3C12 for ; Thu, 9 Nov 2023 10:55:07 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cc28719cb0so2562695ad.0 for ; Thu, 09 Nov 2023 10:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556107; x=1700160907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PRi+qAy0bRoafy49vwIjB8vcVV09afunArSCgU/jH/8=; b=LA+sVoGnwa9W3vsSL4f+Kwf+yFOv9WG90xZDpAOD1jJquoMgHTTTpbzDBgJGP3BEMg oEybdvKTzQHeRTcrfwRvZcwnZjLkEJ53xfoAohGtC9wauweiEwVJAHTnQ8V75F9K4ngS dUbOOrET5eeOFhBlulk+bJRPAzsoICFASsfJ1PW3jltcD0d1hN8AXm7rvfLiRH97i+rf LQtHAZ2PA+WGISy8Xw4VWhC4BsRViw2ymqf9aljYI0/qriyJhwJksSQrNTvbnnHnhkZE H2904BWtrWdfos0ap1JpKjKU8v6nPxXqp6KtjxdUiY3QvOU63cFyfnSTjDxn4EF8ZT1n rdfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556107; x=1700160907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PRi+qAy0bRoafy49vwIjB8vcVV09afunArSCgU/jH/8=; b=IQbIidPhytEE91oExz4/rBWTkXzKbDOzkWinqiVoD7XMNrG3n2MPk12CDpAXoKAiqk NBi83jn8Y3MqaOl2Uhxi7niZCRTJ8spsuRzZhNV+f4X3NkGiFH+RBYNXml4AHU9KxrDp Jnq55n1bqNJbqACeR1rJgnAeLERZaNh98YwkMfgpPeSQvoNLn4GsQjn80UdQt9Er09qq xSc8nBCjkK5IybNXPbxI4Nheh26WCIkExVPvdKNODJMZX7oQNGCiNpG/33jvORp4/8DI GnZRKNSfV0VZRh4vft4kd18R/eHcblbE7xH9lXLDaOnYYtBEEx0DAupQ5iIkrz0T4R1y cvPQ== X-Gm-Message-State: AOJu0YzdfcVhSxS1FJFx6G992yp+qi+zfcYeHLR/1qKMJHquHI1yHNLc 8JdxMB4WOp39K45cayEy1W0= X-Google-Smtp-Source: AGHT+IEjlXJkC2bw7tWXPOMaDfWHKiPmPN5r1CPOZIEmM6XpA/df2WMR8wr6JLELmvE8T9Bj+So2cQ== X-Received: by 2002:a17:902:c943:b0:1c7:5581:f9c with SMTP id i3-20020a170902c94300b001c755810f9cmr6369730pla.0.1699556106845; Thu, 09 Nov 2023 10:55:06 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:55:06 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 4/7] platform/chrome: Fix typo 'lantency' in comment Date: Fri, 10 Nov 2023 02:54:36 +0800 Message-Id: <20231109185439.1535962-5-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'lantency' with 'latency' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 85764e62cbe4..92faf701b8f0 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -176,7 +176,7 @@ static s64 cros_ec_sensor_ring_median(s64 *array, size_= t length) * While a and b are recorded at accurate times (due to the EC real time * nature); c is pretty untrustworthy, even though it's recorded the * first thing in ec_irq_handler(). There is a very good change we'll get - * added lantency due to: + * added latency due to: * other irqs * ddrfreq * cpuidle --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 926BCC4332F for ; Thu, 9 Nov 2023 18:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345136AbjKISzT (ORCPT ); Thu, 9 Nov 2023 13:55:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345074AbjKISzO (ORCPT ); Thu, 9 Nov 2023 13:55:14 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F7773C39 for ; Thu, 9 Nov 2023 10:55:11 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cc28719cb0so2562775ad.0 for ; Thu, 09 Nov 2023 10:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556110; x=1700160910; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g73QTqa4YTCeJuDnfMTOW8eVS9xm1gIdRDmG7TjF/yc=; b=d4XcI6rYNEjzmAg6o3bmaCuSdUurfS2jJCcL14QV6ZwpsD8CfSayTzYA4wXDK9jZ35 XKt7U9tW0OYccqIXMQXqZviXpRaasJheJHrj/nd2OtMMQ3/HnebhLU06iLBXbU5mBg2s oG4gPmmzjDzUm/jZEEa1deEpBoNfeslFxTkApoRNzsXeNzPhsxRzH8eIUITSJ7/oGbkg AWDx8jLN0BviY2SvLVNx4oLPpl2LnawQJM5Mt93EE0aIE9m0hA6BLNLVAAJ9p8IRFdHl 9LrHZoSE4pwzsVhzZ4tDqpUvnChXoQHuGooAVtWTqdhsG1PTv1iCCfp/PCt/zZRDVFjZ i+nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556110; x=1700160910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g73QTqa4YTCeJuDnfMTOW8eVS9xm1gIdRDmG7TjF/yc=; b=skH0IbrDDwbJ/ktxAfvipJg8jLUun2JTZr9sr7Jj+2Cy+79cgDTcdcwZCn7mcMjQNn 0hamEPekXQiYQqnjNRnxusaPfSZLHybp3jpA4APPp+T24Gp5osCFO9DEOLQBI4QLVL5T nR8DGGlij/baQr0/bRK0NsOIl1fpHJ3zA7cYXUBSuIWV3WgU52B5bR2bUGH6DtUYqtcX G9xFHE7eFNYnuQ+Wl0tRvPKl+aHnBLaUZDUEruLc+d5qjXm2fcy8PC/84TO9xGA15q+C 6RIoD+siOr6B3BKMAIYN0b7hXP7rMNYxhzpSWGrWJxuO/WLpSomX6VXZyILxdIJpt22r 0t0A== X-Gm-Message-State: AOJu0Yz3PMkIpaaZFhH0vzeAUCXGXznfzOZBZGPHNj3FPOppM2nStMM8 eePmrtRgQhFbgL+LzSHapi8= X-Google-Smtp-Source: AGHT+IFxZxc4RDzX6HRIMX0zhVB50kMciGdcCmsIWNygaa4MSMM4LrRdrVRhjg7PMLTFpkHhpXk5eQ== X-Received: by 2002:a17:902:c943:b0:1c7:5581:f9c with SMTP id i3-20020a170902c94300b001c755810f9cmr6369880pla.0.1699556110547; Thu, 09 Nov 2023 10:55:10 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:55:10 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 5/7] platform/chrome: Fix typo 'kifo' in commet Date: Fri, 10 Nov 2023 02:54:37 +0800 Message-Id: <20231109185439.1535962-6-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'kifo' with 'kfifo' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 92faf701b8f0..6c2aa2651e5f 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -595,7 +595,7 @@ cros_ec_sensor_ring_spread_add(struct cros_ec_sensorhub= *sensorhub, } else { /* * Push first sample in the batch to the, - * kifo, it's guaranteed to be correct, the + * kfifo, it's guaranteed to be correct, the * rest will follow later on. */ sample_idx =3D 1; --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96D09C4332F for ; Thu, 9 Nov 2023 18:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345086AbjKISz1 (ORCPT ); Thu, 9 Nov 2023 13:55:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345103AbjKISzR (ORCPT ); Thu, 9 Nov 2023 13:55:17 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41A33C25 for ; Thu, 9 Nov 2023 10:55:15 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc41afd376so1916465ad.1 for ; Thu, 09 Nov 2023 10:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556115; x=1700160915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kg9I4ZaIj7Cn80AZ+YJatc/DGTkLCa1gLvsiD/shfvU=; b=j7E0SD9NUFsG+ThDAFM8nNNmuKrjPg0mEol3O7rWtFPbE36Lup82K4EdI1/J4MX0li UrdjxuLdN9thCQoSrGQegzpM7kRKPUY2i/XT5GyqvRZQCuCKlS4tpEn32F1ZkrWFgZ96 hj3GJ9QeaxKQ8mgFYGcWLLnAAtu5uJBMpvgl7AtwzvhVrvM0ZpdqfOTIVz2c9DLv7LTB 0L/5+chsV/yfoq0h5vOWzFDLYDLsoxIxYso2Oiy5w9Kv0qsP2cG4tjHT8BpDDuirdudt v9tikniwSjrncY9OdTUsoDvE6F+CfCZoTjVqoju5U4jgH4XwZUJpaZ+I7bbm3O9ZkqMb GZbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556115; x=1700160915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kg9I4ZaIj7Cn80AZ+YJatc/DGTkLCa1gLvsiD/shfvU=; b=CNk7BHcWJUngnDXYox6JX2hPEXG3HRrG4ahY2tg5uSOUEX/9F8vLp+Axe7ilALLgZM KQ7UIu9AaA2S5sLuQKGXHu0ZTekfiue2Nj/gNj50OTvQ1wd8ULIBLbE/XaApvI0hTmq+ Mbr8P4ucYaaKXo3tEPW4zlgpt5ruFt6+IYhwDiQY19wGdKJaDDeSj5bxFROz8Zd/N3nB j3HjM9R5bp5NGmKyREtKXINRCAOp5AtfI9jTDf9KXGwEv3HfHL18ZcS5Be4YidhPq4P1 U2b8+UXjTgGbJbfXvbnv4ylZiG9rOyDfQ7UQk0xfk3A5Yv2ewJ2ZjFOYcBrZERWKf8VZ TeKg== X-Gm-Message-State: AOJu0YyejQjG9Xc2GGicbO59hivLOdtLJcCsXGR8cJ29pdUpI3KJMn2C Tpg84fjfVew/nrRaW/Yhug9QzIaO4uc= X-Google-Smtp-Source: AGHT+IEtW1oaVYd/An5rg2FaDM6Q0s0wAl5Pr2VY0eMfJkPWNQqJ1LUHlgMkwIfQk4Ow5hwMKO0bCg== X-Received: by 2002:a17:902:ce8c:b0:1cc:3e45:ac1e with SMTP id f12-20020a170902ce8c00b001cc3e45ac1emr6334586plg.6.1699556115257; Thu, 09 Nov 2023 10:55:15 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:55:14 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 6/7] platform/chrome: Fix typo 'change' in comment Date: Fri, 10 Nov 2023 02:54:38 +0800 Message-Id: <20231109185439.1535962-7-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace 'change' with 'chance' in the comment. Signed-off-by: Kuan-Wei Chiu --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 6c2aa2651e5f..9e17f7483ca0 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -175,7 +175,7 @@ static s64 cros_ec_sensor_ring_median(s64 *array, size_= t length) * * While a and b are recorded at accurate times (due to the EC real time * nature); c is pretty untrustworthy, even though it's recorded the - * first thing in ec_irq_handler(). There is a very good change we'll get + * first thing in ec_irq_handler(). There is a very good chance we'll get * added latency due to: * other irqs * ddrfreq --=20 2.25.1 From nobody Tue Dec 30 22:50:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E48DC4332F for ; Thu, 9 Nov 2023 18:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345151AbjKISzf (ORCPT ); Thu, 9 Nov 2023 13:55:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345118AbjKISzY (ORCPT ); Thu, 9 Nov 2023 13:55:24 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0C34223 for ; Thu, 9 Nov 2023 10:55:19 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cc2b8deb23so2248355ad.1 for ; Thu, 09 Nov 2023 10:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699556119; x=1700160919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1F+zsKAZ6psJ2Y0k9zWx71Sew29B0knPhWsJIJOxq3o=; b=nJ9H2dZ5jfpxDUqi2CZIPnWDURnEBcZNZHZ+T8EiMx8v+1ctYuvaBvSBJZl/0knjId xlPGa8DE02n1CtQL6Uqv+R2cPdTtQeQnlbWzoZGcdOu3GEC5bsoCpV2LX8kSBfsWRg87 x6T1bRElFapEzfvnJR3H/51baJbYr17f2c5a62u4nUFnbDP15266iXjIEIX61k15BmoD SX9gY1ZghByO+SZThrT1HU0Z50y9L3q2QPXU9B0stYZaOVD2NF2NFLMvBq/lU5LY5qUJ JsDuzWYVaP6TqR5eLWhVtnWXMfrYfO3SCCYrA/q7CmYR13yQfJpZFQB1jGcnIw78e6Z6 zjag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699556119; x=1700160919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1F+zsKAZ6psJ2Y0k9zWx71Sew29B0knPhWsJIJOxq3o=; b=AysjxRnr5GY8IW9hr/QlsVn+OOxotmesmq7/9j5MQ+NfXjzTc1Bu1dCDVXZqIeJ+VL kgOL6BZbObk/bAXsjwuNWdOv+lsSG01fHA5NkalKNKXEYOhitBQjwS4nS8XVom6rkVjn 6JNkfNxHWGcgAqUPwIq21DPQDZgRmwWa+62Uk8K2Uj14lY1jQM+4xOt/i3C1VuNeUKjc 44BEZAWuOR8coV5hJmvtE0N14hcvYHDvdaZS/hlNbnRNGV6OZQ2snEtZ+K6v0x57yMez 16oj2WMOcNQ4aTcII9/1lskgv4ojH0iga4OW/6gZmXMwRlFm+4hCRqE3HuILFv+5AT+S un3Q== X-Gm-Message-State: AOJu0YxRLTkMhA7mEA2+00Mz5jjQ6tDkyWeq7XRamNx2L+K8EW5iDVny t1ef5QSPXNmqQD2R0xhaSVc= X-Google-Smtp-Source: AGHT+IHq3DPWkkVhxoXkHb0d97mTfbvuE+JfpLRcZwmkaEMx/WorUBpsxL7/EBbJgr1HmsufXxjk0Q== X-Received: by 2002:a17:903:2349:b0:1cc:3c2c:fa1a with SMTP id c9-20020a170903234900b001cc3c2cfa1amr6422376plh.4.1699556118862; Thu, 09 Nov 2023 10:55:18 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id w19-20020a170902d71300b001c61921d4d2sm3821837ply.302.2023.11.09.10.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 10:55:18 -0800 (PST) From: Kuan-Wei Chiu To: bleung@chromium.org, tzungbi@kernel.org Cc: groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH 7/7] platform/chrome: Implement quickselect for median calculation Date: Fri, 10 Nov 2023 02:54:39 +0800 Message-Id: <20231109185439.1535962-8-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231109185439.1535962-1-visitorckw@gmail.com> References: <20231109185439.1535962-1-visitorckw@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The cros_ec_sensor_ring_median function currently uses an inefficient sorting algorithm (> O(n)) to find the median of an array. This patch replaces the sorting approach with the quickselect algorithm, which achieves an average time complexity of O(n). The algorithm employs the median-of-three rule to select the pivot, mitigating worst-case scenarios and reducing the expected number of necessary comparisons. This strategy enhances the algorithm's efficiency and ensures a more balanced partitioning. In the worst case, the runtime of quickselect could regress to O(n^2). To address this, alternative algorithms like median-of-medians that can guarantee O(n) even in the worst case. However, due to higher overhead and increased complexity, quickselect remains a pragmatic choice for our use case. Signed-off-by: Kuan-Wei Chiu --- .../platform/chrome/cros_ec_sensorhub_ring.c | 71 ++++++++++++++----- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/pla= tform/chrome/cros_ec_sensorhub_ring.c index 9e17f7483ca0..4ac718be38b0 100644 --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -133,33 +133,70 @@ int cros_ec_sensorhub_ring_fifo_enable(struct cros_ec= _sensorhub *sensorhub, return ret; } =20 -static int cros_ec_sensor_ring_median_cmp(const void *pv1, const void *pv2) +static void cros_ec_sensor_ring_median_swap(s64 *a, s64 *b) { - s64 v1 =3D *(s64 *)pv1; - s64 v2 =3D *(s64 *)pv2; - - if (v1 > v2) - return 1; - else if (v1 < v2) - return -1; - else - return 0; + s64 tmp =3D *a; + *a =3D *b; + *b =3D tmp; } =20 /* * cros_ec_sensor_ring_median: Gets median of an array of numbers * - * For now it's implemented using an inefficient > O(n) sort then return - * the middle element. A more optimal method would be something like - * quickselect, but given that n =3D 64 we can probably live with it in the - * name of clarity. + * It's implemented using the quickselect algorithm, which achieves an + * average time complexity of O(n) the middle element. In the worst case, + * the runtime of quickselect could regress to O(n^2). To mitigate this, + * algorithms like median-of-medians exist, which can guarantee O(n) even + * in the worst case. However, these algorithms come with a higher + * overhead and are more complex to implement, making quickselect a + * pragmatic choice for our use case. * - * Warning: the input array gets modified (sorted)! + * Warning: the input array gets modified! */ static s64 cros_ec_sensor_ring_median(s64 *array, size_t length) { - sort(array, length, sizeof(s64), cros_ec_sensor_ring_median_cmp, NULL); - return array[length / 2]; + const int k =3D length / 2; + int lo =3D 0; + int hi =3D length - 1; + + while (lo <=3D hi) { + int mid =3D lo + (hi - lo) / 2; + int pivot, pivot_index; + int i =3D lo - 1; + + /* We employ the median-of-three rule to choose the pivot, mitigating + * worst-case scenarios such as already sorted arrays and aiming to redu= ce + * the expected number of necessary comparisons. This strategy enhances = the + * algorithm's performance and ensures a more balanced partitioning. + */ + if (array[lo] > array[mid]) + cros_ec_sensor_ring_median_swap(&array[lo], + &array[mid]); + if (array[lo] > array[hi]) + cros_ec_sensor_ring_median_swap(&array[lo], &array[hi]); + if (array[mid] < array[hi]) + cros_ec_sensor_ring_median_swap(&array[mid], + &array[hi]); + + pivot =3D array[hi]; + + for (int j =3D lo; j < hi; j++) + if (array[j] < pivot) + cros_ec_sensor_ring_median_swap(&array[++i], + &array[j]); + + cros_ec_sensor_ring_median_swap(&array[i + 1], &array[hi]); + pivot_index =3D i + 1; + if (pivot_index =3D=3D k) + return array[pivot_index]; + if (pivot_index > k) + hi =3D pivot_index - 1; + else + lo =3D pivot_index + 1; + } + + /* Should never reach here. */ + return -1; } =20 /* --=20 2.25.1