From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.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 A7D152D0603 for ; Sun, 5 Apr 2026 16:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775405338; cv=none; b=SXGxh2hBAWOIawhmsadvUWlPc5eQxJStPBDHv9ic2UucSBCIIFEy7A0NCmnfAg4EwLMQLCYAZlPF3kV3GHo5jwpLfaObIV720JdlDUPw1agadAz+pMLCf9VtWP34dqdZEDBgv3En/dG6MX0L2kSZVo+tXLbrXdufOCEiRW3K40g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775405338; c=relaxed/simple; bh=VpvLA2sk63soR8le8LkGKvWDcGPULDAGakl1/zSX0wQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SrRnTz8qYqM6y9pv9oAUaHkm5V9Bt0AV5aX9BdlJpdLDWmbjK/Shff7OFlmRD/Y2amOsFzpoJgCsi/U6VheyGxoMjzy5LiZPL2OTE5IRSmF17WMwyENcnmLhCPVYCJMc3PSp3a/ig+/u5BmzR0A3I7TSYqgpmcpkbxSZ1O16i6U= 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=RhD1iX54; arc=none smtp.client-ip=209.85.208.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="RhD1iX54" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-66bb66db39dso5018886a12.0 for ; Sun, 05 Apr 2026 09:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775405335; x=1776010135; 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=ywiInDy1yFOYubYwYax/CzV6b7EwEWTvrFn7OFi+978=; b=RhD1iX54mHKXXFOwg6ZbBG3LTMm7g4soocxqJeirvPlmxn1/SKAvcK9m7WOYR/b9Lc Hjx4qRY5TeQ/bf+O/ceW3bukI2H5QrMX6PU8PGlvikWo/4m4HejA5Ne9saXoEF0zkcSl yVCbtDqjMqP2WezuoFQXBXGJ2crbN1981YUW1wwwCmAFVHakyt4XfQJeJzavG0fbydAj QRQdOhoCjVX9y0EvZF/wDIrGmT7/0UTZ2VkuxqFftP4nv+h69uy0araxFBDHM/TORAo0 ix2RxJ1KyiankQhVId9V8rB+M2p4aq2z9x4wKs3TfCqZxm/AfN30m/jJ7yqmAqcsCwTD 2jMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775405335; x=1776010135; 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=ywiInDy1yFOYubYwYax/CzV6b7EwEWTvrFn7OFi+978=; b=G5XAt4ec2zcPILWx6p6fNLYHKS00+K1GIFLdaPuEdYnvg64DMIAsj18sZfQ2Us/xf8 SEXgHPiPl4RE+n7QuyvJevIzC6oAr6+oiwLZ5WGoLWUDdyls8zAoCjwqW3MWejTq8QmI e1QdNjBVsQpnk41yD6n4/YPfFdx1PVbhk5tt1piGaKBurqEVrROYXCqn6MjLDmQi3jpo TZ1CrO/IPSDVS1/D56xHUZWX1mtJj0FOPoMpUIxxWqj+hZZqVKuwhhAhIls4gTxWh4s7 O4bydRmrchpPFKM1cdP8s48ywppe88qsn3hcE5fdkEiw+2VV4d4up9W4spsK8g7SivMn 4zXQ== X-Forwarded-Encrypted: i=1; AJvYcCViKdZcQpzCKPm236yxWT3BAYrrLqxEDjls1+iYsmxSkmr9bOkVsjU7ov4QL2GUZaQgjL+QqOkwJZhdHxI=@vger.kernel.org X-Gm-Message-State: AOJu0YzX48egJ5Jqq5f/By1qZKsThBL4WItm1lZyaOJWvRN1Mwxm9mZt ocAJ9bp4R5UHIdrMVFBsJFtegjo+hPdbg12KK7d0yFCzlOsGr7mmMpWs X-Gm-Gg: AeBDievutxZFTPgDXvJAJ+VI6FkO3h5Gj/4shWgfj7dg+DJAAM9V2hr1efnF1TPrvZy Tozm/gDtPbSAcn4+qfArb7fHWHz7pLN0ZfL7vNaYkCffBqg63SqB03WSxfwZvkUaAHHUSg2lcND iABDbGXOLUPVHeG2c8k7KZqQy472XOVvDXF2Sh70QGx8UFtvdnYk2qYeKxDez2LR60esLhQgJth qEWWD0qilA/rSuW6JGS+SlxBRmKVn7jLlyLymV9YzSInGGbPOwY2adIMhdFcR9j5pUknAQwvK+Z U/Y9RldTTRab4nQsr0gOi92XpQ/eYNNOgU5yfe/yYO70Rd4ND1RlKV9AyJu6y7SfMbiL+kQLfNE sLRGBSpe4I1BWEGi9euODcli5fgvdiiEx3CgKeb8d6MmxFrTSNLOIXsjgeqlyg17e2YQAnTx22B lVjrNSk2miT0l9aoHE6mWObuEz+Q== X-Received: by 2002:a05:6402:1ecb:b0:66e:f4c0:c077 with SMTP id 4fb4d7f45d1cf-66ef4c0c17bmr327308a12.16.1775405335015; Sun, 05 Apr 2026 09:08:55 -0700 (PDT) Received: from [192.168.0.39] ([79.133.247.80]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-66e02f389absm3195890a12.13.2026.04.05.09.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 09:08:54 -0700 (PDT) From: Erikas Bitovtas Date: Sun, 05 Apr 2026 19:08:38 +0300 Subject: [PATCH v2 1/6] iio: light: vcnl4000: validate device by prod ID instead of table ID 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: 7bit Message-Id: <20260405-vcnl4000-drop-enum-v2-1-7c8dc98c3974@gmail.com> References: <20260405-vcnl4000-drop-enum-v2-0-7c8dc98c3974@gmail.com> In-Reply-To: <20260405-vcnl4000-drop-enum-v2-0-7c8dc98c3974@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.15.1 Add a new field for vcnl4000_chip_spec and check if we have the right device by that instead of the index from enum table. This leaves the enum table being used only for picking the right vcnl4000_chip_spec, allowing us to drop it later on. Signed-off-by: Erikas Bitovtas --- drivers/iio/light/vcnl4000.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 9650dbc41f2b..72d68d54864e 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -234,6 +234,7 @@ struct vcnl4000_chip_spec { const int(*als_it_times)[][2]; const int num_als_it_times; const unsigned int ulux_step; + const int prod_id; }; static const struct i2c_device_id vcnl4000_id[] = { @@ -265,12 +266,12 @@ static int vcnl4000_init(struct vcnl4000_data *data) prod_id = ret >> 4; switch (prod_id) { case VCNL4000_PROD_ID: - if (data->id != VCNL4000) + if (data->chip_spec->prod_id != VCNL4000_PROD_ID) dev_warn(&data->client->dev, "wrong device id, use vcnl4000"); break; case VCNL4010_PROD_ID: - if (data->id != VCNL4010) + if (data->chip_spec->prod_id != VCNL4010_PROD_ID) dev_warn(&data->client->dev, "wrong device id, use vcnl4010/4020"); break; @@ -1901,6 +1902,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .int_reg = VCNL4040_INT_FLAGS, .ps_it_times = &vcnl4040_ps_it_times, .num_ps_it_times = ARRAY_SIZE(vcnl4040_ps_it_times), + .prod_id = VCNL4040_PROD_ID, }, [VCNL4000] = { .prod = "VCNL4000", @@ -1911,6 +1913,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .channels = vcnl4000_channels, .num_channels = ARRAY_SIZE(vcnl4000_channels), .info = &vcnl4000_info, + .prod_id = VCNL4000_PROD_ID, }, [VCNL4010] = { .prod = "VCNL4010/4020", @@ -1924,6 +1927,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .irq_thread = vcnl4010_irq_thread, .trig_buffer_func = vcnl4010_trigger_handler, .buffer_setup_ops = &vcnl4010_buffer_ops, + .prod_id = VCNL4010_PROD_ID, }, [VCNL4040] = { .prod = "VCNL4040", @@ -1941,6 +1945,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .als_it_times = &vcnl4040_als_it_times, .num_als_it_times = ARRAY_SIZE(vcnl4040_als_it_times), .ulux_step = 100000, + .prod_id = VCNL4040_PROD_ID, }, [VCNL4200] = { .prod = "VCNL4200", @@ -1958,6 +1963,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .als_it_times = &vcnl4200_als_it_times, .num_als_it_times = ARRAY_SIZE(vcnl4200_als_it_times), .ulux_step = 24000, + .prod_id = VCNL4200_PROD_ID, }, }; -- 2.53.0