media: ngene: Replace semaphore cmd_mutex with mutex
authorBinoy Jayan <binoy.jayan@linaro.org>
Tue, 13 Jun 2017 08:58:48 +0000 (05:58 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 24 Jun 2017 19:36:40 +0000 (16:36 -0300)
The semaphore 'cmd_mutex' is used as a simple mutex, so
it should be written as one. Also, replace down with
mutex_destroy to ensure sane state when ngene_stop is
called.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/ngene/ngene-core.c
drivers/media/pci/ngene/ngene.h

index ce69e648b663a934f5ace1c834e8c0b1642d044a..eeb61ebbfd2e619d641211bdb29cb47cadc67e0f 100644 (file)
@@ -336,9 +336,9 @@ int ngene_command(struct ngene *dev, struct ngene_command *com)
 {
        int result;
 
-       down(&dev->cmd_mutex);
+       mutex_lock(&dev->cmd_mutex);
        result = ngene_command_mutex(dev, com);
-       up(&dev->cmd_mutex);
+       mutex_unlock(&dev->cmd_mutex);
        return result;
 }
 
@@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
 
 static void ngene_stop(struct ngene *dev)
 {
-       down(&dev->cmd_mutex);
+       mutex_destroy(&dev->cmd_mutex);
        i2c_del_adapter(&(dev->channel[0].i2c_adapter));
        i2c_del_adapter(&(dev->channel[1].i2c_adapter));
        ngwritel(0, NGENE_INT_ENABLE);
@@ -1346,7 +1346,7 @@ static int ngene_start(struct ngene *dev)
        init_waitqueue_head(&dev->cmd_wq);
        init_waitqueue_head(&dev->tx_wq);
        init_waitqueue_head(&dev->rx_wq);
-       sema_init(&dev->cmd_mutex, 1);
+       mutex_init(&dev->cmd_mutex);
        sema_init(&dev->stream_mutex, 1);
        sema_init(&dev->pll_mutex, 1);
        sema_init(&dev->i2c_switch_mutex, 1);
@@ -1606,10 +1606,10 @@ static void ngene_unlink(struct ngene *dev)
        com.in_len = 3;
        com.out_len = 1;
 
-       down(&dev->cmd_mutex);
+       mutex_lock(&dev->cmd_mutex);
        ngwritel(0, NGENE_INT_ENABLE);
        ngene_command_mutex(dev, &com);
-       up(&dev->cmd_mutex);
+       mutex_unlock(&dev->cmd_mutex);
 }
 
 void ngene_shutdown(struct pci_dev *pdev)
index 10d8f74c4f0a50a4f282b0211b8bb0b616919d5a..e600b70415daa6a15e0e862c5a96fc041cafa171 100644 (file)
@@ -762,7 +762,7 @@ struct ngene {
 
        wait_queue_head_t     cmd_wq;
        int                   cmd_done;
-       struct semaphore      cmd_mutex;
+       struct mutex          cmd_mutex;
        struct semaphore      stream_mutex;
        struct semaphore      pll_mutex;
        struct semaphore      i2c_switch_mutex;