From patchwork Sat Jun 18 00:13:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 12886139 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 CE92BC433EF for ; Sat, 18 Jun 2022 00:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237928AbiFRAPD (ORCPT ); Fri, 17 Jun 2022 20:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237736AbiFRAPD (ORCPT ); Fri, 17 Jun 2022 20:15:03 -0400 Received: from sonic304-23.consmr.mail.ir2.yahoo.com (sonic304-23.consmr.mail.ir2.yahoo.com [77.238.179.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022DB15829 for ; Fri, 17 Jun 2022 17:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1655511300; bh=pWKwob//oMrCGdu8osqOK8fSSKjG7fXLFNCSSjKHJOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=RLkbMJFCN4DTt1mf1AcvyEjPUEE/4fko1m/nWuyrBEXICb/DHAA26olHEA1r1/U+5+y3ZLZAePUXHutOJpAD3bNYs/dTV6sj76NG0GjJePxSbBejhcfYA84I/3H4LzA201iRdGg/sNBgqBWURAub8GHBm0Oj2jtpQXHqcphr0w4BDPN9W5Pva4khsUghRvH1diLL2UDdhwLaXlFjirI67X5JmNB1eecsLcrC3m4OYI3pOoviV7j6MA0Kg8HuBkVNH5RT3lnNo7HhxPx7AYiLrDDW/7IPQ/59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8ij881BtcuVVLw7evMjvvhaVW0.rOZ9NcIzN TysoLombwfRcezjklqCwGkY4Goqq2wYighJXK2xBkcLR4EnWMDhrnSLjsLnd.mi9jjvf7e0Wm2PB .cPxU6CApl00gHyuHfrPBWjQOQAql4LThdK_x8bNSmY7GneziWbGuTONS6NxkQ6jk0vNxJkVqJuK lvhyNV00QZyjGPFImxI16wI8nG0TpUaTcad_nuE6M7RmbHMIagXaGaLxRxZ.zFXqtq5fvGVh6qCS N3ZVv2dwzgaHRyIQKa0EA1DMNgokKLUGb6.w5YBI1zKNlafb1cvI5i0DCM7luadvm_iTXiaMY_80 OlkgkRJTxQhonmVJ4gIWwcSp2ydbzGm9ikPpqBnSBUVI6he5ZcqL3AxJNAv_V9jralM77ekpDg.. HfrqdVkxMw9lbfUP5XwuqZ4yqKCZ1vu8jkqwNcn25n9TJ.zhTm0Lwk0DCH7kSU4nlf8tDgUZ0UOs ta7mpKylSDzfMSOK5IGBuy8Rl4XTjhv2GcazZw.ZGlA.f5HwL6xQgw5apDxIgsudjpNygzGkZ3SA nhDfPw1zH9w_9FacPcuDvDK6Cr7sT6Q2ihHMCbzLmywAgfAqaQm6yzX9VHh8QGru4o_G.531sSUy uatQuY2iA2iuTl7yDANEiZWdeFvpT.EqckENlnQsfmkakVdLgZQusuR2lqDutV7O.IgUabqVbfQH Jvt4cn4_IiK8hXKSUwc7uKLH_hVf8Ajc1hdmUKN7VGXVBS6RLCCY4HAMGUDkRhJItyn1NuxkkUj4 ODdJESHe6fDnCTILcuQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ir2.yahoo.com with HTTP; Sat, 18 Jun 2022 00:15:00 +0000 Received: by hermes--canary-production-ir2-c9bf9d9bc-74fwm (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8b08f14069c990c2ed22165f3e3da032; Sat, 18 Jun 2022 00:14:57 +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 3/8] iio: magnetometer: yas530: Correct scaling of magnetic axes Date: Sat, 18 Jun 2022 02:13:11 +0200 Message-Id: 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 Looks like YAS530 raw values return picotesla and YAS532 nanotesla. Adapt comments and scaling. Cc: Linus Walleij Signed-off-by: Jakob Hauser Reviewed-by: Linus Walleij Reviewed-by: Andy Shevchenko --- drivers/iio/magnetometer/yamaha-yas530.c | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 2799ae0784fd..bd43b2555b73 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -310,8 +310,6 @@ static s32 yas5xx_linearize(struct yas5xx *yas5xx, u16 val, int axis) * @yo: Y axis out * @zo: Z axis out * @return: 0 on success or error code - * - * Returned values are in nanotesla according to some code. */ static int yas5xx_get_measure(struct yas5xx *yas5xx, s32 *to, s32 *xo, s32 *yo, s32 *zo) { @@ -417,14 +415,24 @@ static int yas5xx_read_raw(struct iio_dev *indio_dev, *val = 1; return IIO_VAL_INT; } - /* - * The axis values are in nanotesla according to the vendor - * drivers, but is clearly in microtesla according to - * experiments. Since 1 uT = 0.01 Gauss, we need to divide - * by 100000000 (10^8) to get to Gauss from the raw value. - */ - *val = 1; - *val2 = 100000000; + switch (yas5xx->devid) { + case YAS530_DEVICE_ID: + /* + * Raw values of YAS530 are in picotesla. Divide by + * 100000000 (10^8) to get Gauss. + */ + *val = 1; + *val2 = 100000000; + break; + case YAS532_DEVICE_ID: + /* + * Raw values of YAS532 are in nanotesla. Divide by + * 100000 (10^5) to get Gauss. + */ + *val = 1; + *val2 = 100000; + break; + } return IIO_VAL_FRACTIONAL; default: /* Unknown request */