From nobody Wed Apr 1 21:59:40 2026 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 27C833F87E9 for ; Wed, 1 Apr 2026 11:24:34 +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=1775042676; cv=none; b=SGpNtifUzI6gWiJ5/C21h8KLSJ5nsOxhdx2kRrcuvP8XFPEMqZsbyFvtzrXtO1GC3Em1nHh/faEbEFCwimS642IXDuRuTt7bN/CFdQgSkV4XsNQM4TxlWvKTL3Q3Ra8Ty/yyUp7K5eIT1KEz6HrIAealSmuMuNlK25u0KotZHGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775042676; c=relaxed/simple; bh=vYqIW/Gqq4fflDfaI8Jf/yJIutWh/VhqHqfWtmFgBVo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=beI00ohOGld3v5hp2vJF/cWVxbgnaS9POcLSuC7eKf3IA0KZk2yFzCT9fUvKj518BbXnCKGador8X2q5SJFrSYSTPs0ARSD6WDFSlcSsnpKF3nbdUXLBJscTQICepdsTWeUaz+uew9LpW59Ho675NTMI/9Yqh5Z2AW3jdtCV6IM= 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=o4c0KfSr; 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="o4c0KfSr" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4853e1ce427so83313265e9.3 for ; Wed, 01 Apr 2026 04:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775042673; x=1775647473; 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=9895e4FwG2ovO6tBDWw3OwKtNs1gDVGzeGbxIRzOTSQ=; b=o4c0KfSr0pwJYs56IU0D9krouQYo8ifmPFomN3pDSpK9Xct79Di5IGseUxPAP8kBm2 Auu2B/XUgT0vrdnSLDzEsTx1Bqm2g6dWw6r8mqs3CpwaSMz0xyy/WldIrydFibhWQmna qBqWr8sGPMsPHTfazaHHlXmd0bvjmz14yahoGGP3vjS2K0c2K4cg29PGTrrnG5wePUr3 3oEyQfgFoYVQ+QrmcMQCvmmRc1IP65hZ/a/AjU4ug8Nm3xg6Zhh7Wlq456oROcbAOJrx qKvLOiCPLAn01akalOsZB6zpzpP0XMjZ0vHTpK2R75R4MEevt+IpWNnE7jXUFhcDeXIA /wZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775042673; x=1775647473; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9895e4FwG2ovO6tBDWw3OwKtNs1gDVGzeGbxIRzOTSQ=; b=kTgg0QWCEZbE2pXlAK/YPMcTkPYo9eDGXZhPKMTHXNSOvZJHiUijz9mwmzDWJV2A8d O0WQCHrfUlOLmz7YhPgGyjSegDIO2BwMkCAnz0GObna8ct3uVbzvyxIS0YRvDla4NDHV hrLk4ZdU6afFi1SYIrqmr+EVWWRZ/MZPhYTvzMwen5fdgcTOshtXZvgSua2Omq/HGERE sr5+19M3F52cZ5D8ZLDTVJrLnD8Wn0laFrNig9vS4PtfR4zaXDbEXWeZa1yoN9eZSbXw Bf0UREPZXdkbRBlrypKthG6UGg6MhGw06vUsBDdTbMvqXvSV9+UKuHxVM2dl/ePnMPqV cZlQ== X-Forwarded-Encrypted: i=1; AJvYcCVbZnW0z/svPbhOluA6sQDEo7SnywWoDyXZLhiy4ntHDIN+n/2wLUd9T5lx8p63H/43HeU5vY6EkM/PHmk=@vger.kernel.org X-Gm-Message-State: AOJu0YyXAgZeOpC1/4N/oxDAgkALPn7SEFcD0+lQLZFIunCBU7qrfCU2 43HUBjLRieDN1K0dbXZbPVN/48fo6HPOkg35caiGN9ceXQjrjUSaaEjC210QzA== X-Gm-Gg: ATEYQzwpegSar14NmKo8kfGPky+0Ydhh2fnu8vZ5rh3imR+nZkQ2vD4UdeOmkby3Xms w7279wnHEc9SKaZNdQBm+fqzQKZ7wpaFLW6nN//GK7yNjGENFg8D8OJxEX21gFzloncfJiqVm+Y oTTRV1cXlqXPgQtuyfdBj+KpZ7qPIin36PJ/vZRUmry/tucizZGPWwm07jbGeltzUT2mKxNxBBL 1HNTpH5oi3oAwv2qGkWTJ77Om0RxIQ49eCbFJ8M341o45PrtcCJmNpuccAquvBbNflj5RsmlxoJ EyR8YPtBdRcFKiNZvY/uaRFPjPP/9zHVp7sztXKbCFkvk1drUt4XsPIEjLe/fKBFfqMifCgaCx2 OP7zOR/b5rfioIcvLIAEjH2qj9pac0pbfvlil2/5sPFcqiRoxh2MJLv564ruLlb2Sujejq2vBIB uwFaYwP4O0Qd6jWxVBeEc1ENLi2+jJdIxI X-Received: by 2002:a05:600c:828f:b0:485:2ce2:4c8a with SMTP id 5b1f17b1804b1-4888355ec67mr57945285e9.1.1775042673055; Wed, 01 Apr 2026 04:24:33 -0700 (PDT) Received: from [127.0.0.1] ([79.133.247.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887aacb99csm43450165e9.1.2026.04.01.04.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 04:24:32 -0700 (PDT) From: Erikas Bitovtas Date: Wed, 01 Apr 2026 14:22:37 +0300 Subject: [PATCH 2/3] iio: light: vcnl4000: drop enum id table in favor of chip structs 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: <20260401-vcnl4000-drop-enum-v1-2-ffd201f0c848@gmail.com> References: <20260401-vcnl4000-drop-enum-v1-0-ffd201f0c848@gmail.com> In-Reply-To: <20260401-vcnl4000-drop-enum-v1-0-ffd201f0c848@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Erikas Bitovtas X-Mailer: b4 0.14.3 Instead of creating an enum table with chip IDs, store pointers to structs directly. This drops the association between chip structs and enum IDs and allows for easier addition or removal of new devices. Signed-off-by: Erikas Bitovtas --- drivers/iio/light/vcnl4000.c | 205 +++++++++++++++++++++------------------= ---- 1 file changed, 98 insertions(+), 107 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 72d68d54864e..cbe0a9e056ec 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -185,14 +185,6 @@ static const int vcnl4040_ps_oversampling_ratio[] =3D = {1, 2, 4, 8}; =20 #define VCNL4000_SLEEP_DELAY_MS 2000 /* before we enter pm_runtime_suspend= */ =20 -enum vcnl4000_device_ids { - CM36672P, - VCNL4000, - VCNL4010, - VCNL4040, - VCNL4200, -}; - struct vcnl4200_channel { u8 reg; ktime_t last_measurement; @@ -202,7 +194,6 @@ struct vcnl4200_channel { =20 struct vcnl4000_data { struct i2c_client *client; - enum vcnl4000_device_ids id; int rev; int al_scale; int ps_scale; @@ -237,18 +228,6 @@ struct vcnl4000_chip_spec { const int prod_id; }; =20 -static const struct i2c_device_id vcnl4000_id[] =3D { - { "cm36672p", CM36672P }, - { "cm36686", VCNL4040 }, - { "vcnl4000", VCNL4000 }, - { "vcnl4010", VCNL4010 }, - { "vcnl4020", VCNL4010 }, - { "vcnl4040", VCNL4040 }, - { "vcnl4200", VCNL4200 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, vcnl4000_id); - static int vcnl4000_set_power_state(struct vcnl4000_data *data, bool on) { /* no suspend op */ @@ -1889,82 +1868,84 @@ static const struct iio_info vcnl4040_info =3D { .read_avail =3D vcnl4040_read_avail, }; =20 -static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] =3D { - [CM36672P] =3D { - .prod =3D "CM36672P", - .init =3D vcnl4200_init, - .measure_proximity =3D vcnl4200_measure_proximity, - .set_power_state =3D vcnl4200_set_power_state, - .channels =3D cm36672p_channels, - .num_channels =3D ARRAY_SIZE(cm36672p_channels), - .info =3D &vcnl4040_info, - .irq_thread =3D vcnl4040_irq_thread, - .int_reg =3D VCNL4040_INT_FLAGS, - .ps_it_times =3D &vcnl4040_ps_it_times, - .num_ps_it_times =3D ARRAY_SIZE(vcnl4040_ps_it_times), - .prod_id =3D VCNL4040_PROD_ID, - }, - [VCNL4000] =3D { - .prod =3D "VCNL4000", - .init =3D vcnl4000_init, - .measure_light =3D vcnl4000_measure_light, - .measure_proximity =3D vcnl4000_measure_proximity, - .set_power_state =3D vcnl4000_set_power_state, - .channels =3D vcnl4000_channels, - .num_channels =3D ARRAY_SIZE(vcnl4000_channels), - .info =3D &vcnl4000_info, - .prod_id =3D VCNL4000_PROD_ID, - }, - [VCNL4010] =3D { - .prod =3D "VCNL4010/4020", - .init =3D vcnl4000_init, - .measure_light =3D vcnl4000_measure_light, - .measure_proximity =3D vcnl4000_measure_proximity, - .set_power_state =3D vcnl4000_set_power_state, - .channels =3D vcnl4010_channels, - .num_channels =3D ARRAY_SIZE(vcnl4010_channels), - .info =3D &vcnl4010_info, - .irq_thread =3D vcnl4010_irq_thread, - .trig_buffer_func =3D vcnl4010_trigger_handler, - .buffer_setup_ops =3D &vcnl4010_buffer_ops, - .prod_id =3D VCNL4010_PROD_ID, - }, - [VCNL4040] =3D { - .prod =3D "VCNL4040", - .init =3D vcnl4200_init, - .measure_light =3D vcnl4200_measure_light, - .measure_proximity =3D vcnl4200_measure_proximity, - .set_power_state =3D vcnl4200_set_power_state, - .channels =3D vcnl4040_channels, - .num_channels =3D ARRAY_SIZE(vcnl4040_channels), - .info =3D &vcnl4040_info, - .irq_thread =3D vcnl4040_irq_thread, - .int_reg =3D VCNL4040_INT_FLAGS, - .ps_it_times =3D &vcnl4040_ps_it_times, - .num_ps_it_times =3D ARRAY_SIZE(vcnl4040_ps_it_times), - .als_it_times =3D &vcnl4040_als_it_times, - .num_als_it_times =3D ARRAY_SIZE(vcnl4040_als_it_times), - .ulux_step =3D 100000, - .prod_id =3D VCNL4040_PROD_ID, - }, - [VCNL4200] =3D { - .prod =3D "VCNL4200", - .init =3D vcnl4200_init, - .measure_light =3D vcnl4200_measure_light, - .measure_proximity =3D vcnl4200_measure_proximity, - .set_power_state =3D vcnl4200_set_power_state, - .channels =3D vcnl4040_channels, - .num_channels =3D ARRAY_SIZE(vcnl4000_channels), - .info =3D &vcnl4040_info, - .irq_thread =3D vcnl4040_irq_thread, - .int_reg =3D VCNL4200_INT_FLAGS, - .ps_it_times =3D &vcnl4200_ps_it_times, - .num_ps_it_times =3D ARRAY_SIZE(vcnl4200_ps_it_times), - .als_it_times =3D &vcnl4200_als_it_times, - .num_als_it_times =3D ARRAY_SIZE(vcnl4200_als_it_times), - .ulux_step =3D 24000, - .prod_id =3D VCNL4200_PROD_ID, - }, +static const struct vcnl4000_chip_spec cm36672p_spec =3D { + .prod =3D "CM36672P", + .init =3D vcnl4200_init, + .measure_proximity =3D vcnl4200_measure_proximity, + .set_power_state =3D vcnl4200_set_power_state, + .channels =3D cm36672p_channels, + .num_channels =3D ARRAY_SIZE(cm36672p_channels), + .info =3D &vcnl4040_info, + .irq_thread =3D vcnl4040_irq_thread, + .int_reg =3D VCNL4040_INT_FLAGS, + .ps_it_times =3D &vcnl4040_ps_it_times, + .num_ps_it_times =3D ARRAY_SIZE(vcnl4040_ps_it_times), + .prod_id =3D VCNL4040_PROD_ID, +}; + +static const struct vcnl4000_chip_spec vcnl4000_spec =3D { + .prod =3D "VCNL4000", + .init =3D vcnl4000_init, + .measure_light =3D vcnl4000_measure_light, + .measure_proximity =3D vcnl4000_measure_proximity, + .set_power_state =3D vcnl4000_set_power_state, + .channels =3D vcnl4000_channels, + .num_channels =3D ARRAY_SIZE(vcnl4000_channels), + .info =3D &vcnl4000_info, + .prod_id =3D VCNL4000_PROD_ID, +}; + +static const struct vcnl4000_chip_spec vcnl4010_spec =3D { + .prod =3D "VCNL4010/4020", + .init =3D vcnl4000_init, + .measure_light =3D vcnl4000_measure_light, + .measure_proximity =3D vcnl4000_measure_proximity, + .set_power_state =3D vcnl4000_set_power_state, + .channels =3D vcnl4010_channels, + .num_channels =3D ARRAY_SIZE(vcnl4010_channels), + .info =3D &vcnl4010_info, + .irq_thread =3D vcnl4010_irq_thread, + .trig_buffer_func =3D vcnl4010_trigger_handler, + .buffer_setup_ops =3D &vcnl4010_buffer_ops, + .prod_id =3D VCNL4010_PROD_ID, +}; + +static const struct vcnl4000_chip_spec vcnl4040_spec =3D { + .prod =3D "VCNL4040", + .init =3D vcnl4200_init, + .measure_light =3D vcnl4200_measure_light, + .measure_proximity =3D vcnl4200_measure_proximity, + .set_power_state =3D vcnl4200_set_power_state, + .channels =3D vcnl4040_channels, + .num_channels =3D ARRAY_SIZE(vcnl4040_channels), + .info =3D &vcnl4040_info, + .irq_thread =3D vcnl4040_irq_thread, + .int_reg =3D VCNL4040_INT_FLAGS, + .ps_it_times =3D &vcnl4040_ps_it_times, + .num_ps_it_times =3D ARRAY_SIZE(vcnl4040_ps_it_times), + .als_it_times =3D &vcnl4040_als_it_times, + .num_als_it_times =3D ARRAY_SIZE(vcnl4040_als_it_times), + .ulux_step =3D 100000, + .prod_id =3D VCNL4040_PROD_ID, +}; + +static const struct vcnl4000_chip_spec vcnl4200_spec =3D { + .prod =3D "VCNL4200", + .init =3D vcnl4200_init, + .measure_light =3D vcnl4200_measure_light, + .measure_proximity =3D vcnl4200_measure_proximity, + .set_power_state =3D vcnl4200_set_power_state, + .channels =3D vcnl4040_channels, + .num_channels =3D ARRAY_SIZE(vcnl4000_channels), + .info =3D &vcnl4040_info, + .irq_thread =3D vcnl4040_irq_thread, + .int_reg =3D VCNL4200_INT_FLAGS, + .ps_it_times =3D &vcnl4200_ps_it_times, + .num_ps_it_times =3D ARRAY_SIZE(vcnl4200_ps_it_times), + .als_it_times =3D &vcnl4200_als_it_times, + .num_als_it_times =3D ARRAY_SIZE(vcnl4200_als_it_times), + .ulux_step =3D 24000, + .prod_id =3D VCNL4200_PROD_ID, }; =20 static const struct iio_trigger_ops vcnl4010_trigger_ops =3D { @@ -1991,7 +1972,6 @@ static int vcnl4010_probe_trigger(struct iio_dev *ind= io_dev) =20 static int vcnl4000_probe(struct i2c_client *client) { - const struct i2c_device_id *id =3D i2c_client_get_device_id(client); const char * const regulator_names[] =3D { "vdd", "vio", "vled" }; struct device *dev =3D &client->dev; struct vcnl4000_data *data; @@ -2005,8 +1985,7 @@ static int vcnl4000_probe(struct i2c_client *client) data =3D iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client =3D client; - data->id =3D id->driver_data; - data->chip_spec =3D &vcnl4000_chip_spec_cfg[data->id]; + data->chip_spec =3D i2c_get_match_data(client); =20 ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names), regulator_names); @@ -2081,32 +2060,32 @@ static int vcnl4000_probe(struct i2c_client *client) static const struct of_device_id vcnl_4000_of_match[] =3D { { .compatible =3D "capella,cm36672p", - .data =3D (void *)CM36672P, + .data =3D &cm36672p_spec, }, /* Capella CM36686 is fully compatible with Vishay VCNL4040 */ { .compatible =3D "capella,cm36686", - .data =3D (void *)VCNL4040, + .data =3D &vcnl4040_spec, }, { .compatible =3D "vishay,vcnl4000", - .data =3D (void *)VCNL4000, + .data =3D &vcnl4000_spec, }, { .compatible =3D "vishay,vcnl4010", - .data =3D (void *)VCNL4010, + .data =3D &vcnl4010_spec, }, { .compatible =3D "vishay,vcnl4020", - .data =3D (void *)VCNL4010, + .data =3D &vcnl4010_spec, }, { .compatible =3D "vishay,vcnl4040", - .data =3D (void *)VCNL4040, + .data =3D &vcnl4040_spec, }, { .compatible =3D "vishay,vcnl4200", - .data =3D (void *)VCNL4200, + .data =3D &vcnl4200_spec, }, { } }; @@ -2148,6 +2127,18 @@ static int vcnl4000_runtime_resume(struct device *de= v) static DEFINE_RUNTIME_DEV_PM_OPS(vcnl4000_pm_ops, vcnl4000_runtime_suspend, vcnl4000_runtime_resume, NULL); =20 +static const struct i2c_device_id vcnl4000_id[] =3D { + { "cm36672p", (kernel_ulong_t)&cm36672p_spec }, + { "cm36686", (kernel_ulong_t)&vcnl4040_spec }, + { "vcnl4000", (kernel_ulong_t)&vcnl4000_spec }, + { "vcnl4010", (kernel_ulong_t)&vcnl4010_spec }, + { "vcnl4020", (kernel_ulong_t)&vcnl4010_spec }, + { "vcnl4040", (kernel_ulong_t)&vcnl4040_spec }, + { "vcnl4200", (kernel_ulong_t)&vcnl4200_spec }, + { } +}; +MODULE_DEVICE_TABLE(i2c, vcnl4000_id); + static struct i2c_driver vcnl4000_driver =3D { .driver =3D { .name =3D VCNL4000_DRV_NAME, --=20 2.52.0