From nobody Sun Dec 14 11:32:39 2025 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 DE65841C6A for ; Thu, 16 Jan 2025 17:32:31 +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=1737048753; cv=none; b=urkc4XRR37Y45r+BxhgHenBzYuw08v9+xI+0me+QOpdPHKNi4HOKaK74o2c7bcg+tU4fXEHmw4PauyCHYhV/eWBRZ8rUq5eLJKeKRLvgVvUR1LlN7pZFgkaCYyI4J6YcCUB3x4U7zuUVlhVYG1oRQ3/5sph9CVQ4e9F8cL8fU8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737048753; c=relaxed/simple; bh=zEW5K2/phz/49lLz80p4xhEHmzhVd+bbbhqnAzLmxNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FCQ5R52Qubi0HPi9bPwqZT2ZGF8HK6Ycl5ycLNPe+vJoFcNOum/LamlHVnD9Jh1TgQEhCNIk2QHxCyQuEPEkJJbZdu6yHL3VFy8AMCmCffKPs22x+GY3yYVXM5VLOjSCN/0mchOOS1KA3lrqdtuTsrihdJn3wy9HeGDxFRFp0lI= 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=hutsRqzo; 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="hutsRqzo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1737048750; bh=zEW5K2/phz/49lLz80p4xhEHmzhVd+bbbhqnAzLmxNc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hutsRqzobAa2y5umZDzmUatXKcgcDuBeVY0W7wnNMv2pz8jSr/TC3a6YaSO7BZI92 SLz9LU5t+hebCQIn61LYcsRsQjyC0fG0jSURMcwYqdtgszYt4PK5CDQyI1plAWh+NC mno1vwm5ayvGREJB8KcfJDGWJAn4m9WJTUXTrLtE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 16 Jan 2025 18:32:28 +0100 Subject: [PATCH 2/6] sysfs: transparently handle const pointers in ATTRIBUTE_GROUPS() 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: <20250116-sysfs-const-attr-prep-v1-2-15e72dba4205@weissschuh.net> References: <20250116-sysfs-const-attr-prep-v1-0-15e72dba4205@weissschuh.net> In-Reply-To: <20250116-sysfs-const-attr-prep-v1-0-15e72dba4205@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737048749; l=1101; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zEW5K2/phz/49lLz80p4xhEHmzhVd+bbbhqnAzLmxNc=; b=EI+uR3WhMi2ugOVkiGa96n8GyI8NsXURKAfMV2dmi9/oAm3Eq0RhnD699PTyhnpv58DPQomrL 96opjIi2CEmC8o7T5H5OEM1bDgXCSqelyMU5NjeA8JZG5JA6ifnFqtZ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= To ease the constification process of 'struct attribute', transparently handle the const pointers in ATTRIBUTE_GROUPS(). A cast is used instead of assigning to .attrs_new as it keeps the macro smaller. As both members are aliased to each other the result is identical. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/sysfs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f5e25bed777a6a6e717f10973f1abcd12111f5c5..52d4862bbcef2a6b143710a1980= 1222bf7abc346 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -290,7 +290,12 @@ static const struct attribute_group *_name##_groups[] = =3D { \ =20 #define ATTRIBUTE_GROUPS(_name) \ static const struct attribute_group _name##_group =3D { \ - .attrs =3D _name##_attrs, \ + .attrs =3D _Generic(_name##_attrs, \ + struct attribute **: \ + _name##_attrs, \ + const struct attribute *const *: \ + (void *)_name##_attrs \ + ), \ }; \ __ATTRIBUTE_GROUPS(_name) =20 --=20 2.48.1