From patchwork Tue Nov 7 19:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreeya Patel X-Patchwork-Id: 162698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp457469vqo; Tue, 7 Nov 2023 11:21:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHknq+eNqbXyskNlGZVlyvz/CpEKLaelaRdzds3sz9oagFXDgUUMjjkciXstqQ+tInis1T X-Received: by 2002:a17:903:1390:b0:1cc:2f05:7edb with SMTP id jx16-20020a170903139000b001cc2f057edbmr29061327plb.35.1699384897465; Tue, 07 Nov 2023 11:21:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699384897; cv=none; d=google.com; s=arc-20160816; b=BvSmH/YBA9I7nHz1/GnZ1oogKZ6HiLYSGwXzo6e8SlhCSaSu18hGhK37EE14NptOQn PPIp/962hGp9FDt2BXbdL7VNKF81D7SJnAxdqtq3npshPGIxxrFd1FAaMk+Q3BWT8soQ zZF4IgpUirccRxgA+C06sb0MwgQufFBgZ39ycWRXV7/mOKi9b8AW/dKY8SvF7g2EVREO Sd+J4pHtWJTBe0Gtgky0+R4xZIbl9gbo0qAMAP1bferVH9zmbIdl6xODMLkcL+exWV6V M9a5sUWueD+dvipehScuLV88cGwCXgCIQ2SQOTEvzdogiKHolJoX3vtxy0TZCxZHXLtb zdCA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oXZZfeGJ9fLj1MKgNgU2AI9xZ3dn/4CIMDwv43fVXnA=; fh=iXjoeWIHtxo6D4EadtGy+KzKVWzxoj7ht9clc0i3oFQ=; b=wjc8nLqpq5pi4HZQmI45f9g8g87l4fkxB4/tr0XTbO14GD8VdROrIGWkjOKNIP1XTT wFoiJwCW2vcpBbwsghHor7YncgyEzfjhdIqX1rfm5xm5ZyqsP5mHa5mV18V+OOqjMCma SwyzcCFjol08kIsdWKjCxm5D5vOVyDBSDlfBGS2XZHkr+GESNuDDQxBg2QKeleblIP40 y1Ie1UE9zQJZWwK4bBA3ZwjQeBZieuHNXnQCZ6Kbc+Mop1+1qZwkwN3ZN9MOnKbGFXsl QtS2xyT1dXAt9tgL4K2BhQI+4kfKpcN8Teh0FreR5H1avBwDwk5DicxxZ8pLJr7ttEy1 Y2pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VRIlsB1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q20-20020a170902e31400b001bb9e2c38ecsi341514plc.264.2023.11.07.11.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 11:21:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VRIlsB1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A604081167BD; Tue, 7 Nov 2023 11:21:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235181AbjKGTUe (ORCPT + 32 others); Tue, 7 Nov 2023 14:20:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235182AbjKGTU3 (ORCPT ); Tue, 7 Nov 2023 14:20:29 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2EA0D43; Tue, 7 Nov 2023 11:20:27 -0800 (PST) Received: from shreeya.shreeya (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: shreeya) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0B588660748C; Tue, 7 Nov 2023 19:20:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699384825; bh=v/+HlUbdkVlvRYJEfDzKEel5tt1IxqqmV9wyYAz5uuM=; h=From:To:Cc:Subject:Date:From; b=VRIlsB1i9+5UiaT42ltAk6+bQE3hononkVqwxA+v9BZeHeHhUwwVByVglRmmTe1Ky 5cyF8e//xVUHbXwKw+OYnwDeRAkhJ/Zc2Z54EFBmO6LefqNjaPd5gzwrfxkAd8yOPe 8peLRWsj6j5uDJYR5wBm28WUIcTHadMDPd+WiCwnQizIF/mNUMeF8q9MleRFfApAR5 DHF04yh/ko0Ssbtg9BTx7hT7rhuOyVt8DmSs2VDU896iwvEIyHdsAhJOGz9iCLI8CG oOiOPAZqtC+9GsNxwKzyZdbzUtNOPXX9hTTLGvD+4i1mCpOVy6zpjYrDiQ+TA+Z1AT nl1HJcKBkABdw== From: Shreeya Patel To: jic23@kernel.org, lars@metafoo.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Shreeya Patel Subject: [PATCH] iio: light: ltrf216a: Return floating point values Date: Wed, 8 Nov 2023 00:50:05 +0530 Message-Id: <20231107192005.285534-1-shreeya.patel@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 07 Nov 2023 11:21:04 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781934218246902873 X-GMAIL-MSGID: 1781934218246902873 For better precision of input light intesity, return floating point values through sysfs instead of an integer value Signed-off-by: Shreeya Patel --- drivers/iio/light/ltrf216a.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/ltrf216a.c b/drivers/iio/light/ltrf216a.c index 8de4dd849936..68dc48420a88 100644 --- a/drivers/iio/light/ltrf216a.c +++ b/drivers/iio/light/ltrf216a.c @@ -234,7 +234,7 @@ static int ltrf216a_read_data(struct ltrf216a_data *data, u8 addr) static int ltrf216a_get_lux(struct ltrf216a_data *data) { int ret, greendata; - u64 lux, div; + u64 lux; ret = ltrf216a_set_power_state(data, true); if (ret) @@ -246,10 +246,9 @@ static int ltrf216a_get_lux(struct ltrf216a_data *data) ltrf216a_set_power_state(data, false); - lux = greendata * 45 * LTRF216A_WIN_FAC * 100; - div = data->als_gain_fac * data->int_time_fac * 100; + lux = greendata * 45 * LTRF216A_WIN_FAC; - return div_u64(lux, div); + return lux; } static int ltrf216a_read_raw(struct iio_dev *indio_dev, @@ -279,7 +278,8 @@ static int ltrf216a_read_raw(struct iio_dev *indio_dev, if (ret < 0) return ret; *val = ret; - return IIO_VAL_INT; + *val2 = data->als_gain_fac * data->int_time_fac; + return IIO_VAL_FRACTIONAL; case IIO_CHAN_INFO_INT_TIME: mutex_lock(&data->lock); ret = ltrf216a_get_int_time(data, val, val2);