From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E47C1CEAB7; Tue, 1 Oct 2024 20:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814101; cv=none; b=djS20nDvzlB9zcUCDtgXR+EIMKfE+O1fQrZPaEWIPEosTaPvF6OK85RStrMMzr+DB/BNSU7zPCvYh2kmAGn8rsci+81m+MKaHlE4oJBU4Meh/qz1ROQECfCCPThvrbLj1rLjnKiNCArTLt2f/C8k/wbreEtDhRI2UH5izNIvG9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814101; c=relaxed/simple; bh=1RsPKRPudkh/zaGzMI0PE1tFHEL/1QvupHlsrF3dUhg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JdU5lrCl72xPtI4CGrc1vrZemyacQrMPkyI+ywjG8M7OlVAVI193LAZlY7GJKIfpHvi5+lQ0s4BRYUf0xBM/NPMhdygqtzH58nqXVQNJ3nLKLsA1ZszWNeKO0Us0mMnULvB/8cFASyL/n8MAiS1hUjOVgGoeiqxfldPsDsfJD7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fK+AvEzj; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fK+AvEzj" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42e748f78d6so49175175e9.0; Tue, 01 Oct 2024 13:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814098; x=1728418898; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HQ+uP1JQqGSRuWfHsOXrzhAA8JAtxqy8o2L56kWhkGk=; b=fK+AvEzjENxzg1Ft8xErVXYC7z9EQYl8OkwG9zY3suwPI6KvP4vJAWjhP4GIN+AeAV j47ifoIn6PUKcUxZyaVcdrnpciXns4Bl2tbF0nblSa1mKzYFAwc3RsSNxEFiJlxHga7Y JzZpvF35ffnO2YcgHEI9QU/KfXVRhQn/UucVpWr14qNVBqjrka6LTOQU/pIcCT8RL+rD jewXLFvHiAyPVg/q3jYPYdkaI5VKAxSDRXYE4Q0BmO3j3EYOw+Ky9IVt68ynagPlVNTu o6g/kRQF2xnflhFshNFbx4XtQ3m06yJrQZgos2BJs6IRuhCnPLkI3/V0Yu8gfsAbF5Ik J3UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814098; x=1728418898; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HQ+uP1JQqGSRuWfHsOXrzhAA8JAtxqy8o2L56kWhkGk=; b=AFKf/9qLCn2UWTFlv1IWrD8LjQQGJOX1OSe5k8UUpZP0ztht1n6qAKXqcnZp2Q+tOM 8xFjp1vOFJLgrOT46DRdTmlelVK3yr/5C1vBrH09VTGhaae1W1AsrpKrnVsS509HHLkJ 4dRs15NjLpId+gH+O3ePnOtNm5KhPwA5OfpUtWUp9+wLqAsmMzm5HFy/AxwOGhbaku9a QmR7Nj6BOzFRPA9NwyJQ4koIHXl9pqmqRL1buNmW/P6w63qNMuYvdkgAxLlzU21xTXxn eja8TKpMtVkO5dnD/1bTEdACf/E+r8g8RgzZtMLTOSsNdxo9Xj2CMrP2je4i+B5KhMs7 g7Bg== X-Forwarded-Encrypted: i=1; AJvYcCVCkosaQN8b4sEDIhIQKPbgOwHpTbB6P2pso7Qnkg9hAsB5zRCFes3zRsq/50IpNVMr+nk+CLtMQJEs@vger.kernel.org, AJvYcCVstSwqTuFm8YsP74WuX0wVygdvam8EnEAqEluNB4n1/OC8W8K1cMy84DLPleCZJ2GRruZCFnySMcyvSP+y@vger.kernel.org X-Gm-Message-State: AOJu0YyJg8Ez6+KHEJVzn5yKU63T2n6g4dAFUXwkeiD4vEE3VDdpviWN foBGBKasvqw+D4BIfO5ibkDrX7afgiJZfcFVnppdoY5pRiEJNCPAVVroeHT6 X-Google-Smtp-Source: AGHT+IFsujAGwiUtUHctuq+0EM9Xdx6DX2hDtMlZsKqnFg8nTqRKzW2D4s5UbK8ECKth4OzdMROs4g== X-Received: by 2002:a05:600c:4e8f:b0:428:1608:831e with SMTP id 5b1f17b1804b1-42f777ec6d4mr5592935e9.22.1727814098129; Tue, 01 Oct 2024 13:21:38 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:35 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:14 +0200 Subject: [PATCH v3 1/9] iio: light: veml6030: add set up delay after any power on sequence Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-1-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=1605; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=1RsPKRPudkh/zaGzMI0PE1tFHEL/1QvupHlsrF3dUhg=; b=wqn1lmrcPFug9Cyt7s5wSPx4GBCU0Kq1i9cZsfQ9n3LeReOEdT8Yz+IrAaQt1+l1lWdpv6mGO Zv9MCLoiJsXBtNIE/+SanrtYVh0kVdYolvu0iYRomS9/pu9NP2T6fCD X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6030 requires a delay of 4 ms after activating the sensor. That is done correctly during the hw initialization, but it's missing after resuming. Move the delay to the power on function to make sure that it is always observerd. When at it, use fsleep() instead of usleep_range() as such a narrow range is not required. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 4c436c5e0787..94e38a983cf3 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -144,8 +144,17 @@ static const struct attribute_group veml6030_event_att= r_group =3D { =20 static int veml6030_als_pwr_on(struct veml6030_data *data) { - return regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, - VEML6030_ALS_SD); + int ret; + + ret =3D regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, + VEML6030_ALS_SD); + if (ret) + return ret; + + /* Wait 4 ms to let processor & oscillator start correctly */ + fsleep(4000); + + return 0; } =20 static int veml6030_als_shut_down(struct veml6030_data *data) @@ -767,9 +776,6 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) return ret; } =20 - /* Wait 4 ms to let processor & oscillator start correctly */ - usleep_range(4000, 4002); - /* Clear stale interrupt status bits if any during start */ ret =3D regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); if (ret < 0) { --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C2D01CDFAE; Tue, 1 Oct 2024 20:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814108; cv=none; b=Paqu0bOoeYjMuflL7TdK+bF/gGBf+1Dlrip1dbAzYGk6H3JbR7vYjbd9qZDXApjn1QunwTkw9UGZmc+Pdb3RrtN8+ms9di65dQsF0Wro3TV9Ylb/agl5owO2w13aFzXhQOjMLOZLfMIGncqz5JYgnfChWvTxz3Cz5Cg3pbIMsbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814108; c=relaxed/simple; bh=iCU63FBzBRIP83YwKMMy/0f2h/0RPDJeJcQgqOrF4G0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GB5jq80/VfYgXpUNouYRqL7QS9CurKYBDBuFyO+4DOMXQZw94SxJ8+zHVNLCvTwcXhOrxwszmUqlWqvf5kIvAkI6NjiXIoaMo0uj5+V233q+dA/p6hRkZh14JJY0zyEcIywT0J2qpojNFn7l73rvvJ1RCoa52OZDQ+ZFdgVA/uA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lDKJW6Qq; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lDKJW6Qq" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-37ccd81de57so116006f8f.0; Tue, 01 Oct 2024 13:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814104; x=1728418904; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=i1SEf8uN32PzFnwgT/mEmooqPepRUwIPluKBDrqdS9I=; b=lDKJW6QqgLjYWgPBFJ4y426HouvSH4zu1Pic8ST61rbPl0z7HHwnFbkhD5pDp0NUdM J1uD+2/LLX+/ogEkXyXCUeeWQ7yRI37hElr2l3wqZEC5GWvBWt4LF/byt+iqnIzfzW1R IkdOS4l6VqtZcX6rZ/i1fdDJivIem2hilkweMs9Emsbxwwd66Ipu9g7rBHSBGRokhjc/ mq7gral5xnDsEX3Hmg744UReOJhrOSDONLD2+bGD7cDtNhXUYUG93cnuefBgXxZSDjKg HZRnu24mBbw7YvMyATQ/bT6YVFMfdQ9tS0XIKPXMRinnsjrmXbBDmVXmpELxIoANpGtX Z0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814104; x=1728418904; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i1SEf8uN32PzFnwgT/mEmooqPepRUwIPluKBDrqdS9I=; b=Kl4KgtY3bWwUadLYWYjmXHhJlpcZhvSvRmFhS3GW7qUD5aZp7NjR3L63dl95lgXZx9 n+pDnKIfs/dfkYRENyhhPwrK8+j6GirRPLLT7fElAjMVHaqQmG/U9U+zFfTJVGSaMyb/ 74r+8gkclenDHU5lKOy26+vc/wYS4RaNMftJAGbFz36rZmpvPq1RJ7A9gmusOH2uOy62 367dFVKoeawUdkQ16cEDEjQNfkDlHqdAcyby2W+WCI3TQky/SzIAi7jjcUxM0dxtgei8 GbR46neJWTwQ0wjIHt2KN+WZ10S5vvDiRYTanU3UmGoowMD1jEmJq9MUuBuwO+WYmDD5 +erw== X-Forwarded-Encrypted: i=1; AJvYcCV6g435CK9C8JjRGySQpbSTkOulpxHPjaHZRWOaHE8LdEJtSUKKjoI0JL2NYi6L9mFcwnAvifNFdGwL8Y3i@vger.kernel.org, AJvYcCVcIzjR4ObYyssygsnrAp8W94KBOu6k7e4gHJc1uMOb90vrLMMV091AT4K0a+7rgyMtqnwDR4uPLQbc@vger.kernel.org X-Gm-Message-State: AOJu0Yzkfe8OBe98xLb0tR29SET0rdoDQocEX0QgXM0gi80SC7epZ/VO 5i+UaeJg0J2iDVdJ2t6BbIw7Z/wXuJjse5JucJgc2PUhwwgKfYaPCvuRscNP X-Google-Smtp-Source: AGHT+IFGy4ajxWqzarP6iUs/nAWdUhAafGtqUsMgD5Qk+xaq0E765UC1ylngMiNeOYRqaQGfMNapLw== X-Received: by 2002:a05:6000:4106:b0:37c:f997:5b94 with SMTP id ffacd0b85a97d-37cf997631amr2424923f8f.12.1727814104135; Tue, 01 Oct 2024 13:21:44 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:40 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:15 +0200 Subject: [PATCH v3 2/9] iio: light: veml6030: use dev_err_probe() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-2-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=4012; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=iCU63FBzBRIP83YwKMMy/0f2h/0RPDJeJcQgqOrF4G0=; b=eub0w+xwIZM+n9FKemH5HdEBO8RiY42VFgAxBOfb/K7xINl7JvNBS1KsSiZZf0WZIJhS7JSNR 1ZRnGE++miNAKwWBID4aw6LaJQAozuxcqrIj8EF3S+xHbPAFgQfZhFd X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Use the more convenient dev_err_probe() to get rid of the dev_err() + return sequence in the probe error paths. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 72 ++++++++++++++++++----------------------= ---- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 94e38a983cf3..6646fe2e74a7 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -740,49 +740,39 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) struct i2c_client *client =3D data->client; =20 ret =3D veml6030_als_shut_down(data); - if (ret) { - dev_err(&client->dev, "can't shutdown als %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "can't shutdown als\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_CONF, 0x1001); - if (ret) { - dev_err(&client->dev, "can't setup als configs %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup als configs\n"); =20 ret =3D regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM, VEML6030_PSM | VEML6030_PSM_EN, 0x03); - if (ret) { - dev_err(&client->dev, "can't setup default PSM %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup default PSM\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF); - if (ret) { - dev_err(&client->dev, "can't setup high threshold %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup high threshold\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000); - if (ret) { - dev_err(&client->dev, "can't setup low threshold %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup low threshold\n"); =20 ret =3D veml6030_als_pwr_on(data); - if (ret) { - dev_err(&client->dev, "can't poweron als %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "can't poweron als\n"); =20 /* Clear stale interrupt status bits if any during start */ ret =3D regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); - if (ret < 0) { - dev_err(&client->dev, - "can't clear als interrupt status %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "can't clear als interrupt status\n"); =20 /* Cache currently active measurement parameters */ data->cur_gain =3D 3; @@ -799,16 +789,14 @@ static int veml6030_probe(struct i2c_client *client) struct iio_dev *indio_dev; struct regmap *regmap; =20 - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "i2c adapter doesn't support plain i2c\n"); - return -EOPNOTSUPP; - } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return dev_err_probe(&client->dev, -EOPNOTSUPP, + "i2c adapter doesn't support plain i2c\n"); =20 regmap =3D devm_regmap_init_i2c(client, &veml6030_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&client->dev, "can't setup regmap\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&client->dev, PTR_ERR(regmap), + "can't setup regmap\n"); =20 indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -829,11 +817,11 @@ static int veml6030_probe(struct i2c_client *client) NULL, veml6030_event_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "veml6030", indio_dev); - if (ret < 0) { - dev_err(&client->dev, - "irq %d request failed\n", client->irq); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "irq %d request failed\n", + client->irq); + indio_dev->info =3D &veml6030_info; } else { indio_dev->info =3D &veml6030_info_no_irq; --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B0A41CEE97; Tue, 1 Oct 2024 20:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814110; cv=none; b=RhpUGgQCABhsXMRXA89drJqgp5mRga92/0q2lL+df2oftP+UZatZCFS3dsaaZKEayVtV3isukXUzKRnPcX6xqrOYRwONa3De9JWo0tI1oQOLJZa710qFYQ3lmf0KzV29k1jzOZASeIAMfELdEerTEttMLen+qAfrfY5maRmh8Ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814110; c=relaxed/simple; bh=q8FwDwo56C9iqr9K04+IlFVkhpkEpUaFpNVqlpnaH0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=POgvGH/4Fe/7bf8KDaYzYbTVZM6tMnDzb8hI8j51t/GyCwvPMylMFeNvHJDJaYOojxr2uiBWAzJG2rckt2MBvwTtK5bqJDkOl3CW1tE+c5twnj2QxlJYMDf5P1vZ262wosI4pTfKLCGcyx8RBYE9mE9dNs5RVl99QA/5rKl8WkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z+Zfh2X3; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z+Zfh2X3" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42ca4e0299eso49008105e9.2; Tue, 01 Oct 2024 13:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814107; x=1728418907; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3ELev4uZv7sI4OXtICgXw+pXJd/SMDS1j69x7XKzekk=; b=Z+Zfh2X3XEo2RC4FUjpbIF2O37f+IR/yIsMJozeOrNXHdp3c1YbsMqEiXlUgRYc1yk c+JFf28r8+ybnDaZYpPbtYSOw5Fk92X9uk37aBol4cmAdPvQ7lwVRB5ysK+PoC6rxP86 8Dhb+ByGJnRLgOuxSHKU66X5zIes77ASV3Vf9/UBIOdy01UYN0cUhO++cxE/kgfXLkNJ Nf0q03iuXYAYPl+99u+jGQzP7EkwL69xN0AN6SF9crKFzFOOFg1ELIzaI0svsu6vb8IV COgeiE1+5D0jQaQbEp5bG7LU8tpIMSaraLFKkUTGgtWoVa4cyOZH292E4E7sSWUk08ED aYOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814107; x=1728418907; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3ELev4uZv7sI4OXtICgXw+pXJd/SMDS1j69x7XKzekk=; b=NEIwkpdkGV5N0mvgKz6uPoqI7HHIhDSnK4ohfV3CJHNOlT9iliB21FKkrpDsT8twvt xl4JuOPlU9U+SN5HaYFaKfvUQ3Djuvfc8PQ5bRKwyeWagLYjc8RpIIfBNBZtW32kEuYE GwvPZAADTM2SS9WAAVr0dwdYgmPrvTFU/paoWzU1gfjIUik6wZUga2B63L7dczlPLoAA YXZO/efe+9mbnxyTldSSSXjW8BBduuydhe/KPZ3rfphu0uPI1cLfw+RXLoScBBuM4G7M C58+RTnCW2aC8OJ0OEY74TPU1POjBdtLgCQTjOvvFsavOA94+y/6IwGCKt1zbZq1R5Ml PZAw== X-Forwarded-Encrypted: i=1; AJvYcCUPefzRIc/XdjArZQZlPVzmYLhVf+XviBVYHL2xQPjf/zDWpBw5fRbVB1gYrbqWS9v3QmaEIX0FAMRdT+V1@vger.kernel.org, AJvYcCUfQqkWgU+m5FbCazLVvQOfd98+lXqaxuHZaPwq3Hc1jXVoFmFrWMbIf9aGLoVn8y4Vx4te4OAtGu18@vger.kernel.org X-Gm-Message-State: AOJu0YwSyjQ8JbZC1k19dFCD0ulDOKRbs+4ZGMjszVI+6eI480kyj2X9 khN/pp2tpRQhw6oRG/ycpDQIsVlZsjB6lGtTUjs3xJgMr4Bp/3RrHEBUl2rD X-Google-Smtp-Source: AGHT+IGNJk6cnlBlay1XsFzUdSfqL+mtSzambJy8vwOBwnzNlpo+PS9VwHIh/1vO1PXcYJhFz8iDTw== X-Received: by 2002:a05:600c:35d2:b0:42a:a6aa:4135 with SMTP id 5b1f17b1804b1-42f777c278dmr4507025e9.20.1727814106941; Tue, 01 Oct 2024 13:21:46 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:45 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:16 +0200 Subject: [PATCH v3 3/9] dt-bindings: iio: light: veml6030: add vdd-supply property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-3-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco , Krzysztof Kozlowski X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=1080; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=q8FwDwo56C9iqr9K04+IlFVkhpkEpUaFpNVqlpnaH0A=; b=rqHVmh5s9yN2L7KEiDDT5/+g7334tsHwmy3yBTWilHgfSUo1GkWM5wtp12cOo9kqsCEs2si4B waH+izMv4XOAgvlTXA8lPevkVYs9C4i3lecXjCPMwIXbFTg2CBuYQnq X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Add vdd-supply to account for the sensor's power source. Acked-by: Krzysztof Kozlowski Signed-off-by: Javier Carrasco --- Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.ya= ml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index 7f4995557570..42a78cd4f812 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -41,9 +41,12 @@ properties: interrupt client node bindings. maxItems: 1 =20 + vdd-supply: true + required: - compatible - reg + - vdd-supply =20 additionalProperties: false =20 @@ -59,6 +62,7 @@ examples: compatible =3D "vishay,veml6030"; reg =3D <0x10>; interrupts =3D <12 IRQ_TYPE_LEVEL_LOW>; + vdd-supply =3D <&vdd>; }; }; ... --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 641111CF287; Tue, 1 Oct 2024 20:21:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814114; cv=none; b=lpDtMO7peJlF18Tc859isJqa2TXWzYQYO7W61gI3fsh2gf7w3zb/FYaic73u02sGAFJwU4aImoudNckSNR+C5XcAFgqGnJGNslaPfAY31U6vAnuzn/xylLQMng1B3CYdtftAYSHAMHGiu6M4w/wruELVfn+fqRJ5mHR4Jm7MWRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814114; c=relaxed/simple; bh=xgxLh+rAz89buZ/oPb9iuOaqEqfTt0zyVA8NpMpdP5M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OXh/xk3vJ/HtGU50hO485fcMR/DoAcskkMBGqbIUpxqd0ZdVAeDhgUze9hvBA4DtJscBI+pIfV9uWDdlHWSUbH0kjbjMSV9IwK2BgFLz3Db51EkDimjplc2lKzllOowUUxaeCtuEafJwNdUcf1/eJRV7TVLt785WThYl88NVmvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PzeSNhrk; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PzeSNhrk" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cc8782869so54982995e9.2; Tue, 01 Oct 2024 13:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814110; x=1728418910; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BKpfX4jd/6xZA26W9u5SbrDdfUvg83IHr89HZKnf32E=; b=PzeSNhrkkQ5foGLU4XgkW0GVtwk95qFPmMR08Qp5rAZxDwmdYoM4mFuPLZQd42a7MH 7AWIaFXJeIQnENfQiDwrtKIEoGeCLYbhIIbSDW1pFlRpUbRkzuvRMA0fg/yJx4pP4gdg FD/Be8utJWr1gfC4DW/ZeJK/DHY4cax/zIEvyBjO2YFus6Kie/B3HfktNABlNEriMc3C zoj2RbbBDdeNrvgPwbP/+RwJ2tSnDtrhqkp+6xZMst5pl4oAk3pLtxXhOdNIP/TCVO/S 6ZLZvNIeFDpfr6K2LEmmF8cOO8CqxdhA3jK9L2ZNhMoDoU4gU77zejbzfGsi9bssFoP5 p5NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814110; x=1728418910; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BKpfX4jd/6xZA26W9u5SbrDdfUvg83IHr89HZKnf32E=; b=o7WQdELTEnxGrwiKqrSLTLB5MvwHtBZN11wC8ER1EWzl00psmEXjgv+x9WWH0Q64bO ZFBHrH0ahbGYxP3DsSfYYq+OjznHUmrfIBYVd8/1zWRiVk+ex8EoSzd1bEymvq67SCpo +B2jR8y4SJm5piWUXKZLdfpBehCGP7RRYEL03hM7UXQ2WHiqM7OMEdd1J/y31/IScZVo FsvRhhFJeJd2n6lsTax0IoU1JWr1yQq99mttXUZlZ7VjaQskX8E5OFfoozg0LxBPxcVH /V5suyjdtbz7HMk7fg1AJwMn+cMHXK9ww2XIWvVLs6x4O7/c9NWqNLEVbOOm5q76orRb 9DgA== X-Forwarded-Encrypted: i=1; AJvYcCWEOklxUbDm0rmnfylnrcuggYq+rzbRPP7s0GPm9SPGSIAXmzbB9jln1/iGaJIdRh0T5X0qR/hvOkBG@vger.kernel.org, AJvYcCWcE0USEN0T+cC++fQh7d0noAUSC3/NJvUw2Vw0LxLjJkn8lsUSWNOdrY/rA/7amIVOuNZsmHVqU2q+1NFH@vger.kernel.org X-Gm-Message-State: AOJu0YxPG8PTDMfiK2Zfe6IKcM5K8nx57Uteafaa7O9keIILKSYgc5B3 dvq+Ju94BiYIvj/KkyHF2I5IXc5ijCfxRNHUlL+zSqPlhTyclrQnNpmGkG34 X-Google-Smtp-Source: AGHT+IH+xZ06kSpbFzz1J/U1jWJri+7DC5+I0vCOTUnE16ElPXoMisXkskG82QwmBGspp8y+V/moRQ== X-Received: by 2002:a05:600c:1d9c:b0:42c:bd27:4be4 with SMTP id 5b1f17b1804b1-42f7936bf09mr1435015e9.8.1727814110410; Tue, 01 Oct 2024 13:21:50 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:49 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:17 +0200 Subject: [PATCH v3 4/9] iio: light: veml6030: add support for a regulator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-4-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=1203; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=xgxLh+rAz89buZ/oPb9iuOaqEqfTt0zyVA8NpMpdP5M=; b=Kb7WMcoe4jq1SIKn27ycLgVdEsX0zrNGY3hHW+vYCr1gost4wlbG+Y3UIw73/xbqZ6MxSmy3x vDMP+s/LzScBaVPny1BOGsnQevKvevH4+GqeaCl54c0MrVsyaOt3NWe X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Use the device managed function from the regulator API to get and enable a regulator powering the device. Use "vdd" as the ID to account for the provided name in the datasheet. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 6646fe2e74a7..72c1988e48e6 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -807,6 +808,11 @@ static int veml6030_probe(struct i2c_client *client) data->client =3D client; data->regmap =3D regmap; =20 + ret =3D devm_regulator_get_enable(&client->dev, "vdd"); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to enable regulator\n"); + indio_dev->name =3D "veml6030"; indio_dev->channels =3D veml6030_channels; indio_dev->num_channels =3D ARRAY_SIZE(veml6030_channels); --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 171541CF2BB; Tue, 1 Oct 2024 20:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814118; cv=none; b=F34j3DNQEUQX4TuwGrO+dG0WSjY9/qSSziQqz3YiWxatMPD8l69BeYkkSpUFzts+cPcHf35FCV1JEiD1noZnkIbZLQyyzf6SB34bk7bHpsDmM6l7dP89yg2KP4XHyfuRGXbalWPiAvlmPb+sEFn7CWcM0mPRSeoYyIIHDEYiq7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814118; c=relaxed/simple; bh=D2F2Y4S1DywiDWYkW1F7OG7AQaV3uviqxsquxVHQ4XY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u630IIaKKLWpg+0xM/r+/D3ssEG+66U3FHMD+Nb0Dz2effvmbKN5YnJlffBz5+U6us8A00Ovp5H3s02M2VCZChIlnHrRrWTfCBzoWe/KGAQkjuAhTuwCvKmi0f/WP1xt/D7vGZe092hICu0ydguW0hACrE6aGBOhDhNZxUcIojY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XZRlexeV; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XZRlexeV" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42cb0f28bfbso46677625e9.1; Tue, 01 Oct 2024 13:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814115; x=1728418915; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6LLIfUoLjCg8+1pCkoboZ6/Lt3e71o0HRH+OVBICLC8=; b=XZRlexeVkAP7miiUHx0e7znbvz5UM3TZzT4jtEfV7XS3PqmSh+d3IQW8wU3plAkIeG /owQulqfsBbxb1PCNoRoOCVj431QuvO8NUEd/r2DwLT4qHEpjFmq+Zl3ysPj6LUZy3kK Evmaoxfn7Kr2AT7xPr/gQubuG3YWM1lQ6qmo7IyUjd/P2/JnwrBCPMzdqBhThJnUyQQC y0ndLZp8f1iYDHf9ThzyJ9qDB7plZnLtuWvjsPeh4Xo/JIYjoiYHNTLb8AwPn1KxXxty zDBCNZTiIJ+gWpKWF2i04zftdAV7MhcOAAnv83umpBnECboMrngRG4BjaMH0y7KESlZB n9fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814115; x=1728418915; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6LLIfUoLjCg8+1pCkoboZ6/Lt3e71o0HRH+OVBICLC8=; b=XfJHDOVljTtnXC1jDATB5lwAbgH0PvUWbZaUpA185lIjBjXJyGs7F3fs2XPxXb/lnO ujcntrTP+U0CjAQEh/IuJonRv1TkEW/y+2ismqd2Opq3vbwFyPEDmpUsASFKQ6PjVNJ2 Pwd9mWMblJNSnH1ue26fMf8djo068WFP7M/1fi0lf1A6LTKHYgJRVcp/CkBRRd2jrffE Kcw1VLUjbF9TIV1a5I2NTkMwFTh6z9hyGyRYtKL9XxmtwVolRRYCjThDo7pkce1KG+in E+6nZHOokqCsyjGdjKrCmkOKIxA0eik66+tPFGq4HaGSCo0SK/m2tSAidC1YWt9jP3rA pBLQ== X-Forwarded-Encrypted: i=1; AJvYcCWIjDwAm7xjUJlZZYibdHQEJ7gGTUTONJg0QxT5xRW/yfqcByHMdxtDqo/NyPJIuJHAeD26QQ8zPEtz@vger.kernel.org, AJvYcCXTOmSIK2RI6ui2CSlZpbdlyrLEYQLbtQNWSC8GBXTB81fpIA4oDEqcqD7RoDBnf5JURGIPhQxZZHvoN++h@vger.kernel.org X-Gm-Message-State: AOJu0Yx4pqpmqBhW13DgEPZk9UIQkX58NC9LJ2X2NETMI87PkuQB19dn sge7UaQrLaBLx8EvAk4Vu9UyDJgyaeIeebVOyCtGVAltyhX7EL/YTANxIFCt X-Google-Smtp-Source: AGHT+IGQEk5Zw6aF/QNo3iK9HBDsJ5FFF60+RPQzz3216JAyqycMw0wnPz6q/NeG7tqmLQMvQ+y9CA== X-Received: by 2002:a05:600c:5254:b0:42c:de9b:a1b5 with SMTP id 5b1f17b1804b1-42f778f37cfmr4326925e9.32.1727814114989; Tue, 01 Oct 2024 13:21:54 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:52 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:18 +0200 Subject: [PATCH v3 5/9] iio: light: veml6030: use read_avail() for available attributes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-5-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=5305; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=D2F2Y4S1DywiDWYkW1F7OG7AQaV3uviqxsquxVHQ4XY=; b=hXJKqdrjgIAaCIRAJUQ+NpEd12SdHlxmxgpvGFxly7Hh88Uts36QbU4LofS/D/YRgvWl14RfX yqW0f8ET+LGCEcDRkXmiO/o34QukAozPI7QSwXSJpoFPaxHempjIifB X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Drop custom attributes by using the standard read_avail() callback to read scale and integration time. When at it, add the integration time and scale attributes fro the WHITE channel, as they modify its value as well. To avoid breaking the current ABI, these attributes must be kept as separate for both channels even though they are shared under the hood. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 82 +++++++++++++++++++++++++---------------= ---- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 72c1988e48e6..fe6d2f9a2e01 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -58,25 +58,24 @@ struct veml6030_data { int cur_integration_time; }; =20 -/* Integration time available in seconds */ -static IIO_CONST_ATTR(in_illuminance_integration_time_available, - "0.025 0.05 0.1 0.2 0.4 0.8"); +static const int veml6030_it_times[][2] =3D { + { 0, 25000 }, + { 0, 50000 }, + { 0, 100000 }, + { 0, 200000 }, + { 0, 400000 }, + { 0, 800000 }, +}; =20 /* * Scale is 1/gain. Value 0.125 is ALS gain x (1/8), 0.25 is * ALS gain x (1/4), 1.0 =3D ALS gain x 1 and 2.0 is ALS gain x 2. */ -static IIO_CONST_ATTR(in_illuminance_scale_available, - "0.125 0.25 1.0 2.0"); - -static struct attribute *veml6030_attributes[] =3D { - &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr, - &iio_const_attr_in_illuminance_scale_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group veml6030_attr_group =3D { - .attrs =3D veml6030_attributes, +static const int veml6030_scale_vals[][2] =3D { + { 0, 125000 }, + { 0, 250000 }, + { 1, 0 }, + { 2, 0 }, }; =20 /* @@ -200,6 +199,8 @@ static const struct iio_chan_spec veml6030_channels[] = =3D { BIT(IIO_CHAN_INFO_PROCESSED) | BIT(IIO_CHAN_INFO_INT_TIME) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), .event_spec =3D veml6030_event_spec, .num_event_specs =3D ARRAY_SIZE(veml6030_event_spec), }, @@ -209,7 +210,11 @@ static const struct iio_chan_spec veml6030_channels[] = =3D { .modified =3D 1, .channel2 =3D IIO_MOD_LIGHT_BOTH, .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_PROCESSED), + BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), }, }; =20 @@ -555,37 +560,44 @@ static int veml6030_read_raw(struct iio_dev *indio_de= v, return -EINVAL; } case IIO_CHAN_INFO_INT_TIME: - if (chan->type =3D=3D IIO_LIGHT) - return veml6030_get_intgrn_tm(indio_dev, val, val2); - return -EINVAL; + return veml6030_get_intgrn_tm(indio_dev, val, val2); case IIO_CHAN_INFO_SCALE: - if (chan->type =3D=3D IIO_LIGHT) - return veml6030_get_als_gain(indio_dev, val, val2); - return -EINVAL; + return veml6030_get_als_gain(indio_dev, val, val2); default: return -EINVAL; } } =20 +static int veml6030_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + *vals =3D (int *)&veml6030_it_times; + *length =3D 2 * ARRAY_SIZE(veml6030_it_times); + *type =3D IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + case IIO_CHAN_INFO_SCALE: + *vals =3D (int *)&veml6030_scale_vals; + *length =3D 2 * ARRAY_SIZE(veml6030_scale_vals); + *type =3D IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + } + + return -EINVAL; +} + static int veml6030_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { switch (mask) { case IIO_CHAN_INFO_INT_TIME: - switch (chan->type) { - case IIO_LIGHT: - return veml6030_set_intgrn_tm(indio_dev, val, val2); - default: - return -EINVAL; - } + return veml6030_set_intgrn_tm(indio_dev, val, val2); case IIO_CHAN_INFO_SCALE: - switch (chan->type) { - case IIO_LIGHT: - return veml6030_set_als_gain(indio_dev, val, val2); - default: - return -EINVAL; - } + return veml6030_set_als_gain(indio_dev, val, val2); default: return -EINVAL; } @@ -684,19 +696,19 @@ static int veml6030_write_interrupt_config(struct iio= _dev *indio_dev, =20 static const struct iio_info veml6030_info =3D { .read_raw =3D veml6030_read_raw, + .read_avail =3D veml6030_read_avail, .write_raw =3D veml6030_write_raw, .read_event_value =3D veml6030_read_event_val, .write_event_value =3D veml6030_write_event_val, .read_event_config =3D veml6030_read_interrupt_config, .write_event_config =3D veml6030_write_interrupt_config, - .attrs =3D &veml6030_attr_group, .event_attrs =3D &veml6030_event_attr_group, }; =20 static const struct iio_info veml6030_info_no_irq =3D { .read_raw =3D veml6030_read_raw, + .read_avail =3D veml6030_read_avail, .write_raw =3D veml6030_write_raw, - .attrs =3D &veml6030_attr_group, }; =20 static irqreturn_t veml6030_event_handler(int irq, void *private) --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D2E71CF5CF; Tue, 1 Oct 2024 20:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814122; cv=none; b=MoO0FIzdXnHwiV3LGL5n+6errqBohyL5qKAJRLfWhJkLw/XwisGYlV6M0g4LT8OrD23O0zKp08Jeb39HDtnBdVkR9v+QlsJHatXEZQ+rUIOjKEezM4klPQ9DLBgz6ghRMdMoiFWxf6pnFalWhf/dSTeDvr9Y50lN67TkNvQixyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814122; c=relaxed/simple; bh=6FdgvinlhFTPyzFS1cRR4OBTLX5M2H3vaJ1nXi+ddos=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m+SyveIX8S01ZFUxLNAkDslPEb2N70lSLGsy/bzJRJWWjrLpWRyhP7/SLs7W+31AJ06M1p939yu7aHw+QN8N7k+cfQqISBF0QfgMkxGtpxxbWaLvCsdFyRZ5vvnBe06M6uWp6dZV8VfeparjSF9grumHGWjpEWwxJxcABz7puK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kGpoFo0w; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kGpoFo0w" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42f6bec84b5so21957025e9.1; Tue, 01 Oct 2024 13:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814118; x=1728418918; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2AjnAb2fU4G/kpoYJbvKEuDGRJMSHdPRKJh3hKN4HM4=; b=kGpoFo0wtoc8xd5h0eHgZNANrLHUL4ctiErrX/71pzBe17Yb9ARi3qC2cZXlu71AF1 +peHOPuISM4fxK22+4Lrwya+AvPtZOL4YvHh3v0k6x7g6qmR6hkwUNceU7Piql3fWJb/ acEQ1cQpnZ4Y/2772s0sz7/vOGfBSnoiB1ZZjtuLvQMkcVe4MrV6crWzdN77Ah16WJ2k 8pky3FTFGwofC5Cnt10HwuIUwrQR32i6TPDgO9GLq13tD0A2P8xI0OMHe5TOfXlGg5xX jEJig5OipaHblecHWXBDjfRucgF3/nB5gKGcPBkPhVVePqCTdM+vXfQytbOdLl1PzwOi tWrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814118; x=1728418918; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2AjnAb2fU4G/kpoYJbvKEuDGRJMSHdPRKJh3hKN4HM4=; b=fCok/17SbFHpM25v4tlRCDkzFEM3UhYojp6EjIcVm98YUeasu3xoNRXNtC6fyan93z LqOktAa7G8LXXoeIa+3SSu9wGGRF/7HZLQo/tmSOsk4pmbFxL+UXpDbvYLxi3OAfP99j 3a874M/+UgH+tfV328Q05eLmmwqyk/erNwQVK5KHSNr+8L0FCTafzpOZuZ62DxhRv3oT CLjD6e2VVM9YZTSzn8tXyDm3Qly936TBewbkUy6kTJQNcs6hAfu1SkwcpK1KG1a21j6m o822Iph6BoZdMvu3yx98WnPLnb91tdttCWXGlEMmh4b9/AhReGWkWNaEXx+H1fIEgKtj GlCg== X-Forwarded-Encrypted: i=1; AJvYcCU9QDJGrND9khs3WNcNNMOhIvQ9PZ5f7OPsNlmNa6io98+xfN7oLrdDJovQ3kkbbWo5lRc+3pz4SNrDQYfu@vger.kernel.org, AJvYcCWRW0UUL99mIJs0AG4YpWj8SAwWu9YuCriHh6qlVlls/HdiThaIjSeCF7DnThTbBhAPeDnPPnbZgkxH@vger.kernel.org X-Gm-Message-State: AOJu0YxnnECKGlQrbk0Y8dKrKlD4I1YezImlQnq8QLny4feOTvOB6xrw y5qxE4pYDPtHrwVNWTFxSued1ZP5gAo5M94cFZEblLqE+olfH43Jwi14ojA/ X-Google-Smtp-Source: AGHT+IGAEJ7v4r5lwzCjG6WtYFulkb3KxzrHOVLqH6D3v3U85UA1HsgjOFERjrQJ+9YYOAhy1xz6og== X-Received: by 2002:a05:600c:358e:b0:42c:df54:18ec with SMTP id 5b1f17b1804b1-42f777ee3f9mr4438865e9.28.1727814118137; Tue, 01 Oct 2024 13:21:58 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:56 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:19 +0200 Subject: [PATCH v3 6/9] iio: light: veml6030: drop processed info for white channel Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-6-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=1568; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=6FdgvinlhFTPyzFS1cRR4OBTLX5M2H3vaJ1nXi+ddos=; b=O/L27EDv0iYqC/1NBfcPqeNFaUtH/dE0y0voKVbrs+wLvQrLw4wTQW25bnbhL3qpoHI7YIFGr zvDrb0Lgs1DA9tYqcA12MEcgzDEcToKfuVx2MNBQuHgY1VsQdIZ4ul3 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The resolution of the WHITE channel is not provided by the manufacturer, neither in the datasheet nor in the application note (even their proprietary application only processes the ALS channel, giving raw values for WHITE). The current implementation assumes that both resolutions are identical, which is extremely unlikely, especially for photodiodes with different spectral responses. Drop the processed information as it is meaningless. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index fe6d2f9a2e01..677374e401b3 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -210,7 +210,6 @@ static const struct iio_chan_spec veml6030_channels[] = =3D { .modified =3D 1, .channel2 =3D IIO_MOD_LIGHT_BOTH, .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_PROCESSED) | BIT(IIO_CHAN_INFO_INT_TIME) | BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | @@ -549,11 +548,6 @@ static int veml6030_read_raw(struct iio_dev *indio_dev, dev_err(dev, "can't read white data %d\n", ret); return ret; } - if (mask =3D=3D IIO_CHAN_INFO_PROCESSED) { - *val =3D (reg * data->cur_resolution) / 10000; - *val2 =3D (reg * data->cur_resolution) % 10000; - return IIO_VAL_INT_PLUS_MICRO; - } *val =3D reg; return IIO_VAL_INT; default: --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2CFD1CF5E6; Tue, 1 Oct 2024 20:22:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814124; cv=none; b=gVerbs8Pwqjetv1/vceZrrsUJdK8L0jo+Q0POuoptXMnainRBMg9rPGetu65Bez68LGFX4fKngYcF7fPwBsz1OzbMaJcDVUwVetMzAb4Z9xQ63cLQiF6VbCUY9JeuiNHERTKHZ6Zk40ktLqjOrUPUDoNy7WWDHNM5nXQ4+MIwEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814124; c=relaxed/simple; bh=+GWkCMN4psn2gtNcb+/LyHIlKEDipE9L1RayFLQLUg8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OCeZJOcKqgBAen92ZNquXkhW2QwF01RWQomNbf6Z9DYQXoCXon+Ll9BV6xb7mUVw5gk9gdkCWfRllWEbf0HpHdqb1GP5+GJOBbkvyQ4lvXiI34kpnUeYlt58BU0vrGpiSucOtDhHmURzprzp1wZZ6Leu+3Ao6uma528XvN1WoPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Mig3M1gf; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Mig3M1gf" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-37cd8a5aac9so2225762f8f.2; Tue, 01 Oct 2024 13:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814121; x=1728418921; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=d9affU7BQtNzzNlV+YhjgliO4rgtVPUyI9GrtMaD5Zg=; b=Mig3M1gfCPITy1GVWIS7W6PAlmG8zQmMbNjaA9HLGpYFsn5OcZJs4ghKS7tJRoH+Va +0rV0JpLsMrEicRWQrPfgKRHByBvzP2CdwHGVJQqORcrKsBErIhD9VoTuQ+IpX//ANXc qYZw26cBpnSSkeSzWcKjY+mFqARP/ch2S76jd3e0E8VXvwrTU66lord9wH582ltfVH5v C1+ZA/WmwrScy8iLmRVoBacZ7Pgvr6lAqXLP5SYeqihFwUZxDQAyMJoWaucqrkwtx4Pl WmurkiLR66QTVP3OsUTBGPDaePPxaQTsFzgejyz7G0vWGQfNxme1pmaiw8u0epNiR7F7 H3HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814121; x=1728418921; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d9affU7BQtNzzNlV+YhjgliO4rgtVPUyI9GrtMaD5Zg=; b=m2JMczVjPRfozdWHhFZm94WZM7Lia0jwS9AtmKbNowmFG/XEk942L143o8/kEtCmuN wePVcJ09PMcs6pCW4iManRb9S/6+jZi4AvWNoiNinuVav4JdDB5tew4KY+EdQ2Crjy/n zbAyKn/t8SMPrNrYOcqJ3MPmPWUZFzjH2v5RUD3W2uaoD3LsPEhEoxRTS0gB8Ul5hPc0 uhePPqV7ZvuDrCpk07pcnHUn+zSW1mcVphDJGT2VjvFfEt6avZSZt01UXOMFt4ncqyVO 8hneRATpHLU9qhgZK65aIlCluMX2DuBg0aZ5vGhw+yqsX5F78tT9bZ5a4a2yD9BFJO6A mDmA== X-Forwarded-Encrypted: i=1; AJvYcCWWqmozr+6qSq9g6iCbkirbF4M/bw/JgApUsi3IwJbIU248AuCEYCr0RLQrVEZzziV6k+VJYetLsiaLEerf@vger.kernel.org, AJvYcCX/qOKmUvn/yn7/lZEluSWhoN7f+4cA3pT/YfEaZuM2nMKuJWDXGWIIKLFnS5tXpsBPjvinlMe09yMS@vger.kernel.org X-Gm-Message-State: AOJu0Yy0yJGP6EWzjEpUhPLU0J3CB+dwuZbIgBUlrdJt0dGjK6Xo3XxF Fffk/QbudPai5VxAVh/7T0IPLNDWobu/YA+yyjg50vultbM8XEg+dWmj7pok X-Google-Smtp-Source: AGHT+IE4JfnQv9+88lHTSu63DfabFVZhhunBTwUAeGlaC6TXLuqxgbfuRyxpYZUUNP0Kyw3s5g9fTw== X-Received: by 2002:a5d:6acf:0:b0:378:e8cd:71fa with SMTP id ffacd0b85a97d-37cfba03ed2mr605024f8f.39.1727814120616; Tue, 01 Oct 2024 13:22:00 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:21:59 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:20 +0200 Subject: [PATCH v3 7/9] iio: light: veml6030: power off device in probe error paths Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-7-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=3359; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=+GWkCMN4psn2gtNcb+/LyHIlKEDipE9L1RayFLQLUg8=; b=V1dnjsWCjQV59GpuuHwxXxBTs+cDsj0NVRPEFo8LC5p0hOEX7p9VE04swzcbg/LGXh2jDdik/ bcp9HBYRlN7DHT/HHXeQKiydC1CerSzQcpj66kOm6AXa/OiVmjkz1R0 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Move devm_add_action_or_reset() with a device shut down action to the hardware initialization function to ensure that any error path after powering on the device leads to a power off. Add struct device *dev to the argument list to clarify the device the action is registered against, and use it wherever &client->dev was used. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 677374e401b3..0e4c36e8a566 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -740,45 +740,44 @@ static irqreturn_t veml6030_event_handler(int irq, vo= id *private) * interrupt disabled by default. First shutdown the sensor, * update registers and then power on the sensor. */ -static int veml6030_hw_init(struct iio_dev *indio_dev) +static int veml6030_hw_init(struct iio_dev *indio_dev, struct device *dev) { int ret, val; struct veml6030_data *data =3D iio_priv(indio_dev); - struct i2c_client *client =3D data->client; =20 ret =3D veml6030_als_shut_down(data); if (ret) - return dev_err_probe(&client->dev, ret, "can't shutdown als\n"); + return dev_err_probe(dev, ret, "can't shutdown als\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_CONF, 0x1001); if (ret) - return dev_err_probe(&client->dev, ret, - "can't setup als configs\n"); + return dev_err_probe(dev, ret, "can't setup als configs\n"); =20 ret =3D regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM, VEML6030_PSM | VEML6030_PSM_EN, 0x03); if (ret) - return dev_err_probe(&client->dev, ret, - "can't setup default PSM\n"); + return dev_err_probe(dev, ret, "can't setup default PSM\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF); if (ret) - return dev_err_probe(&client->dev, ret, - "can't setup high threshold\n"); + return dev_err_probe(dev, ret, "can't setup high threshold\n"); =20 ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000); if (ret) - return dev_err_probe(&client->dev, ret, - "can't setup low threshold\n"); + return dev_err_probe(dev, ret, "can't setup low threshold\n"); =20 ret =3D veml6030_als_pwr_on(data); if (ret) - return dev_err_probe(&client->dev, ret, "can't poweron als\n"); + return dev_err_probe(dev, ret, "can't poweron als\n"); + + ret =3D devm_add_action_or_reset(dev, veml6030_als_shut_down_action, data= ); + if (ret < 0) + return ret; =20 /* Clear stale interrupt status bits if any during start */ ret =3D regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); if (ret < 0) - return dev_err_probe(&client->dev, ret, + return dev_err_probe(dev, ret, "can't clear als interrupt status\n"); =20 /* Cache currently active measurement parameters */ @@ -839,12 +838,7 @@ static int veml6030_probe(struct i2c_client *client) indio_dev->info =3D &veml6030_info_no_irq; } =20 - ret =3D veml6030_hw_init(indio_dev); - if (ret < 0) - return ret; - - ret =3D devm_add_action_or_reset(&client->dev, - veml6030_als_shut_down_action, data); + ret =3D veml6030_hw_init(indio_dev, &client->dev); if (ret < 0) return ret; =20 --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14C811CF7A6; Tue, 1 Oct 2024 20:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814126; cv=none; b=JRcD/o9tiW2518K46Mp/hjYYUw0ub/dFCOrWWvN/W1cUr+NpE8VdlBmxvO6ssVHTdsaq5PWJAdB9XtxEdmt1xLtG3/fpJScvMX+an+hezAKdxMIXLx6kSth+TT7t8/yM3zxkOyTUuficsW1AQChn0q4phtmpa5Zq6Z1PL7+wOyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814126; c=relaxed/simple; bh=idyTbEXVNejNq/0RN4IT9GEkYOnmgvJGdw+H+vgQLoM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CFxcX2LNNuL8NsScb8+sECZUOODSgpI1HRTNPynagXJapXcI8ux0SiuK5kyu6lMRN/dJDCQgNvQATvJ2CLs7Su2hlRLMLOVUBR7milXFLzP0t0vrHGsdwi96Du+ABZcH6sdKbPkYEAFebGl1OesZOmA063qw+ESxiqWkcUwuluk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=liQOW+oa; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="liQOW+oa" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42e5e758093so47938845e9.1; Tue, 01 Oct 2024 13:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814123; x=1728418923; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dKYY9xrjJ6XXlAI0aWmqIA4xwpuELm//meQdtRiMDgI=; b=liQOW+oaTRn3iRANe+2YlR+mDXp/sHd+peUgDspTlENFexXw3Mgpffk1eqfKl5Tszg qrEpu/rXL31tnZlU5YAj/DMUZTbqlsQg4eGFFHQukhShtxiOiSX4Tm896FFYBIGLiG6u yVjZ46Gby0a+DlE9g3r7RPS2c3fJ5Ux/6wzsP2X5tIE8z1Qqb9FuDtnkY44gEYQCMik5 KBSPD1bOPCoPIOFODYPkEOUCPQchATq8fWeKLOCR0Tr8jUR7q3h2xkme4wnaeEpFgjxK cXZ1J6F+bOy3FcE6UZsygvWprINots2jYyaeDLapWsxPjI8gD2nIn86gDsyTodYB91YA /ifg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814123; x=1728418923; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dKYY9xrjJ6XXlAI0aWmqIA4xwpuELm//meQdtRiMDgI=; b=WLBLL6AsUo5Q+HwtPwmKqGrzvCt7U/qyaycSxh6ZamRq2UyUYY8tVyFvVILU5ec9xi 10+atXBb4l3Z/2/FuKdO0633mIeryKh7lUrlqh1aW/UKj+AxoyLF2nO8uMrWP0tgnKqV jOC3irNOOYO+4lyhRFPmWZaMlQYKocvg3wII0onbQDHzRtAp3VXdYet06/jTiTabGTWR egxzsJJazNMPR+NUuXFicjwC8mHKlXAhjBsWF3DRr08OODgNXl4U3+ryfPrJbEasu602 zCZJa/SVl49c9m07JkyOkMhiX8VNU4P+qTRDmuq+xG2l/8hEMcLEPxWpNTDGBNIBm1kp vmuw== X-Forwarded-Encrypted: i=1; AJvYcCVhp8hJTFjcNNEzzD65+Bc5zB9PygQK0I0MnMGFPudCDhikEt2PWibi3qpJ87Jy3GiRXCiZ+LgX+kisx/0v@vger.kernel.org, AJvYcCX9QjYMNOZqpL0GDEc9oMT38HwGLI9vifFf4c5yITldQbFQ8bNAgxlb4kxdFup94NALiCF3X2ZszIGa@vger.kernel.org X-Gm-Message-State: AOJu0YzjQxqAyUZsTOaYPusYo0wPu/WqGD1impA8wu4e2wj0NDSiwjZF yLolgDI0TiFQdO37ag19QPHA1VV13HJopeBYzss3madsJthWrq60HJG3J9ih X-Google-Smtp-Source: AGHT+IGcVFZh0eszxBi1Rr2d7L3CUZ6xC3M1GcaKVLdQyW6K/YApqBeUJkcnhiBNX4DOSGJBZ94Qpw== X-Received: by 2002:a5d:468b:0:b0:378:89d8:8242 with SMTP id ffacd0b85a97d-37cfb8cfaabmr378427f8f.26.1727814123022; Tue, 01 Oct 2024 13:22:03 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:22:01 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:21 +0200 Subject: [PATCH v3 8/9] dt-bindings: iio: light: veml6030: add veml6035 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-8-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco , Conor Dooley X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=2791; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=idyTbEXVNejNq/0RN4IT9GEkYOnmgvJGdw+H+vgQLoM=; b=Zb9b3hsddSBX8POqKPfv+xviuQeQJkQBNsgIMbz98ADnayn8j1jGoQIBaNH++P0fnLl1wDy2k psozBzhvn5HCA0QOqDepE6yYvgnxg6J1h9mK+jq0AIKGEjOnzzJqQN3 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6035 is a similar ambient light sensor to the veml6030, and from the bindings point of view, it shares the same properties. Its only difference in that respect is a different I2C address. Estend the existing bindings to support the veml6035 ALS. Acked-by: Conor Dooley Signed-off-by: Javier Carrasco --- .../bindings/iio/light/vishay,veml6030.yaml | 40 +++++++++++++++++-= ---- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.ya= ml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index 42a78cd4f812..6218273b0e86 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -4,14 +4,14 @@ $id: http://devicetree.org/schemas/iio/light/vishay,veml6030.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: VEML6030 Ambient Light Sensor (ALS) +title: VEML6030 and VEML6035 Ambient Light Sensors (ALS) =20 maintainers: - Rishi Gupta =20 description: | - Bindings for the ambient light sensor veml6030 from Vishay - Semiconductors over an i2c interface. + Bindings for the ambient light sensors veml6030 and veml6035 from + Vishay Semiconductors over an i2c interface. =20 Irrespective of whether interrupt is used or not, application can get the ALS and White channel reading from IIO raw interface. @@ -19,20 +19,18 @@ description: | If the interrupts are used, application will receive an IIO event whenever configured threshold is crossed. =20 - Specifications about the sensor can be found at: + Specifications about the sensors can be found at: https://www.vishay.com/docs/84366/veml6030.pdf + https://www.vishay.com/docs/84889/veml6035.pdf =20 properties: compatible: enum: - vishay,veml6030 + - vishay,veml6035 =20 reg: - description: - I2C address of the device. - enum: - - 0x10 # ADDR pin pulled down - - 0x48 # ADDR pin pulled up + maxItems: 1 =20 interrupts: description: @@ -48,6 +46,30 @@ required: - reg - vdd-supply =20 +allOf: + - if: + properties: + compatible: + enum: + - vishay,veml6030 + then: + properties: + reg: + enum: + - 0x10 # ADDR pin pulled down + - 0x48 # ADDR pin pulled up + + - if: + properties: + compatible: + enum: + - vishay,veml6035 + then: + properties: + reg: + enum: + - 0x29 + additionalProperties: false =20 examples: --=20 2.43.0 From nobody Thu Nov 28 10:36:32 2024 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E8161CF7C6; Tue, 1 Oct 2024 20:22:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814131; cv=none; b=lOxaymwNPuukGaE7l6m5PyIQ60Ngy6wDv52tk+U0Z+OqAvD7up/MbkrszgPN2cOXP4KuBVUfKpMO9S8fYt6Xz2YIwsglC6HgPUJtwgfah4IKIge89hTdFFRgtQBekSwtTg3K3hEGZ8OUalSU032RMMdfAPVM3M8pDE5lIHnx1GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727814131; c=relaxed/simple; bh=/pwrzZflSvG9k5ba+Bzsv9QpL6npAQhZwanNFnxWnqg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YWEqdvdSIqqxd0kw51BR3HlU8D9z8pQtYvgKq7rf5Z3bFNFRunxY4DElG/IOOKOgLkBmd0d2Jza8h3C7Kn1GVY7CjFcVsYg2VdkQr+wLnqPpWHydbfZxTIpRxcS/ODtX/cIjby/U2xgHSRVd3P9D5JPDAj9WkdpNzQtCBmF3szw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IF8EGUef; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IF8EGUef" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42cde6b5094so52595345e9.3; Tue, 01 Oct 2024 13:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727814125; x=1728418925; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=k+abLVP0EMhDabZt2X4T0m3nFOg9Swuuy4a8ah850zU=; b=IF8EGUefritWMObRwIfNzxzjYMjlizRBk910iLmWkKaDLU1ruxCemhSyp6Bz3dHMpf zIf2jWagl/a4+o6Bh7nL+7LLVUehgkeRIbwcSn77Qas/+xJXJOMVFn17AIuyXfkv6+L9 hkHvqE0H1W8eZ+c+HnSPkXkRheqxnRcEdW7y+CP1NqPhsufwfjRocI4ECH7UKnBt1ajd q99cXNby6WU4O0W+HSx+4EMM4ZQDuh++c1kKWQKf9DSiOdhPZX9x211NQGd5exGncKEa Vr96VA3J5R1aVBeAUYsdGq+WRcEe3zthNZShk3LGy9xAVJ3/tP9q9+zg/yHZbCePNEux 2alw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727814125; x=1728418925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k+abLVP0EMhDabZt2X4T0m3nFOg9Swuuy4a8ah850zU=; b=A/aQ1sd+jxA7zYFdG1bV/s5fzq/FKehgzaw8JX3lmFqKcTVMqYYa8YYyeCrOJ9YAgp PTfbREDOmO6B/zvbR0X4cvJOSy0+ecYvvp1XgqQ5+YKaSmcrBfnVNtuStwNkPQIz8zmg CfSa7Ccxx0xAbiw85sxKAysg0Pd59+5D/PVotsctz24t/8lgWpqI0SseomTsCz7PxGuQ +AlIl5w69X7jwz7EsrREVUTI3Za5o73tuUzG/Z4zgX5XB7prLAvOPcESUzoyNQKmxnhB OgtgebPsVAS6v7BRr2N8WrY8UinjszJsTz70lYcyMCwMal+1Q6OJE2xaTBe6LUXxw+lt Uhdw== X-Forwarded-Encrypted: i=1; AJvYcCUKyJcgiNEsFfVeJj3gIxaIc5SH7tBH811b4JtZV0zXJ/z30jpvNhvvqJPjuzZzS7OuISrvRSiVUt6x@vger.kernel.org, AJvYcCV9nCNbNbxOIkP24V8Q1fpjiDuDHVtqSx/3dyJRzewTikDf7UXCFdJpH2V6sRMICCHyHtypCV4gnPbFkPoB@vger.kernel.org X-Gm-Message-State: AOJu0Yxd0ADArjwBbHMT7nQkYOMjhPe+m0sbiZGKqJZo/nXpj5EACyLR pCT9LbmsBSpqlqR1CDNKB9PMZ5T/3mBiaRLP68e8lh1a7FjCFB9ltODPBNJV X-Google-Smtp-Source: AGHT+IHDAMkxcIw0lUd2GyKKv8cr5e8++DND6GHUeK9fCpWgJHbSKG3TLAsAdc9HcSJxuIh0ybySCg== X-Received: by 2002:a05:600c:3c9f:b0:42c:aeaa:6aff with SMTP id 5b1f17b1804b1-42f777c0705mr5229005e9.10.1727814125118; Tue, 01 Oct 2024 13:22:05 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-41f4-a392-01d5-d74d.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:41f4:a392:1d5:d74d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a55336sm188680935e9.47.2024.10.01.13.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 13:22:04 -0700 (PDT) From: Javier Carrasco Date: Tue, 01 Oct 2024 22:21:22 +0200 Subject: [PATCH v3 9/9] iio: light: veml6030: add support for veml6035 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241001-veml6035-v3-9-d789f6ff147c@gmail.com> References: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> In-Reply-To: <20241001-veml6035-v3-0-d789f6ff147c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727814089; l=15172; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=/pwrzZflSvG9k5ba+Bzsv9QpL6npAQhZwanNFnxWnqg=; b=Mn8v52sYUhDva6h44BV77ZgFtcZOxdzDhvC0B2/1vVDn1FvSqvy2nDiWmmnNmTMr0drvLmj0w 5pn1QOeCE2cCakOUtnekpA9t/wYRX8OauDKT17cixQgTzEGQhVErcZD X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6035 is an ALS that shares most of its functionality with the veml6030, which allows for some code recycling. Some chip-specific properties differ and dedicated functions to get and set the sensor gain as well as its initialization are required. Signed-off-by: Javier Carrasco --- drivers/iio/light/Kconfig | 4 +- drivers/iio/light/veml6030.c | 290 +++++++++++++++++++++++++++++++++++++++= ---- 2 files changed, 265 insertions(+), 29 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 515ff46b5b82..171ccaecf5b6 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -669,12 +669,12 @@ config VCNL4035 module will be called vcnl4035. =20 config VEML6030 - tristate "VEML6030 ambient light sensor" + tristate "VEML6030 and VEML6035 ambient light sensors" select REGMAP_I2C depends on I2C help Say Y here if you want to build a driver for the Vishay VEML6030 - ambient light sensor (ALS). + and VEML6035 ambient light sensors (ALS). =20 To compile this driver as a module, choose M here: the module will be called veml6030. diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 0e4c36e8a566..a5deae333554 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -1,13 +1,19 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * VEML6030 Ambient Light Sensor + * VEML6030 and VMEL6035 Ambient Light Sensors * * Copyright (c) 2019, Rishi Gupta * + * VEML6030: * Datasheet: https://www.vishay.com/docs/84366/veml6030.pdf * Appnote-84367: https://www.vishay.com/docs/84367/designingveml6030.pdf + * + * VEML6035: + * Datasheet: https://www.vishay.com/docs/84889/veml6035.pdf + * Appnote-84944: https://www.vishay.com/docs/84944/designingveml6035.pdf */ =20 +#include #include #include #include @@ -39,16 +45,34 @@ #define VEML6030_ALS_INT_EN BIT(1) #define VEML6030_ALS_SD BIT(0) =20 +#define VEML6035_GAIN_M GENMASK(12, 10) +#define VEML6035_GAIN BIT(10) +#define VEML6035_DG BIT(11) +#define VEML6035_SENS BIT(12) +#define VEML6035_INT_CHAN BIT(3) +#define VEML6035_CHAN_EN BIT(2) + +struct veml603x_chip { + const char *name; + const int(*scale_vals)[][2]; + const int num_scale_vals; + const struct iio_info *info; + const struct iio_info *info_no_irq; + int (*hw_init)(struct iio_dev *indio_dev, struct device *dev); + int (*set_als_gain)(struct iio_dev *indio_dev, int val, int val2); + int (*get_als_gain)(struct iio_dev *indio_dev, int *val, int *val2); +}; + /* * The resolution depends on both gain and integration time. The * cur_resolution stores one of the resolution mentioned in the * table during startup and gets updated whenever integration time * or gain is changed. * - * Table 'resolution and maximum detection range' in appnote 84367 + * Table 'resolution and maximum detection range' in the appnotes * is visualized as a 2D array. The cur_gain stores index of gain - * in this table (0-3) while the cur_integration_time holds index - * of integration time (0-5). + * in this table (0-3 for VEML6030, 0-5 for VEML6035) while the + * cur_integration_time holds index of integration time (0-5). */ struct veml6030_data { struct i2c_client *client; @@ -56,6 +80,7 @@ struct veml6030_data { int cur_resolution; int cur_gain; int cur_integration_time; + const struct veml603x_chip *chip; }; =20 static const int veml6030_it_times[][2] =3D { @@ -69,7 +94,8 @@ static const int veml6030_it_times[][2] =3D { =20 /* * Scale is 1/gain. Value 0.125 is ALS gain x (1/8), 0.25 is - * ALS gain x (1/4), 1.0 =3D ALS gain x 1 and 2.0 is ALS gain x 2. + * ALS gain x (1/4), 0.5 is ALS gain x (1/2), 1.0 is ALS gain x 1, + * 2.0 is ALS gain x2, and 4.0 is ALS gain x 4. */ static const int veml6030_scale_vals[][2] =3D { { 0, 125000 }, @@ -78,6 +104,15 @@ static const int veml6030_scale_vals[][2] =3D { { 2, 0 }, }; =20 +static const int veml6035_scale_vals[][2] =3D { + { 0, 125000 }, + { 0, 250000 }, + { 0, 500000 }, + { 1, 0 }, + { 2, 0 }, + { 4, 0 }, +}; + /* * Persistence =3D 1/2/4/8 x integration time * Minimum time for which light readings must stay above configured @@ -386,6 +421,21 @@ static int veml6030_write_persistence(struct iio_dev *= indio_dev, return ret; } =20 +/* + * Cache currently set gain & update resolution. For every + * increase in the gain to next level, resolution is halved + * and vice-versa. + */ +static void veml6030_update_gain_res(struct veml6030_data *data, int gain_= idx) +{ + if (data->cur_gain < gain_idx) + data->cur_resolution <<=3D gain_idx - data->cur_gain; + else if (data->cur_gain > gain_idx) + data->cur_resolution >>=3D data->cur_gain - gain_idx; + + data->cur_gain =3D gain_idx; +} + static int veml6030_set_als_gain(struct iio_dev *indio_dev, int val, int val2) { @@ -416,19 +466,49 @@ static int veml6030_set_als_gain(struct iio_dev *indi= o_dev, return ret; } =20 - /* - * Cache currently set gain & update resolution. For every - * increase in the gain to next level, resolution is halved - * and vice-versa. - */ - if (data->cur_gain < gain_idx) - data->cur_resolution <<=3D gain_idx - data->cur_gain; - else if (data->cur_gain > gain_idx) - data->cur_resolution >>=3D data->cur_gain - gain_idx; + veml6030_update_gain_res(data, gain_idx); =20 - data->cur_gain =3D gain_idx; + return 0; +} =20 - return ret; +static int veml6035_set_als_gain(struct iio_dev *indio_dev, int val, int v= al2) +{ + int ret, new_gain, gain_idx; + struct veml6030_data *data =3D iio_priv(indio_dev); + + if (val =3D=3D 0 && val2 =3D=3D 125000) { + new_gain =3D VEML6035_SENS; + gain_idx =3D 5; + } else if (val =3D=3D 0 && val2 =3D=3D 250000) { + new_gain =3D VEML6035_SENS | VEML6035_GAIN; + gain_idx =3D 4; + } else if (val =3D=3D 0 && val2 =3D=3D 500000) { + new_gain =3D VEML6035_SENS | VEML6035_GAIN | + VEML6035_DG; + gain_idx =3D 3; + } else if (val =3D=3D 1 && val2 =3D=3D 0) { + new_gain =3D 0x0000; + gain_idx =3D 2; + } else if (val =3D=3D 2 && val2 =3D=3D 0) { + new_gain =3D VEML6035_GAIN; + gain_idx =3D 1; + } else if (val =3D=3D 4 && val2 =3D=3D 0) { + new_gain =3D VEML6035_GAIN | VEML6035_DG; + gain_idx =3D 0; + } else { + return -EINVAL; + } + + ret =3D regmap_update_bits(data->regmap, VEML6030_REG_ALS_CONF, + VEML6035_GAIN_M, new_gain); + if (ret) { + dev_err(&data->client->dev, "can't set als gain %d\n", ret); + return ret; + } + + veml6030_update_gain_res(data, gain_idx); + + return 0; } =20 static int veml6030_get_als_gain(struct iio_dev *indio_dev, @@ -468,6 +548,52 @@ static int veml6030_get_als_gain(struct iio_dev *indio= _dev, return IIO_VAL_INT_PLUS_MICRO; } =20 +static int veml6035_get_als_gain(struct iio_dev *indio_dev, int *val, int = *val2) +{ + int ret, reg; + struct veml6030_data *data =3D iio_priv(indio_dev); + + ret =3D regmap_read(data->regmap, VEML6030_REG_ALS_CONF, ®); + if (ret) { + dev_err(&data->client->dev, + "can't read als conf register %d\n", ret); + return ret; + } + + switch (FIELD_GET(VEML6035_GAIN_M, reg)) { + case 0: + *val =3D 1; + *val2 =3D 0; + break; + case 1: + case 2: + *val =3D 2; + *val2 =3D 0; + break; + case 3: + *val =3D 4; + *val2 =3D 0; + break; + case 4: + *val =3D 0; + *val2 =3D 125000; + break; + case 5: + case 6: + *val =3D 0; + *val2 =3D 250000; + break; + case 7: + *val =3D 0; + *val2 =3D 500000; + break; + default: + return -EINVAL; + } + + return IIO_VAL_INT_PLUS_MICRO; +} + static int veml6030_read_thresh(struct iio_dev *indio_dev, int *val, int *val2, int dir) { @@ -556,7 +682,7 @@ static int veml6030_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_INT_TIME: return veml6030_get_intgrn_tm(indio_dev, val, val2); case IIO_CHAN_INFO_SCALE: - return veml6030_get_als_gain(indio_dev, val, val2); + return data->chip->get_als_gain(indio_dev, val, val2); default: return -EINVAL; } @@ -567,6 +693,8 @@ static int veml6030_read_avail(struct iio_dev *indio_de= v, const int **vals, int *type, int *length, long mask) { + struct veml6030_data *data =3D iio_priv(indio_dev); + switch (mask) { case IIO_CHAN_INFO_INT_TIME: *vals =3D (int *)&veml6030_it_times; @@ -574,8 +702,8 @@ static int veml6030_read_avail(struct iio_dev *indio_de= v, *type =3D IIO_VAL_INT_PLUS_MICRO; return IIO_AVAIL_LIST; case IIO_CHAN_INFO_SCALE: - *vals =3D (int *)&veml6030_scale_vals; - *length =3D 2 * ARRAY_SIZE(veml6030_scale_vals); + *vals =3D (int *)*data->chip->scale_vals; + *length =3D 2 * data->chip->num_scale_vals; *type =3D IIO_VAL_INT_PLUS_MICRO; return IIO_AVAIL_LIST; } @@ -587,11 +715,13 @@ static int veml6030_write_raw(struct iio_dev *indio_d= ev, struct iio_chan_spec const *chan, int val, int val2, long mask) { + struct veml6030_data *data =3D iio_priv(indio_dev); + switch (mask) { case IIO_CHAN_INFO_INT_TIME: return veml6030_set_intgrn_tm(indio_dev, val, val2); case IIO_CHAN_INFO_SCALE: - return veml6030_set_als_gain(indio_dev, val, val2); + return data->chip->set_als_gain(indio_dev, val, val2); default: return -EINVAL; } @@ -699,12 +829,28 @@ static const struct iio_info veml6030_info =3D { .event_attrs =3D &veml6030_event_attr_group, }; =20 +static const struct iio_info veml6035_info =3D { + .read_raw =3D veml6030_read_raw, + .read_avail =3D veml6030_read_avail, + .write_raw =3D veml6030_write_raw, + .read_event_value =3D veml6030_read_event_val, + .write_event_value =3D veml6030_write_event_val, + .read_event_config =3D veml6030_read_interrupt_config, + .write_event_config =3D veml6030_write_interrupt_config, + .event_attrs =3D &veml6030_event_attr_group, +}; + static const struct iio_info veml6030_info_no_irq =3D { .read_raw =3D veml6030_read_raw, .read_avail =3D veml6030_read_avail, .write_raw =3D veml6030_write_raw, }; =20 +static const struct iio_info veml6035_info_no_irq =3D { + .read_raw =3D veml6030_read_raw, + .write_raw =3D veml6030_write_raw, +}; + static irqreturn_t veml6030_event_handler(int irq, void *private) { int ret, reg, evtdir; @@ -788,6 +934,62 @@ static int veml6030_hw_init(struct iio_dev *indio_dev,= struct device *dev) return ret; } =20 +/* + * Set ALS gain to 1/8, integration time to 100 ms, ALS and WHITE + * channel enabled, ALS channel interrupt, PSM enabled, + * PSM_WAIT =3D 0.8 s, persistence to 1 x integration time and the + * threshold interrupt disabled by default. First shutdown the sensor, + * update registers and then power on the sensor. + */ +static int veml6035_hw_init(struct iio_dev *indio_dev, struct device *dev) +{ + int ret, val; + struct veml6030_data *data =3D iio_priv(indio_dev); + + ret =3D veml6030_als_shut_down(data); + if (ret) + return dev_err_probe(dev, ret, "can't shutdown als\n"); + + ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_CONF, + VEML6035_SENS | VEML6035_CHAN_EN | VEML6030_ALS_SD); + if (ret) + return dev_err_probe(dev, ret, "can't setup als configs\n"); + + ret =3D regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM, + VEML6030_PSM | VEML6030_PSM_EN, 0x03); + if (ret) + return dev_err_probe(dev, ret, "can't setup default PSM\n"); + + ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF); + if (ret) + return dev_err_probe(dev, ret, "can't setup high threshold\n"); + + ret =3D regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000); + if (ret) + return dev_err_probe(dev, ret, "can't setup low threshold\n"); + + ret =3D veml6030_als_pwr_on(data); + if (ret) + return dev_err_probe(dev, ret, "can't poweron als\n"); + + ret =3D devm_add_action_or_reset(dev, veml6030_als_shut_down_action, data= ); + if (ret < 0) + return ret; + + /* Clear stale interrupt status bits if any during start */ + ret =3D regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); + if (ret < 0) + return dev_err_probe(dev, ret, + "can't clear als interrupt status\n"); + + /* Cache currently active measurement parameters */ + data->cur_gain =3D 5; + data->cur_resolution =3D 1024; + data->cur_integration_time =3D 3; + + return 0; +} + static int veml6030_probe(struct i2c_client *client) { int ret; @@ -818,7 +1020,11 @@ static int veml6030_probe(struct i2c_client *client) return dev_err_probe(&client->dev, ret, "failed to enable regulator\n"); =20 - indio_dev->name =3D "veml6030"; + data->chip =3D i2c_get_match_data(client); + if (!data->chip) + return -EINVAL; + + indio_dev->name =3D data->chip->name; indio_dev->channels =3D veml6030_channels; indio_dev->num_channels =3D ARRAY_SIZE(veml6030_channels); indio_dev->modes =3D INDIO_DIRECT_MODE; @@ -827,18 +1033,18 @@ static int veml6030_probe(struct i2c_client *client) ret =3D devm_request_threaded_irq(&client->dev, client->irq, NULL, veml6030_event_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "veml6030", indio_dev); + indio_dev->name, indio_dev); if (ret < 0) return dev_err_probe(&client->dev, ret, "irq %d request failed\n", client->irq); =20 - indio_dev->info =3D &veml6030_info; + indio_dev->info =3D data->chip->info; } else { - indio_dev->info =3D &veml6030_info_no_irq; + indio_dev->info =3D data->chip->info_no_irq; } =20 - ret =3D veml6030_hw_init(indio_dev, &client->dev); + ret =3D data->chip->hw_init(indio_dev, &client->dev); if (ret < 0) return ret; =20 @@ -874,14 +1080,44 @@ static int veml6030_runtime_resume(struct device *de= v) static DEFINE_RUNTIME_DEV_PM_OPS(veml6030_pm_ops, veml6030_runtime_suspend, veml6030_runtime_resume, NULL); =20 +static const struct veml603x_chip veml6030_chip =3D { + .name =3D "veml6030", + .scale_vals =3D &veml6030_scale_vals, + .num_scale_vals =3D ARRAY_SIZE(veml6030_scale_vals), + .info =3D &veml6030_info, + .info_no_irq =3D &veml6030_info_no_irq, + .hw_init =3D veml6030_hw_init, + .set_als_gain =3D veml6030_set_als_gain, + .get_als_gain =3D veml6030_get_als_gain, +}; + +static const struct veml603x_chip veml6035_chip =3D { + .name =3D "veml6035", + .scale_vals =3D &veml6035_scale_vals, + .num_scale_vals =3D ARRAY_SIZE(veml6035_scale_vals), + .info =3D &veml6035_info, + .info_no_irq =3D &veml6035_info_no_irq, + .hw_init =3D veml6035_hw_init, + .set_als_gain =3D veml6035_set_als_gain, + .get_als_gain =3D veml6035_get_als_gain, +}; + static const struct of_device_id veml6030_of_match[] =3D { - { .compatible =3D "vishay,veml6030" }, + { + .compatible =3D "vishay,veml6030", + .data =3D &veml6030_chip, + }, + { + .compatible =3D "vishay,veml6035", + .data =3D &veml6035_chip, + }, { } }; MODULE_DEVICE_TABLE(of, veml6030_of_match); =20 static const struct i2c_device_id veml6030_id[] =3D { - { "veml6030" }, + { "veml6030", (kernel_ulong_t)&veml6030_chip}, + { "veml6035", (kernel_ulong_t)&veml6035_chip}, { } }; MODULE_DEVICE_TABLE(i2c, veml6030_id); --=20 2.43.0