Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2703587pxb; Sat, 30 Jan 2021 11:16:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+y2BDvhK/U8PcBZatyc+JxurfUANPlX0ujLWsBox7dpNz0pS4/qJ/PWnEILLjXOisUcjI X-Received: by 2002:a17:906:e84:: with SMTP id p4mr10343757ejf.141.1612034185034; Sat, 30 Jan 2021 11:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612034185; cv=none; d=google.com; s=arc-20160816; b=V9seqLfaG9hwv11TsPC1OB7kSCE8UKUjDuAcynsIx+kqnFIrQlLCtlwTsUUR7xHAB4 FqufLDIOrXrp6+c4zDuneXFEmfE2+IXzfEPC9cYNiDDyrpOUb7z28635VACHzQ8xwQdJ UeH45zxjS+nblW57hnlk4abAdUuxDltEBCt4jS8vHt2/c+JVXv6ufIkequDalCleBUjv Y8AdLXjDm17VwDgqMOS8xZGhLBwl5BzRJ66yaVSQxmUrccOHnYRsV+ielsdmB0ki0knP hhdMOg/EsOJFHOKEALdUxlFP5t0tUgffW+fqdFKxhErx6h4s4qk4+afkWegid94or2gM qMZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=zQU5NIF0XmtQZXnaa3INz4DLG1iULO8NHTrCkNtMhw8=; b=IFNYcuezwbpHcTCKA3OBlCtG/gxqPBtsiph5hkxC3NOotov/JPY8IlAhJb5oSiT5/7 UQATvbOWf7geCBjNs4NyveTtTMmMBxc/VtLCt9Yjvgi6KteLkejOxvL9npSkIy0mkSRn CkdtiWc9zI9YqWhaoNB/ol0SjWmYLBFpOo6k/ZqQMVcczjQUAc1Ad6KlgOTe517OFDdV Dmnd4JTQlIMIfJe0AsLantk8PVyLOdsF+FVd83X6h9qr6XPeeoDBOTudDqyt97ya/ECR 95hyVM8OmYdiE0N6tOob8Yvvqk41ryWjptNbj8ayvsSsFDiuX92GbQa91LFkQD1mnaux pQWA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q21si7384916edt.445.2021.01.30.11.16.00; Sat, 30 Jan 2021 11:16:25 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbhA3TPP (ORCPT + 99 others); Sat, 30 Jan 2021 14:15:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:37360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbhA3TPO (ORCPT ); Sat, 30 Jan 2021 14:15:14 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7CBF64E11; Sat, 30 Jan 2021 19:14:32 +0000 (UTC) Date: Sat, 30 Jan 2021 19:14:29 +0000 From: Jonathan Cameron To: Ye Xiang Cc: jikos@kernel.org, srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: hid-sensor-prox: Fix scale not correct issue Message-ID: <20210130191429.2c485212@archlinux> In-Reply-To: <20210130102530.31064-1-xiang.ye@intel.com> References: <20210130102530.31064-1-xiang.ye@intel.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 30 Jan 2021 18:25:30 +0800 Ye Xiang wrote: > 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. > > Fixes: 39a3a0138f61 ("iio: hid-sensors: Added Proximity Sensor Driver") > Signed-off-by: Ye Xiang Hi Ye Xiang, There was a bit of fuzz on this so please take a look at my fixes-togreg branch and check it went in cleanly. > --- > v2: > - Add Fixes tag > > --- > 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; > } >