Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp28468pxb; Tue, 19 Jan 2021 23:52:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4rGkx5R1yz6+Lh4abCBdjodn6SW7jTQA9gryh7nQgdJihfeVL4ZMD57HyrvnE6d5JRkCu X-Received: by 2002:a17:907:160d:: with SMTP id hb13mr5334602ejc.521.1611129147818; Tue, 19 Jan 2021 23:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611129147; cv=none; d=google.com; s=arc-20160816; b=cDhFOpuw3VcpZvjuBWSY1OEnuveMkEd2WgEAhjOguCZXNCA2DU5+XOPl7Z2NO39Cdn fMdyclnafx/lAxAbWuwBi0hqkJuIDpEbQ8pHbp8t1LLPfZL3QrM5u7upU64DsnnNvq/2 vqKO+CJBkW9e9qK0Tb8EtyvJNRq7qs6gVNa6P+8XvGqS47O5RTTkmkS2ToknHjO9lMRu CKdltZ3fCZXffxI8z51jPXR168qlcV84fXpuxJ5XPbTce+Ul5k9l8Ib6GAN0Tjhret0T CFEVIfCzF+VEoBQyGp28EuwfwAFjbHEmgm3FJKRgOQZ/B/bSWudu/fBrSp12tTdL97Z+ 0DnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=1+HsZTwFNw0fZdChrwBfOsPGBCT0Lre/MyGWNkbCoBE=; b=LgMJ+LTB7GH2xk9HzcPBWxVLKhOlsgu2KoyB0wxihv3P1bsOtEmXV191Qgfb6csSkE 1m5u4zetsHtiQ/v62chJLzbBPse9KnN3hyemscYVoP50KpA/J0dep7wKPHeTMn7QcZZB tKeHPE20zG/6flbOSgMzoyFv8/DZTW1wokz8L6PTBYIUnjFHecky3Ssu4Fuq/VsIlA7Z 466duY8zJ/kg9PoQiBO6avIDkEDWmE6KGhP7neaGt0Z+FuWc1sE/sCuOWbl/fS/gs3Jh 0RadhcQkDcFCPdKSNqvf9bLpt0WYCTRK5v9K2QzzaiDk9W8/YkQxIiZtnyCxsLCfKvuJ I67Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si565439edr.34.2021.01.19.23.52.03; Tue, 19 Jan 2021 23:52:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbhATHug (ORCPT + 99 others); Wed, 20 Jan 2021 02:50:36 -0500 Received: from mga06.intel.com ([134.134.136.31]:35549 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728911AbhATHtR (ORCPT ); Wed, 20 Jan 2021 02:49:17 -0500 IronPort-SDR: jlC9l65W0gAMoq1RiTzbaujQtE+zshnUHmbOeI3Aed5C/V69tKEaETioMbBBpspwWMJkoqb69/ n9sv+Toedw1g== X-IronPort-AV: E=McAfee;i="6000,8403,9869"; a="240600210" X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="240600210" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2021 23:48:32 -0800 IronPort-SDR: N3eeg1rePNFLLAsJnzVHKgnfVbVszaQDBbzpl6XmLKR+Ow0jkLkbNSb6kDO6MUDtUTGbBP0gyb FtdDwtPyiA+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="426810673" Received: from host.sh.intel.com ([10.239.154.115]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2021 23:48:29 -0800 From: Ye Xiang To: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@linux.intel.com Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ye Xiang Subject: [PATCH] iio: hid-sensor-prox: Fix scale not correct issue Date: Wed, 20 Jan 2021 15:49:35 +0800 Message-Id: <20210120074935.26637-1-xiang.ye@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the proxy sensor scale is zero because it just return the exponent directly. To fix this issue, this patch use hid_sensor_format_scale to process the scale first then return the output. Signed-off-by: Ye Xiang --- drivers/iio/light/hid-sensor-prox.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 4ab285a418d5..4abcfe48f1d4 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -23,6 +23,9 @@ struct prox_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info prox_attr; u32 human_presence; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; }; static const u32 prox_sensitivity_addresses[] = { @@ -98,8 +101,9 @@ static int prox_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = prox_state->prox_attr.units; - ret_type = IIO_VAL_INT; + *val = prox_state->scale_pre_decml; + *val2 = prox_state->scale_post_decml; + ret_type = prox_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: *val = hid_sensor_convert_exponent( @@ -221,6 +225,11 @@ static int prox_parse_report(struct platform_device *pdev, dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index, st->prox_attr.report_id); + st->scale_precision = hid_sensor_format_scale( + hsdev->usage, + &st->prox_attr, + &st->scale_pre_decml, &st->scale_post_decml); + return ret; } -- 2.17.1