From: Bard Liao <yung-chuan.liao@linux.intel.com>
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 [thread overview]
Message-ID: <20210323022529.21915-1-yung-chuan.liao@linux.intel.com> (raw)
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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 <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
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
next reply other threads:[~2021-03-23 2:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 2:25 Bard Liao [this message]
2021-03-23 6:57 ` Vinod Koul
2021-03-23 18:30 ` Pierre-Louis Bossart
2021-04-19 1:46 ` Liao, Bard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210323022529.21915-1-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bard.liao@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hui.wang@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=vinod.koul@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®