Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3902613pxf; Mon, 22 Mar 2021 19:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsUtO5bWyk+q9vvQDPMejFnEZHvyTM8/F7AUc7srCl9nAH5lAs22kJ5b5W84Sak5erQmCD X-Received: by 2002:a17:906:32da:: with SMTP id k26mr2563090ejk.483.1616466735268; Mon, 22 Mar 2021 19:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616466735; cv=none; d=google.com; s=arc-20160816; b=qowVvvl3fKbwjfsyN7SHUpadxCo/EIOnCA3WMldZ2/cdT0ppWkaZdAfa7wL3p57UTc gDXwvCacW6s7DdVFaICkh1spdtdl1lcjREa9nx+IQB2m/Qip3f03MUEkzV5vPBStF8RM JicorE8mk0du2fRd75imtYIhFFbOchVg78IM5gc7PP7BUosvL5B4WXs04XSnYt44xNIp SVserrS4NCLVQjzE2T+25txhlKBQjr9dCC0RSu89f6ApNx0H8nqQTSEyC0eFTIjgt7tF 5orWj/G37lrJhfqwpzid9zDuNi0B1N3CGFTcGhKYdtwo+0vjzTOqb55bbYQahJHzLLAa iqmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=r2Zm4iObI1ZzrAeK1kZgk22P6sDafyc3TbFW6NZfvgw=; b=GEpx0JRnx8i271KYH9CMdmSYf8CDVzeyUeHGbP904wtz+WoK+Fr1NsZV2G3n7ZQaSD kWJGhUPrzaoqQmqPqdbLD6dUdIRMWfufXixdqQhR9qIIQG3pnvrMHO+G+rCA/nI6yQSG 5veZj2on82nAf8uC09hRG0kPIgrW9aTFeTaGiKox+X2yWTVcwCxIYCMmms+CWNd5eiHh UVO9QxXnHj0ZIKO2N0wJ5itixqVmDT1g+jakHK0QbpwxDBkApJNRYGYxKNdsVGFyjGBL vo9QORb59eagn4Sro9/SKtVwdgKDJMUUOhBsWdnBBaTDqvnDOuSFuhWEbaIw5NlexSJV rEpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si12345083edq.351.2021.03.22.19.31.52; Mon, 22 Mar 2021 19:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbhCWC0M (ORCPT + 99 others); Mon, 22 Mar 2021 22:26:12 -0400 Received: from mga18.intel.com ([134.134.136.126]:33649 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229467AbhCWCZm (ORCPT ); Mon, 22 Mar 2021 22:25:42 -0400 IronPort-SDR: ybBWTpiSaXAJTlK9ta7/u+28z6sJTsV2PlV+l6iq+2ijzG5I8PO0mzhh67hJlDA2dfo+bvUenc O1lbXW0qTJzg== X-IronPort-AV: E=McAfee;i="6000,8403,9931"; a="177958152" X-IronPort-AV: E=Sophos;i="5.81,270,1610438400"; d="scan'208";a="177958152" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2021 19:25:42 -0700 IronPort-SDR: Ov9wswf9uFOPGcZiDu+jkVsxI0EX4JqdmTfALU0YnRF1hwGceR0SNSuBGyE3FVgMYll87xhg+K qSHEzmqfUtsw== X-IronPort-AV: E=Sophos;i="5.81,270,1610438400"; d="scan'208";a="414751850" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2021 19:25:39 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, hui.wang@canonical.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, bard.liao@intel.com Subject: [PATCH] soundwire: add slave device to linked list after device_register() Date: Tue, 23 Mar 2021 10:25:29 +0800 Message-Id: <20210323022529.21915-1-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart We currently add the slave device to a linked list before device_register(), and then remove it if device_register() fails. It's not clear why this sequence was necessary, this patch moves the linked list management to after the device_register(). Suggested-by: Keyon Jie Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- drivers/soundwire/slave.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c index 112b21967c7a..0c92db2e1ddc 100644 --- a/drivers/soundwire/slave.c +++ b/drivers/soundwire/slave.c @@ -65,9 +65,6 @@ int sdw_slave_add(struct sdw_bus *bus, for (i = 0; i < SDW_MAX_PORTS; i++) init_completion(&slave->port_ready[i]); - mutex_lock(&bus->bus_lock); - list_add_tail(&slave->node, &bus->slaves); - mutex_unlock(&bus->bus_lock); ret = device_register(&slave->dev); if (ret) { @@ -77,13 +74,15 @@ int sdw_slave_add(struct sdw_bus *bus, * On err, don't free but drop ref as this will be freed * when release method is invoked. */ - mutex_lock(&bus->bus_lock); - list_del(&slave->node); - mutex_unlock(&bus->bus_lock); put_device(&slave->dev); return ret; } + + mutex_lock(&bus->bus_lock); + list_add_tail(&slave->node, &bus->slaves); + mutex_unlock(&bus->bus_lock); + sdw_slave_debugfs_init(slave); return ret; -- 2.17.1