From nobody Thu Aug 27 01:20:22 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E652A3AD51C; Thu, 6 Aug 2026 06:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996558; cv=none; b=lDO+NWfY6bYJTjxvF10VHJFqSdPtNWLHBXLFwolBAXbeb0GyZJxep8fvWjd49YBn3pkm/t6WXr9IjjnnHTca+QvlQdc/6aIvxJsAhsBdRNgP7SJ5lNu1CaZYun6qr8Kln+YRo0q3nU3qTkkiAANyNs7a60efKJADcYfWi/DZsfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996558; c=relaxed/simple; bh=rCxRUSaMWLbQLn6N+pcEVJwlZ0QBqb1hNTJLsJijcLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z8iT46n9D2eF3kD5uuNH37Ffz5im5JIYvhRw/tB1SSymO1BfmYbT+vFG34xabgFPNXDHm+YZuMYR/4pnd43WHK7YQRGeO/xbbmL/UAgvwzCXqZTaHwTtd9HRFkXbijXjC06ezcmddMXYX0IDhQsgEMFvT+RX62uBYgoZ0IeBOpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=YH0risMH; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="YH0risMH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1785996553; bh=rCxRUSaMWLbQLn6N+pcEVJwlZ0QBqb1hNTJLsJijcLU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YH0risMHeeQhrmpzOseiDakql/XCjxfc5+9+TVfP3U8KqBkypPTh2+yNiC13ELgaL 9TO/khvXmMp4qoZhpna69siOaYDgXAhw3t9dRN7tnkK2cpH90a1IS0tYY6N7lltE+9 Xki3k7axs6DqgshOW76s5hdtHdqKgWG31Z5/d3vE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 06 Aug 2026 08:09:11 +0200 Subject: [PATCH v2 1/3] hwmon: (core) Constify device attributes 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: <20260806-sysfs-const-attr-hwmon-v2-1-22fee8b85509@weissschuh.net> References: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> In-Reply-To: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1785996552; l=1906; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=rCxRUSaMWLbQLn6N+pcEVJwlZ0QBqb1hNTJLsJijcLU=; b=QemP7Krd0Py7t4hamT7LzPfJr8XxJKJ9LIT8pt+NZs0wNwNYUIfZqmdVarvgZZTleTcYc1OZf MP8Mydh89QrDBdRidg4ylGrBI1mLz+gHsYB5A7cAtJhQVSZIFDS6RR2 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Mark the attribute structures as const, as they are never modified. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/hwmon/hwmon.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 55a9a3ddd4aa..84108a16ef60 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -71,27 +71,27 @@ struct hwmon_thermal_data { }; =20 static ssize_t -name_show(struct device *dev, struct device_attribute *attr, char *buf) +name_show(struct device *dev, const struct device_attribute *attr, char *b= uf) { return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->name); } -static DEVICE_ATTR_RO(name); +static const DEVICE_ATTR_RO(name); =20 static ssize_t -label_show(struct device *dev, struct device_attribute *attr, char *buf) +label_show(struct device *dev, const struct device_attribute *attr, char *= buf) { return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->label); } -static DEVICE_ATTR_RO(label); +static const DEVICE_ATTR_RO(label); =20 -static struct attribute *hwmon_dev_attrs[] =3D { +static const struct attribute *const hwmon_dev_attrs[] =3D { &dev_attr_name.attr, &dev_attr_label.attr, NULL }; =20 static umode_t hwmon_dev_attr_is_visible(struct kobject *kobj, - struct attribute *attr, int n) + const struct attribute *attr, int n) { struct device *dev =3D kobj_to_dev(kobj); struct hwmon_device *hdev =3D to_hwmon_device(dev); @@ -106,8 +106,8 @@ static umode_t hwmon_dev_attr_is_visible(struct kobject= *kobj, } =20 static const struct attribute_group hwmon_dev_attr_group =3D { - .attrs =3D hwmon_dev_attrs, - .is_visible =3D hwmon_dev_attr_is_visible, + .attrs_const =3D hwmon_dev_attrs, + .is_visible_const =3D hwmon_dev_attr_is_visible, }; =20 static const struct attribute_group *hwmon_dev_attr_groups[] =3D { --=20 2.55.0 From nobody Thu Aug 27 01:20:22 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E65BF3AD525; Thu, 6 Aug 2026 06:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996557; cv=none; b=jhsWgqVv9KUY7s9vNvn3diwrH902mrZq6mVeBUNh1sV9PoW/hh0QIwlzMfZNlnUR0ALA2JOVukDn+TPS5s18p+pmmrpzQesCVpjkqf4CjDS4tBnnU8AJa7j40o6Mq+w1ak6S/E3q6GuoUt51kfBh0McBQ4eoi3TIvWdMoraN9dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996557; c=relaxed/simple; bh=hOR1T775ofVcH8arb7Vd0lW6mldP5yfQgdSPBSRI9KU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bkjUiiyg2j42qBY9YNJgtBhHMe2HBVuv4pQ+GJjiEHwv/FQgpCtqPiUg+aZrUBL2rTCf99KLc2ZkIX9WD0kEak3zoZ+utYNk7ZI6oICDHMwKrm9EhkA9eg0hIOhl0fyFAPxzAHQCgl4aJNEJBtruk/Z4RIDBeWoag6+iic62/5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=jVJ1FLDz; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="jVJ1FLDz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1785996554; bh=hOR1T775ofVcH8arb7Vd0lW6mldP5yfQgdSPBSRI9KU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jVJ1FLDzLOw6iA8DsgijNIu0NASpskX3Jacwwx8OYXax/cWUn5TF/I6JDs0XSq6HH mX2RDoPd5nqvH5A+NLcfpSWIlBBTgtbb7IHaNSWL2cWv0F7GRKoW+RrVLqfPp9N/qQ eJEZTu78a5pT5NOs/EV1rXG0xAyOOlEkkIjkgpNo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 06 Aug 2026 08:09:12 +0200 Subject: [PATCH v2 2/3] hwmon: (core) Use const APIs for the dynamically allocated sysfs attributes 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: <20260806-sysfs-const-attr-hwmon-v2-2-22fee8b85509@weissschuh.net> References: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> In-Reply-To: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1785996552; l=5961; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=hOR1T775ofVcH8arb7Vd0lW6mldP5yfQgdSPBSRI9KU=; b=GLmvgC/Nf2lc/PfEY68eFc7mBz+n6da/3jy76wh+a9b4n8Zr+rs6LCAB8/212AQSqnNiq1KMo kXgOQPIuGPpCOQiBwjEBawW3GfEZ7IqeCF5tZCjjXt7w8z5mkve+grm X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The non-const sysfs attribute APIs are going to go away at some point. Switch to the const variants to prepare for that. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/hwmon/hwmon.c | 54 +++++++++++++++++++++++++----------------------= ---- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 84108a16ef60..90ceb815f43e 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -57,8 +57,8 @@ struct hwmon_device_attribute { }; =20 #define to_hwmon_attr(d) \ - container_of(d, struct hwmon_device_attribute, dev_attr) -#define to_dev_attr(a) container_of(a, struct device_attribute, attr) + container_of_const(d, struct hwmon_device_attribute, dev_attr) +#define to_dev_attr(a) container_of_const(a, struct device_attribute, attr) =20 /* * Thermal zone information @@ -115,13 +115,13 @@ static const struct attribute_group *hwmon_dev_attr_g= roups[] =3D { NULL }; =20 -static void hwmon_free_attrs(struct attribute **attrs) +static void hwmon_free_attrs(const struct attribute *const *attrs) { int i; =20 for (i =3D 0; attrs[i]; i++) { - struct device_attribute *dattr =3D to_dev_attr(attrs[i]); - struct hwmon_device_attribute *hattr =3D to_hwmon_attr(dattr); + const struct device_attribute *dattr =3D to_dev_attr(attrs[i]); + const struct hwmon_device_attribute *hattr =3D to_hwmon_attr(dattr); =20 kfree(hattr); } @@ -132,8 +132,8 @@ static void hwmon_dev_release(struct device *dev) { struct hwmon_device *hwdev =3D to_hwmon_device(dev); =20 - if (hwdev->group.attrs) - hwmon_free_attrs(hwdev->group.attrs); + if (hwdev->group.attrs_const) + hwmon_free_attrs(hwdev->group.attrs_const); kfree(hwdev->groups); kfree(hwdev->label); kfree(hwdev); @@ -425,9 +425,9 @@ static int hwmon_pec_register(struct device *hdev) /* sysfs attribute management */ =20 static ssize_t hwmon_attr_show(struct device *dev, - struct device_attribute *devattr, char *buf) + const struct device_attribute *devattr, char *buf) { - struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); + const struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); struct hwmon_device *hwdev =3D to_hwmon_device(dev); s64 val64; long val; @@ -450,10 +450,10 @@ static ssize_t hwmon_attr_show(struct device *dev, } =20 static ssize_t hwmon_attr_show_string(struct device *dev, - struct device_attribute *devattr, + const struct device_attribute *devattr, char *buf) { - struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); + const struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); struct hwmon_device *hwdev =3D to_hwmon_device(dev); enum hwmon_sensor_types type =3D hattr->type; const char *s; @@ -473,10 +473,10 @@ static ssize_t hwmon_attr_show_string(struct device *= dev, } =20 static ssize_t hwmon_attr_store(struct device *dev, - struct device_attribute *devattr, + const struct device_attribute *devattr, const char *buf, size_t count) { - struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); + const struct hwmon_device_attribute *hattr =3D to_hwmon_attr(devattr); struct hwmon_device *hwdev =3D to_hwmon_device(dev); long val; int ret; @@ -510,12 +510,12 @@ static bool is_string_attr(enum hwmon_sensor_types ty= pe, u32 attr) (type =3D=3D hwmon_fan && attr =3D=3D hwmon_fan_label); } =20 -static struct attribute *hwmon_genattr(const void *drvdata, - enum hwmon_sensor_types type, - u32 attr, - int index, - const char *template, - const struct hwmon_ops *ops) +static const struct attribute *hwmon_genattr(const void *drvdata, + enum hwmon_sensor_types type, + u32 attr, + int index, + const char *template, + const struct hwmon_ops *ops) { struct hwmon_device_attribute *hattr; struct device_attribute *dattr; @@ -552,8 +552,8 @@ static struct attribute *hwmon_genattr(const void *drvd= ata, hattr->ops =3D ops; =20 dattr =3D &hattr->dev_attr; - dattr->show =3D is_string ? hwmon_attr_show_string : hwmon_attr_show; - dattr->store =3D hwmon_attr_store; + dattr->show_const =3D is_string ? hwmon_attr_show_string : hwmon_attr_sho= w; + dattr->store_const =3D hwmon_attr_store; =20 a =3D &dattr->attr; sysfs_attr_init(a); @@ -831,7 +831,7 @@ static int hwmon_num_channel_attrs(const struct hwmon_c= hannel_info *info) } =20 static int hwmon_genattrs(const void *drvdata, - struct attribute **attrs, + const struct attribute **attrs, const struct hwmon_ops *ops, const struct hwmon_channel_info *info) { @@ -850,7 +850,7 @@ static int hwmon_genattrs(const void *drvdata, u32 attr; =20 while (attr_mask) { - struct attribute *a; + const struct attribute *a; =20 attr =3D __ffs(attr_mask); attr_mask &=3D ~BIT(attr); @@ -869,11 +869,11 @@ static int hwmon_genattrs(const void *drvdata, return aindex; } =20 -static struct attribute ** +static const struct attribute ** __hwmon_create_attrs(const void *drvdata, const struct hwmon_chip_info *ch= ip) { int ret, i, aindex =3D 0, nattrs =3D 0; - struct attribute **attrs; + const struct attribute **attrs; =20 for (i =3D 0; chip->info[i]; i++) nattrs +=3D hwmon_num_channel_attrs(chip->info[i]); @@ -928,7 +928,7 @@ __hwmon_device_register(struct device *dev, const char = *name, void *drvdata, hdev =3D &hwdev->dev; =20 if (chip) { - struct attribute **attrs; + const struct attribute **attrs; int ngroups =3D 2; /* terminating NULL plus &hwdev->groups */ =20 if (groups) @@ -947,7 +947,7 @@ __hwmon_device_register(struct device *dev, const char = *name, void *drvdata, goto free_hwmon; } =20 - hwdev->group.attrs =3D attrs; + hwdev->group.attrs_const =3D attrs; ngroups =3D 0; hwdev->groups[ngroups++] =3D &hwdev->group; =20 --=20 2.55.0 From nobody Thu Aug 27 01:20:22 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E64943AD512; Thu, 6 Aug 2026 06:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996557; cv=none; b=ugWW/ilNJgObIdg3PwB2sPxoHzYgiOOjLVoM45xfxsC+DaMy++bzqath+eidzU/AONaphUi0Y3888SW9kEVPKhA23cDet336iLIg+1ymN2H/gO6Bs60BnVW4K7TiHwAnmh4YDzy7OSEKGNh566YRpsUEi1hhwLYEYX83MSZvMzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996557; c=relaxed/simple; bh=6xUUJfvoEfXULuBw5XctDVku6yzV5Bm7RvuwwUO/dkQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XMDhwUKwpVsMVV8Xh5ad8j4W08TwvB8aTREofE1wsM7o8W0Xox7GMwC7beKnLcRXSEp1lWUkxITvpoyjYf83s4CUukiGjvou3U7lskRCrBq/pqY0YbQS+TCKexiUEPtFdZI2A/qTpxkYlwFIe0qnFQoxwS8d56G9aQqaY8sJHyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=OsflkV76; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="OsflkV76" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1785996553; bh=6xUUJfvoEfXULuBw5XctDVku6yzV5Bm7RvuwwUO/dkQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OsflkV76TD/v03vVvkq7YE3khEdBq9hx2XgGGtlv2sBtGPTE8wNgUSMJYjKaz31rq +dlEDcoR15XhC3v60c1v/rVtJNxseKRFiqKFm3MiS3QWYjT1bw0cRYiL7hi/fjD/ZM ZbMFz4C3a6uurxiTILtVklubU17bpewa9VEhV4PM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 06 Aug 2026 08:09:13 +0200 Subject: [PATCH v2 3/3] hwmon: (sysfs) Allow drivers to register const attributes 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: <20260806-sysfs-const-attr-hwmon-v2-3-22fee8b85509@weissschuh.net> References: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> In-Reply-To: <20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net> To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1785996552; l=1879; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=6xUUJfvoEfXULuBw5XctDVku6yzV5Bm7RvuwwUO/dkQ=; b=iX7aj/mnDl/hacYBjnQRq7z2GjVTnua4nuKlrZOYMmoBWRnX7cMymfZSZE7h1eDxUSeY4p7Z0 h0yBm9D/TdaA0ElZDTHauL9FyioNRFMa+6Q9zswF+2VQceO2vMwUlhJ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Switch to the __DEVICE_ATTR() macro which can handle callbacks taking both const and non-const attribute structure arguments. Allow the step-wise migration of the drivers. Also use container_of_const() over container_of() to avoid casting away the constness accidentally. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/hwmon-sysfs.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index d896713359cd..ee5b33185b2d 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h @@ -15,10 +15,10 @@ struct sensor_device_attribute{ int index; }; #define to_sensor_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct sensor_device_attribute, dev_attr) + container_of_const(_dev_attr, struct sensor_device_attribute, dev_attr) =20 -#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr =3D __ATTR(_name, _mode, _show, _store), \ +#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ + { .dev_attr =3D __DEVICE_ATTR(_name, _mode, _show, _store), \ .index =3D _index } =20 #define SENSOR_ATTR_RO(_name, _func, _index) \ @@ -49,11 +49,11 @@ struct sensor_device_attribute_2 { u8 nr; }; #define to_sensor_dev_attr_2(_dev_attr) \ - container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) + container_of_const(_dev_attr, struct sensor_device_attribute_2, dev_attr) =20 -#define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ - { .dev_attr =3D __ATTR(_name, _mode, _show, _store), \ - .index =3D _index, \ +#define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ + { .dev_attr =3D __DEVICE_ATTR(_name, _mode, _show, _store), \ + .index =3D _index, \ .nr =3D _nr } =20 #define SENSOR_ATTR_2_RO(_name, _func, _nr, _index) \ --=20 2.55.0