From nobody Sat Feb 7 10:44:43 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 7DE85287259 for ; Fri, 23 Jan 2026 18:22:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769192544; cv=none; b=qAdHsmxGqVvXgn/wViW5yF9LxEBNYH76vt7Zizuu4VwgSWRhaq+dtOzU02xRbaNm9yEiMQ6ROaF4iNvRadtjaD/NynhzHVOWjCOTHgxKPZK0PbxWckMYzKfB8NC52f7tf0gcm21DBNl++giV4GhVQsX/pH6raSNsmV3+jhAqlmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769192544; c=relaxed/simple; bh=pjFIKTAcgTOMhK443dH8yu6xajqx4n3WaCh4sL4FWoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UlrFiLvYrfpWS+ZI+SdiLLA99QXdqGtz9JctyjA7oKT167r8SNRYry9xzo3MbbS2pWWtAvBeHGx//o0sPtUMYWLMrQLXg7DUv2gGZGvI1pEeA6V4svZVv1WSESI5veTsad3Am2yCocZ3eUsMEe/KRct0f6mKrvl12Q0QyK6nrxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Up1OdfDR; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net 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="Up1OdfDR" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2a0a95200e8so16903195ad.0 for ; Fri, 23 Jan 2026 10:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769192542; x=1769797342; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=tkJ+o7BV1rRzeunFqGJvREeRYIZ540q5bogHmtrFmU0=; b=Up1OdfDRtohvyuQcuiOAdUbFqFjcsjm87NrZxt3eiKlPB4Ub9imIALghoZ0m/d/Mj2 CScoz34F5UfUW/Lg0i+q27avIJpkFq2SNMgizAsNKM3QX6vux83O0EUam9oeA8U//W/b qx1oR3nbbJr+bj5bW39sotrqUK5pnWJVq2hbS9nIEsgwa2zWdrSh7ip4dgrkB6KadHbM kyZ84eZ7rdyAzSfOx5y9bQLzcr2GCI82DE1yXzeGIm4yGS4LBNlpm9PRUHnAVtf3G4fz dPsNU6RdQrpYFULO471Gw5gnJJQhM93djan0srDG+hazXaE79RKFHuG3Z0RmKDokHmrt AlBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769192542; x=1769797342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tkJ+o7BV1rRzeunFqGJvREeRYIZ540q5bogHmtrFmU0=; b=JPZmgV3HxqA8x0xr9DE073/B6Wxg2tLmD5iv84KAMutDKKFaG5ujuoVtSKJ5fQcL1l ctRzbJwpvL0FGFhMtaVBv9XzFnS+8lG+oS0f/sIzYZiyKHoSzo5KsjrfJ1TolAFKsSy1 Pah1Qd+jj66dpk455GLlbfI81TUUmON4y+tMEFO9nVClb1l08LqlvNm+wbCwHBoqUalX Dc9+ODQqJOGu1AIle9Nhs6WJY4KPU2JxAcWwYUrRoxwjEdwqyomiTcxb2AG2oWdT6KZH BuzSpoRm+E57UFicu1Lv6/9srW3gT/eE7VshJdOSnI+K+tXpqapnvb8ZgqwSc/CngcMH IKjA== X-Forwarded-Encrypted: i=1; AJvYcCWAcR7yY+/l81mijXlKJ+kdlYnA3hTujNtikkbmqE+9p/MnaH+aaFhoVbEQrE/NxoAukbFzWGE6FskJVIs=@vger.kernel.org X-Gm-Message-State: AOJu0YzMPANbGqwQDsPeISvnRl+hVNUZ9rOE2ex2rakB6Y5f3qiaXaLg m6YW81Puwf3/dFThlFtip9m43u+LPOOIpy11JcPQwdy1l5z28BtmC3cA X-Gm-Gg: AZuq6aJwZATma8QqFK0tXFU1fF10Q15CyYau7sj+TvQ35ybGXqbHWUE5WK7HEBZkN7L wcspBEpZ8Zqt5AHLz8rrWEe8+VgdEiQ5slPlOiDT8Z2e1lVq8LtqjNDznTFy/C1/sapehJHSZ4p D0D6gUovgfOH6AKDvIh9LwBPFtFfR1iU5KknSB2CBnorluymsZ4rQybSW6MLFkebvs07HumfoF7 rYsN4RWsjT4vEVvRIMzBBF3gQ6bwW7U8i2ug6bq63QFyxCmXXqDYdZTN/C9ZLlaST9/4KXEy1SQ 4946ixZCyXemDRakwa54BAsyKlionl4XrU9MD9pPwrE/sgIMcgqEqmQKYyMUrqXsuTMQEiYHzNo QQ5+HkCMLF3ZePOcXiBn4mSwEMFUKr4usj8dRUegViVhX3IuCbHFGDHZpw3NQgjQXdlI2um3EU6 kVQypDuMZOUi9vPVY0I2EYuwAn X-Received: by 2002:a17:903:2443:b0:2a0:b62e:e016 with SMTP id d9443c01a7336-2a7fe625081mr32543535ad.32.1769192541799; Fri, 23 Jan 2026 10:22:21 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a802fb03dfsm25604715ad.75.2026.01.23.10.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 10:22:20 -0800 (PST) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jaroslav Pulchart , "Rafael J . Wysocki" , lihuisong , Guenter Roeck Subject: [PATCH RFT 4/5] hwmon: Implement hwmon_update_groups() Date: Fri, 23 Jan 2026 10:22:07 -0800 Message-ID: <20260123182208.2229670-5-linux@roeck-us.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260123182208.2229670-1-linux@roeck-us.net> References: <20260123182208.2229670-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some situations the visibility of hwmon sysfs attributes may change. Support this by providing a new API function hwmon_update_groups() to update both visible attributes and thermal zones. Signed-off-by: Guenter Roeck --- Documentation/hwmon/hwmon-kernel-api.rst | 8 ++++++++ drivers/hwmon/hwmon.c | 24 ++++++++++++++++++++++++ include/linux/hwmon.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/Documentation/hwmon/hwmon-kernel-api.rst b/Documentation/hwmon= /hwmon-kernel-api.rst index 1d7f1397a827..a41b1038fbf0 100644 --- a/Documentation/hwmon/hwmon-kernel-api.rst +++ b/Documentation/hwmon/hwmon-kernel-api.rst @@ -42,6 +42,8 @@ register/unregister functions:: =20 char *devm_hwmon_sanitize_name(struct device *dev, const char *name); =20 + int hwmon_update_groups(struct device *dev); + void hwmon_lock(struct device *dev); void hwmon_unlock(struct device *dev); =20 @@ -89,6 +91,12 @@ for other functions such as interrupt handlers or for at= tributes which are fully implemented in the driver, hwmon_lock() and hwmon_unlock() can be us= ed to ensure that calls to those functions are serialized. =20 +If the visibility of sysfs attributes changes during runtime, the driver +needs to call hwmon_update_groups() with the hwmon device as parameter +to update attribute visibility. If the driver registered thermal zones +using hwmon_device_register_with_info() and the visibility of thermal +sensors changes, this call will also update thermal zones as needed. + Using devm_hwmon_device_register_with_info() -------------------------------------------- =20 diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index cb89218a0b6a..9163b8290dbe 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -330,6 +330,11 @@ static int hwmon_thermal_register_sensors(struct devic= e *dev) return hwmon_thermal_handle_sensors(dev, false); } =20 +static int hwmon_thermal_update_sensors(struct device *dev) +{ + return hwmon_thermal_handle_sensors(dev, true); +} + static void hwmon_thermal_notify(struct device *dev, int index) { struct hwmon_thermal_data *tzdata =3D hwmon_thermal_find_tz(dev, index); @@ -799,6 +804,25 @@ static const int __templates_size[] =3D { [hwmon_intrusion] =3D ARRAY_SIZE(hwmon_intrusion_attr_templates), }; =20 +int hwmon_update_groups(struct device *dev) +{ + struct hwmon_device *hwdev =3D to_hwmon_device(dev); + const struct hwmon_chip_info *chip =3D hwdev->chip; + const struct hwmon_channel_info * const *info; + int ret; + + ret =3D sysfs_update_groups(&dev->kobj, dev->groups); + if (ret || !chip) + return ret; + + info =3D chip->info; + if (info[0]->type !=3D hwmon_chip || !(info[0]->config[0] & HWMON_C_REGIS= TER_TZ)) + return 0; + + return hwmon_thermal_update_sensors(dev); +} +EXPORT_SYMBOL_GPL(hwmon_update_groups); + int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel) { diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index 301a83afbd66..8cadba24ed4b 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -492,6 +492,8 @@ int hwmon_notify_event(struct device *dev, enum hwmon_s= ensor_types type, char *hwmon_sanitize_name(const char *name); char *devm_hwmon_sanitize_name(struct device *dev, const char *name); =20 +int hwmon_update_groups(struct device *dev); + void hwmon_lock(struct device *dev); void hwmon_unlock(struct device *dev); =20 --=20 2.45.2