Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp966256rwd; Tue, 13 Jun 2023 02:58:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DmlaLB+Xl9ylqObYJEfvQxmCM+HB3m9HT8QTpaBeJkWBepOrPU68Iw+1GVciThVbFzITj X-Received: by 2002:a17:90a:7ac4:b0:259:b67:2a7d with SMTP id b4-20020a17090a7ac400b002590b672a7dmr14484520pjl.7.1686650314678; Tue, 13 Jun 2023 02:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686650314; cv=none; d=google.com; s=arc-20160816; b=Ipwb6jnEkYfoongd43NKiHNSuWrDkKH0UaYwZuCf61XPuD+ZHTYo3YosClvkjl5fmg cjSFV71GxrQJcnAW1r36TlP7ZyITv4WbMIfe92Vi7LJ2b9xTVv6Jn/VZ+IqTTum6hBwX ZF017+a4YE+wW9R3Lu9KdUkcLK0EaNa83PI5eqoRFNCowFnISbuuktyQkJzml457Dduw ntwccFZdslbjy74fjsgcXcLgWId8MbroDZmGrqXnPTAvD+qAecraTzI5d82N6OrANt0u PGUVp7CIdSsv9MGbqqLwiYLDB1kQwqFlRXhof1s3Ekf03rSgcA7jPmTreeTDzW3N5DT/ dhrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=o6Psb5RzioVdv/upXxW5xP0CZJnFju9Mn7noJG9metU=; b=nYSc7lLrV+aA8IUtyKuu0sApJB7mRtjodnSNszgAtrQllVF/6vq9GeZOyqaAqllBFs tKwdPD/+Hqr87zXoFVRNXVF6uQnjX9tOQVd1Rj5F7iJ44rFgxsB7hJBWghpa5D894Gb1 6xy6mj2iamaR2lJsnWmwqRYeSeWzgch6hCXCgEvXsj27BV45jplH7li/Mo1nFVE3CY6+ XmYBMnocOVfSFSKvVsiYd9Ew5AQ1jzTfDSHdfdNDAxNX5zyTenA1aFgvOAuZlx5X5aKq zzFCbCS1heY9Zqp1WmMWyvQPTeMaGxV++RVyXvZJ/cFTzec6q42AiUOrRPKJbZwTa3Yu vFug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=U0qFk2NH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk17-20020a17090b081100b002569e5bd4a2si10236775pjb.87.2023.06.13.02.58.22; Tue, 13 Jun 2023 02:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=U0qFk2NH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240529AbjFMJfq (ORCPT + 99 others); Tue, 13 Jun 2023 05:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240727AbjFMJeo (ORCPT ); Tue, 13 Jun 2023 05:34:44 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC3310C6; Tue, 13 Jun 2023 02:34:42 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f5f728c4aaso6180723e87.0; Tue, 13 Jun 2023 02:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686648881; x=1689240881; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=o6Psb5RzioVdv/upXxW5xP0CZJnFju9Mn7noJG9metU=; b=U0qFk2NHmdFHLVYK1fC29dJoOLEi5nDNoxvVWPiYdXeeJcOK6yjfONOq90JJ95jKis NKPJtFtJzZwCSdiR4kcOVURutAlHbK3eStqyD9xMpChTMmjlpxIvmEshZS941a78iPBw 1SKkileQ/L4oOiDbM24gdHR5PeapqxGzJB64mnMd29sja9F3qpjZVY+CIEFQnVg7YJLG mq+0uUzvwPuC1TkHZFX13EAQME75E5FnJ9B5SNoIH8YlHH2z3Lmve13S0vLFSJFIWquQ 2E/k7eFT9tJXimdIl/dQG1EihPnlhf+MR0i/+Wyf55boBoqh8tgN8CgyEi1oqGNQ2ymz tW5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686648881; x=1689240881; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=o6Psb5RzioVdv/upXxW5xP0CZJnFju9Mn7noJG9metU=; b=BaemCsn4vnIUWskAOcyPaPkcBDViz0adpeVoDUOHdqauvjl51yNO5lCY1GU4Ns4PKQ O7C9ZnQhr4pXeK7iJA9NNgBw4vrne21MERBQtQueGdDjGRHhIZoqAT5/DgteOHcZyaXU dNUpVP6eQzpVEe5T0CEq2GRY3zvt/5UUmE3wMvWmcSQez3pV39MpzCwAVfnsj96F83U8 xB5QgazxK6YqjYc9tmMFI9P6+731a5Ow0mwVSfJ5//UByflzRP/WCOjrYfgSNfxH8RDO Nd7QUQr3lhDLGlktvHqKuo3ixDrlVU5GvVyxwjK0JDCF5013lPnxIOPOlzSZ1RS4xW3f su3g== X-Gm-Message-State: AC+VfDwxXbPTbZans3QZ3xe6864R1pgfb2/wz3aX1f5EnFaU42bg6nZX 1QFd8vwrKX7ScyuAzgVU26A= X-Received: by 2002:a19:4f15:0:b0:4f6:5473:7bf0 with SMTP id d21-20020a194f15000000b004f654737bf0mr3802608lfb.21.1686648880585; Tue, 13 Jun 2023 02:34:40 -0700 (PDT) Received: from dc78bmyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc78bmyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f8:1500::1]) by smtp.gmail.com with ESMTPSA id o14-20020a056512050e00b004f517c21ef0sm1722501lfb.82.2023.06.13.02.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 02:34:39 -0700 (PDT) Date: Tue, 13 Jun 2023 12:34:36 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] iio: light: bu27034: Fix scale format Message-ID: <5369117315cf05b88cf0ccb87373fd77190f6ca2.1686648422.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nu5zW1gmaBLRAMXS" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nu5zW1gmaBLRAMXS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The driver is expecting accuracy of NANOs for intensity scale in raw_write. The IIO core is however defaulting to MICROs. This leads the raw-write of smallest scales to never succeed as correct selector(s) are not found. Fix this by implementing the .write_raw_get_fmt callback to use NANO accuracy for writes of IIO_CHAN_INFO_SCALE. Signed-off-by: Matti Vaittinen Fixes: e52afbd61039 ("iio: light: ROHM BU27034 Ambient Light Sensor") --- drivers/iio/light/rohm-bu27034.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27= 034.c index 846c3d43aa34..f737d62bdf92 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -572,7 +572,7 @@ static int bu27034_set_scale(struct bu27034_data *data,= int chan, return -EINVAL; =20 if (chan =3D=3D BU27034_CHAN_ALS) { - if (val =3D=3D 0 && val2 =3D=3D 1000) + if (val =3D=3D 0 && val2 =3D=3D 1000000) return 0; =20 return -EINVAL; @@ -584,7 +584,7 @@ static int bu27034_set_scale(struct bu27034_data *data,= int chan, goto unlock_out; =20 ret =3D iio_gts_find_gain_sel_for_scale_using_time(&data->gts, time_sel, - val, val2 * 1000, &gain_sel); + val, val2, &gain_sel); if (ret) { /* * Could not support scale with given time. Need to change time. @@ -621,7 +621,7 @@ static int bu27034_set_scale(struct bu27034_data *data,= int chan, =20 /* Can we provide requested scale with this time? */ ret =3D iio_gts_find_gain_sel_for_scale_using_time( - &data->gts, new_time_sel, val, val2 * 1000, + &data->gts, new_time_sel, val, val2, &gain_sel); if (ret) continue; @@ -1213,6 +1213,21 @@ static int bu27034_read_raw(struct iio_dev *idev, } } =20 +static int bu27034_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + return IIO_VAL_INT_PLUS_NANO; + case IIO_CHAN_INFO_INT_TIME: + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } +} + static int bu27034_write_raw(struct iio_dev *idev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -1260,6 +1275,7 @@ static int bu27034_read_avail(struct iio_dev *idev, static const struct iio_info bu27034_info =3D { .read_raw =3D &bu27034_read_raw, .write_raw =3D &bu27034_write_raw, + .write_raw_get_fmt =3D &bu27034_write_raw_get_fmt, .read_avail =3D &bu27034_read_avail, }; =20 --=20 2.40.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --nu5zW1gmaBLRAMXS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmSIOCwACgkQeFA3/03a ocXCAAf9ERi4KO6rwKLhEuFdPFdT/FdFqLaO52sZGLctWan4v97H2FXMfxftrlIF qwpKynSIi8iXl4FHVqxqw6JfCjKbYhb77DOsxKiHdbGNRDDr2TtVzffT5iLZgUSY vLnnA/QLdjYx1w9oRdP3TOWBW3rz+9oyhyvRerhYYbc2t3pq9Z6dLENHJ+nvvfD4 yN4i7EGiX/T1hEbTakYp142ZIv9eaLex4PV0yjpaCoTNwZPbYBZFrvAunAeJrnJB HmczDnxqxn2YQc2Iiyb3ETv1qlqZgf1ata7edS3po8XAUPrxuP9bvlTA6Yzpl/ZH TsoO/9EnLc2PCK1kt5cpCqe1+McSlg== =jbbw -----END PGP SIGNATURE----- --nu5zW1gmaBLRAMXS--