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 3018922D4FF for ; Thu, 16 Jan 2025 17:32:34 +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=1737048756; cv=none; b=Qz2YKnR3ivS9bbHhgbUPX59L+tFg14OzpJHl6vEUpQrU3ji6WAAX+qXMAXuFRjS9S/OTDVbL5mIeOR+E9FwSHfqGNUY6zTZIl9/S41jWxKq2E5QXfMJd9xDcZAo9ZE47ADZSgRGcdpLTcRgqrREEmOe5au2gUTHhOqp/+oAcx1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737048756; c=relaxed/simple; bh=sE6+BpKZUxyQgUzl3N5TKDKS1J/Ojw3PKu+s1rUHYWk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=idICZ2i1GpBdpuwlctF7NNADez0dK4ACek6FbnjYUYWVVC6W1kEl8DlVB1WeQ2f8HmH4zP8Wt+IogUz+SP2iXOAROEUEZIV7VrNHc5Wx9+yDlPhdvX3nCKY1Ikr7prjVo/HHa3z3mQvjURZ7xwQhYcFQYe6rKsJ/ci5+wM6jNWU= 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=jPjl6/Gb; 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="jPjl6/Gb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1737048750; bh=sE6+BpKZUxyQgUzl3N5TKDKS1J/Ojw3PKu+s1rUHYWk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jPjl6/GbgM4kHzbqjwwCXT34Sl+nvXeS0pLwWPKLid5017mmVr1lp83EsPuiTpGRm PKLn/KG9pGrfkInBH2DsTGJaG/DbFfAZ+0zng55otLudg8NGFvT+6LVNRghwfOumdu 6ZCtmnWxWlES8FOt0Wx6m3Rjt4QPVXh31NpNVfYc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 16 Jan 2025 18:32:30 +0100 Subject: [PATCH 4/6] sysfs: attribute_group: enable const variants of is_visible() 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-4-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=2324; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=sE6+BpKZUxyQgUzl3N5TKDKS1J/Ojw3PKu+s1rUHYWk=; b=cOt02KgVOdSpvj1ruvm1aiLBDXTrawZjswSznw6HC37nyRh/eqcKYcTeeB4VSRfO8bmorlkXD wfCmOP0EtuJA5c5UuOiwidJiORhoEFv0FLeeH0h1+931gPNEhudroUe X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= When constifying instances of struct attribute, for consistency the corresponding .is_visible() callback should be adapted, too. Introduce a temporary transition mechanism until all callbacks are converted. Signed-off-by: Thomas Wei=C3=9Fschuh --- fs/sysfs/group.c | 10 ++++++++-- include/linux/sysfs.h | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 8b01a7eda5fb3239e138372417d01967c7a3f122..2a227bf209f84f5bfe5da06a5ca= 1633f69ca4368 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -36,6 +36,9 @@ static umode_t __first_visible(const struct attribute_gro= up *grp, struct kobject if (grp->attrs && grp->attrs[0] && grp->is_visible) return grp->is_visible(kobj, grp->attrs[0], 0); =20 + if (grp->attrs && grp->attrs[0] && grp->is_visible_new) + return grp->is_visible_new(kobj, grp->attrs[0], 0); + if (grp->bin_attrs && grp->bin_attrs[0] && grp->is_bin_visible) return grp->is_bin_visible(kobj, grp->bin_attrs[0], 0); =20 @@ -61,8 +64,11 @@ static int create_files(struct kernfs_node *parent, stru= ct kobject *kobj, */ if (update) kernfs_remove_by_name(parent, (*attr)->name); - if (grp->is_visible) { - mode =3D grp->is_visible(kobj, *attr, i); + if (grp->is_visible || grp->is_visible_new) { + if (grp->is_visible) + mode =3D grp->is_visible(kobj, *attr, i); + else + mode =3D grp->is_visible_new(kobj, *attr, i); mode &=3D ~SYSFS_GROUP_INVISIBLE; if (!mode) continue; diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 46e9261bc35f248a733d27c05c931080b0c58e17..c68496ad5bcc7964b98291df689= c7451cf75eac8 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -104,8 +104,12 @@ do { \ */ struct attribute_group { const char *name; - umode_t (*is_visible)(struct kobject *, - struct attribute *, int); + __SYSFS_FUNCTION_ALTERNATIVE( + umode_t (*is_visible)(struct kobject *, + struct attribute *, int); + umode_t (*is_visible_new)(struct kobject *, + const struct attribute *, int); + ); umode_t (*is_bin_visible)(struct kobject *, const struct bin_attribute *, int); size_t (*bin_size)(struct kobject *, --=20 2.48.1