Skip to content

Commit b037d60

Browse files
osctobegregkh
authored andcommitted
misc: atmel-ssc: lock with mutex instead of spinlock
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: [email protected] Fixes: 099343c ("ARM: at91: atmel-ssc: add device tree support") Signed-off-by: Michał Mirosław <[email protected]> Link: https://lore.kernel.org/r/50f0d7fa107f318296afb49477c3571e4d6978c5.1592998403.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9ebcfad commit b037d60

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/misc/atmel-ssc.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <linux/clk.h>
1111
#include <linux/err.h>
1212
#include <linux/io.h>
13-
#include <linux/spinlock.h>
13+
#include <linux/mutex.h>
1414
#include <linux/atmel-ssc.h>
1515
#include <linux/slab.h>
1616
#include <linux/module.h>
@@ -20,15 +20,15 @@
2020
#include "../../sound/soc/atmel/atmel_ssc_dai.h"
2121

2222
/* Serialize access to ssc_list and user count */
23-
static DEFINE_SPINLOCK(user_lock);
23+
static DEFINE_MUTEX(user_lock);
2424
static LIST_HEAD(ssc_list);
2525

2626
struct ssc_device *ssc_request(unsigned int ssc_num)
2727
{
2828
int ssc_valid = 0;
2929
struct ssc_device *ssc;
3030

31-
spin_lock(&user_lock);
31+
mutex_lock(&user_lock);
3232
list_for_each_entry(ssc, &ssc_list, list) {
3333
if (ssc->pdev->dev.of_node) {
3434
if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
@@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
4444
}
4545

4646
if (!ssc_valid) {
47-
spin_unlock(&user_lock);
47+
mutex_unlock(&user_lock);
4848
pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
4949
return ERR_PTR(-ENODEV);
5050
}
5151

5252
if (ssc->user) {
53-
spin_unlock(&user_lock);
53+
mutex_unlock(&user_lock);
5454
dev_dbg(&ssc->pdev->dev, "module busy\n");
5555
return ERR_PTR(-EBUSY);
5656
}
5757
ssc->user++;
58-
spin_unlock(&user_lock);
58+
mutex_unlock(&user_lock);
5959

6060
clk_prepare(ssc->clk);
6161

@@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc)
6767
{
6868
bool disable_clk = true;
6969

70-
spin_lock(&user_lock);
70+
mutex_lock(&user_lock);
7171
if (ssc->user)
7272
ssc->user--;
7373
else {
7474
disable_clk = false;
7575
dev_dbg(&ssc->pdev->dev, "device already free\n");
7676
}
77-
spin_unlock(&user_lock);
77+
mutex_unlock(&user_lock);
7878

7979
if (disable_clk)
8080
clk_unprepare(ssc->clk);
@@ -237,9 +237,9 @@ static int ssc_probe(struct platform_device *pdev)
237237
return -ENXIO;
238238
}
239239

240-
spin_lock(&user_lock);
240+
mutex_lock(&user_lock);
241241
list_add_tail(&ssc->list, &ssc_list);
242-
spin_unlock(&user_lock);
242+
mutex_unlock(&user_lock);
243243

244244
platform_set_drvdata(pdev, ssc);
245245

@@ -258,9 +258,9 @@ static int ssc_remove(struct platform_device *pdev)
258258

259259
ssc_sound_dai_remove(ssc);
260260

261-
spin_lock(&user_lock);
261+
mutex_lock(&user_lock);
262262
list_del(&ssc->list);
263-
spin_unlock(&user_lock);
263+
mutex_unlock(&user_lock);
264264

265265
return 0;
266266
}

0 commit comments

Comments
 (0)