staging: most: make function most_submit_mbo return void
authorChristian Gromm <christian.gromm@microchip.com>
Wed, 21 Sep 2016 12:49:05 +0000 (14:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2016 09:54:46 +0000 (11:54 +0200)
Function most_submit_mbo() causes an exception only if either the pointer
mbo or mbo->context equals NULL. From the underlying architecture's point
of view both cases must _not_ come true and would happen only, if something
has tampered with the pointers. This would render runtime code unable to
recover anyway. So, instead trying to hide that things are already
critically out of control we're better off with a WARN_ON() assertion.

This patch replaces the return type of the function most_submit_mbo() with
'void' and adds a WARN_ONCE() assertion. Additionally, code calling the
function is adapted accordingly.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/aim-cdev/cdev.c
drivers/staging/most/aim-sound/sound.c
drivers/staging/most/mostcore/core.c
drivers/staging/most/mostcore/mostcore.h

index 1c20ae69c5616713eb70cf5876e8623387ca2b56..5458fb932d860ec0346b1197d9fac1002800cddb 100644 (file)
@@ -214,10 +214,7 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
                goto put_mbo;
        }
 
-       ret = most_submit_mbo(mbo);
-       if (ret)
-               goto put_mbo;
-
+       most_submit_mbo(mbo);
        mutex_unlock(&c->io_mutex);
        return actual_len;
 put_mbo:
index 9c645801cff4dbd18c0da93faefe984e6013a688..3dc625c1d1f40756717ea20c6e05100996e8bc0d 100644 (file)
@@ -234,7 +234,6 @@ static int playback_thread(void *data)
        while (!kthread_should_stop()) {
                struct mbo *mbo = NULL;
                bool period_elapsed = false;
-               int ret;
 
                wait_event_interruptible(
                        channel->playback_waitq,
@@ -250,10 +249,7 @@ static int playback_thread(void *data)
                else
                        memset(mbo->virt_address, 0, mbo->buffer_length);
 
-               ret = most_submit_mbo(mbo);
-               if (ret)
-                       channel->is_stream_running = false;
-
+               most_submit_mbo(mbo);
                if (period_elapsed)
                        snd_pcm_period_elapsed(channel->substream);
        }
index bd555ecfe0b935685afa39173fb5d6313894e123..5f05a13157f742f4d56047c4b7ce911cabac8028 100644 (file)
@@ -1323,17 +1323,14 @@ _exit:
 /**
  * most_submit_mbo - submits an MBO to fifo
  * @mbo: pointer to the MBO
- *
  */
-int most_submit_mbo(struct mbo *mbo)
+void most_submit_mbo(struct mbo *mbo)
 {
-       if (unlikely((!mbo) || (!mbo->context))) {
-               pr_err("Bad MBO or missing channel reference\n");
-               return -EINVAL;
-       }
+       if (WARN_ONCE(!mbo || !mbo->context,
+                     "bad mbo or missing channel reference\n"))
+               return;
 
        nq_hdm_mbo(mbo);
-       return 0;
 }
 EXPORT_SYMBOL_GPL(most_submit_mbo);
 
index e768cb863e4c354019af0b74e15610028c0082a9..7644f44062183b888450a7908b378fef1952b8a6 100644 (file)
@@ -287,7 +287,7 @@ struct kobject *most_register_interface(struct most_interface *iface);
  * @intf_instance Pointer to the interface instance description.
  */
 void most_deregister_interface(struct most_interface *iface);
-int most_submit_mbo(struct mbo *mbo);
+void most_submit_mbo(struct mbo *mbo);
 
 /**
  * most_stop_enqueue - prevents core from enqueing MBOs