From nobody Fri Jun 12 20:23:29 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 69C423D45E5 for ; Tue, 12 May 2026 16:39:29 +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=1778603971; cv=none; b=WDJvLHoQYROqPX5+ingSBv9Mu/rPkjyrBROypvwZN+Fl3n41WpiS0CPD3eCKH2yALsIgemDhefhrNWqPSifpTpkTwwIMRmn4jmoT4YyYIR9oSRcoKdNxbBX41Ugn/Z59z8RnPIkAz/cJWkxWi4Y6LQrkM6j1Rfpx9RgQk8lMpKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603971; c=relaxed/simple; bh=vqKSWoKvW5QRnRu+bO9tguWyf/3swh3oVBfCT9wypb8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gJM+Agw7H76LZmONQgPDXH632ef5kter5eRM/06+dkLVVpouGhcQkyAwWsFLRYw644IsqNXCkG0kurX7L3g5Pq9ldEpiajR8Z6zo414NrlU7K/idsA0tnn69q6SDTWBUusOECJb6JC3PnOnA+qsfCoIDxgCMgjlyVUQnENWYXMY= 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=fPUz1Kzf; 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="fPUz1Kzf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778603956; bh=vqKSWoKvW5QRnRu+bO9tguWyf/3swh3oVBfCT9wypb8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fPUz1Kzfeh6Zwq2WuMmi/P8FrWF62c6gCNko29LHYn6giymcRBVMWadCzXRm2X6Vy LNZyrqk7B7bXcCyt7eYZUdY9zVEa6yWURo4bf5bJXrwUaTZMQmTEWVC7E72p7WqkxI t5zsyLWSL0cMhwkJYs8u0SWk+M4Wva/23CRKm14w= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 12 May 2026 18:39:11 +0200 Subject: [PATCH v3 1/5] driver core: Delete DEVICE_ATTR_PREALLOC() 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: <20260512-sysfs-const-attr-device_attr-prep-v3-1-cb7c17b34d52@weissschuh.net> References: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> In-Reply-To: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: driver-core@lists.linux.dev, 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=1778603956; l=1296; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=vqKSWoKvW5QRnRu+bO9tguWyf/3swh3oVBfCT9wypb8=; b=gu/REruyP7/wOXLhV04RqczWgg62iirHTzFcP5uZtjP/Z84JdokDPsoJKAXIOal8zKgwNwblG pK1ntZ6lcA9BqMDM9N7/JSYarg1a3BwIkttIQGAMoJcfVHNVjuNvdEG X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This macro is unused and would create extra work during the upcoming constification of device attributes. Remove it. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/device.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/linux/device.h b/include/linux/device.h index 9c8fde6a3d86..06ec4e27a1e1 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -157,19 +157,6 @@ ssize_t device_show_string(struct device *dev, struct = device_attribute *attr, #define DEVICE_ATTR(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name =3D __ATTR(_name, _mode, _show, = _store) =20 -/** - * DEVICE_ATTR_PREALLOC - Define a preallocated device attribute. - * @_name: Attribute name. - * @_mode: File mode. - * @_show: Show handler. Optional, but mandatory if attribute is readable. - * @_store: Store handler. Optional, but mandatory if attribute is writabl= e. - * - * Like DEVICE_ATTR(), but ``SYSFS_PREALLOC`` is set on @_mode. - */ -#define DEVICE_ATTR_PREALLOC(_name, _mode, _show, _store) \ - struct device_attribute dev_attr_##_name =3D \ - __ATTR_PREALLOC(_name, _mode, _show, _store) - /** * DEVICE_ATTR_RW - Define a read-write device attribute. * @_name: Attribute name. --=20 2.54.0 From nobody Fri Jun 12 20:23:29 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 8C9E73C8C5A for ; Tue, 12 May 2026 16:39:24 +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=1778603968; cv=none; b=q2cHXUFxWNOTerWPpYr7QAztvSdpA4ujy5OXrDk4mxW5Z7kiG9HImHXDc/8RzygDffd4vHlgY/HY7wWtHHy3mRj3GkbKx3iTRr5pqf7JqPRpmuBJ0fy+XW9NJP5Qv7Y3ZV4V80aIk+VW3HwpcDZ7+m9YyfeomrGVaKck3nbAo/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603968; c=relaxed/simple; bh=qVTV8qeG6V+Z9IZtbOivrANMEblCi5CBzzop6HZ4Z0U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jradi8RH+DtKOVW8k+7w0DElDTUEnO3x2o44bl4cZRhzWCcWYgPtexISJH009v9XnzKY0xxyIrtFKwn4z4OfaW6JC0nKJAHfO5+tfLG5WLGy5DwfSd6Pyidyuq2PaOb83krmTYV7jUjrK7cR4olC0Nos9qt70LHgWSlenEXha8Q= 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=dRthu1nf; 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="dRthu1nf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778603956; bh=qVTV8qeG6V+Z9IZtbOivrANMEblCi5CBzzop6HZ4Z0U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dRthu1nf+LTY45xiwjbDgogtYEjmORklZgMBy8/5gbQvBW9O+xh48Tp0cBYdpb5Mj BfG8YCCEabkeQ88PRD1GNS71ohfYwnCNU9/43dxYYJWcU/8sBFTP0xdj5BvVopEcUU 3l43NLVSDc3qrdgcNK3/TzHTU6JPow2OgxK443JQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 12 May 2026 18:39:12 +0200 Subject: [PATCH v3 2/5] driver core: Add low-level macros for 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: <20260512-sysfs-const-attr-device_attr-prep-v3-2-cb7c17b34d52@weissschuh.net> References: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> In-Reply-To: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: driver-core@lists.linux.dev, 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=1778603956; l=5979; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=qVTV8qeG6V+Z9IZtbOivrANMEblCi5CBzzop6HZ4Z0U=; b=kr9KqPnQS1NgwtuitCmYxoiXVW7amMHsR/WHA4OKuqB21sPRgRgAAMLVtViBZ1rqDvaDo8xqS kNsBZpxXZw/D+hbzavqRyJUWL+xtT1Y1HZwjx2nNagA2Z5XKukLoppg X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= For the upcoming constification of device attributes the generic __ATTR() macros are insufficient. Prepare for a split by introducing new low-level macros specific to device attributes. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/device.h | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/include/linux/device.h b/include/linux/device.h index 06ec4e27a1e1..24ed3a6caad2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -135,6 +135,27 @@ ssize_t device_store_bool(struct device *dev, struct d= evice_attribute *attr, ssize_t device_show_string(struct device *dev, struct device_attribute *at= tr, char *buf); =20 +#define __DEVICE_ATTR(_name, _mode, _show, _store) \ + __ATTR(_name, _mode, _show, _store) + +#define __DEVICE_ATTR_RO_MODE(_name, _mode) \ + __ATTR_RO_MODE(_name, _mode) + +#define __DEVICE_ATTR_RO(_name) \ + __ATTR_RO(_name) + +#define __DEVICE_ATTR_WO(_name) \ + __ATTR_WO(_name) + +#define __DEVICE_ATTR_RW_MODE(_name, _mode) \ + __ATTR_RW_MODE(_name, _mode) + +#define __DEVICE_ATTR_RW(_name) \ + __ATTR_RW(_name) + +#define __DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ + __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) + /** * DEVICE_ATTR - Define a device attribute. * @_name: Attribute name. @@ -155,7 +176,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * }; */ #define DEVICE_ATTR(_name, _mode, _show, _store) \ - struct device_attribute dev_attr_##_name =3D __ATTR(_name, _mode, _show, = _store) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR(_name, _mode, = _show, _store) =20 /** * DEVICE_ATTR_RW - Define a read-write device attribute. @@ -165,7 +186,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * and @_store is <_name>_store. */ #define DEVICE_ATTR_RW(_name) \ - struct device_attribute dev_attr_##_name =3D __ATTR_RW(_name) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR_RW(_name) =20 /** * DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute. @@ -174,7 +195,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * Like DEVICE_ATTR_RW(), but @_mode is 0600. */ #define DEVICE_ATTR_ADMIN_RW(_name) \ - struct device_attribute dev_attr_##_name =3D __ATTR_RW_MODE(_name, 0600) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR_RW_MODE(_name,= 0600) =20 /** * DEVICE_ATTR_RW_NAMED - Define a read-write device attribute with a sysf= s name @@ -199,7 +220,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * Like DEVICE_ATTR(), but @_mode is 0444 and @_show is <_name>_show. */ #define DEVICE_ATTR_RO(_name) \ - struct device_attribute dev_attr_##_name =3D __ATTR_RO(_name) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR_RO(_name) =20 /** * DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute. @@ -208,7 +229,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * Like DEVICE_ATTR_RO(), but @_mode is 0400. */ #define DEVICE_ATTR_ADMIN_RO(_name) \ - struct device_attribute dev_attr_##_name =3D __ATTR_RO_MODE(_name, 0400) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR_RO_MODE(_name,= 0400) =20 /** * DEVICE_ATTR_RO_NAMED - Define a read-only device attribute with a sysfs= name @@ -232,7 +253,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, * Like DEVICE_ATTR(), but @_mode is 0200 and @_store is <_name>_store. */ #define DEVICE_ATTR_WO(_name) \ - struct device_attribute dev_attr_##_name =3D __ATTR_WO(_name) + struct device_attribute dev_attr_##_name =3D __DEVICE_ATTR_WO(_name) =20 /** * DEVICE_ATTR_WO_NAMED - Define a read-only device attribute with a sysfs= name @@ -260,7 +281,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, */ #define DEVICE_ULONG_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name =3D \ - { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } + { __DEVICE_ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(= _var) } =20 /** * DEVICE_INT_ATTR - Define a device attribute backed by an int. @@ -272,7 +293,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, */ #define DEVICE_INT_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name =3D \ - { __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) } + { __DEVICE_ATTR(_name, _mode, device_show_int, device_store_int), &(_var= ) } =20 /** * DEVICE_BOOL_ATTR - Define a device attribute backed by a bool. @@ -284,7 +305,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, */ #define DEVICE_BOOL_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name =3D \ - { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } + { __DEVICE_ATTR(_name, _mode, device_show_bool, device_store_bool), &(_v= ar) } =20 /** * DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o strin= g. @@ -297,11 +318,11 @@ ssize_t device_show_string(struct device *dev, struct= device_attribute *attr, */ #define DEVICE_STRING_ATTR_RO(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name =3D \ - { __ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var) } + { __DEVICE_ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var= ) } =20 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name =3D \ - __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) + __DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) =20 int device_create_file(struct device *device, const struct device_attribute *entry); --=20 2.54.0 From nobody Fri Jun 12 20:23:29 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 8C94D3C415D for ; Tue, 12 May 2026 16:39:24 +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=1778603968; cv=none; b=oRV2w+T09S2ND9n/3f3Mc2zjRaZG3FJlB1Xb5exrxqoW1asy8joRdzhg3BfQj0CQn6gbnBJLVHXjmgR65eYuZ/Hkv8fPqUCNrqB74crTHFCO+Zwx1E8/2vFGTjKcPso6QJOiqyX7M1XeyqwA9RF+5Ubb9tab/Vxf54HRDkj22Vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603968; c=relaxed/simple; bh=Q2Kj+fih1psN3SqbcUkOIM/tNiFEPciiP5rTFtjkws4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YbDDiibr+9A3pYUyDr1trKFitY4Ka9C7sZlc4/Mm6ExpWqaRYlcdoVjqvQaJYiiWBS6Ad7Ie3FC1HhqHIHctxu2Pc2eygyfMbUyh35dQmq+lk1ye5H0jRmbwIQ5qpd/TncBgi8qpgVMCVJIzz2zQe7GTm4P04b8qMVeflxMetX0= 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=B9dlfPmc; 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="B9dlfPmc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778603956; bh=Q2Kj+fih1psN3SqbcUkOIM/tNiFEPciiP5rTFtjkws4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B9dlfPmcXJwj01QFdURv7miStetZ0xOlhsRSWzOOZBcmfDS0Fo7SgXBaAxCRuyLha 2+ZrnqBVZ6xBZcpKB7FDyLbPwESImcEtggfxpNgaetNI8s/DsqKkJMxUTZT0gvNc0m VI0I1vRwj7zpyS8Bq1zRXLNXF0+PFRrhqUL6pbVU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 12 May 2026 18:39:13 +0200 Subject: [PATCH v3 3/5] driver core: Stop using generic sysfs macros for 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: <20260512-sysfs-const-attr-device_attr-prep-v3-3-cb7c17b34d52@weissschuh.net> References: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> In-Reply-To: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: driver-core@lists.linux.dev, 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=1778603956; l=2231; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Q2Kj+fih1psN3SqbcUkOIM/tNiFEPciiP5rTFtjkws4=; b=9Co0muNHbxA2SY3sTKaXUdvzzoncXtyfRKaXIAFU60PpLfhwh7qmAoWhQW5UozocQM+aF6pdR 5lBVyrUF1REBGu/w4vz8hWOpbH1U2SHsBjkr9XFlpnUz5qI6cO7/4oj X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The constification of device attributes will require a transition phase, where 'struct device_attribute' contains a classic non-const and a new const variant of the 'show' and 'store' callbacks. As __ATTR() and friends can not handle this duplication stop using them. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/device.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/include/linux/device.h b/include/linux/device.h index 24ed3a6caad2..17150b0dfcd6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -135,26 +135,38 @@ ssize_t device_store_bool(struct device *dev, struct = device_attribute *attr, ssize_t device_show_string(struct device *dev, struct device_attribute *at= tr, char *buf); =20 -#define __DEVICE_ATTR(_name, _mode, _show, _store) \ - __ATTR(_name, _mode, _show, _store) +#define __DEVICE_ATTR(_name, _mode, _show, _store) { \ + .attr =3D {.name =3D __stringify(_name), \ + .mode =3D VERIFY_OCTAL_PERMISSIONS(_mode) }, \ + .show =3D _show, \ + .store =3D _store, \ +} =20 #define __DEVICE_ATTR_RO_MODE(_name, _mode) \ - __ATTR_RO_MODE(_name, _mode) + __DEVICE_ATTR(_name, _mode, _name##_show, NULL) =20 #define __DEVICE_ATTR_RO(_name) \ - __ATTR_RO(_name) + __DEVICE_ATTR_RO_MODE(_name, 0444) =20 #define __DEVICE_ATTR_WO(_name) \ - __ATTR_WO(_name) + __DEVICE_ATTR(_name, 0200, NULL, _name##_store) =20 #define __DEVICE_ATTR_RW_MODE(_name, _mode) \ - __ATTR_RW_MODE(_name, _mode) + __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store) =20 #define __DEVICE_ATTR_RW(_name) \ - __ATTR_RW(_name) - -#define __DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ - __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) + __DEVICE_ATTR_RW_MODE(_name, 0644) + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +#define __DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \ + .attr =3D {.name =3D __stringify(_name), .mode =3D _mode, \ + .ignore_lockdep =3D true }, \ + .show =3D _show, \ + .store =3D _store, \ +} +#else +#define __DEVICE_ATTR_IGNORE_LOCKDEP __DEVICE_ATTR +#endif =20 /** * DEVICE_ATTR - Define a device attribute. --=20 2.54.0 From nobody Fri Jun 12 20:23:29 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 8CAD93CB8F0 for ; Tue, 12 May 2026 16:39:24 +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=1778603967; cv=none; b=TJT9MfMB7JoKWLx71q6uf9Lg1ub26ODmsNzrn9mFmwM7+A8vx12nmeMdYJOisLipMbifAIHbGLGfKtiVKbtkTxEcvFSVyCO3DWeW0/Dst4XZyDhyLzJDm7CVh2Vvq3070mIQ1I4KmDbxUEZyRy45kR9MsuHF1exVwMNigUkUmiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603967; c=relaxed/simple; bh=cUdVNVjErc1TuS8AxGPhITg+PWnyvjVsEFQ9D6CtD04=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J1ayHyLzhM6y7Dyi5M2ufeL+yJZ+rzwfAiy8Nkh1P8zf2jOr2QVzBIRlqTu35B4PcuAfbmHBgc51CrmVVvl+wyFhFANx7dJq3ZAbmN3TqJ12SdjdQ3ZkTRpqWhxm7Cui5gEbTuXKEBurIcdfWcQwp9aR5l6axOE6+HN4tdQH80k= 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=TwW/0FgV; 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="TwW/0FgV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778603956; bh=cUdVNVjErc1TuS8AxGPhITg+PWnyvjVsEFQ9D6CtD04=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TwW/0FgV8yUHkrQ+vZRdfQvG2myxOc/ngs3ANN66drHw1pePXDqVOafP6VSvK/+ev mk8vQ2qt/rkVS9TZy588gLf5DT208OZ5T7Wal/9kEJxbhVP1R3R0b/0N5PRjkZ5l8Y oJKBRxhHwLCmp/uD/LSsNIEHPxsPTGnLKMcLJZUg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 12 May 2026 18:39:14 +0200 Subject: [PATCH v3 4/5] driver core: Allow the constification of 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: <20260512-sysfs-const-attr-device_attr-prep-v3-4-cb7c17b34d52@weissschuh.net> References: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> In-Reply-To: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: driver-core@lists.linux.dev, 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=1778603956; l=6530; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=cUdVNVjErc1TuS8AxGPhITg+PWnyvjVsEFQ9D6CtD04=; b=djR8ZKOo3pPypRN4s/oFQes17+rZL2YP5Sm2pTmGSdTer4FaHYPI/LuxJ92IhccbS+ti74hnY jCuaM8R/w32BYm32JC5yvbNB8jDxyHUD5XscIZ+TNNFcDRYeh5Y6GWz X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Allow device attribute to reside in read-only memory. Both const and non-const attributes are handled by the utility macros and attributes can be migrated one-by-one. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/base/core.c | 12 ++++++--- include/linux/device.h | 69 +++++++++++++++++++++++++++++++++++++++++-----= ---- 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index bd2ddf2aab50..6e2ee6d55a0b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2419,9 +2419,11 @@ static ssize_t dev_attr_show(struct kobject *kobj, s= truct attribute *attr, =20 if (dev_attr->show) ret =3D dev_attr->show(dev, dev_attr, buf); + else if (dev_attr->show_const) + ret =3D dev_attr->show_const(dev, dev_attr, buf); if (ret >=3D (ssize_t)PAGE_SIZE) { - printk("dev_attr_show: %pS returned bad count\n", - dev_attr->show); + printk("dev_attr_show: %pS/%pS returned bad count\n", + dev_attr->show, dev_attr->show_const); } return ret; } @@ -2435,6 +2437,8 @@ static ssize_t dev_attr_store(struct kobject *kobj, s= truct attribute *attr, =20 if (dev_attr->store) ret =3D dev_attr->store(dev, dev_attr, buf, count); + else if (dev_attr->store_const) + ret =3D dev_attr->store_const(dev, dev_attr, buf, count); return ret; } =20 @@ -3047,10 +3051,10 @@ int device_create_file(struct device *dev, int error =3D 0; =20 if (dev) { - WARN(((attr->attr.mode & S_IWUGO) && !attr->store), + WARN(((attr->attr.mode & S_IWUGO) && !(attr->store || attr->store_const)= ), "Attribute %s: write permission without 'store'\n", attr->attr.name); - WARN(((attr->attr.mode & S_IRUGO) && !attr->show), + WARN(((attr->attr.mode & S_IRUGO) && !(attr->show || attr->show_const)), "Attribute %s: read permission without 'show'\n", attr->attr.name); error =3D sysfs_create_file(&dev->kobj, &attr->attr); diff --git a/include/linux/device.h b/include/linux/device.h index 17150b0dfcd6..354f54be02b9 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -104,10 +104,18 @@ struct device_type { */ struct device_attribute { struct attribute attr; - ssize_t (*show)(struct device *dev, struct device_attribute *attr, - char *buf); - ssize_t (*store)(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count); + __SYSFS_FUNCTION_ALTERNATIVE( + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*show_const)(struct device *dev, const struct device_attribute = *attr, + char *buf); + ); + __SYSFS_FUNCTION_ALTERNATIVE( + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + ssize_t (*store_const)(struct device *dev, const struct device_attribute= *attr, + const char *buf, size_t count); + ); }; =20 /** @@ -135,11 +143,50 @@ ssize_t device_store_bool(struct device *dev, struct = device_attribute *attr, ssize_t device_show_string(struct device *dev, struct device_attribute *at= tr, char *buf); =20 +typedef ssize_t __device_show_handler_const(struct device *dev, const stru= ct device_attribute *attr, + char *buf); +typedef ssize_t __device_store_handler_const(struct device *dev, const str= uct device_attribute *attr, + const char *buf, size_t count); + +#ifdef CONFIG_CFI + +#define __DEVICE_ATTR_SHOW_STORE(_show, _store) \ + .show =3D _Generic(_show, \ + __device_show_handler_const * : NULL, \ + default : _show \ + ), \ + .show_const =3D _Generic(_show, \ + __device_show_handler_const * : _show, \ + default : NULL \ + ), \ + .store =3D _Generic(_store, \ + __device_store_handler_const * : NULL, \ + default : _store \ + ), \ + .store_const =3D _Generic(_store, \ + __device_store_handler_const * : _store, \ + default : NULL \ + ), + +#else + +#define __DEVICE_ATTR_SHOW_STORE(_show, _store) \ + .show =3D _Generic(_show, \ + __device_show_handler_const * : (void *)_show, \ + default : _show \ + ), \ + .store =3D _Generic(_store, \ + __device_store_handler_const * : (void *)_store, \ + default : _store \ + ), \ + +#endif + + #define __DEVICE_ATTR(_name, _mode, _show, _store) { \ .attr =3D {.name =3D __stringify(_name), \ .mode =3D VERIFY_OCTAL_PERMISSIONS(_mode) }, \ - .show =3D _show, \ - .store =3D _store, \ + __DEVICE_ATTR_SHOW_STORE(_show, _store) \ } =20 #define __DEVICE_ATTR_RO_MODE(_name, _mode) \ @@ -161,8 +208,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, #define __DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \ .attr =3D {.name =3D __stringify(_name), .mode =3D _mode, \ .ignore_lockdep =3D true }, \ - .show =3D _show, \ - .store =3D _store, \ + __DEVICE_ATTR_SHOW_STORE(_show, _store) \ } #else #define __DEVICE_ATTR_IGNORE_LOCKDEP __DEVICE_ATTR @@ -221,8 +267,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, #define DEVICE_ATTR_RW_NAMED(_name, _attrname) \ struct device_attribute dev_attr_##_name =3D { \ .attr =3D { .name =3D _attrname, .mode =3D 0644 }, \ - .show =3D _name##_show, \ - .store =3D _name##_store, \ + __DEVICE_ATTR_SHOW_STORE(_name##_show, _name##_store) \ } =20 /** @@ -255,7 +300,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, #define DEVICE_ATTR_RO_NAMED(_name, _attrname) \ struct device_attribute dev_attr_##_name =3D { \ .attr =3D { .name =3D _attrname, .mode =3D 0444 }, \ - .show =3D _name##_show, \ + __DEVICE_ATTR_SHOW_STORE(_name##_show, NULL) \ } =20 /** @@ -279,7 +324,7 @@ ssize_t device_show_string(struct device *dev, struct d= evice_attribute *attr, #define DEVICE_ATTR_WO_NAMED(_name, _attrname) \ struct device_attribute dev_attr_##_name =3D { \ .attr =3D { .name =3D _attrname, .mode =3D 0200 }, \ - .store =3D _name##_store, \ + __DEVICE_ATTR_SHOW_STORE(NULL, _name##_store) \ } =20 /** --=20 2.54.0 From nobody Fri Jun 12 20:23:29 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 8CB553CE09B for ; Tue, 12 May 2026 16:39:24 +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=1778603968; cv=none; b=Ngi6+O8na4RNSFH+4KYnC0Jyh67AzE9LHHVzjI3xYNyKJV2hkDI7VSvmq1FviX+s/eed3lwP/Q5YBQfDinCHhq1rszGxqzPJLuSHMnIc6X5EhA7+T9V3aLXTetzwpWEsuMJPdGVZ0mAF6WTh2qAOKvK/SM0kCUOC0V+GWZSnI0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603968; c=relaxed/simple; bh=VxuYWSwBKFFH32VXfB6zYskoltvcu43x2BtIsZN1AAI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EW6911+a/fAuuJd5wdUth1C+7sfaGTTZTTBWUehBmO3jfK/Nd3CWfrf0Z08CrlT7Ln3vxNwybOGRg2ST5Qn4kk/BFQV32vHAV303hA23u9HLbkcEF7LyvWCt8PaJ6GJce/I54nKo1uTXpK92IYX2wouZB4Mt68PQWpLQVDLNmCU= 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=qlz/xUed; 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="qlz/xUed" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778603957; bh=VxuYWSwBKFFH32VXfB6zYskoltvcu43x2BtIsZN1AAI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qlz/xUedjV4TLm31I/p1sm/JRAeh6f9OWzqActmm0AlchJSVAgwM52qzI1Cq7wjkg P31GjFMf2BQQjVgcKdTbhdHHhMMTFIB3DEbjPOh5+aZFHb3jPK9Zecd/Ru86PCpMZo u0QQNAsuT7m9bJD8AiKUHFO0yOmCNptiEaJv1EBc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 12 May 2026 18:39:15 +0200 Subject: [PATCH v3 5/5] driver core: Constify core 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: <20260512-sysfs-const-attr-device_attr-prep-v3-5-cb7c17b34d52@weissschuh.net> References: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> In-Reply-To: <20260512-sysfs-const-attr-device_attr-prep-v3-0-cb7c17b34d52@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: driver-core@lists.linux.dev, 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=1778603956; l=5762; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=VxuYWSwBKFFH32VXfB6zYskoltvcu43x2BtIsZN1AAI=; b=ImBmo5GgBMwu66gbvkxL5/ohm0HkZ6ATQKy+OmGtPHdyUF3mgar0eKkHXz/RUiISwxVYDkaTS 98+IRUWkt/xBlCrfuMAlpwJCMwvy/oLVbBT3HmmQmSfCTlbd4QFYMPX X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= To make sure these attributes are not modified by accident or by an attacker, move them to read-only memory. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/base/core.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 6e2ee6d55a0b..57650f4c4dc9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -422,7 +422,7 @@ void device_pm_move_to_tail(struct device *dev) #define to_devlink(dev) container_of((dev), struct device_link, link_dev) =20 static ssize_t status_show(struct device *dev, - struct device_attribute *attr, char *buf) + const struct device_attribute *attr, char *buf) { const char *output; =20 @@ -452,10 +452,10 @@ static ssize_t status_show(struct device *dev, =20 return sysfs_emit(buf, "%s\n", output); } -static DEVICE_ATTR_RO(status); +static const DEVICE_ATTR_RO(status); =20 static ssize_t auto_remove_on_show(struct device *dev, - struct device_attribute *attr, char *buf) + const struct device_attribute *attr, char *buf) { struct device_link *link =3D to_devlink(dev); const char *output; @@ -469,27 +469,27 @@ static ssize_t auto_remove_on_show(struct device *dev, =20 return sysfs_emit(buf, "%s\n", output); } -static DEVICE_ATTR_RO(auto_remove_on); +static const DEVICE_ATTR_RO(auto_remove_on); =20 static ssize_t runtime_pm_show(struct device *dev, - struct device_attribute *attr, char *buf) + const struct device_attribute *attr, char *buf) { struct device_link *link =3D to_devlink(dev); =20 return sysfs_emit(buf, "%d\n", device_link_test(link, DL_FLAG_PM_RUNTIME)= ); } -static DEVICE_ATTR_RO(runtime_pm); +static const DEVICE_ATTR_RO(runtime_pm); =20 static ssize_t sync_state_only_show(struct device *dev, - struct device_attribute *attr, char *buf) + const struct device_attribute *attr, char *buf) { struct device_link *link =3D to_devlink(dev); =20 return sysfs_emit(buf, "%d\n", device_link_test(link, DL_FLAG_SYNC_STATE_= ONLY)); } -static DEVICE_ATTR_RO(sync_state_only); +static const DEVICE_ATTR_RO(sync_state_only); =20 -static struct attribute *devlink_attrs[] =3D { +static const struct attribute *const devlink_attrs[] =3D { &dev_attr_status.attr, &dev_attr_auto_remove_on.attr, &dev_attr_runtime_pm.attr, @@ -1233,7 +1233,7 @@ static void device_link_drop_managed(struct device_li= nk *link) } =20 static ssize_t waiting_for_supplier_show(struct device *dev, - struct device_attribute *attr, + const struct device_attribute *attr, char *buf) { bool val; @@ -1244,7 +1244,7 @@ static ssize_t waiting_for_supplier_show(struct devic= e *dev, device_unlock(dev); return sysfs_emit(buf, "%u\n", val); } -static DEVICE_ATTR_RO(waiting_for_supplier); +static const DEVICE_ATTR_RO(waiting_for_supplier); =20 /** * device_links_force_bind - Prepares device to be force bound @@ -2726,7 +2726,7 @@ static const struct kset_uevent_ops device_uevent_ops= =3D { .uevent =3D dev_uevent, }; =20 -static ssize_t uevent_show(struct device *dev, struct device_attribute *at= tr, +static ssize_t uevent_show(struct device *dev, const struct device_attribu= te *attr, char *buf) { struct kobject *top_kobj; @@ -2769,7 +2769,7 @@ static ssize_t uevent_show(struct device *dev, struct= device_attribute *attr, return len; } =20 -static ssize_t uevent_store(struct device *dev, struct device_attribute *a= ttr, +static ssize_t uevent_store(struct device *dev, const struct device_attrib= ute *attr, const char *buf, size_t count) { int rc; @@ -2783,9 +2783,9 @@ static ssize_t uevent_store(struct device *dev, struc= t device_attribute *attr, =20 return count; } -static DEVICE_ATTR_RW(uevent); +static const DEVICE_ATTR_RW(uevent); =20 -static ssize_t online_show(struct device *dev, struct device_attribute *at= tr, +static ssize_t online_show(struct device *dev, const struct device_attribu= te *attr, char *buf) { bool val; @@ -2796,7 +2796,7 @@ static ssize_t online_show(struct device *dev, struct= device_attribute *attr, return sysfs_emit(buf, "%u\n", val); } =20 -static ssize_t online_store(struct device *dev, struct device_attribute *a= ttr, +static ssize_t online_store(struct device *dev, const struct device_attrib= ute *attr, const char *buf, size_t count) { bool val; @@ -2814,9 +2814,9 @@ static ssize_t online_store(struct device *dev, struc= t device_attribute *attr, unlock_device_hotplug(); return ret < 0 ? ret : count; } -static DEVICE_ATTR_RW(online); +static const DEVICE_ATTR_RW(online); =20 -static ssize_t removable_show(struct device *dev, struct device_attribute = *attr, +static ssize_t removable_show(struct device *dev, const struct device_attr= ibute *attr, char *buf) { const char *loc; @@ -2833,7 +2833,7 @@ static ssize_t removable_show(struct device *dev, str= uct device_attribute *attr, } return sysfs_emit(buf, "%s\n", loc); } -static DEVICE_ATTR_RO(removable); +static const DEVICE_ATTR_RO(removable); =20 int device_add_groups(struct device *dev, const struct attribute_group *const *groups) @@ -2984,12 +2984,12 @@ static void device_remove_attrs(struct device *dev) device_remove_groups(dev, class->dev_groups); } =20 -static ssize_t dev_show(struct device *dev, struct device_attribute *attr, +static ssize_t dev_show(struct device *dev, const struct device_attribute = *attr, char *buf) { return print_dev_t(buf, dev->devt); } -static DEVICE_ATTR_RO(dev); +static const DEVICE_ATTR_RO(dev); =20 /* /sys/devices/ */ struct kset *devices_kset; --=20 2.54.0