Commit 7a61c7bb authored by Michał Mirosław's avatar Michał Mirosław Committed by Greg Kroah-Hartman

misc: atmel-ssc: lock with mutex instead of spinlock

commit b037d60a upstream.

Uninterruptible context is not needed in the driver and causes lockdep
warning because of mutex taken in of_alias_get_id(). Convert the lock to
mutex to avoid the issue.

Cc: stable@vger.kernel.org
Fixes: 099343c6 ("ARM: at91: atmel-ssc: add device tree support")
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/50f0d7fa107f318296afb49477c3571e4d6978c5.1592998403.git.mirq-linux@rere.qmqm.plSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 44151409
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/spinlock.h> #include <linux/mutex.h>
#include <linux/atmel-ssc.h> #include <linux/atmel-ssc.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "../../sound/soc/atmel/atmel_ssc_dai.h" #include "../../sound/soc/atmel/atmel_ssc_dai.h"
/* Serialize access to ssc_list and user count */ /* Serialize access to ssc_list and user count */
static DEFINE_SPINLOCK(user_lock); static DEFINE_MUTEX(user_lock);
static LIST_HEAD(ssc_list); static LIST_HEAD(ssc_list);
struct ssc_device *ssc_request(unsigned int ssc_num) struct ssc_device *ssc_request(unsigned int ssc_num)
...@@ -31,7 +31,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) ...@@ -31,7 +31,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
int ssc_valid = 0; int ssc_valid = 0;
struct ssc_device *ssc; struct ssc_device *ssc;
spin_lock(&user_lock); mutex_lock(&user_lock);
list_for_each_entry(ssc, &ssc_list, list) { list_for_each_entry(ssc, &ssc_list, list) {
if (ssc->pdev->dev.of_node) { if (ssc->pdev->dev.of_node) {
if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc") if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
...@@ -47,18 +47,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num) ...@@ -47,18 +47,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
} }
if (!ssc_valid) { if (!ssc_valid) {
spin_unlock(&user_lock); mutex_unlock(&user_lock);
pr_err("ssc: ssc%d platform device is missing\n", ssc_num); pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
if (ssc->user) { if (ssc->user) {
spin_unlock(&user_lock); mutex_unlock(&user_lock);
dev_dbg(&ssc->pdev->dev, "module busy\n"); dev_dbg(&ssc->pdev->dev, "module busy\n");
return ERR_PTR(-EBUSY); return ERR_PTR(-EBUSY);
} }
ssc->user++; ssc->user++;
spin_unlock(&user_lock); mutex_unlock(&user_lock);
clk_prepare(ssc->clk); clk_prepare(ssc->clk);
...@@ -70,14 +70,14 @@ void ssc_free(struct ssc_device *ssc) ...@@ -70,14 +70,14 @@ void ssc_free(struct ssc_device *ssc)
{ {
bool disable_clk = true; bool disable_clk = true;
spin_lock(&user_lock); mutex_lock(&user_lock);
if (ssc->user) if (ssc->user)
ssc->user--; ssc->user--;
else { else {
disable_clk = false; disable_clk = false;
dev_dbg(&ssc->pdev->dev, "device already free\n"); dev_dbg(&ssc->pdev->dev, "device already free\n");
} }
spin_unlock(&user_lock); mutex_unlock(&user_lock);
if (disable_clk) if (disable_clk)
clk_unprepare(ssc->clk); clk_unprepare(ssc->clk);
...@@ -240,9 +240,9 @@ static int ssc_probe(struct platform_device *pdev) ...@@ -240,9 +240,9 @@ static int ssc_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
spin_lock(&user_lock); mutex_lock(&user_lock);
list_add_tail(&ssc->list, &ssc_list); list_add_tail(&ssc->list, &ssc_list);
spin_unlock(&user_lock); mutex_unlock(&user_lock);
platform_set_drvdata(pdev, ssc); platform_set_drvdata(pdev, ssc);
...@@ -261,9 +261,9 @@ static int ssc_remove(struct platform_device *pdev) ...@@ -261,9 +261,9 @@ static int ssc_remove(struct platform_device *pdev)
ssc_sound_dai_remove(ssc); ssc_sound_dai_remove(ssc);
spin_lock(&user_lock); mutex_lock(&user_lock);
list_del(&ssc->list); list_del(&ssc->list);
spin_unlock(&user_lock); mutex_unlock(&user_lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment