From patchwork Tue Jan 30 18:46:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 194274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1426791dyb; Tue, 30 Jan 2024 10:48:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH43+JG6+hUxfX5JXcwf5mnLPEJRq4sZNeEUlIAbG7ojfknUASAnxqBPbnRp65zbNFy8NcZ X-Received: by 2002:a17:90a:b887:b0:292:6cc5:a881 with SMTP id o7-20020a17090ab88700b002926cc5a881mr6175384pjr.10.1706640493213; Tue, 30 Jan 2024 10:48:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706640493; cv=pass; d=google.com; s=arc-20160816; b=Y+1uGtbD/DCfG8giSt4Fv1Vm0QwML9EtJT4METUCzzjyGbY2UH+YVz6mwbS6TSsKZX GHJHbXSrfJKrTgqLWZA7Aj6LGeuK7iLhQaYSOhnLuPFm495cKkh+7mPiJN37XoCGMVEq 7PldXL/zS/pvkARrU9SCCm41QZpya4uKEGfhMUdFG35myTWYIg6JyH+EkoQuumIWXeri vcLxBDUynK11W2578Jd2807LdhpZV5X+uxzp+o3wuI8K7pEI2IhogE7/GTeRUUUEMfJ6 KUdbV+R1HQVXNFcF1Gbl+RTYmyBRGnTXo8FOv/aFtvhHK7WGnrQTIQBSLbrC8Shkx4ZQ 55Dg== 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=XQOOhZyQiGq2jd1UcHJu26/sJFfHrE0NVt0yGojSft4=; fh=ZUcPkiVf4gvMgVDOUhavBu3WqSDJFLN7Q4rE5Smm1Ig=; b=ZAxC+3ochOFjk7Ocf3TlJR1HzHOOq7HIGH6CiYg9nZ/vXmKIZaq5J/YWKbb8dui4Bv 8Mnm/4s5J512l4A17b8PPxQxADM4m12QQKC2+HnZn7qf8ITKijolrZTA+MoQB18nVSmC qDW1GguGSlwuYGMWvLlJKlG+4m1TJIyEmXyxWpfxdj07RcZY/WXHVf3uxar9eFlAgDCZ Ck7ZraxnPp0tbw41XjbcfTzOMSiOt0KNFg7wLDPS4u4YH5LtuhpRSLPWTTvqyo/qF0p4 3/C/sGAjxv7jAieJr2KreQmuyVMfEEzgY1MGlnFkOBYRiyQ3cGRzpkkTCCBkF5n3teTp Q3VQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PlUdiYBw; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-45135-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45135-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y1-20020a17090322c100b001d7587f372dsi8137536plg.213.2024.01.30.10.48.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:48:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45135-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PlUdiYBw; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-45135-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45135-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 129E2B250E0 for ; Tue, 30 Jan 2024 18:47:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ADA6157053; Tue, 30 Jan 2024 18:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PlUdiYBw" 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 CC42278B7A for ; Tue, 30 Jan 2024 18:46:43 +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=oTb5pv6VFA58Tm5Cw1iF3m0eqmJGh903oKfGqeZNuh7HE6YZbvb5TT270mNFVzbnYJELYgGWcx4S+5dsvRj4i+6Zvfy681tbH8r9aPzb+eNqlVno75kjRZoWhmpbnRH5OEN1xAQofza/TSraKGYFryoXKgjM2ECeC+1vKcFPgGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706640403; c=relaxed/simple; bh=zjX6COLrzX2UnAbnR13vMj+lXPKV02pQPeYFqk/O8jM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vF1GGIvUPb67BTKtfTIenMGkjVun3ZehBKj3z6yEkbpJQS+45BNXecEYzI22T/bgpMewynv63ohcrM2Xiiw2XJposYB+HlJFHcDQGGtAGfqH5O+13sVXGmcBZaBbpmKvAd5QksC0Q/UZRaY6Wo+RFY3kv4Rv2achfE4ZgOZACMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PlUdiYBw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 662CCC433B1; Tue, 30 Jan 2024 18:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706640403; bh=zjX6COLrzX2UnAbnR13vMj+lXPKV02pQPeYFqk/O8jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PlUdiYBw+1A31R3cg/zeFou3VlBY2FXsJc2k9fFlothmw0HEIqEvAYL16dRxQycAL 2Ad8G0ET9DNs45zDq2jLaVCauoMZ0P5LO07A5Kw/xmq+o8mVI+oYQcrVIjtAWENE7O 3RzcN/XIYRO3TVH3L3BrR0T0eLespWFNanVPrR7E= 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 4/6] soundwire: sysfs: have the driver core handle the creation of the device groups Date: Tue, 30 Jan 2024 10:46:30 -0800 Message-ID: <2024013030-worsening-rocket-a3cb@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: 70 X-Developer-Signature: v=1; a=openpgp-sha256; l=2734; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=zjX6COLrzX2UnAbnR13vMj+lXPKV02pQPeYFqk/O8jM=; b=owGbwMvMwCRo6H6F97bub03G02pJDKk7XdgyEnavUmgT0xffUnLtkcSzDOGKlGfCq1+f8uq5f FTmnvurjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIvD0M81POZVT+i332yPDM 3vv9fG8fbt8zI5lhntY6xaNLhE60zDFxWbjeedGtJx+nBwEA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789542262033951983 X-GMAIL-MSGID: 1789542262033951983 The driver core supports the ability to handle the creation and removal of device-specific sysfs files in a race-free manner. Take advantage of that by converting this driver to use this by moving the sysfs attributes into a group and assigning the dev_groups pointer to it. 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 Reviewed-by: Dan Williams --- drivers/soundwire/bus_type.c | 1 + drivers/soundwire/sysfs_local.h | 3 +++ drivers/soundwire/sysfs_slave.c | 6 +----- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c index 9fa93bb923d7..5abe5593395a 100644 --- a/drivers/soundwire/bus_type.c +++ b/drivers/soundwire/bus_type.c @@ -221,6 +221,7 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner) drv->driver.probe = sdw_drv_probe; drv->driver.remove = sdw_drv_remove; drv->driver.shutdown = sdw_drv_shutdown; + drv->driver.dev_groups = sdw_attr_groups; return driver_register(&drv->driver); } diff --git a/drivers/soundwire/sysfs_local.h b/drivers/soundwire/sysfs_local.h index 7268bc24c538..3ab8658a7782 100644 --- a/drivers/soundwire/sysfs_local.h +++ b/drivers/soundwire/sysfs_local.h @@ -11,6 +11,9 @@ /* basic attributes to report status of Slave (attachment, dev_num) */ extern const struct attribute_group *sdw_slave_status_attr_groups[]; +/* attributes for all soundwire devices */ +extern const struct attribute_group *sdw_attr_groups[]; + /* additional device-managed properties reported after driver probe */ int sdw_slave_sysfs_init(struct sdw_slave *slave); int sdw_slave_sysfs_dpn_init(struct sdw_slave *slave); diff --git a/drivers/soundwire/sysfs_slave.c b/drivers/soundwire/sysfs_slave.c index 8876c7807048..3afc0dc06c98 100644 --- a/drivers/soundwire/sysfs_slave.c +++ b/drivers/soundwire/sysfs_slave.c @@ -214,7 +214,7 @@ static const struct attribute_group dp0_group = { .name = "dp0", }; -static const struct attribute_group *slave_groups[] = { +const struct attribute_group *sdw_attr_groups[] = { &slave_attr_group, &sdw_slave_dev_attr_group, &dp0_group, @@ -225,10 +225,6 @@ int sdw_slave_sysfs_init(struct sdw_slave *slave) { int ret; - ret = devm_device_add_groups(&slave->dev, slave_groups); - if (ret < 0) - return ret; - if (slave->prop.source_ports || slave->prop.sink_ports) { ret = sdw_slave_sysfs_dpn_init(slave); if (ret < 0)