Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1865145pxb; Sat, 23 Jan 2021 08:06:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqxREeOchfSnvs9cickP+0UEH/6Bm6MtjhDFpoKRaOUUfMQ3nnSDj+3jRn+rx0rjXbuFE/ X-Received: by 2002:a17:906:804c:: with SMTP id x12mr7631ejw.42.1611417996149; Sat, 23 Jan 2021 08:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611417996; cv=none; d=google.com; s=arc-20160816; b=hY05dWYj34VotKBcQxemj09sHcauoSNwtp4voij5yTn5cwwvSgwLh3xnySFMNExmFG IoMul9W5LDnjJ6IiUeXog0OWpu0Xf35dUlxkOi0fmw3u39zounGT5UFdsJP5mC+bojEJ rLT+XiL4jIcYvobm9rinDkE7i5ChVKb8UlFxfzMvYhAD52WL5j/6KEInVI0ox8wgB2Au QtcZ/H0eFmEIWgncqdltaDpi+46/Vp7MfUi7rgEWasuS2RQok4jbGQn/PLz++rECa0i/ Kv6SchB+sS3/6yVdNtAJlEWCzQnJsUopsVBp/wZrZKUWEd44+grU0leL4aH+fBHYIfZO 3qFQ== 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=ZbULlrMJemXEBPIn19t0kz07M4+bXKNO15v/jEU+GsM=; b=LX88MoYi3QIiRwYCMqnCJLrCPY6pPr5qrIIkkIXfgAQ4rPYLOTGYRYa92Smme80fqa bzlGZEN/E9rPK44vZlUyTuZu/Xg+mVxhlpw5Y8dzYO+Uo8Mh147SSbAzxtpUPoxiGaB8 3ooUzNbU3cCZ1EI9Asa8K3xSnrfqVQR1BqQNpKRAmWteciFm3rs+UEHopvNFoEvb8b49 p6llbsiHXdVcrI36zClJt9z3TbOj3BFbuwhrQwhru8BcT4YSluoLjWl/hZRlTLjDSbtU ZFcKGlySqxAYhJ28KG9Jmdx0L1wphVqGN6lLb9UOw4yQt5MEnUXOxDUUn7Ssprg8ytid 3Vsg== 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 lk20si4235999ejb.599.2021.01.23.08.06.12; Sat, 23 Jan 2021 08:06:36 -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 S1726163AbhAWQFM (ORCPT + 99 others); Sat, 23 Jan 2021 11:05:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:48800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbhAWQFA (ORCPT ); Sat, 23 Jan 2021 11:05:00 -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 E25A822A84; Sat, 23 Jan 2021 16:04:18 +0000 (UTC) Date: Sat, 23 Jan 2021 16:04:15 +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] iio: hid-sensor-prox: Fix scale not correct issue Message-ID: <20210123160415.542202ca@archlinux> In-Reply-To: <20210120074935.26637-1-xiang.ye@intel.com> References: <20210120074935.26637-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 Wed, 20 Jan 2021 15:49:35 +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. > > Signed-off-by: Ye Xiang Fixes tag please. Otherwise, looks correct to me. Thanks Jonathan > --- > 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; > } >