From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 2A5EE394492 for ; Mon, 13 Jul 2026 07:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783928794; cv=none; b=WCtBmk5HLVlqZl33pRjw6apCiS5MHiKdu1Ci1MgCUsosbuJxYj+ltXPbVY+eoHo8BQFrqjGGPsAoQlZkJXYAYBSJ2fK5YCDkoQIBc3qnMcRuojIwcCO0JKVRXYRWVzRP3chcO0+0mjoK3vc6VvivvkrylgZm78LYKa7v/ocgPpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783928794; c=relaxed/simple; bh=qNUzWMILPAZO0p4szJmpre9sZOFFrs7wKaz01ErPF64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m5pll7kOKVFFLH6eZZkMc20JDv3yxPSNSzX+ujTIdgVTTS//XUjhbTN8WkEnHKGIvXgjTit+fTVZb9uDbz5EMLRDhMA0eD94/t3+aDFOPinzRukXlzAA9gr/5T0SmG5boirM/K0vtScUPzX9CXQTSwpqJfyt1rMWycLZmKUcXqU= 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=JeYFemyg; arc=none smtp.client-ip=209.85.214.169 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="JeYFemyg" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2cedda2ce6fso1173505ad.1 for ; Mon, 13 Jul 2026 00:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783928792; x=1784533592; 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=ekqLWa6qOCBXZnPyawtHFyqbZUfQTxYgXo+F6hxou6w=; b=JeYFemygWih8CNTk/rn7JCSEDqhYr5hIReKF/CVYGudemfie6i/5/ocI1VT5xBdnss WFSG43PSUuqSsMExtWsTuI6/HGG+ZmKa1yjtYN+D3fxsMZEkTQA56Q3l8uhRsFurDaDT MqTl5MaeVcjZBE4rdLPVhRoBKLBopOgQkFReMibWk7RTDio5Q2lps3sR3GNNVdgFs9Ht mRtwfbq6vF/2vmX3iQlBcHzkgcQXaq9vtagxTse2ixEmycZdRtwci1VwXYhju6A8+VGm MHb21+WCUyv85EYDVKE16yj0EfOVE5WkSWQmpoTyZ+WpeFOafVuSSIy8UGzPrMH0vdCO Miqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783928792; x=1784533592; 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=ekqLWa6qOCBXZnPyawtHFyqbZUfQTxYgXo+F6hxou6w=; b=oZ3zrUvM1eeqbso+tQMPvzWKuebgIngUUE/GUkjW1+J57BJPovYBEcgu2xOr4zgLJL Lj+mraMKgCwj2QFHYhxiw6zJLhpFMuPsLT1fgEPssGI336rCARB3TzQJ/wAhHYL5wjJm otp7dzyk3zI5/0nMBay43t15nSN8FIY868bw2J/dDnWm11WjomT3H+lRAwZbN2ThSNYF 6g66mEbEMeQCl2m5kMGovsaXEBvqp40dnheYUDFOID4oaMJ/Ny83zn/h4Thzhjvp8aF5 rHhkdbursS5jTN7SwnBTgz31psdJ7KOc3SCOrg29XgWXirdk6wE4kKxDayvjMX6gIeSi EJZg== X-Forwarded-Encrypted: i=1; AHgh+RrsoyZRoOzrXO1YBU6sKokRiE42WoTgGAu4yOCKjY3Awe8AFNri0BSLe3am6TPRuGVzgVoYLuOZuGyAqpw=@vger.kernel.org X-Gm-Message-State: AOJu0YylIpRk6YruCHvYASd0RaOb7e/x1VtB07T8ByfWY3+M1x6n2WCi tl3gNzRI9V0ofB28qJT8D+pNIOnPRFEWr77pi0VBq5NswiM934hyKgt7 X-Gm-Gg: AfdE7clElBiBavooSHjWSZRtHLto6jNwaYUKFXh2hyINujUTR2tLABD5Zrubzgc77Fe 78UwLyYQJQcyeXG1tPfTULxlGDYUce3FPEYcbnCmYTK8iX92XitfS+pRqM5QT9lHV9B4gyzo1wr fmtsCqAbvO5ar6m9V/1tPdRkJM0z5pF5pmLFumQxnrdI34y7tofgWfyKcAG5n9Fwar1HDyZ8VuX 3Qy79/zhLgq53z5ITVIpVtRPsyZJxG/XY9vIu4pzwLnsh5H3nkCIEViTQdes4UIb3maImhNeqOb OtSRdaOtAWX6HzVI6ZzlZuOAofEA0uiNKRUQIX78ZX3O7U0mV8ogb2IgTjL1vCoS1XyAiP8Eibj 4/TnW1dJoxLkRYoslMWj/7qvTRdR9NMnALEkzkx/M1k0GG58T/R8aGmhNsrr8sa5vhJBkLNAZBu bvMDIDPlomyIbmM5i3XS1ZuQ== X-Received: by 2002:a17:902:d988:b0:2ca:bad4:33a2 with SMTP id d9443c01a7336-2ce9e9ac01emr86979945ad.11.1783928791635; Mon, 13 Jul 2026 00:46:31 -0700 (PDT) Received: from HP.localdomain ([27.217.83.168]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9d5bde9sm94960105ad.79.2026.07.13.00.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 00:46:31 -0700 (PDT) From: Zaixiang Xu To: Guenter Roeck Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zaixiang Xu Subject: [PATCH v7 3/4] hwmon: (sht3x) Add devicetree support Date: Mon, 13 Jul 2026 15:45:58 +0800 Message-Id: <20260713074559.12196-4-zaixiang.xu.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713074559.12196-1-zaixiang.xu.dev@gmail.com> References: <20260713074559.12196-1-zaixiang.xu.dev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add an of_device_id table to support devicetree based instantiation of the supported sensors. The devicetree binding models all higher accuracy parts with a fallback to the base part of their group, so only the two base compatibles need to be listed. The match data distinguishes the humidity and temperature parts (SHT3x) from the temperature-only parts (STS3x), which require different configuration. Start enum sht3x_chips at 1: with sht3x equal to 0, the OF match data for the SHT devices would be NULL, causing i2c_get_match_data() to fall back to i2c_device_id name matching, which fails for devicetree names. The devices would then only work because the resulting chip id 0 happens to equal sht3x. Non-zero match data avoids relying on that coincidence. Signed-off-by: Zaixiang Xu --- drivers/hwmon/sht3x.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index c2f6b73aa7f3..6d47cfd340f8 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -61,7 +61,7 @@ static const unsigned char sht3x_cmd_read_serial_number[] = { 0x37, 0x80 }; #define SHT3X_MAX_HUMIDITY 100000 enum sht3x_chips { - sht3x, + sht3x = 1, sts3x, }; @@ -939,8 +939,19 @@ static const struct i2c_device_id sht3x_ids[] = { MODULE_DEVICE_TABLE(i2c, sht3x_ids); +static const struct of_device_id sht3x_of_match[] = { + { .compatible = "sensirion,sht30", .data = (void *)(uintptr_t)sht3x }, + { .compatible = "sensirion,sts30", .data = (void *)(uintptr_t)sts3x }, + { } +}; + +MODULE_DEVICE_TABLE(of, sht3x_of_match); + static struct i2c_driver sht3x_i2c_driver = { - .driver.name = "sht3x", + .driver = { + .name = "sht3x", + .of_match_table = sht3x_of_match, + }, .probe = sht3x_probe, .id_table = sht3x_ids, }; -- 2.34.1