From patchwork Sat Jun 18 00:13:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 12886143 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 887E8CCA479 for ; Sat, 18 Jun 2022 00:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380215AbiFRAPQ (ORCPT ); Fri, 17 Jun 2022 20:15:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348242AbiFRAPP (ORCPT ); Fri, 17 Jun 2022 20:15:15 -0400 Received: from sonic314-20.consmr.mail.ir2.yahoo.com (sonic314-20.consmr.mail.ir2.yahoo.com [77.238.177.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E97E21259 for ; Fri, 17 Jun 2022 17:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1655511311; bh=jJGcjXdRFHjvy2vr53L1DCuPWMWBd4P6XV8ec+te0zA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=Jki6R99TZeoRckSDEAevrRi4J1HWPZ2F9xjYI5nU21BUMqyK+IzVtUbzaQSqUDMoWB37n4hMcM8aDFK8adAecJgxkfDewGkogTZ7gaYb6FdFzsuUc7OnCCndPfwE0asK4c0rMJ9DfLKPbUnrY5+Dt9V2GkhSGW6a3c0NMsYgwks+VDEFGzjUNhB9Ou5r41j0Wz7bmjNTwO0596+LDiHA+GO4Z8d7mFzWRuZ9WpcP+QHhCqUvMlM3hLdyeGCe1WKwmlpFWrQ6cMPWB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RP7YAYsvsyRnpe1 7NuhFs99uO5I_vHuDDNVZVaujcPS86yd6IcGCWlAv55DmGfz2X06VTqEYI6jLAkd0BPTMntT_W9r xWCpNOFQTlBAgI1Bnq6wamTVKaIVnU1iiJJUrL2.9G7qfKIcg5TTLJImqUOz26A2kXuabaPXTUYJ 1R6lEm8TpwD4huxpQ8m.1P.DDj8JWk8UpQG3kIWqszsSewAhuISoGomEdVcoP9bvmuVbZL2Ls_PV MAo4vntPyvp4kCdyL6g4XTE1kaCzpkL6ji9A2y6nry1_.JkBK2pWC5yolWsnd06N9wXPsvY57Wej AXORKc75tujuaQFhhtSWSKyE.OBeV0XbOAjEba6fHBaK7Zxrv.tafAQ44wgzYedaAjqzNJ2N4JNy w5cTJrOiVQbPG4HTfBm9PXynf6rVyMsoTb2AlEkZ56ovlyl1gzUkuezUz76LdjVXrtAHFYb_dHpX ZY1N7L0vPk8_tKD16KkLULAVcbrvDNi3xJvk9j4CrfjZ8CyfNCpv9qpYv1G.o1JfZSsLGu_AYMcS J3pbod2gT8MstdRdoN._HhpplzijiPvZbNdJLr3CcTDwSW6qIYUnqoMiRuedEDYaN13uivFp30T0 .Bm1PUaC_BNfdZWdW0eccIXjTNsV.lcp_nGiv7YV8abex42riUtnpTuACRYf7mL.Xl6LgS_ksF_g AbgLz9qybxB0IdryerwmlLNuDcErOoVqYB3TfEfB1d2oGUv4Uc_1T.g3SjP4yBEvI7auAhYY3hB4 q3bFVlD6u4n_D_oIvqQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Sat, 18 Jun 2022 00:15:11 +0000 Received: by hermes--canary-production-ir2-c9bf9d9bc-74fwm (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8b08f14069c990c2ed22165f3e3da032; Sat, 18 Jun 2022 00:15:06 +0000 (UTC) From: Jakob Hauser To: Jonathan Cameron Cc: Lars-Peter Clausen , Linus Walleij , Andy Shevchenko , Hans de Goede , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH v3 7/8] iio: magnetometer: yas530: Apply minor cleanups Date: Sat, 18 Jun 2022 02:13:15 +0200 Message-Id: <362744427c87bfcfa8c885b1bb174dacc4861ec3.1655509425.git.jahau@rocketmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This commit gathers minor cleanups in the current driver. In the device examples, "Xiaomi" is too generic, specific devices should be listed here. E.g. Xiaomi Redmi 2 seems to have YAS537 but it's not fully clear if this applies to all its variants. Samsung Galaxy S7 is often quoted in conjunction with YAS537. In the function yas530_get_calibration_data(), the debug dump was extended to 16 elements as this is the size of the calibration data array of YAS530. --- drivers/iio/magnetometer/yamaha-yas530.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 98c8d365fab7..72a75dc57e11 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -10,7 +10,7 @@ * (YAS534 is a magnetic switch, not handled) * YAS535 MS-6C * YAS536 MS-3W - * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5, Xiaomi) + * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5, Galaxy S7) * YAS539 MS-3S (2018 Samsung Galaxy A7 SM-A750FN) * * Code functions found in the MPU3050 YAS530 and YAS532 drivers @@ -322,7 +322,7 @@ static int yas530_532_get_measure(struct yas5xx *yas5xx, s32 *to, { struct yas5xx_calibration *c = &yas5xx->calibration; u16 t_ref, t, x, y1, y2; - /* These are "signed x, signed y1 etc */ + /* These are signed x, signed y1 etc */ s32 sx, sy1, sy2, sy, sz; int ret; @@ -656,9 +656,12 @@ static int yas530_get_calibration_data(struct yas5xx *yas5xx) ret = regmap_bulk_read(yas5xx->map, YAS530_532_CAL, data, sizeof(data)); if (ret) return ret; - dev_dbg(yas5xx->dev, "calibration data: %*ph\n", 14, data); + dev_dbg(yas5xx->dev, "calibration data: %16ph\n", data); + /* Contribute calibration data to the input pool for kernel entropy */ add_device_randomness(data, sizeof(data)); + + /* Extract version */ yas5xx->version = data[15] & GENMASK(1, 0); /* Extract the calibration from the bitfield */ @@ -685,6 +688,7 @@ static int yas530_get_calibration_data(struct yas5xx *yas5xx) c->r[0] = sign_extend32(FIELD_GET(GENMASK(28, 23), val), 5); c->r[1] = sign_extend32(FIELD_GET(GENMASK(20, 15), val), 5); c->r[2] = sign_extend32(FIELD_GET(GENMASK(12, 7), val), 5); + return 0; } @@ -703,15 +707,17 @@ static int yas532_get_calibration_data(struct yas5xx *yas5xx) ret = regmap_bulk_read(yas5xx->map, YAS530_532_CAL, data, sizeof(data)); if (ret) return ret; - dev_dbg(yas5xx->dev, "calibration data: %*ph\n", 14, data); + dev_dbg(yas5xx->dev, "calibration data: %14ph\n", data); /* Sanity check, is this all zeroes? */ - if (memchr_inv(data, 0x00, 13) == NULL) { + if (!memchr_inv(data, 0x00, 13)) { if (!(data[13] & BIT(7))) dev_warn(yas5xx->dev, "calibration is blank!\n"); } + /* Contribute calibration data to the input pool for kernel entropy */ add_device_randomness(data, sizeof(data)); + /* Only one bit of version info reserved here as far as we know */ yas5xx->version = data[13] & BIT(0); @@ -720,6 +726,7 @@ static int yas532_get_calibration_data(struct yas5xx *yas5xx) c->Cy1 = data[1] * 10 - 1280; c->Cy2 = data[2] * 10 - 1280; yas530_532_extract_calibration(&data[3], c); + /* * Extract linearization: * Linearization layout in the 32 bits at byte 10: