Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1201982rdb; Tue, 30 Jan 2024 10:47:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHq8E4j+Akeo3Q2n6d7b6pzUaAbtTWjJKmSdT3/IyqWvfcNCMuUz7XsRgTm8ysX2Nhn2g5 X-Received: by 2002:a05:6358:8a0:b0:178:6dcb:b942 with SMTP id m32-20020a05635808a000b001786dcbb942mr6496718rwj.28.1706640432005; Tue, 30 Jan 2024 10:47:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706640431; cv=pass; d=google.com; s=arc-20160816; b=bvPialF7r8rY/bEPx+kghJ0zAIvdkbRKpeERFaWIie0WRxkgtThMfzzimR0gT1UXWy bo9VrGwJU3tMrfk6YzcDH2GFqMfifqurBEFN8ahGgXGS9N/zowa4Bt8az65Fk0gsz1yj 8yxuqZQRUj56tjaPJJ5LdZXFPlW/t0kbixA2VD77xwy1HZknu7Bz2GvvwfN4jZHMBLT8 7qg4vIJt6+9CLFIN/hGxlp0tZ/akeVAXWjDx35xGv3eWw9w0Wz8U5vl43UPQ7uv9uUVM C5ICmykb+zdJOVdKn2MGvn80UPeWUkjUPvXOIJcQkx8bkjD0ZH5uflBu5FmtACSKzuZc OA5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/MxwDnU7Qm/tFgTCygmukfYx3eJymCRnBBR4t/XpFUk=; fh=ZUcPkiVf4gvMgVDOUhavBu3WqSDJFLN7Q4rE5Smm1Ig=; b=M2T+/jJJOXgJDPvTTlfpaU1TArBwaRwPUpO48b4GfcO+yuUgzgGqwdskmJrDT5SQoU k3g8cBXEQXRfRiGnplrVMOOu+eERzNtRPscN3bjgGfmbQT+fVwUC6CBsPZHVFw7jesl4 c6ndipD2X2opz5E0LPU3aXXUtIMVZGl+slt1Qm+jAMCL7CnuReIu/PWvCP+n2gu4pwv3 QcKGATsdlZhM2SqlDh7FFGVXTee6mzhfL7FPaGlOUAJtxHqLOEUZ/KCG/1a90GNddN+L vdLMoWPZWDmpo0LDGhPQ6edar8JDDo5aNirbmTFJovrDvQi0a0hTVktT0GIiviW0s42L 5bqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gxE/1m3L"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-45134-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h37-20020a631225000000b005be1e55546esi7917477pgl.51.2024.01.30.10.47.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:47:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45134-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gxE/1m3L"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-45134-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 443A3289F10 for ; Tue, 30 Jan 2024 18:47:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07CF25B5CA; Tue, 30 Jan 2024 18:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gxE/1m3L" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 306E778B62 for ; Tue, 30 Jan 2024 18:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706640403; cv=none; b=KjbhpmTARIXwSMs0sv7CxClw2Evz47kMsNCyoH8jobElX6LSw8pLWPlaclmqjBnmQvt3h8mkgjLnEl29Kc+XydOFQm8+WHHIIC5r0jzDqzFyjawtzdBcLVHAK5KRUy2FkDkxY76xzTr5AT11shc+bzjvKxtwph7RD7cRgz4xBoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706640403; c=relaxed/simple; bh=+h2BNyNBH2PQ5+Cwjewz2w+MpDwd4+tscGSgxiN4bBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ONPVfvsjeGc6tjNUm44Sdc64rNaDX3cynwhqygD/+aXxPvjUqXQyBGURCH8v8w1vO2AEmo/MpKW36jKP+KAAlula0pNDhlgv+K+L9rKLG51uaXirOZ3uTpRKzkBcv+xJh53TK1TAbSEAJ9ohoBSn2HafeEEmz/HYOiAqKBmU2PA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gxE/1m3L; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99253C43390; Tue, 30 Jan 2024 18:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706640402; bh=+h2BNyNBH2PQ5+Cwjewz2w+MpDwd4+tscGSgxiN4bBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxE/1m3LBF4/0Uug8Ja3628zL9XNu1jPKRDjIb+WoJn9bSz80+kQE1VSaK8IGV36w kY6fxwphK6yqq4kk4NJSjj89nLgrv9NOzmBSNj/AeKTgQYNP73fFIr+OMI9g4eIS2q bOWkXgSN95hGjetUpnZIgmPF5aJFt6dD6DXjrFjU= From: Greg Kroah-Hartman To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Dan Williams , Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale Subject: [PATCH 3/6] soundwire: sysfs: cleanup the logic for creating the dp0 sysfs attributes Date: Tue, 30 Jan 2024 10:46:29 -0800 Message-ID: <2024013029-budget-mulled-5b34@gregkh> X-Mailer: git-send-email 2.43.0 In-Reply-To: <2024013025-spoiling-exact-ad20@gregkh> References: <2024013025-spoiling-exact-ad20@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 80 X-Developer-Signature: v=1; a=openpgp-sha256; l=2392; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=+h2BNyNBH2PQ5+Cwjewz2w+MpDwd4+tscGSgxiN4bBw=; b=owGbwMvMwCRo6H6F97bub03G02pJDKk7XVhfd9kz3i+ziuUsbZn91kua31/nxW6Lq/e7v0ZWH 3Hb2FLYEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABOpz2WYn5egX7lZUK/wMuuz qjcsv3dWRTbuY5jvNWNKbtb0F41zllTeZXxww81vwYR8AA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit There's no need to special-case the dp0 sysfs attributes, the is_visible() callback in the attribute group can handle that for us, so add that and add it to the attribute group list making the logic simpler overall. This is a step on the way to moving all of the sysfs attribute handling into the default driver core attribute group logic so that the soundwire core does not have to do any of it manually. Cc: Vinod Koul Cc: Bard Liao Cc: Pierre-Louis Bossart Cc: Sanyog Kale Cc: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/soundwire/sysfs_slave.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/soundwire/sysfs_slave.c b/drivers/soundwire/sysfs_slave.c index 83e3f6cc3250..8876c7807048 100644 --- a/drivers/soundwire/sysfs_slave.c +++ b/drivers/soundwire/sysfs_slave.c @@ -184,18 +184,40 @@ static struct attribute *dp0_attrs[] = { NULL, }; +static umode_t dp0_attr_visible(struct kobject *kobj, struct attribute *attr, + int n) +{ + struct sdw_slave *slave = dev_to_sdw_dev(kobj_to_dev(kobj)); + + if (slave->prop.dp0_prop) + return attr->mode; + return 0; +} + +static bool dp0_group_visible(struct kobject *kobj) +{ + struct sdw_slave *slave = dev_to_sdw_dev(kobj_to_dev(kobj)); + + if (slave->prop.dp0_prop) + return true; + return false; +} +DEFINE_SYSFS_GROUP_VISIBLE(dp0); + /* * we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory * for dp0-level properties */ static const struct attribute_group dp0_group = { .attrs = dp0_attrs, + .is_visible = SYSFS_GROUP_VISIBLE(dp0), .name = "dp0", }; static const struct attribute_group *slave_groups[] = { &slave_attr_group, &sdw_slave_dev_attr_group, + &dp0_group, NULL, }; @@ -207,12 +229,6 @@ int sdw_slave_sysfs_init(struct sdw_slave *slave) if (ret < 0) return ret; - if (slave->prop.dp0_prop) { - ret = devm_device_add_group(&slave->dev, &dp0_group); - if (ret < 0) - return ret; - } - if (slave->prop.source_ports || slave->prop.sink_ports) { ret = sdw_slave_sysfs_dpn_init(slave); if (ret < 0) -- 2.43.0