From nobody Mon Nov 23 10:29:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794731879; b=OeMUNTrOCwQtzT81rD9zM94fQVAnD6VxN37SkxZcv6dPVFZWu3zGYSKo/0bfUjHK5+Uw f7YU3IsTMIdGWs2fq77dNkdbux+wcVhr6PZP/70P4eqz7zPK47V1UGuJyGlaSnyWnUfR/ 3jWuKCYiHH8J3S5A0pR1ArRYFWGN6idUULJXAvJUa5Q3PUpjY9gON9M643LrlUdsSUJZd ht4Ga2jr0sFxWaqwOV777rCj6mimM6tLCtt16TdYagNjJ1XDQw6CzLfgy+3ysYrgr5UCJ Dg336Wd8JpXpwOsu8vRsDtczzhUHQvdBKZzdSAvSgUKif8Cs3nv6LQ204rxjJQiI2Hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794731879; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=jtbqpR4PVOYpBoo8BS7ac5grEKA6PA4yUOvkcxAWBqE=; b=iJc1KVtRiblolxY7dBmYn5slJsmPu929rGmjlG110WzYIVVhppDqzPoo28rHqf6B0m99 JFCsgtKpBDp/HuvBFCqKdnh0kRm55CHXD4Se4GDuhJdoXDGfcnK6sNPMztKecBohzlFld +UmPFrViffYHrxMNphRvRdpgs7sQs5K7G7bZACtSgbZaRrKCStSUY0uTsUFImklZys+WC 0+eVPvxm9ss59HAqd0naqJf2r1uYLEeLVs8nuDROQCyT/Qy6Rkf9rsT+5Nv45douTfcvz hps8ydKe27D5IUwFcgzgZdvOUXEGwkj9RwghfmD6l0cW89OWsZ2pZMWfQbGsPKcnzuQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xSWolltU; arc=none smtp.remote-ip=209.85.218.41 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC8A4606A33E for ; Sun, 15 Nov 2026 08:37:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC8A4606A33E 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.a=rsa-sha256 header.s=20260707 header.b=xSWolltU Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-c4322d310e7so491324266b.0 for ; Sun, 15 Nov 2026 00:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794731877; x=1795336677; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jtbqpR4PVOYpBoo8BS7ac5grEKA6PA4yUOvkcxAWBqE=; b=xSWolltUx0cu9rG0v3Gwyfon4ESyDGwACQeay5cjvh3GLW5ysHvcrsvGNJmpi1pFhI CtveyAbd/zl5WNXbKMS4atuvD1OWiwkCLcaKX7v2hDVoypIf7VinfoXLqSJ/vxKcoRqs TPResK1jWndOW+X8QsW8CthUkAPmxTQ86xu6s6Euy+0dnqLYPXHZTqgWKnPgq9ZiJMJ5 IIw1Jgbm9RsPmViiz8YJTsXHIM4ApWGVBfhOh04HZLqDZL30hwo4tw0TjZUVzoI04Bjc Kh9fPNTgtdEMCZhOEA5ISYz0GCr/UIjtPAxly/xAM8QgxWHowoeEPk5cO8Bs5TkPTg+5 vj0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794731877; x=1795336677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=jtbqpR4PVOYpBoo8BS7ac5grEKA6PA4yUOvkcxAWBqE=; b=bhhYte3IV7SS389hXxiSWNoOzuW3V4pABzRv7wmkg921xHlu8DmhKlVqYMk9xWCVux n3HE0OtuoPdXIL6ZU0MGPBFoAkJp/4r9CKAdXShj9+2kkb4MOXWC+ud45LdoYI23zBX6 cJhhK7d29Z670z3LyJnDeLc2Bvf3pIKM3FW5XEpCHajKMuWQA1FDAyl1fDaNTQIhg7rW fa1cZ0KFM7uRTBqwoej34UW9v1FQum7Mnbjdl6jKzTDmEYgQCI1iTfB9nM6jImAO2Tw8 2Yh5zsrpamvTM8WjHNLH4VxU0/OqOiOjjssEhX5KEBDsHTkxZJ9JS3MzzdbUJUuPmdS7 pPog== X-Forwarded-Encrypted: i=1; AL+hErEuMPkNkU1lucgGxtgy8KuZLg9lBDq4tz+rHfg8+6StGj0a2VNTsSDcnSRdziFPgELIrODIYAcUen0TIic=@vger.kernel.org X-Gm-Message-State: APuU4Z/q/09FfvUkWrZArmg73+UT6wkO+UYDEK7/3SFsoyLxu8iUe0sE xJU+ZQBLvaZ3KJ1Pq/g3aYdgNB4FEuHSO+W6JBqzIBR1z5WoEblFSPR3 X-Gm-Gg: AYBFou0+0/oeptqEYgWFM+R+LwucMzLr4DuFjYZBxSK7Kwbh5SdzhZk/hxt2UMvoFfL 2MvozwazudlNaSy6FfLQebEFz3LkEqrfLbEQKynxrIvam9/J/MY2kWPOMtn8yvvfG/YWgtwIsV6 zXC0h+IV1zRjnQxOCxoNpKTJU6C3zeaUpkj2OhZTUP29ewSqTKyy0l+LLa1MuSpiWofcjpZCW5V g1r62VglUNNG03QYWwOBYvzC90tD+cfm7lOytsIJ+G6e3ov6j+btgxpnF+9ptf2u0wwmZxiomn8 Oy8yVNlCCCUx+QiyMOiuoJQG00Ta+kJ2JxsWpzb4ZP0eor9VBrP4CsZrEUj5Z2dgJw2dzJff8ys TCef2sMvVi+/JINHqmub8DxoaKevACGbu7FIUiqwe8RWh13wmzvEsOzM5gUMsVjZT7+bcwRxsww gyv6ACvGVA/oP6dvYA0BKEUmlj/exJ5Bqy3FxtcEbXraGvfPgdAixgxsnOibD6I8k/7lHxp1tl3 6vextKX5mf0XfhIDWQ3F+M8FDpDsSy8pxi0dTmkZh6dJ9/gqq8tW7r5kbj0EocchrAx1oPgel2y IhZ0e+mFoXpOgDTHz82CWhFgAJeARzPcSqFkMyIm+pqIzmZix0BT+OwT7u/4DTbHRAqWRhhPhJp vBvEtv8Nlx/yir30UdXcxMs9gKOzap8E= X-Received: by 2002:a17:907:8687:b0:c4c:eb16:b567 with SMTP id a640c23a62f3a-c50963114ccmr577809566b.19.1794731877111; Sun, 15 Nov 2026 00:37:57 -0800 (PST) Received: from xeon ([188.163.112.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c5095a5ad9esm284815666b.2.2026.11.15.00.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 00:37:55 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Esben Haabendal , Kuppuswamy Sathyanarayanan , Svyatoslav Ryhel , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= , Pan Chuang , Hemanth Selam , Antoniu Miclaus , Nikita Travkin Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration Date: Sun, 15 Nov 2026 10:37:38 +0200 Message-ID: <20261115083741.62140-2-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261115083741.62140-1-clamor95@gmail.com> References: <20261115083741.62140-1-clamor95@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch to the read_avail() operation from manual attribute group registration. This eliminates the need for per-chip attribute_group structures and related ltr501_chip_info iio_info entries. Adjust LTR501_INTENSITY_CHANNEL to account for the new info_mask_*_available layout, allowing the removal of _shared since all intensity channels share the same layout of available entries. Signed-off-by: Svyatoslav Ryhel --- drivers/iio/light/ltr501.c | 193 +++++++++++++++---------------------- 1 file changed, 77 insertions(+), 116 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 24733607d1b49..3662aed5225bc 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -133,6 +133,22 @@ static const struct ltr501_gain ltr559_ps_gain_tbl[] = =3D { {0, 15624}, }; =20 +static const int int_time_avail[][2] =3D { + { 0, 50000 }, + { 0, 100000 }, + { 0, 200000 }, + { 0, 400000 }, +}; + +static const int samp_freq_avail[][2] =3D { + { 20, 0 }, + { 10, 0 }, + { 5, 0 }, + { 2, 0 }, + { 1, 0 }, + { 0, 500000 }, +}; + struct ltr501_chip_info { u8 partid; const struct ltr501_gain *als_gain; @@ -145,8 +161,6 @@ struct ltr501_chip_info { bool no_irq_support; struct iio_chan_spec const *channels; const int no_channels; - const struct iio_info *info; - const struct iio_info *info_no_irq; }; =20 struct ltr501_data { @@ -164,6 +178,8 @@ struct ltr501_data { struct regmap_field *reg_als_prst; struct regmap_field *reg_ps_prst; uint32_t near_level; + struct ltr501_gain als_gain_tbl[ARRAY_SIZE(ltr559_als_gain_tbl)]; + u32 als_gain_tbl_len; }; =20 static const struct ltr501_samp_table ltr501_als_samp_table[] =3D { @@ -582,14 +598,18 @@ static const struct iio_event_spec ltr501_pxs_event_s= pec[] =3D { }, }; =20 -#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared, \ - _evspec, _evsize) { \ +#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _evspec, _evsize) { \ .type =3D IIO_INTENSITY, \ .modified =3D 1, \ .address =3D (_addr), \ .channel2 =3D (_mod), \ .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type =3D (_shared), \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_INT_TIME) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_shared_by_type_available =3D BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ .scan_index =3D (_idx), \ .scan_type =3D { \ .sign =3D 'u', \ @@ -609,19 +629,18 @@ static const struct iio_event_spec ltr501_pxs_event_s= pec[] =3D { =20 static const struct iio_chan_spec ltr501_channels[] =3D { LTR501_LIGHT_CHANNEL(), - LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, + LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, ltr501_als_event_spec, ARRAY_SIZE(ltr501_als_event_spec)), - LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, - BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME) | - BIT(IIO_CHAN_INFO_SAMP_FREQ), - NULL, 0), + LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, NULL, 0), { .type =3D IIO_PROXIMITY, .address =3D LTR501_PS_DATA, .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_separate_available =3D BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), .scan_index =3D 2, .scan_type =3D { .sign =3D 'u', @@ -638,14 +657,10 @@ static const struct iio_chan_spec ltr501_channels[] = =3D { =20 static const struct iio_chan_spec ltr301_channels[] =3D { LTR501_LIGHT_CHANNEL(), - LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0, + LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, ltr501_als_event_spec, ARRAY_SIZE(ltr501_als_event_spec)), - LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, - BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME) | - BIT(IIO_CHAN_INFO_SAMP_FREQ), - NULL, 0), + LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR, NULL, 0), IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 @@ -1111,111 +1126,56 @@ static int ltr501_write_event_config(struct iio_de= v *indio_dev, return -EINVAL; } =20 -static ssize_t ltr501_show_proximity_scale_avail(struct device *dev, - struct device_attribute *attr, - char *buf) +static int ltr501_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, long mask) { - struct ltr501_data *data =3D iio_priv(dev_to_iio_dev(dev)); + struct ltr501_data *data =3D iio_priv(indio_dev); const struct ltr501_chip_info *info =3D data->chip_info; - ssize_t len =3D 0; - int i; =20 - for (i =3D 0; i < info->ps_gain_tbl_size; i++) { - if (info->ps_gain[i].scale =3D=3D LTR501_RESERVED_GAIN) - continue; - len +=3D scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ", - info->ps_gain[i].scale, - info->ps_gain[i].uscale); - } - - buf[len - 1] =3D '\n'; + switch (mask) { + case IIO_CHAN_INFO_SCALE: + if (chan->type =3D=3D IIO_INTENSITY) { + *length =3D data->als_gain_tbl_len; + *vals =3D (const int *)data->als_gain_tbl; + } else { + *length =3D info->ps_gain_tbl_size * 2; + *vals =3D (const int *)info->ps_gain; + } + *type =3D IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; =20 - return len; -} + case IIO_CHAN_INFO_INT_TIME: + *vals =3D (const int *)int_time_avail; + *type =3D IIO_VAL_INT_PLUS_MICRO; + *length =3D ARRAY_SIZE(int_time_avail) * 2; + return IIO_AVAIL_LIST; =20 -static ssize_t ltr501_show_intensity_scale_avail(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct ltr501_data *data =3D iio_priv(dev_to_iio_dev(dev)); - const struct ltr501_chip_info *info =3D data->chip_info; - ssize_t len =3D 0; - int i; + case IIO_CHAN_INFO_SAMP_FREQ: + *vals =3D (const int *)samp_freq_avail; + *type =3D IIO_VAL_INT_PLUS_MICRO; + *length =3D ARRAY_SIZE(samp_freq_avail) * 2; + return IIO_AVAIL_LIST; =20 - for (i =3D 0; i < info->als_gain_tbl_size; i++) { - if (info->als_gain[i].scale =3D=3D LTR501_RESERVED_GAIN) - continue; - len +=3D scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ", - info->als_gain[i].scale, - info->als_gain[i].uscale); + default: + return -EINVAL; } - - buf[len - 1] =3D '\n'; - - return len; } =20 -static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4"); -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("20 10 5 2 1 0.5"); - -static IIO_DEVICE_ATTR(in_proximity_scale_available, S_IRUGO, - ltr501_show_proximity_scale_avail, NULL, 0); -static IIO_DEVICE_ATTR(in_intensity_scale_available, S_IRUGO, - ltr501_show_intensity_scale_avail, NULL, 0); - -static struct attribute *ltr501_attributes[] =3D { - &iio_dev_attr_in_proximity_scale_available.dev_attr.attr, - &iio_dev_attr_in_intensity_scale_available.dev_attr.attr, - &iio_const_attr_integration_time_available.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL -}; - -static struct attribute *ltr301_attributes[] =3D { - &iio_dev_attr_in_intensity_scale_available.dev_attr.attr, - &iio_const_attr_integration_time_available.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group ltr501_attribute_group =3D { - .attrs =3D ltr501_attributes, -}; - -static const struct attribute_group ltr301_attribute_group =3D { - .attrs =3D ltr301_attributes, -}; - static const struct iio_info ltr501_info_no_irq =3D { .read_raw =3D ltr501_read_raw, .write_raw =3D ltr501_write_raw, - .attrs =3D <r501_attribute_group, + .read_avail =3D ltr501_read_avail, }; =20 static const struct iio_info ltr501_info =3D { .read_raw =3D ltr501_read_raw, .write_raw =3D ltr501_write_raw, - .attrs =3D <r501_attribute_group, - .read_event_value =3D <r501_read_event, - .write_event_value =3D <r501_write_event, - .read_event_config =3D <r501_read_event_config, - .write_event_config =3D <r501_write_event_config, -}; - -static const struct iio_info ltr301_info_no_irq =3D { - .read_raw =3D ltr501_read_raw, - .write_raw =3D ltr501_write_raw, - .attrs =3D <r301_attribute_group, -}; - -static const struct iio_info ltr301_info =3D { - .read_raw =3D ltr501_read_raw, - .write_raw =3D ltr501_write_raw, - .attrs =3D <r301_attribute_group, - .read_event_value =3D <r501_read_event, - .write_event_value =3D <r501_write_event, - .read_event_config =3D <r501_read_event_config, - .write_event_config =3D <r501_write_event_config, + .read_avail =3D ltr501_read_avail, + .read_event_value =3D <r501_read_event, + .write_event_value =3D <r501_write_event, + .read_event_config =3D <r501_read_event_config, + .write_event_config =3D <r501_write_event_config, }; =20 static const struct ltr501_chip_info ltr501_chip_info_tbl[] =3D { @@ -1226,8 +1186,6 @@ static const struct ltr501_chip_info ltr501_chip_info= _tbl[] =3D { .als_mode_active =3D BIT(0) | BIT(1), .als_gain_mask =3D BIT(3), .als_gain_shift =3D 3, - .info =3D <r301_info, - .info_no_irq =3D <r301_info_no_irq, .channels =3D ltr301_channels, .no_channels =3D ARRAY_SIZE(ltr301_channels), }, @@ -1238,8 +1196,6 @@ static const struct ltr501_chip_info ltr501_chip_info= _tbl[] =3D { .als_mode_active =3D BIT(0), .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), .als_gain_shift =3D 2, - .info =3D <r301_info, - .info_no_irq =3D <r301_info_no_irq, .channels =3D ltr301_channels, .no_channels =3D ARRAY_SIZE(ltr301_channels), }, @@ -1251,7 +1207,6 @@ static const struct ltr501_chip_info ltr501_chip_info= _tbl[] =3D { .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), .als_gain_shift =3D 2, .no_irq_support =3D true, - .info_no_irq =3D <r301_info_no_irq, .channels =3D ltr301_channels, .no_channels =3D ARRAY_SIZE(ltr301_channels), }, @@ -1264,8 +1219,6 @@ static const struct ltr501_chip_info ltr501_chip_info= _tbl[] =3D { .als_mode_active =3D BIT(0) | BIT(1), .als_gain_mask =3D BIT(3), .als_gain_shift =3D 3, - .info =3D <r501_info, - .info_no_irq =3D <r501_info_no_irq, .channels =3D ltr501_channels, .no_channels =3D ARRAY_SIZE(ltr501_channels), }, @@ -1278,8 +1231,6 @@ static const struct ltr501_chip_info ltr501_chip_info= _tbl[] =3D { .als_mode_active =3D BIT(0), .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), .als_gain_shift =3D 2, - .info =3D <r501_info, - .info_no_irq =3D <r501_info_no_irq, .channels =3D ltr501_channels, .no_channels =3D ARRAY_SIZE(ltr501_channels), }, @@ -1450,6 +1401,7 @@ static int ltr501_probe(struct i2c_client *client) const void *ddata =3D NULL; int partid, chip_idx; const char *name; + int j =3D 0; int ret; =20 indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); @@ -1548,7 +1500,16 @@ static int ltr501_probe(struct i2c_client *client) &data->near_level)) data->near_level =3D 0; =20 - indio_dev->info =3D data->chip_info->info; + for (int i =3D 0; i < data->chip_info->als_gain_tbl_size; i++) { + if (data->chip_info->als_gain[i].scale =3D=3D LTR501_RESERVED_GAIN) + continue; + + data->als_gain_tbl[j++].scale =3D data->chip_info->als_gain[i].scale; + data->als_gain_tbl[j++].uscale =3D data->chip_info->als_gain[i].uscale; + } + data->als_gain_tbl_len =3D j; + + indio_dev->info =3D <r501_info; indio_dev->channels =3D data->chip_info->channels; indio_dev->num_channels =3D data->chip_info->no_channels; indio_dev->name =3D name; @@ -1573,7 +1534,7 @@ static int ltr501_probe(struct i2c_client *client) if (ret) goto powerdown_on_error; } else { - indio_dev->info =3D data->chip_info->info_no_irq; + indio_dev->info =3D <r501_info_no_irq; } =20 ret =3D iio_triggered_buffer_setup(indio_dev, NULL, --=20 2.53.0 From nobody Mon Nov 23 10:29:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794731882; b=QKVJGYlaWu1VhW9zkeNmpNkj9sUo2T2q5eUotDBUjUjLs+1pVCFtGx2ILtzS/qEGYPJs ob9zswRsjFOEq6nTcYphsHlvy+I1UEsQjNMSRuxr6MpM9QAAeJMbjU19cChbeZz3/00Wm gDUji8Z3G4rz2+DVCRxe2ARUIdA7/Z5aZ1iSl1zbSdszvcS7WS3/6dLQHzDe524Awzedd DVHKijvq+r60V6IqlldxK7eg2JhZAXCImdimbYTR8GttxMyEBT9+xTvYQksx/8WwMW2qN ZtUK1S/zM7pcDVZhFCqGAcP3sYZ1gdovh7YYcjvFkvTNOk0pduQYr9k/5f5G1zt0UcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794731882; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=wahMUn7lkVoWLk+//TfvQSoTRo4HIjxmomQS8JoF+OY=; b=J3T+Pa3DL/ionps3NK/3+NYTMMwsDZzsaueT1MY/j68DgfiF7CAIh7iWU1iC1gcGFB4d qTrWA0HdmfcmyX62PKGuDZDrqXVgcl60MHe4G8GZ2Zloqusv7ihB8bz5L40KAHswmFxIk qn+IP9skug2gL0fPOj0tNwL/xgNyHGi3L05qWnL8EKTLXpSkMvytFYu5oLhMWwyO78YXC O9d8qrnbFEq2d0rPztSAGb3H3hUZyD1KYi2TOBcgpLYlFhPq6UpgVfe3j0Jfl6IlV7trJ pZfPucFO3Dz93QQ0HkbTF5nso12+TjpBykyxNaG7RctiT+FA7h71LuWsWqSusl7t8oA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=MTfaI9aE; arc=none smtp.remote-ip=209.85.218.53 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5ABE606A893 for ; Sun, 15 Nov 2026 08:38:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E5ABE606A893 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.a=rsa-sha256 header.s=20260707 header.b=MTfaI9aE Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c505b2e1cb9so377786566b.2 for ; Sun, 15 Nov 2026 00:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794731880; x=1795336680; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wahMUn7lkVoWLk+//TfvQSoTRo4HIjxmomQS8JoF+OY=; b=MTfaI9aEMF3OzLwQVnQbXB8NyMbTdlt3VND41vNLrCTmCfPF9BCy39d4WkJgLAeJOI 2N9YmMo8KQZ9xzD+hZOfWSuWNaUtCzSbSJrxxHav11/L71i3grd6uZBVTP6yIPaXyvuq RCuyac7ucKuGafA1SPmrjFWUhICKaKuTSQVoJCv7HeYnJ9R9SYUobo9ib1cGcGUXPqjo plguW7aljmVl4kKihHq/n4dei3RdXe1gsodt7cHz8bnTT2HHtmWrmctSuBO/CXRiz3ai sDPew9ELe6H3Y0o7JIoxA2gFrOeC9V3fDENJZ1Te8KfwzZotDgsPsuXUtMmwBoSSmuB8 IbSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794731880; x=1795336680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wahMUn7lkVoWLk+//TfvQSoTRo4HIjxmomQS8JoF+OY=; b=NYzjWjZ0LMaUM1ZvXMPhuCkflbXrInkiIhu0GOaTDLucNnilrFIZ08PzaMo6xQyRAb b5qSkRRQeeLPpVetU2J2+mcKxii6EU7h0fj/wGpiexHhw8HIM0Bqqj1aJXaxNC2h4m6L saUoIzXV4KDo0+x1k2IRw/z+/jpYBMFt6q7z6AALADKaXkICU2Sk0VkIBUDmzN10a9yH eGK52NWYJeX3Fo0k4o+RDi39Y1AKzfi6IoFMdPWIyJAnmEaX8tXBmNuezO79amcsdXkt /Lo6MmBRYSY9uIQfcK47HomfLSmK70I84/bakVj3XbOTgcw1AP/U5BExyQ3mgZg8vTTD 18Tg== X-Forwarded-Encrypted: i=1; AL+hErEFinzwHJb5sXnZLTkAtsFzuNguM2zw93G41I0z0x9vUiI8UmMYt/5ItMLP8Py/dzgQpwOUvpEOL3xRKU8=@vger.kernel.org X-Gm-Message-State: APuU4Z+9nsNo8wG/1xxw1ohfoyBiDnaExyKbIIOfodLUUzx3tNnnvQEX Vh71utGoYB5e/EK0ZONiuem7yEO0OeTETOQ30jZXbyBlb3GruI0T6UiO X-Gm-Gg: AYBFou2/fOlr8iK+yLvkgdwp01MggmgzzNOtFN0Tbn7XIfob1XA/YVvgTe9/QYTUWXN KeCUZ27GM0G/5ECHB6nLszjjVeulmAIoqU/BevdUY5bEEsLGF6MvE2PwpgL13aE7RCBkqtqcsTG 7XVD8iAKkk3VSrivVtH5BrxgpRa/6LN2+RRU3S5Yw3a+wYhbIM9mNLX7n+ODTQ8MYJiX/WqA78o 7HVHjXS7iUp31AMLza6TWLfL7U2LVEhA3f8sxIkF6/KRCAZSIDjI3tSR/Lb6x2ceKDuACGDXh5X IbB1X6k366M+tIWnRcmVKxqJcLoyED5ODXcxPulA8+F7iotKQQ5ksrPJ8On7JXPVjuAkI2pu4ri W+Jfl/vVw7PttpmNLj/UVhK5FaDlOGo3ev29Txma1XVkDiFabH0lZHmrPoyhtJ1gndpFJsGqG4D Ya9sIf4tl+wgyUojSWT3JBl60AxMXzc/biHCHJo943DPVvD+3w2voZ5NaJkySfew3DAzr/19lRe ZInEg/1RAWC0lCmLVksyaXHOqLpt9uWK0q9ZprzQ2RHTMw06xC3S457Jmq2g4Xrs8zK9I7oqWmn LksZAS4aKn417xZN346Ik1MA0B4qrS/6++Sp7AjCu1vSqifhupO6TgPqK0eBvb4uayLM6RO9paw TlS/5gP/kmw== X-Received: by 2002:a17:907:d10:b0:c4c:ddd1:cffa with SMTP id a640c23a62f3a-c5096398ae2mr615143166b.29.1794731880219; Sun, 15 Nov 2026 00:38:00 -0800 (PST) Received: from xeon ([188.163.112.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c5095a5ad9esm284815666b.2.2026.11.15.00.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 00:37:59 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Esben Haabendal , Kuppuswamy Sathyanarayanan , Svyatoslav Ryhel , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= , Pan Chuang , Hemanth Selam , Antoniu Miclaus , Nikita Travkin Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] iio: light: ltr501: Switch to modern match mechanism Date: Sun, 15 Nov 2026 10:37:39 +0200 Message-ID: <20261115083741.62140-3-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261115083741.62140-1-clamor95@gmail.com> References: <20261115083741.62140-1-clamor95@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the chip enum, break the chip list structure into individual elements, and pass each element using i2c_get_match_data(). Preserve the iio_dev name configuration and replace the iio_get_acpi_device_name_and_data() call with a simple dev_name(), since the former is just a wrapper for the latter in this use case. Signed-off-by: Svyatoslav Ryhel --- drivers/iio/light/ltr501.c | 164 +++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 90 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 3662aed5225bc..bf3cc32a55c3c 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -90,14 +90,6 @@ struct ltr501_samp_table { =20 #define LTR501_RESERVED_GAIN -1 =20 -enum { - ltr301, - ltr303, - ltr329, - ltr501, - ltr559, -}; - struct ltr501_gain { int scale; int uscale; @@ -1178,62 +1170,64 @@ static const struct iio_info ltr501_info =3D { .write_event_config =3D <r501_write_event_config, }; =20 -static const struct ltr501_chip_info ltr501_chip_info_tbl[] =3D { - [ltr301] =3D { - .partid =3D 0x08, - .als_gain =3D ltr501_als_gain_tbl, - .als_gain_tbl_size =3D ARRAY_SIZE(ltr501_als_gain_tbl), - .als_mode_active =3D BIT(0) | BIT(1), - .als_gain_mask =3D BIT(3), - .als_gain_shift =3D 3, - .channels =3D ltr301_channels, - .no_channels =3D ARRAY_SIZE(ltr301_channels), - }, - [ltr303] =3D { - .partid =3D 0x0A, - .als_gain =3D ltr559_als_gain_tbl, - .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), - .als_mode_active =3D BIT(0), - .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), - .als_gain_shift =3D 2, - .channels =3D ltr301_channels, - .no_channels =3D ARRAY_SIZE(ltr301_channels), - }, - [ltr329] =3D { - .partid =3D 0x0A, - .als_gain =3D ltr559_als_gain_tbl, - .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), - .als_mode_active =3D BIT(0), - .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), - .als_gain_shift =3D 2, - .no_irq_support =3D true, - .channels =3D ltr301_channels, - .no_channels =3D ARRAY_SIZE(ltr301_channels), - }, - [ltr501] =3D { - .partid =3D 0x08, - .als_gain =3D ltr501_als_gain_tbl, - .als_gain_tbl_size =3D ARRAY_SIZE(ltr501_als_gain_tbl), - .ps_gain =3D ltr501_ps_gain_tbl, - .ps_gain_tbl_size =3D ARRAY_SIZE(ltr501_ps_gain_tbl), - .als_mode_active =3D BIT(0) | BIT(1), - .als_gain_mask =3D BIT(3), - .als_gain_shift =3D 3, - .channels =3D ltr501_channels, - .no_channels =3D ARRAY_SIZE(ltr501_channels), - }, - [ltr559] =3D { - .partid =3D 0x09, - .als_gain =3D ltr559_als_gain_tbl, - .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), - .ps_gain =3D ltr559_ps_gain_tbl, - .ps_gain_tbl_size =3D ARRAY_SIZE(ltr559_ps_gain_tbl), - .als_mode_active =3D BIT(0), - .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), - .als_gain_shift =3D 2, - .channels =3D ltr501_channels, - .no_channels =3D ARRAY_SIZE(ltr501_channels), - }, +static const struct ltr501_chip_info ltr301_chip_info_tbl =3D { + .partid =3D 0x08, + .als_gain =3D ltr501_als_gain_tbl, + .als_gain_tbl_size =3D ARRAY_SIZE(ltr501_als_gain_tbl), + .als_mode_active =3D BIT(0) | BIT(1), + .als_gain_mask =3D BIT(3), + .als_gain_shift =3D 3, + .channels =3D ltr301_channels, + .no_channels =3D ARRAY_SIZE(ltr301_channels), +}; + +static const struct ltr501_chip_info ltr303_chip_info_tbl =3D { + .partid =3D 0x0A, + .als_gain =3D ltr559_als_gain_tbl, + .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), + .als_mode_active =3D BIT(0), + .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), + .als_gain_shift =3D 2, + .channels =3D ltr301_channels, + .no_channels =3D ARRAY_SIZE(ltr301_channels), +}; + +static const struct ltr501_chip_info ltr329_chip_info_tbl =3D { + .partid =3D 0x0A, + .als_gain =3D ltr559_als_gain_tbl, + .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), + .als_mode_active =3D BIT(0), + .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), + .als_gain_shift =3D 2, + .no_irq_support =3D true, + .channels =3D ltr301_channels, + .no_channels =3D ARRAY_SIZE(ltr301_channels), +}; + +static const struct ltr501_chip_info ltr501_chip_info_tbl =3D { + .partid =3D 0x08, + .als_gain =3D ltr501_als_gain_tbl, + .als_gain_tbl_size =3D ARRAY_SIZE(ltr501_als_gain_tbl), + .ps_gain =3D ltr501_ps_gain_tbl, + .ps_gain_tbl_size =3D ARRAY_SIZE(ltr501_ps_gain_tbl), + .als_mode_active =3D BIT(0) | BIT(1), + .als_gain_mask =3D BIT(3), + .als_gain_shift =3D 3, + .channels =3D ltr501_channels, + .no_channels =3D ARRAY_SIZE(ltr501_channels), +}; + +static const struct ltr501_chip_info ltr559_chip_info_tbl =3D { + .partid =3D 0x09, + .als_gain =3D ltr559_als_gain_tbl, + .als_gain_tbl_size =3D ARRAY_SIZE(ltr559_als_gain_tbl), + .ps_gain =3D ltr559_ps_gain_tbl, + .ps_gain_tbl_size =3D ARRAY_SIZE(ltr559_ps_gain_tbl), + .als_mode_active =3D BIT(0), + .als_gain_mask =3D BIT(2) | BIT(3) | BIT(4), + .als_gain_shift =3D 2, + .channels =3D ltr501_channels, + .no_channels =3D ARRAY_SIZE(ltr501_channels), }; =20 static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_= val) @@ -1398,9 +1392,7 @@ static int ltr501_probe(struct i2c_client *client) struct ltr501_data *data; struct iio_dev *indio_dev; struct regmap *regmap; - const void *ddata =3D NULL; - int partid, chip_idx; - const char *name; + int partid; int j =3D 0; int ret; =20 @@ -1481,18 +1473,10 @@ static int ltr501_probe(struct i2c_client *client) if (ret < 0) return ret; =20 - if (id) { - name =3D id->name; - chip_idx =3D id->driver_data; - } else { - name =3D iio_get_acpi_device_name_and_data(&client->dev, &ddata); - chip_idx =3D (intptr_t)ddata; - } - if (!name) + data->chip_info =3D i2c_get_match_data(client); + if (!data->chip_info) return -ENODEV; =20 - data->chip_info =3D <r501_chip_info_tbl[chip_idx]; - if ((partid >> 4) !=3D data->chip_info->partid) return -ENODEV; =20 @@ -1512,7 +1496,7 @@ static int ltr501_probe(struct i2c_client *client) indio_dev->info =3D <r501_info; indio_dev->channels =3D data->chip_info->channels; indio_dev->num_channels =3D data->chip_info->no_channels; - indio_dev->name =3D name; + indio_dev->name =3D id ? id->name : dev_name(&client->dev); indio_dev->modes =3D INDIO_DIRECT_MODE; =20 ret =3D ltr501_init(data); @@ -1583,29 +1567,29 @@ static int ltr501_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resu= me); =20 static const struct acpi_device_id ltr_acpi_match[] =3D { - { .id =3D "LTER0301", .driver_data =3D ltr301 }, + { .id =3D "LTER0301", .driver_data =3D (kernel_ulong_t)<r301_chip_info_= tbl }, /* https://www.catalog.update.microsoft.com/Search.aspx?q=3Dlter0303 */ - { .id =3D "LTER0303", .driver_data =3D ltr303 }, + { .id =3D "LTER0303", .driver_data =3D (kernel_ulong_t)<r303_chip_info_= tbl }, { } }; MODULE_DEVICE_TABLE(acpi, ltr_acpi_match); =20 static const struct i2c_device_id ltr501_id[] =3D { - { .name =3D "ltr301", .driver_data =3D ltr301 }, - { .name =3D "ltr303", .driver_data =3D ltr303 }, - { .name =3D "ltr329", .driver_data =3D ltr329 }, - { .name =3D "ltr501", .driver_data =3D ltr501 }, - { .name =3D "ltr559", .driver_data =3D ltr559 }, + { .name =3D "ltr301", .driver_data =3D (kernel_ulong_t)<r301_chip_info_= tbl }, + { .name =3D "ltr303", .driver_data =3D (kernel_ulong_t)<r303_chip_info_= tbl }, + { .name =3D "ltr329", .driver_data =3D (kernel_ulong_t)<r329_chip_info_= tbl }, + { .name =3D "ltr501", .driver_data =3D (kernel_ulong_t)<r501_chip_info_= tbl }, + { .name =3D "ltr559", .driver_data =3D (kernel_ulong_t)<r559_chip_info_= tbl }, { } }; MODULE_DEVICE_TABLE(i2c, ltr501_id); =20 static const struct of_device_id ltr501_of_match[] =3D { - { .compatible =3D "liteon,ltr301", }, - { .compatible =3D "liteon,ltr303", }, - { .compatible =3D "liteon,ltr329", }, - { .compatible =3D "liteon,ltr501", }, - { .compatible =3D "liteon,ltr559", }, + { .compatible =3D "liteon,ltr301", .data =3D <r301_chip_info_tbl }, + { .compatible =3D "liteon,ltr303", .data =3D <r303_chip_info_tbl }, + { .compatible =3D "liteon,ltr329", .data =3D <r329_chip_info_tbl }, + { .compatible =3D "liteon,ltr501", .data =3D <r501_chip_info_tbl }, + { .compatible =3D "liteon,ltr559", .data =3D <r559_chip_info_tbl }, { } }; MODULE_DEVICE_TABLE(of, ltr501_of_match); --=20 2.53.0 From nobody Mon Nov 23 10:29:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794731885; b=LKH04O63Yk4XVySkrhhlufMwrnqgs+uFUll9lUEAd8zGEQ60zIXpq3Ek1yxF3E9EGoJH YctHF/wN1A8ZPXQhTDoqwkj//FUrPFQ6KQBGx2irwOc8fFaKbVndIlBRmKTMuyBY/Cf0e fRwlmNff9gRg7h1+cQ2QAEi5RPMR2FpFahJOpyRkipFKlhpfn76am+uNTauYTJc2P19B0 ToJvfai91MthkdaHCkLJoSdnEpr+vhi0hDbagCuGs0L/7M45M20ixH8R1pQzTLE9NNOFa jiKnqPC7xW0gJxCQWvY/Hfjcd39nApqUweODFgTbJJzetcMNatkCuktNkkr5avSweQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794731885; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=g+JNwiCu6bm0rcLmuJWSYeAtStEl9n5lsa7a5i38a1Q=; b=SdFLVbjvWfQrtk7jNliHlPo/4detc+LjHW6kBSL28GiDYbvyVpGFIcyUXeJpKCrBXkX+ Yv4qyM7Atr827ofkicHGEST+m5lNWnHZJHB8AlxN4WVJRovT70FQ3uIhuxCtEaW54aqt6 UI8X8gAjfcphr+BJc1GeoFj1s/Jq0fN0hyUIldY3nwF7lPyojvaMipkdt88eiMZO9A6o4 iL6lAJMnVXQKEvSIycbo6Py5vnKhUxY6NiFw20jEYIUHITVnCHtlVraPEbM3gVHbIKKBd LO97vPsWJx5KmzVa1ydurA6RofPkR3mBrqAgmlKwbIdRBuzmu1NiesKNTv4pyq2m3Eg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qvVKeoHM; arc=none smtp.remote-ip=209.85.208.41 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11698606A33D for ; Sun, 15 Nov 2026 08:38:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11698606A33D 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.a=rsa-sha256 header.s=20260707 header.b=qvVKeoHM Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-6b81214ab40so265953a12.0 for ; Sun, 15 Nov 2026 00:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794731883; x=1795336683; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g+JNwiCu6bm0rcLmuJWSYeAtStEl9n5lsa7a5i38a1Q=; b=qvVKeoHM4kmAdUefhbLzNsQaTehL/q6/ivDkdZOAGX/7czeIdJxqhrwmPEW8Gh/6F7 sbSVMqL0foqRicWhK1ok6tB4VnEe93keo4KAR8lG/m2/3Wwkm5LeTGifc8ZAHmpzbzLF rGUP7AgUkygDQ6beLqTYBhv8JvX1VsTYvy416KjYN4vxzhbUFhxpFKv2km7H2mbH8XN8 oHRnQN0UPr/IXDAIFItpyZABunCQGaOI5pDRNb1I8joEPua4W4PM+Hy1Xb9c29rgSLyi 4/JBVnhylkZCvfegBFoCUhVZ0SGbSPe8tujYYs5r4yTgwat0TidTciy4GKiI3mrKLx0j MUIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794731883; x=1795336683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=g+JNwiCu6bm0rcLmuJWSYeAtStEl9n5lsa7a5i38a1Q=; b=A61aIIhCXqL7D91ESoO4XPVIYqnen6GwMovOW6aruco1t5V/F/U5Gd/77gi+QIsBFO Gmyjtctr8hBcuFYCCwNtXLssbtZCJlhXSxYPOB3U2UWwEN42/rbZ052sJEpnUFJVXAOJ Tj/gpb9qOG2er35ClZDiHLzSz7NIvTyGpEO/SIQAXucNCZb74izfIZBV8h8h+JEUTGEW nCMv97nCI8X62vkJErp0a40yGM3PACsaho8212+b+S+6yWbMz3qRvJnOZfdgHyOQlAhp J4a6bj6r9fCUYjHYfmQfvALCEzOW3tizh0pxsRBXW3G3sYuGjHx+YsCxt9yEPCtW288x AvFA== X-Forwarded-Encrypted: i=1; AL+hErGxUm70wOQR18/DNbJ5UYaJTbsCttaDSIcvV1Mk9+krY5q2HYFFv4a3NsAY+aqX8HEC4q7YMVT9BhFtoP0=@vger.kernel.org X-Gm-Message-State: APuU4Z/gvQHSWhWkF1RKUXuq4TIVkhP/sOYqkUzPKZpKmAa4Y53tuIAT sM77We7XnuiGXEgfhzt5ChbwMyAcbzjimH+v0JQBWAidOYs4bVIoSBwD X-Gm-Gg: AYBFou2vN2DV+w0Yl6b1BGVY4fLljfq9zRZJyO/qIH/kRxZVhXNeP4a+VQu4HKS5aGY U0lLPjh103WLJf/kApGDDOhz2URDp1IqEMaklw9fC7Lo/WegtQHmhbFMtk4B5kszCPlNfToykjh v7s54hDQ8438Ru6hpNZLDB5fTFYIJ7rS5pRzCrwUPmft7UaeaVEQzwTQyPb5UkFWBHWbj2/ahML LK+GMjJ3LCt/GXNzHntY11+IxILgg0986cdifJvaH4o5mpee7C0Fpwm+uW/WMuRcUeOYwqAWcJW 2nLW9pq4MTOa5NTQ79AlJv5i4YuMmNXjEdCipoQ2yjAGfXLWtr6lzgLZNTdzoPCKXiFEzUivzhV WwZhc0GQkPuvdarwP4Mi99mXL1Tq4kYUHBNVThk4+uBgKB2H3UVhIDL38mhrz5PBsQWWfPt6aUs MoLnXSwhj8X7w4EMbVkJHeerMrFgjzQgwmzhWlof6q+eOok5gRJfvPlxVnyUi03aag22DGClWz1 Mx1nQT2Lwy4q7sVPgcNU5KQ3ReVN3OPp+OJl88kF0tCQraRO/8X3GtrixSWnFwch8zQZkdxM29Z zEyCAK9lDwZIOxh7/6d93kF9ComzFdnaL1/a9U2NEQoItblC7KHWVj6qVlDwkLwg96sFNp59rOM 7WAETwql6LQ== X-Received: by 2002:a17:907:d01:b0:c2d:d4dd:8d0 with SMTP id a640c23a62f3a-c507c3c72b7mr878493266b.16.1794731883335; Sun, 15 Nov 2026 00:38:03 -0800 (PST) Received: from xeon ([188.163.112.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c5095a5ad9esm284815666b.2.2026.11.15.00.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 00:38:01 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Esben Haabendal , Kuppuswamy Sathyanarayanan , Svyatoslav Ryhel , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= , Pan Chuang , Hemanth Selam , Antoniu Miclaus , Nikita Travkin Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] dt-bindings: iio: light: ltr501: Document LTR659 proximity sensor Date: Sun, 15 Nov 2026 10:37:40 +0200 Message-ID: <20261115083741.62140-4-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261115083741.62140-1-clamor95@gmail.com> References: <20261115083741.62140-1-clamor95@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The LTR-659PS-01 is a proximity sensor similar to the LTR-559ALS-01, but without ambient light sensing support. Acked-by: Conor Dooley Signed-off-by: Svyatoslav Ryhel --- Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml= b/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml index 20abd7da080d6..85ac3b540c206 100644 --- a/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml +++ b/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml @@ -17,6 +17,7 @@ properties: - liteon,ltr329 - liteon,ltr501 - liteon,ltr559 + - liteon,ltr659 =20 reg: maxItems: 1 --=20 2.53.0 From nobody Mon Nov 23 10:29:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794731888; b=E6VqBx02BXhUyUHniw5Z3QdfDfkHUy/LmwwGHkveuQr51r4KhoqvGQFqfiES+SO+3EkO QjW4z0XvaFQ3ZDzUPPVtiPOCL0sfCQbD43d4J9Emn8SG4s4Obpk8KTteA+ZJQaI2MVr6m Wn7G2+ENt4ZzpeDctF6ji1HtIZ2quWSb4jE1tJr3K6GxhwF8io6beBt94OAz50fz4pLRy i4VrXetzDo7AzCSWsntBjVEvw7UUQziKExcytPWaVWeDxUQzRkyJF8nsL29HIjTxHwp0k 0iuUyHkZK/0lWEK3f6p5vctj0mNAv4MppY+lZVEgPLgR/7zdKU4kjVGv6dUtLPurXxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794731888; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=/MbbDD57P/KeyF+nc1m1H/fHW8AV7QTTEwuQUWKknZ8=; b=udWYkKOUE9EWofsCJWcjX5r8Vw6CRHxePf6VA+OOk/4TokNFvH0JdWQsz53whcoBki/S tRo71RIpK9gFSsDLxFcjzbL3TtTUs1tDoIe0USnSrruKlI+nsDrol7VHjxWAAV31Ow8lo lRh8w2Roena7GPx4if5nkTE4Mg9V6F5ELVjPlxo/1OYkLk6tfbgxDe2gMd7CaKFqpvH+9 R0u/r1jD0DaTeW9OnsJ6pKb+Z4RoozWgr7r6CfCMDcbKijeEmVn/qObilQmpSq8uJX8vO CI70efIbLzy59sM90q0IK0Eal0Ew5CpsV1eU7gV1J7GED/1Z0CZFHas4aEEGSgKnOZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=wl+FGbMJ; arc=none smtp.remote-ip=209.85.218.51 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D63C8606A8AD for ; Sun, 15 Nov 2026 08:38:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D63C8606A8AD 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.a=rsa-sha256 header.s=20260707 header.b=wl+FGbMJ Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-c50cc8e0f84so42143266b.1 for ; Sun, 15 Nov 2026 00:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794731886; x=1795336686; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/MbbDD57P/KeyF+nc1m1H/fHW8AV7QTTEwuQUWKknZ8=; b=wl+FGbMJy3l3qlIgBl3eecuI+VYWFKecwCV7FnBLMa449ZqZK8/EN232t8Odjyfn66 fsf3iqONvCja+h6YdsPrLDxsvopMlg974ujV5iDK9uB5rAkXooEMJLO2+Vl1J8F7Jeiq koSj+6SeZDXzhGOdcEgvu63Wa7eExZOh1e0Tvn6oPIebjGVaOtmxCmcQChllBIEWsilY NoGk4cuoWfqG7rCc+QCyPSMg7NSGRVWQ6z+B/4nFlJ9D+lmx/sDODeXZ5s+KGj6Bb/el JXzYNltgb/bMUnD+hme6nGE7Azfs3l2Xrge5ZgKk6OdL+cWAAK40XTVfGkzm3CT9ezBs UITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794731886; x=1795336686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/MbbDD57P/KeyF+nc1m1H/fHW8AV7QTTEwuQUWKknZ8=; b=flVK30MByhdtDDNdtqmnlkzs4Lf04SHwQCxMEJscwaO/rY1OLniwMbSH0O4+0X8tx/ pxbHGZwGTXALR9ugHQjPZVcLtoJI7Wjfny6b1CT99gq7Op2y3N58cOC13wF7hP+/js2W YcH32tNCUM01ldj48o1bsDG9WQk6zx76aZE+1Me2+qiPkTgajB2BxoCBnDka3acU9IgD lsGsfJFjMwTT7951JiiRGgmXtM5Bj81pLQpahm3rx2Wv9Ms6EEEOexL5dTFyqTuHb8Q9 IbodDM4Ojk6ga033P9CvptiIZaqGM/6IKTkshRc6xwfmRGAm6rQIOWzTA5uV5p9GHWx9 oKuA== X-Forwarded-Encrypted: i=1; AL+hErG/UkuUA7O/Poght7otUhfp8XuTNmmaqPuCijVbsaPF/gLnzxnRR8UBOdxxcZY0w0J3olxsS7Q1d9uVPt8=@vger.kernel.org X-Gm-Message-State: APuU4Z8IeTUK6SqVf4l7ZzkwwD3+PQu5xTa1DlPbY3JDQZWW+NQbGTOK SB7A9NoOMUxEvINtBOC6I95odcauWF5B10/IWk0jL+Kt0FcJz2oCVFms X-Gm-Gg: AYBFou1jPrcV9Ld/OenSrGXjjU0UdOSgSE5yZOrxjaT/fhvlRgvCxIX8lrsd8yppI+G gqfG8c9DP8xnAmfPdB28jAHtAYrzLi2N7Jh+NBc01Vx9e9HmRBV06sSprGsOlKNilGHieMuBqGx 97NrAb/5OdbeUXlVgUReRnmKcNIrEpKTFgXK2vtSpfQWo7qstChn2pW0k9SiNTw94DfUDI3fF2V LEXeKNTL+tqeGupbHImkkFlaQuk0J/mIp0GXCsQ5J55kFe3nWMbUzKgHM/dQgdVwslFYa4jTeqA N6263EngCuQokQejEPORLX/qYBJXj4n4dyrlUYE9WzjDxTzgzuwJFMR5MnmfapRTkhlmUxDRMM1 N/cZpdNWBkl8Q2leyZ0oasfhv8ndjIMTKX+UX1H0MDQys5XkN0ka4U8S96lSq1SAXdV+zp93h61 tUDo5ZeXK+/MuJKU2G5oFxOQLBRW5wQjQLfGVfGERmB3nA2/YjZhe1NYl/F/JPUndNobdQ1slzB NsNa0uWos/xcyLQu4gKOpB6IOMJfp0AaPmB75E64+sqkuzfD3sRC2Xas7eR7YsJm++eK1kWJdF/ hFsypL+2pbH1T83KJNTYRBQApf3ASemDW68V6lZLFGOgalkjT4kyoSsAfYWVNiEb9S7+eOetLv/ sVJi1wJrI1g== X-Received: by 2002:a17:907:6e94:b0:c49:df71:14f5 with SMTP id a640c23a62f3a-c509643acd8mr505346466b.31.1794731886046; Sun, 15 Nov 2026 00:38:06 -0800 (PST) Received: from xeon ([188.163.112.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c5095a5ad9esm284815666b.2.2026.11.15.00.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 00:38:05 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Esben Haabendal , Kuppuswamy Sathyanarayanan , Svyatoslav Ryhel , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= , Pan Chuang , Hemanth Selam , Antoniu Miclaus , Nikita Travkin Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 proximity sensor Date: Sun, 15 Nov 2026 10:37:41 +0200 Message-ID: <20261115083741.62140-5-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261115083741.62140-1-clamor95@gmail.com> References: <20261115083741.62140-1-clamor95@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for the Lite-On LTR-659PS-01 proximity sensor. This device is nearly identical to the LTR-559ALS-01, but omits all elements related to ambient light sensing. Add a no_als_support flag, similar to how no_irq_support is used, to isolate ALS register access for the LTR-659PS-01, since ALS registers are marked as reserved and interactions with them are discouraged. The ltr501_trigger_handler relied on the scan index to identify channels. This approach is fragile regarding channel status flags and can break if the index is not strictly set. Switch to checking the channel type instead. Signed-off-by: Svyatoslav Ryhel --- drivers/iio/light/ltr501.c | 76 ++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index bf3cc32a55c3c..394e08c78005e 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -151,6 +151,7 @@ struct ltr501_chip_info { u8 als_gain_mask; u8 als_gain_shift; bool no_irq_support; + bool no_als_support; struct iio_chan_spec const *channels; const int no_channels; }; @@ -656,6 +657,29 @@ static const struct iio_chan_spec ltr301_channels[] = =3D { IIO_CHAN_SOFT_TIMESTAMP(2), }; =20 +static const struct iio_chan_spec ltr659_channels[] =3D { + { + .type =3D IIO_PROXIMITY, + .address =3D LTR501_PS_DATA, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), + .info_mask_separate_available =3D BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available =3D BIT(IIO_CHAN_INFO_SAMP_FREQ), + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 11, + .storagebits =3D 16, + .endianness =3D IIO_CPU, + }, + .event_spec =3D ltr501_pxs_event_spec, + .num_event_specs =3D ARRAY_SIZE(ltr501_pxs_event_spec), + .ext_info =3D ltr501_ext_info, + }, + IIO_CHAN_SOFT_TIMESTAMP(1), +}; + static int ltr501_read_info_raw(struct ltr501_data *data, struct iio_chan_spec const *chan, int *val) @@ -1230,13 +1254,24 @@ static const struct ltr501_chip_info ltr559_chip_in= fo_tbl =3D { .no_channels =3D ARRAY_SIZE(ltr501_channels), }; =20 +static const struct ltr501_chip_info ltr659_chip_info_tbl =3D { + .partid =3D 0x09, + .ps_gain =3D ltr559_ps_gain_tbl, + .ps_gain_tbl_size =3D ARRAY_SIZE(ltr559_ps_gain_tbl), + .no_als_support =3D true, + .channels =3D ltr659_channels, + .no_channels =3D ARRAY_SIZE(ltr659_channels), +}; + static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_= val) { int ret; =20 - ret =3D regmap_write(data->regmap, LTR501_ALS_CONTR, als_val); - if (ret < 0) - return ret; + if (!data->chip_info->no_als_support) { + ret =3D regmap_write(data->regmap, LTR501_ALS_CONTR, als_val); + if (ret < 0) + return ret; + } =20 return regmap_write(data->regmap, LTR501_PS_CONTR, ps_val); } @@ -1251,16 +1286,21 @@ static irqreturn_t ltr501_trigger_handler(int irq, = void *p) aligned_s64 ts; } scan =3D { }; __le16 als_buf[2]; + unsigned int chan_idx; u8 mask =3D 0; int j =3D 0; int ret, psdata; =20 /* figure out which data needs to be ready */ - if (test_bit(0, indio_dev->active_scan_mask) || - test_bit(1, indio_dev->active_scan_mask)) - mask |=3D LTR501_STATUS_ALS_RDY; - if (test_bit(2, indio_dev->active_scan_mask)) - mask |=3D LTR501_STATUS_PS_RDY; + iio_for_each_active_channel(indio_dev, chan_idx) { + const struct iio_chan_spec *chan =3D &indio_dev->channels[chan_idx]; + + if (chan->type =3D=3D IIO_INTENSITY) + mask |=3D LTR501_STATUS_ALS_RDY; + + if (chan->type =3D=3D IIO_PROXIMITY) + mask |=3D LTR501_STATUS_PS_RDY; + } =20 ret =3D ltr501_drdy(data, mask); if (ret < 0) @@ -1328,11 +1368,13 @@ static int ltr501_init(struct ltr501_data *data) { int ret, status; =20 - ret =3D regmap_read(data->regmap, LTR501_ALS_CONTR, &status); - if (ret < 0) - return ret; + if (!data->chip_info->no_als_support) { + ret =3D regmap_read(data->regmap, LTR501_ALS_CONTR, &status); + if (ret < 0) + return ret; =20 - data->als_contr =3D status | data->chip_info->als_mode_active; + data->als_contr =3D status | data->chip_info->als_mode_active; + } =20 ret =3D regmap_read(data->regmap, LTR501_PS_CONTR, &status); if (ret < 0) @@ -1341,9 +1383,11 @@ static int ltr501_init(struct ltr501_data *data) data->ps_contr =3D status | LTR501_CONTR_ACTIVE; =20 if (ltr501_has_irq_support(data->chip_info)) { - ret =3D ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period); - if (ret < 0) - return ret; + if (!data->chip_info->no_als_support) { + ret =3D ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period); + if (ret < 0) + return ret; + } =20 ret =3D ltr501_read_intr_prst(data, IIO_PROXIMITY, &data->ps_period); if (ret < 0) @@ -1580,6 +1624,7 @@ static const struct i2c_device_id ltr501_id[] =3D { { .name =3D "ltr329", .driver_data =3D (kernel_ulong_t)<r329_chip_info_= tbl }, { .name =3D "ltr501", .driver_data =3D (kernel_ulong_t)<r501_chip_info_= tbl }, { .name =3D "ltr559", .driver_data =3D (kernel_ulong_t)<r559_chip_info_= tbl }, + { .name =3D "ltr659", .driver_data =3D (kernel_ulong_t)<r659_chip_info_= tbl }, { } }; MODULE_DEVICE_TABLE(i2c, ltr501_id); @@ -1590,6 +1635,7 @@ static const struct of_device_id ltr501_of_match[] = =3D { { .compatible =3D "liteon,ltr329", .data =3D <r329_chip_info_tbl }, { .compatible =3D "liteon,ltr501", .data =3D <r501_chip_info_tbl }, { .compatible =3D "liteon,ltr559", .data =3D <r559_chip_info_tbl }, + { .compatible =3D "liteon,ltr659", .data =3D <r659_chip_info_tbl }, { } }; MODULE_DEVICE_TABLE(of, ltr501_of_match); --=20 2.53.0