From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 292BE28BA95; Wed, 23 Apr 2025 17:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430653; cv=none; b=YUfEculqDjP7Wled/nX2Je0Ab67K7yCsPzX9yXGdortimFsket8GgDQrUt8p5AerCt5R7zpg3YBliSkDNIHiVPDD3atFfCvcCURtJ8ndOIaIFVW1/ByKpNAa67RMvUno26aj4i2XWv9CwiahSixOXsGpn2ezQ+y7QBc6e9XPu0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430653; c=relaxed/simple; bh=OkcRkYHAR4Otv+Uk66lK6k1eF+5Jp14O8IBgr67qKS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TfdEo1pox6OcOtqxD8M9dHANRT0Lkaq+HP2EIQ2AlbxO2fgWnnkMfXEDXlydtL17Jr9NUSycWnRe7cvlipsfTmGF6qdr2X/ELo+OlvC0/TJDsYf0UHxklpIPFSS+i/2IiNF56kG6ag54vUU/pe+qUDGVj0HjtMuw5sfbL2onHss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ehpTu1u9; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ehpTu1u9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430652; x=1776966652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OkcRkYHAR4Otv+Uk66lK6k1eF+5Jp14O8IBgr67qKS8=; b=ehpTu1u9P4nu8m3dloPjhXhViLnOzS7NRho0spGRMPBi2Q6rC3WxxPVt 3Rwdrjs87u370zsy8DSStV2cdgbXJF9d3FOrRhS/RDGuy95vo4umj3mcb csHFSOyT3gjl9PcpC2x87idAYyDWlVZEobSeyxBIUVLrRE6ULkYW5ONTZ 45aw5KBPDKZ17Jpp8ONIiW4FAQuN5LR80ktfXSezZcUMHVYTjl4IVJks8 t+CgtZNw63AN4CPTZ5bwEi6+mq2OdQynXypcCCp/v6GhXqTYrAH463yTA zFCCdYTXY4vTqVPNwrSt+mSQ+7MfGemOrDymvcvEDAaep5lcBJItWgde8 Q==; X-CSE-ConnectionGUID: gKCw+OTgQc+XP/DjCXJk/Q== X-CSE-MsgGUID: khOgRIAvQ6+MgvGI1z7v/w== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168316" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168316" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:50 -0700 X-CSE-ConnectionGUID: S97pBJb3RqqCtyigAulA4A== X-CSE-MsgGUID: 27JVomB2QPekfE6KfO4oZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350458" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:50 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 1/7] sysfs: Rename attribute group visibility macros Date: Wed, 23 Apr 2025 10:50:31 -0700 Message-ID: <20250423175040.784680-2-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Update the naming of several macros to provide clearer semantics for controlling group and attribute visibility per Dan Williams' suggestion. Also, add transitional aliases mapping the old macro names to the new ones so that driver code remains functional before changes are again made in a future macro encapsulation patch. This approach ensures that when the encapsulation work is applied, drivers will only need to be updated once without breaking compatibility. Suggested-by: Dan Williams Signed-off-by: David E. Box Reviewed-by: Dan Williams --- include/linux/sysfs.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 18f7e1fd093c..00dc88776f21 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -116,7 +116,7 @@ struct attribute_group { #define SYSFS_GROUP_INVISIBLE 020000 =20 /* - * DEFINE_SYSFS_GROUP_VISIBLE(name): + * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name): * A helper macro to pair with the assignment of ".is_visible =3D * SYSFS_GROUP_VISIBLE(name)", that arranges for the directory * associated with a named attribute_group to optionally be hidden. @@ -142,7 +142,7 @@ struct attribute_group { * return true; * } * - * DEFINE_SYSFS_GROUP_VISIBLE(example); + * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(example); * * static struct attribute_group example_group =3D { * .name =3D "example", @@ -153,9 +153,9 @@ struct attribute_group { * Note that it expects _attr_visible and _group_visible to * be defined. For cases where individual attributes do not need * separate visibility consideration, only entire group visibility at - * once, see DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(). + * once, see DEFINE_SYSFS_GROUP_VISIBILITY(). */ -#define DEFINE_SYSFS_GROUP_VISIBLE(name) \ +#define DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name) = \ static inline umode_t sysfs_group_visible_##name( \ struct kobject *kobj, struct attribute *attr, int n) \ { \ @@ -165,9 +165,9 @@ struct attribute_group { } =20 /* - * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name): + * DEFINE_SYSFS_GROUP_VISIBILITY(name): * A helper macro to pair with SYSFS_GROUP_VISIBLE() that like - * DEFINE_SYSFS_GROUP_VISIBLE() controls group visibility, but does + * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY() controls group visibility, but do= es * not require the implementation of a per-attribute visibility * callback. * Ex. @@ -179,7 +179,7 @@ struct attribute_group { * return true; * } * - * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(example); + * DEFINE_SYSFS_GROUP_VISIBILITY(example); * * static struct attribute_group example_group =3D { * .name =3D "example", @@ -187,7 +187,7 @@ struct attribute_group { * .attrs =3D &example_attrs, * }; */ -#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) \ +#define DEFINE_SYSFS_GROUP_VISIBILITY(name) \ static inline umode_t sysfs_group_visible_##name( \ struct kobject *kobj, struct attribute *a, int n) \ { \ @@ -197,12 +197,12 @@ struct attribute_group { } =20 /* - * Same as DEFINE_SYSFS_GROUP_VISIBLE, but for groups with only binary + * Same as DEFINE_SYSFS_GROUP_COMBO_VISIBILITY, but for groups with only b= inary * attributes. If an attribute_group defines both text and binary * attributes, the group visibility is determined by the function * specified to is_visible() not is_bin_visible() */ -#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) = \ +#define DEFINE_SYSFS_BIN_GROUP_COMBO_VISIBILITY(name) = \ static inline umode_t sysfs_group_visible_##name( \ struct kobject *kobj, const struct bin_attribute *attr, int n) \ { \ @@ -211,7 +211,7 @@ struct attribute_group { return name##_attr_visible(kobj, attr, n); \ } =20 -#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) = \ +#define DEFINE_SYSFS_BIN_GROUP_VISIBILITY(name) \ static inline umode_t sysfs_group_visible_##name( \ struct kobject *kobj, const struct bin_attribute *a, int n) \ { \ @@ -220,6 +220,12 @@ struct attribute_group { return a->mode; \ } =20 +/* Transitional aliases: so legacy code using old names continues to work = */ +#define DEFINE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_COMBO_VISIBILI= TY(name) +#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_VISIBIL= ITY(name) +#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP_COMBO_= VISIBILITY(name) +#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP= _VISIBILITY(name) + #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn =20 /* --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 C345728CF51; Wed, 23 Apr 2025 17:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430654; cv=none; b=fK3c9YnM2XHvbeeL/+dek2ur+LAcS9kX29JFMtCiqNR9M1EJ6k4XcpBoeq6QYKKuentRlUptC0NCS6eB3uWJliOHDTdbi7RbvJCVyINRVc7FTSZLV4ZOODvOJZ/Ms8EpBFYcQio5cxusG+q2dTOqr2fepq3F5X176k4m7ri9sTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430654; c=relaxed/simple; bh=bSyyGAF7NDhuTcHIZRedFHdRfL4/pg8/D3ANmwJWapg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hPmL2D8++yOKpH0shW9RNHqo7ZPrKgLra/KYuUHFRNESJ1LzkP7tcGiAtqAMA+DunTNAZ/ghm8N6g0WMvplZolhdQ6wZsExV7m//543qhVSVUmChqp4Dmt9QnnLWvjdVlsEhdcInTEX9yJiv03k5O9y3NCHraxWnQBwOAUWfYZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PU5s3wPF; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PU5s3wPF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430653; x=1776966653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bSyyGAF7NDhuTcHIZRedFHdRfL4/pg8/D3ANmwJWapg=; b=PU5s3wPF+XXiNzcSFPEfQRrfjIFir47k0H1hoy0LJlToxb/Ax6YXyktq QDAJFfmZo+gNVC39DKvafyXKNxNK22lU12Ij2s4IMI4go4Wc6APgR0RmA FKRHlkw9ZqaigYdymVQdWuZpTnbCw8TCJOFqxx8GECuRGZcPexPx4GPzc hkjGeTY95lyqsufVCOdov9469vthB/Is6Gm18h0i3P7abpCG+nmHwPQEB QlPucEeTYQFl6aw4vbgS84HsbTlnxezNgmnXm+Pi8cQ7vKoLGxzE44rmF hK5kt/QQhFovlFJIdDU+UWsP6lw2qI98YbBHJZ6sf9rBo+yQhLBktiKdj w==; X-CSE-ConnectionGUID: yJznvKtrS0ynKq0XdnReeA== X-CSE-MsgGUID: yuf9R3s4Ruu6yl3CA+dfkA== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168325" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168325" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 X-CSE-ConnectionGUID: 3Zp1D5lvQ9yIKNRtoWBFlw== X-CSE-MsgGUID: vBnpBvT/RDyuCY+UgFwLvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350462" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 2/7] sysfs: Introduce macros to simplify creation of visible attribute groups Date: Wed, 23 Apr 2025 10:50:32 -0700 Message-ID: <20250423175040.784680-3-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Introduce macros to reduce boilerplate in attribute group definitions. Combine DEFINE_SYSFS_ATTRIBUTE_GROUP_[COMBO]_VISIBILITY() with attribute definitions in order to simplify group declarations involving visibility logic. Signed-off-by: David E. Box Reviewed-by: Andy Shevchenko Reviewed-by: Dan Williams --- include/linux/sysfs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 00dc88776f21..0804bffd6013 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -303,6 +303,30 @@ static const struct attribute_group _name##_group =3D = { \ }; \ __ATTRIBUTE_GROUPS(_name) =20 +#define NAMED_ATTRIBUTE_GROUP_VISIBLE(_name) \ +DEFINE_SYSFS_GROUP_VISIBILITY(_name); \ +static const struct attribute_group _name##_group =3D { \ + .name =3D __stringify(_name), \ + .attrs =3D _name##_attrs, \ + .is_visible =3D SYSFS_GROUP_VISIBLE(_name), \ +} + +#define NAMED_ATTRIBUTE_GROUPS_VISIBLE(_name) \ +NAMED_ATTRIBUTE_GROUP_VISIBLE(_name); \ +__ATTRIBUTE_GROUPS(_name) + +#define NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(_name) \ +DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(_name); \ +static const struct attribute_group _name##_group =3D { \ + .name =3D __stringify(_name), \ + .attrs =3D _name##_attrs, \ + .is_visible =3D SYSFS_GROUP_VISIBLE(_name), \ +} + +#define NAMED_ATTRIBUTE_GROUPS_COMBO_VISIBLE(_name) \ +NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(_name); \ +__ATTRIBUTE_GROUPS(_name) + struct file; struct vm_area_struct; struct address_space; --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 21F6D28D826; Wed, 23 Apr 2025 17:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430655; cv=none; b=FJysrOLpJ5Zf8+6vY5V9cmaQhUgDX8h33C/XDBBeVS1oE7+3TyZfmJ9nouDWSaH5MGJ2UiEJOvQ/zKp3oqtrbSuPAYZ01CRM2ZFZwwAQHCdFvGDolXNj8xRFrOveeZxZp9TTb99ToU+JjZSDFKHjw+OJ2SmDDchlXyyZo44uDaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430655; c=relaxed/simple; bh=IJCyRhnBl/jq8ICFiPmQRSjel5Gqz/wB2SAcG7SGuTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nEF1ziNqKikJJgVSzL1R8Z4MC+wlJVzjLE5fL/n6v289rDY5mFNcMgMIA8wXG8Y+j2OPGvUHTP52SSU5sRXZ0gCgp0B+SN8SH6VaROYvLhoLojah2GSWS1tYytgXdp6zCs41n/3gXdQ1tFk2S8d0vpJDUFGEO+ePp2AbnuhDlbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ijI5Bs2y; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ijI5Bs2y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430653; x=1776966653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IJCyRhnBl/jq8ICFiPmQRSjel5Gqz/wB2SAcG7SGuTU=; b=ijI5Bs2yRe42iEeYQe8KyfDmovTappy5+nE8jRknXWFzradmdswjz2EP 4nUQYXhkkj1TnyIkRgawAzQOETeJXpzjnh7857mYkcB+0SkVI7Z0SnLHf jIPMmK+ON+DTLhOLoLAIfJouW2OySN+k2GE2KGldeWECN3cRmLc0BZp9B BjTN2V+PhWD7isQq3dfchPX6HiFHwN+CInt7SJsBUMBNqDckTBxHzxx3M q3zWIkyyIFYSH97BymiLawAUFNps66iHA6ChTiN5TNIrqaL8Dacey8+dE 8IfwNCIaQDdDV+mivdEozTR8MxY7XQHYqnw3i3C7po72fkdEw31udxFYz g==; X-CSE-ConnectionGUID: Ov0x0mhxRh2EhHNKOOJM2Q== X-CSE-MsgGUID: PWcvIQMWQzqdXPGPD2/aPA== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168334" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168334" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 X-CSE-ConnectionGUID: 485ZsBaRRHeCIEPewcWQNQ== X-CSE-MsgGUID: BQw05VOXTYqOkMhR2d36PQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350466" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 3/7] docs: sysfs.rst: document additional attribute group macros Date: Wed, 23 Apr 2025 10:50:33 -0700 Message-ID: <20250423175040.784680-4-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Add documentation to Documentation/filesystems/sysfs.rst for several sysfs helper macros, including recently introduced and previously undocumented helpers. Document the following macros: __ATTR_IGNORE_LOCKDEP DEFINE_SYSFS_GROUP_VISIBILITY DEFINE_SYSFS_BIN_GROUP_VISIBILITY DEFINE_SYSFS_BIN_GROUP_COMBO_VISIBILITY ATTRIBUTE_GROUPS BIN_ATTRIBUTE_GROUPS NAMED_ATTRIBUTE_GROUP_VISIBLE NAMED_ATTRIBUTE_GROUPS_VISIBLE NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE NAMED_ATTRIBUTE_GROUPS_COMBO_VISIBLE Suggested-by: Andy Shevchenko Signed-off-by: David E. Box Reviewed-by: Dan Williams --- Documentation/filesystems/sysfs.rst | 244 ++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystem= s/sysfs.rst index c32993bc83c7..16bcc3e7c80c 100644 --- a/Documentation/filesystems/sysfs.rst +++ b/Documentation/filesystems/sysfs.rst @@ -147,6 +147,250 @@ __ATTR_RW(name): __ATTR_NULL: which sets the name to NULL and is used as end of list indicator (see: kernel/workqueue.c) +__ATTR_IGNORE_LOCKDEP(name, mode, show, store): + like __ATTR() but disables lockdep checks; used in cases + where lockdep may emit false positives + +Additional Attribute Helpers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ATTRIBUTE_GROUPS(name): + Convenience macro to create an array of attribute group pointers. + +Example:: + + static struct attribute *foo_attrs[] =3D { + &attr1.attr, + &attr2.attr, + NULL + }; + ATTRIBUTE_GROUPS(foo); + +BIN_ATTRIBUTE_GROUPS(name): + Same as ATTRIBUTE_GROUPS(), but for bin_attribute_group structures. + +Example:: + + static struct bin_attribute *foo_attrs[] =3D { + &bin_attr1.attr, + &bin_attr2.attr, + NULL + }; + BIN_ATTRIBUTE_GROUPS(bin_foo); + +DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name): + A helper macro to pair with the assignment of + + ".is_visible =3D SYSFS_GROUP_VISIBLE(name)", + + that arranges for the directory associated with a named attribute_= group + to optionally be hidden. This allows for static declaration of + attribute_groups, and the simplification of attribute visibility + lifetime that implies, without polluting sysfs with empty attribute + directories. + +Example:: + + static umode_t example_attr_visible(struct kobject *kobj, + struct attribute *attr, int n) + { + if (example_attr_condition) + return 0; + if (ro_attr_condition) + return 0444; + return a->mode; + } + + static bool example_group_visible(struct kobject *kobj) + { + if (example_group_condition) + return false; + return true; + } + + DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(example); + + static struct attribute_group example_group =3D { + .name =3D "example", + .is_visible =3D SYSFS_GROUP_VISIBLE(example), + .attrs =3D &example_attrs, + }; + +Note that it expects _attr_visible and _group_visible to +be defined. For cases where individual attributes do not need +separate visibility consideration, only entire group visibility at +once, see DEFINE_SYSFS_GROUP_VISIBILITY(). + +DEFINE_SYSFS_GROUP_VISIBILITY(name): + A helper macro to pair with SYSFS_GROUP_VISIBLE() that, like + DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(), controls group visibility, = but + does not require the implementation of a per-attribute visibility + callback. + +Example:: + + static bool example_group_visible(struct kobject *kobj) + { + if (example_group_condition) + return false; + return true; + } + + DEFINE_SYSFS_GROUP_VISIBILITY(example); + + static struct attribute_group example_group =3D { + .name =3D "example", + .is_visible =3D SYSFS_GROUP_VISIBLE(example), + .attrs =3D &example_attrs, + }; + +DEFINE_SYSFS_BIN_GROUP_COMBO_VISIBILITY(name): +DEFINE_SYSFS_BIN_GROUP_VISIBILITY(name): + Same as DEFINE_SYSFS_GROUP_VISIBILITY(), but for groups with only = binary + attributes. If an attribute_group defines both text and binary + attributes, the group visibility is determined by the function + specified to is_visible() not is_bin_visible(). + +Named Attribute Group Macros (with visibility) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These macros define struct attribute_group objects with a static name and +visibility function(s). They are useful for creating named directories in = sysfs +where individual attributes can be conditionally exposed. + +NAMED_ATTRIBUTE_GROUP_VISIBLE(name): + Defines an attribute group with a fixed directory name (matching n= ame) + with a group visibility function. Expects an attribute array + _attrs. The macro automatically defines the visibility funct= ion. + +Example:: + + static ssize_t foo_show(struct device *dev, struct device_attribute *a= ttr, + char *buf) + { + ... + } + + static ssize_t foo_store(struct device *dev, struct device_attribute *= attr, + const char *buf, size_t count) + { + ... + } + static DEVICE_ATTR_RW(foo); + + static bool bar_group_visible(struct kobject *kobj) + { + if (bar_group_condition) + return false; + return true; + } + + static struct attribute *bar_attrs[] =3D { + &dev_attr_foo.attr, + NULL + }; + NAMED_ATTRIBUTE_GROUP_VISIBLE(bar); + +Creates:: + + static const struct attribute_group bar_group =3D { + .name =3D "bar", + .attrs =3D bar_attrs, + .is_visible =3D SYSFS_GROUP_VISIBLE(bar), + }; + + /* + * Where SYSFS_GROUP_VISIBLE(bar) is a function created by + * DEFINE_SYSFS_GROUP_VISIBILITY(bar) that calls bar_group_visible(). + */ + +NAMED_ATTRIBUTE_GROUPS_VISIBLE(name): + Like NAMED_ATTRIBUTE_GROUP_VISIBLE(), defines the visible attribute + group but also creates the group list _groups[]. + +Example:: + + ... + + static struct attribute *bar_attrs[] =3D { + &attr1.attr, + &attr2.attr, + NULL + }; + NAMED_ATTRIBUTE_GROUPS_VISIBLE(bar); + +Creates:: + + static const struct attribute_group bar_group =3D { + .name =3D "bar", + .attrs =3D bar_attrs, + .is_visible =3D SYSFS_GROUP_VISIBLE(bar), + }; + + static const struct attribute_group *bar_groups[] =3D { + &bar_group, + NULL + }; + +NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(name): + Same as NAMED_ATTRIBUTE_GROUP_VISIBLE(), but uses the "combo" visi= bility + variant to support both group and per-attribute visibility control. + Automatically generates the combo visibility boilerplate. + +Example:: + + static ssize_t foo_show(struct device *dev, struct device_attribute *a= ttr, + char *buf) + { + ... + } + + static ssize_t foo_store(struct device *dev, struct device_attribute *= attr, + const char *buf, size_t count) + { + ... + } + static DEVICE_ATTR_RW(foo); + + static umode_t foo_attr_visible(struct kobject *kobj, + struct attribute *attr, int n) + { + if (example_attr_condition) + return 0; + return attr->mode; + } + + static bool foo_group_visible(struct kobject *kobj) + { + if (foo_group_condition) + return false; + return true; + } + + static struct attribute *foo_attrs[] =3D { + &dev_attr_foo.attr, + NULL + }; + NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(foo); + +Creates:: + + static const struct attribute_group foo_group =3D { + .name =3D "foo", + .attrs =3D foo_attrs, + .is_visible =3D SYSFS_GROUP_VISIBLE(foo), + }; + + /* + * Where SYSFS_GROUP_VISIBLE(foo) is a function created by + * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(foo) that calls foo_group_visib= le() + * and foo_attr_visible(). + */ + +NAMED_ATTRIBUTE_GROUPS_COMBO_VISIBLE(name): + Like NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE() defines the attribute g= roup, + supporting both group and per-attribute visibility control, but al= so + creates the group list _groups[]. =20 Subsystem-Specific Callbacks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 F0F7228D830; Wed, 23 Apr 2025 17:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430655; cv=none; b=hY3P2Bj+UZgTYpa5EjHA9s7wc8rsCsbVCDVqq9sVTQJDDANy6FD4707BJS0F+M10KMT2Pt44IVLAUmUWs8vSZryiGKqcehDrbcNWsf+zQ02n4pRCGLdpMltXIOYiuJ7bWhM+eVIS+dtn5jbiLyTqOqIHHgq/AQshpgkdJhYwsTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430655; c=relaxed/simple; bh=4u53bdRqrxzWq/iPTyUJM9eZJs7UD/VsGD1bWIkiQ6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jDZQrXyMzAOQDmKCo3XRzn3fYxJVLKU9E/1arHjiQ1+j3/ODY6qvijGKxcN0t5vff8B5KATAnS9AabDB2OZeeOD9fchTuyH3miYq+2xQkBuheoA5nbw/dXVYOLS/XxMXOzGVaH0B/QhjEfE+CiSzCK5XgZLj58JszQKa379FR0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=J5Eq98EZ; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J5Eq98EZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430654; x=1776966654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4u53bdRqrxzWq/iPTyUJM9eZJs7UD/VsGD1bWIkiQ6w=; b=J5Eq98EZKXw1PvBTMgstAYioQpwvw3efkdIT2Ia+WAZaAEaSEVJxHj/T OoP5GY7WS3YMZEBvMAuz77eyAt6B5pvJ+4r82BBw9DeXuMZPxcA2/tgTp uNVF1yQ468OklQ/YJS2IClj9CI6hvDKgwmbteRQySk9HNJOqxJffMbZ9h sJDAomrXR4V7NA5tg5VLH0SXItuxPMV6kFEhRoOS2a1tYG2/Jx1ISeIQm lH4n2L6wrtj8z1zEJJqKA5JS1l1/ooE686KncM07BheIX7ze5U6800lVD 0z0+IIbjX7pw4cjw5IOhFcozvz+7m1thuo6yhbm0uRcqYJU1MVm4MmlSo w==; X-CSE-ConnectionGUID: F+gemsb8QAqykPBAsvE0sg== X-CSE-MsgGUID: SvS+rZkyTZqkznpZtq6ZvA== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168343" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168343" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 X-CSE-ConnectionGUID: UtMSOq5hRtKpzaJUR3IMWg== X-CSE-MsgGUID: 1nSsHHFLTvSVb510yhqoOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350469" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:51 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 4/7] pci: doe: Replace sysfs visibility macro Date: Wed, 23 Apr 2025 10:50:34 -0700 Message-ID: <20250423175040.784680-5-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Replace deprecated DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE() call with the new DEFINE_SYSFS_GROUP_VISIBILITY() helper for the pci_doe_features_sysfs group in drivers/pci/doe.c. Signed-off-by: David E. Box Reviewed-by: Dan Williams --- drivers/pci/doe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c index aae9a8a00406..18b355506dc1 100644 --- a/drivers/pci/doe.c +++ b/drivers/pci/doe.c @@ -119,7 +119,7 @@ static bool pci_doe_features_sysfs_group_visible(struct= kobject *kobj) =20 return !xa_empty(&pdev->doe_mbs); } -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(pci_doe_features_sysfs) +DEFINE_SYSFS_GROUP_VISIBILITY(pci_doe_features_sysfs) =20 const struct attribute_group pci_doe_sysfs_group =3D { .name =3D "doe_features", --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 A385F28D85D; Wed, 23 Apr 2025 17:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430656; cv=none; b=rZUo1Ub18D4EsR/nnpHyTqM1ZzwtAl1+DI83ku6nIQZrxiyXNKP7zMa/3u2jJFMN5nPxz8DM5B9P+MCrFJX1VjTw4eLohkFeAlqt0+HSuKYB5f6i+1W1PtnOn5dqFBJhKuWJm1PZQSo4UNBN+NVtOgDRcsbAMCp6NhmXiiFFRIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430656; c=relaxed/simple; bh=pspP0LoaB25ewweJpkQNKt1iGCUbJ6t/mkm9l0BSOVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YxfuWen+cTAwU+6hcvZlLK9iS5Fe4kGW5VVn4hdI6pgWWXncKiMTtNbOhlX5HcTs7X6H+rvKbDlhBfo3LQ4VnOe49wp2y9EL1Nx5DyBOVMEvEIIJR14cvf2fH5QjdiSO743aZZT2Ijbd7SJ4Ihw41HTKvN5NhOvzAsx/idxmx5c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IPooBr7l; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IPooBr7l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430655; x=1776966655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pspP0LoaB25ewweJpkQNKt1iGCUbJ6t/mkm9l0BSOVU=; b=IPooBr7lFf1+faR8WHphNIrnWXXxlevJ6tDgrQihw1kqjyUC3+V3Pst0 W5HhhMMiYCIZ2okCl1jkhGF6F0tm3K1Bwo0cuJvd+gcKH9G9X9a0wG8Xh X3q7ZvP8BtJRVSRoOhkvqwcyXUC/7eXzHYBKcUe536lqDj4EP1nX7iWAX Xbq1yPdL7zrM3CqFfgo19iKvxMM4/8xXEamfxk5w6x9LGMM8K8a8Na9vq 3Fff/hPHxdxWB+j/FwqJZz8ToLbOQxOFNVb9Ore50yEwlyKzv/X4uSfON SMsZKtygw0V+V0K9PSl9Ti7uxoZ0mw9Sf55jupDn/mP1uIBhHELQOYrKR w==; X-CSE-ConnectionGUID: I9ztMGPQRP6foR41NcRO3w== X-CSE-MsgGUID: y9s1ZnT5R2ODGOWmE3v0Wg== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168352" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168352" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:52 -0700 X-CSE-ConnectionGUID: xwHH6O9mSkq8biLXi0V1ig== X-CSE-MsgGUID: H3DH1ZQyT1+9xMampYd3Kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350474" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:52 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 5/7] soundwire: sysfs: Use ATTRIBUTE_GROUP_VISIBLE() Date: Wed, 23 Apr 2025 10:50:35 -0700 Message-ID: <20250423175040.784680-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Replace the manual definition of the dp0 attribute group with the newly introduced ATTRIBUTE_GROUP_VISIBLE() macro, simplifying the code and improving maintainability. Consolidate the definition of dp0_attrs and move the attribute array above the macro so that they are visibly tied together. While here, also remove the unneeded trailing comma after NULL at the end of all attribute arrays. No functional changes are intended. Signed-off-by: David E. Box Reviewed-by: Andy Shevchenko Reviewed-by: Dan Williams --- drivers/soundwire/sysfs_slave.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/soundwire/sysfs_slave.c b/drivers/soundwire/sysfs_slav= e.c index c5c22d1708ec..400f2a17f140 100644 --- a/drivers/soundwire/sysfs_slave.c +++ b/drivers/soundwire/sysfs_slave.c @@ -103,7 +103,7 @@ static DEVICE_ATTR_RO(modalias); =20 static struct attribute *slave_attrs[] =3D { &dev_attr_modalias.attr, - NULL, + NULL }; =20 static const struct attribute_group slave_attr_group =3D { @@ -126,7 +126,7 @@ static struct attribute *slave_dev_attrs[] =3D { &dev_attr_master_count.attr, &dev_attr_source_ports.attr, &dev_attr_sink_ports.attr, - NULL, + NULL }; =20 static const struct attribute_group sdw_slave_dev_attr_group =3D { @@ -170,16 +170,6 @@ static ssize_t words_show(struct device *dev, } static DEVICE_ATTR_RO(words); =20 -static struct attribute *dp0_attrs[] =3D { - &dev_attr_max_word.attr, - &dev_attr_min_word.attr, - &dev_attr_words.attr, - &dev_attr_BRA_flow_controlled.attr, - &dev_attr_simple_ch_prep_sm.attr, - &dev_attr_imp_def_interrupts.attr, - NULL, -}; - static umode_t dp0_attr_visible(struct kobject *kobj, struct attribute *at= tr, int n) { @@ -198,19 +188,23 @@ static bool dp0_group_visible(struct kobject *kobj) return true; return false; } -DEFINE_SYSFS_GROUP_VISIBLE(dp0); =20 -static const struct attribute_group dp0_group =3D { - .attrs =3D dp0_attrs, - .is_visible =3D SYSFS_GROUP_VISIBLE(dp0), - .name =3D "dp0", +static struct attribute *dp0_attrs[] =3D { + &dev_attr_max_word.attr, + &dev_attr_min_word.attr, + &dev_attr_words.attr, + &dev_attr_BRA_flow_controlled.attr, + &dev_attr_simple_ch_prep_sm.attr, + &dev_attr_imp_def_interrupts.attr, + NULL }; +NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(dp0); =20 const struct attribute_group *sdw_attr_groups[] =3D { &slave_attr_group, &sdw_slave_dev_attr_group, &dp0_group, - NULL, + NULL }; =20 /* @@ -249,7 +243,7 @@ static DEVICE_ATTR_RO(device_number); static struct attribute *slave_status_attrs[] =3D { &dev_attr_status.attr, &dev_attr_device_number.attr, - NULL, + NULL }; =20 /* --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 34C4928DF1D; Wed, 23 Apr 2025 17:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430657; cv=none; b=cKC/0H/XFkGIX70pudGtN6aU4APy6pgA8nL9dIvbn4vLRY8vFzZ4qm1hJTzTGhzCZWrI9TZV51bcT5c6zjlO1IpW2+U1TYf8dTPuBS1HsficZHy0I4SvYervFFjTGfYKoxK6hlDvV2fpUlWUq/yZM+2H2RxHd1bucs7M1fp1Z3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430657; c=relaxed/simple; bh=IBk/naibZDvcxq96fwpE5v2/BJFqKlCrOvkCRVqKOtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gu+upIIaN5FNu6CWvcbA1l9SVRYDrCzvA5ktjDQdfvdVUtdaQYcwql1mlCGjf/qI8Vk3V3dUhlTGj9c1/7lEyYSLbmJGdSq+uWa4js5QCe8IulV3S0M+Ce4MpXpPZ8R/sVdRj2R11iDEFOdquWCvvJDSizZd0hBvzkoz1iJikZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bmbtD7zJ; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bmbtD7zJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430655; x=1776966655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IBk/naibZDvcxq96fwpE5v2/BJFqKlCrOvkCRVqKOtg=; b=bmbtD7zJa9bOi/fNz+6bGuMRfvDUhuEccyn/xUQNRu62Eb5GqNM45px7 V5sdQPH3k0qda9x8qIPCY0AHef59R37IBArp8FVVNtCrG4gu3lzgOiWpk 2t3f8uzRDSNVqdMxQKgZtZ0HgPrb46Bas5bhZ0Qc5k2ih4YUd/lF+Zk68 fqcVd9KAVpCjet69TrmlI/OBir/vJHsovQWkCxbvI5Lt4SvW8FlS3KQc6 UCz4z2mcnxolnV4jXmSDQ5IDVEvlKvsuQNqg0Ywnnd+FwIoVtG3a/AMlj bYweVm71qsv5xllbMm0RagC2OwUK6zAk7GV0a7bPrL8DQpfPjIfLw5iip A==; X-CSE-ConnectionGUID: xGK/yia6TWS1j7QymFhjJw== X-CSE-MsgGUID: FYp+35JkQ+iwq4jgwww7rg== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168361" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168361" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:52 -0700 X-CSE-ConnectionGUID: dOxbRnqNSNSFZoq87BiKHA== X-CSE-MsgGUID: d8u3x7iUQFS0pjwR1InBCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350482" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:52 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 6/7] platform/x86/dell: alienware-wmi: update sysfs visibility macros Date: Wed, 23 Apr 2025 10:50:36 -0700 Message-ID: <20250423175040.784680-7-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Replace deprecated visibility macros and align group naming with new API. In alienware-wmi-base.c, use NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(rgb_zones) to define the rgb_zones attribute group concisely. To preserve the existing userspace ABI, rename zone_attr_visible and rgb_zones_attr_visible to zone_group_visible and rgb_zones_group_visible, respectively, to reflect the 'rgb_zones' group. In alienware-wmi-wmax.c, replace DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE() with the renamed DEFINE_SYSFS_GROUP_VISIBILITY() macro for the hdmi, amplifier, and deepsleep attributes to match the updated API. While here, add missing sysfs.h include and sort headers alphabetically. No functional changes are intended. Signed-off-by: David E. Box Reviewed-by: Dan Williams Reviewed-by: Kurt Borja --- .../platform/x86/dell/alienware-wmi-base.c | 23 ++++++++----------- .../platform/x86/dell/alienware-wmi-wmax.c | 7 +++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platf= orm/x86/dell/alienware-wmi-base.c index 64562b92314f..ee41892e562c 100644 --- a/drivers/platform/x86/dell/alienware-wmi-base.c +++ b/drivers/platform/x86/dell/alienware-wmi-base.c @@ -10,10 +10,11 @@ =20 #include #include -#include -#include #include #include +#include +#include +#include #include "alienware-wmi.h" =20 MODULE_AUTHOR("Mario Limonciello "); @@ -326,8 +327,8 @@ static ssize_t lighting_control_state_store(struct devi= ce *dev, =20 static DEVICE_ATTR_RW(lighting_control_state); =20 -static umode_t zone_attr_visible(struct kobject *kobj, - struct attribute *attr, int n) +static umode_t rgb_zones_attr_visible(struct kobject *kobj, + struct attribute *attr, int n) { if (n < alienfx->num_zones + 1) return attr->mode; @@ -335,13 +336,12 @@ static umode_t zone_attr_visible(struct kobject *kobj, return 0; } =20 -static bool zone_group_visible(struct kobject *kobj) +static bool rgb_zones_group_visible(struct kobject *kobj) { return alienfx->num_zones > 0; } -DEFINE_SYSFS_GROUP_VISIBLE(zone); =20 -static struct attribute *zone_attrs[] =3D { +static struct attribute *rgb_zones_attrs[] =3D { &dev_attr_lighting_control_state.attr, &dev_attr_zone00.attr, &dev_attr_zone01.attr, @@ -349,12 +349,7 @@ static struct attribute *zone_attrs[] =3D { &dev_attr_zone03.attr, NULL }; - -static struct attribute_group zone_attribute_group =3D { - .name =3D "rgb_zones", - .is_visible =3D SYSFS_GROUP_VISIBLE(zone), - .attrs =3D zone_attrs, -}; +NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(rgb_zones); =20 /* * LED Brightness (Global) @@ -410,7 +405,7 @@ static int alienfx_probe(struct platform_device *pdev) } =20 static const struct attribute_group *alienfx_groups[] =3D { - &zone_attribute_group, + &rgb_zones_group, WMAX_DEV_GROUPS NULL }; diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 0c3be03385f8..559415849bcc 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "alienware-wmi.h" =20 @@ -356,7 +357,7 @@ static bool hdmi_group_visible(struct kobject *kobj) { return alienware_interface =3D=3D WMAX && alienfx->hdmi_mux; } -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); +DEFINE_SYSFS_GROUP_VISIBILITY(hdmi); =20 static struct attribute *hdmi_attrs[] =3D { &dev_attr_cable.attr, @@ -404,7 +405,7 @@ static bool amplifier_group_visible(struct kobject *kob= j) { return alienware_interface =3D=3D WMAX && alienfx->amplifier; } -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); +DEFINE_SYSFS_GROUP_VISIBILITY(amplifier); =20 static struct attribute *amplifier_attrs[] =3D { &dev_attr_status.attr, @@ -475,7 +476,7 @@ static bool deepsleep_group_visible(struct kobject *kob= j) { return alienware_interface =3D=3D WMAX && alienfx->deepslp; } -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); +DEFINE_SYSFS_GROUP_VISIBILITY(deepsleep); =20 static struct attribute *deepsleep_attrs[] =3D { &dev_attr_deepsleep.attr, --=20 2.43.0 From nobody Wed Dec 17 07:05:58 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 EB02F28E61A; Wed, 23 Apr 2025 17:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430657; cv=none; b=YBgRmPm5jc2+sgUzW3ILuz6PUxGv0iOkSnFzi7ot89VkUd2D/rVa1mU2HzQ2b0E+zuE1icvmCGjH8nFftBTeD5zjR/VLNIQYjdqr/jGkRmw7HN4Rwaud7kOdsdaeviF7mT0B3044+Q8Mqx8mhiC7lrQDlIejRAqaZ0HnVu7Bc7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745430657; c=relaxed/simple; bh=Anj1LmE3HMj4PrtjKAY91OthCI8uL5I4H5KJF+CQhR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G9eNy0Bj8AD/UwAKXZ0hHLasd9nnucGJiJGkAHb6MnEn0diV5DCEqt+M5y8ZQt54jZwYOiCzDjlrRYXKToVuMIU/laMTbFUwyCvVV2pnT7PEvm2t+G3qh5WJMgOymWD2SfBXaxN0cridGQOVRt7OrFFn32BWB9KeUjWPYpRFBoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hMy/5VOP; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hMy/5VOP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745430656; x=1776966656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Anj1LmE3HMj4PrtjKAY91OthCI8uL5I4H5KJF+CQhR0=; b=hMy/5VOP1AXp0XlMTP5xgapXB/aVUdKWF9zjdP/kcy0VcZ3Q0U9mJI4U KdA86bSU2hyw7sw9TOFXj63zlvZ0LGfP7vIGp0i6wxV/BVCFCmrjZm/Rx bCfO7Wi3Ae1suUIE9l/YSWECZVpT/nFz85u0BphEuUOpa8Ix7Ty6gs/Eu I2VxHY4O1u3JAb6jOHZ8wGfwjnAoyNqyaeWe/zt1s94pjhfxLQETQH+t4 6L8rAtU2v1HDP58eg/HljmMsZ14lVyv8hJ6yav4tzYetnj4Ztb1l95p1w ADmF/wNIgfPvYfwI03JAz6+76EuPmNsinRYCCTgUPoBeqZdd/KMYynN53 g==; X-CSE-ConnectionGUID: EsYSrsqySUG5CWGK+PVwfg== X-CSE-MsgGUID: 4pl+teqyTT6Iq+H6wa0gqw== X-IronPort-AV: E=McAfee;i="6700,10204,11412"; a="47168370" X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="47168370" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:53 -0700 X-CSE-ConnectionGUID: fGvrM/tlSRuTUeCqu2SAug== X-CSE-MsgGUID: MoJ3ndr2S1KcaJAjbhCHag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,233,1739865600"; d="scan'208";a="163350486" Received: from ldmartin-desk2.corp.intel.com (HELO debox1-desk4.lan) ([10.125.111.241]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2025 10:50:52 -0700 From: "David E. Box" To: corbet@lwn.net, bhelgaas@google.com, kuurtb@gmail.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, sanyog.r.kale@intel.com, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, david.e.box@linux.intel.com, dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com, linux-sound@vger.kernel.org Subject: [PATCH 7/7] sysfs: Remove transitional attribute group alias macros Date: Wed, 23 Apr 2025 10:50:37 -0700 Message-ID: <20250423175040.784680-8-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423175040.784680-1-david.e.box@linux.intel.com> References: <20250423175040.784680-1-david.e.box@linux.intel.com> 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" Remove transitional macros used to alias named and visible sysfs attribute group definitions. These were temporarily introduced to ease migration but are now redundant due to the adoption of the new encapsulated NAMED_ATTRIBUTE_* macros across all relevant drivers. Signed-off-by: David E. Box Reviewed-by: Dan Williams --- include/linux/sysfs.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 0804bffd6013..877fd1976668 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -220,12 +220,6 @@ struct attribute_group { return a->mode; \ } =20 -/* Transitional aliases: so legacy code using old names continues to work = */ -#define DEFINE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_COMBO_VISIBILI= TY(name) -#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_VISIBIL= ITY(name) -#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP_COMBO_= VISIBILITY(name) -#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP= _VISIBILITY(name) - #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn =20 /* --=20 2.43.0