dm: platform: clean up assert() for some platform devices
Tracked-On: #3252 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
parent
1b7995387d
commit
db7e7f1c44
|
@ -26,7 +26,6 @@
|
|||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -43,6 +42,7 @@
|
|||
#include "ps2mouse.h"
|
||||
#include "vmmapi.h"
|
||||
#include "mevent.h"
|
||||
#include "log.h"
|
||||
|
||||
static void
|
||||
atkbdc_assert_kbd_intr(struct atkbdc_base *base)
|
||||
|
@ -291,7 +291,7 @@ atkbdc_sts_ctl_handler(struct vmctx *ctx, int vcpu, int in, int port,
|
|||
int bytes, uint32_t *eax, void *arg)
|
||||
{
|
||||
struct atkbdc_base *base;
|
||||
int error, retval;
|
||||
int retval;
|
||||
|
||||
if (bytes != 1)
|
||||
return -1;
|
||||
|
@ -361,9 +361,8 @@ atkbdc_sts_ctl_handler(struct vmctx *ctx, int vcpu, int in, int port,
|
|||
KBDS_KBD_BUFFER_FULL;
|
||||
break;
|
||||
case KBDC_RESET: /* Pulse "cold reset" line */
|
||||
error = vm_suspend(ctx, VM_SUSPEND_FULL_RESET);
|
||||
vm_suspend(ctx, VM_SUSPEND_FULL_RESET);
|
||||
mevent_notify();
|
||||
assert(error == 0 || errno == EALREADY);
|
||||
break;
|
||||
default:
|
||||
if (*eax >= 0x21 && *eax <= 0x3f) {
|
||||
|
@ -415,8 +414,10 @@ atkbdc_init(struct vmctx *ctx)
|
|||
int error;
|
||||
|
||||
base = calloc(1, sizeof(struct atkbdc_base));
|
||||
|
||||
assert(base != NULL);
|
||||
if (!base) {
|
||||
pr_err("%s: alloc memory fail!\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
base->ctx = ctx;
|
||||
ctx->atkbdc_base = base;
|
||||
|
@ -432,7 +433,8 @@ atkbdc_init(struct vmctx *ctx)
|
|||
iop.arg = base;
|
||||
|
||||
error = register_inout(&iop);
|
||||
assert(error == 0);
|
||||
if (error < 0)
|
||||
goto fail;
|
||||
|
||||
bzero(&iop, sizeof(struct inout_port));
|
||||
iop.name = "atkdbc";
|
||||
|
@ -443,7 +445,8 @@ atkbdc_init(struct vmctx *ctx)
|
|||
iop.arg = base;
|
||||
|
||||
error = register_inout(&iop);
|
||||
assert(error == 0);
|
||||
if (error < 0)
|
||||
goto fail;
|
||||
|
||||
pci_irq_reserve(KBD_DEV_IRQ);
|
||||
base->kbd.irq = KBD_DEV_IRQ;
|
||||
|
@ -453,6 +456,11 @@ atkbdc_init(struct vmctx *ctx)
|
|||
|
||||
base->ps2kbd = ps2kbd_init(base);
|
||||
base->ps2mouse = ps2mouse_init(base);
|
||||
|
||||
return;
|
||||
fail:
|
||||
pr_err("%s: fail to init!\n", __func__);
|
||||
free(base);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "inout.h"
|
||||
|
@ -63,9 +62,6 @@ cmos_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
|
|||
static int buf_offset;
|
||||
static int next_ops; /* 0 for addr, 1 for data, in pair (addr,data)*/
|
||||
|
||||
assert(port == CMOS_ADDR || port == CMOS_DATA);
|
||||
assert(bytes == 1);
|
||||
|
||||
#ifdef CMOS_DEBUG
|
||||
if (!dbg_file)
|
||||
dbg_file = fopen("/tmp/cmos_log", "a+");
|
||||
|
@ -77,7 +73,6 @@ cmos_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
|
|||
if (port == CMOS_ADDR) {
|
||||
|
||||
/* if port is addr, ops should be 0 */
|
||||
assert(next_ops == 0 && !in);
|
||||
if (next_ops != 0) {
|
||||
next_ops = 0;
|
||||
return -1;
|
||||
|
@ -88,7 +83,6 @@ cmos_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
|
|||
|
||||
} else if (port == CMOS_DATA) {
|
||||
|
||||
assert(next_ops == 1);
|
||||
if (next_ops != 1) {
|
||||
next_ops = 0;
|
||||
return -1;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -35,6 +34,7 @@
|
|||
#include "types.h"
|
||||
#include "atkbdc.h"
|
||||
#include "console.h"
|
||||
#include "log.h"
|
||||
|
||||
/* keyboard device commands */
|
||||
#define PS2KC_RESET_DEV 0xff
|
||||
|
@ -225,8 +225,6 @@ ps2kbd_keysym_queue(struct ps2kbd_info *kbd,
|
|||
0x22, 0x35, 0x1a, 0x54, 0x5d, 0x5b, 0x0e, 0x00,
|
||||
};
|
||||
|
||||
/* assert(pthread_mutex_isowned_np(&kbd->mtx)); */
|
||||
|
||||
switch (keysym) {
|
||||
case 0x0 ... 0x7f:
|
||||
if (!down)
|
||||
|
@ -462,8 +460,10 @@ ps2kbd_init(struct atkbdc_base *base)
|
|||
struct ps2kbd_info *kbd;
|
||||
|
||||
kbd = calloc(1, sizeof(struct ps2kbd_info));
|
||||
|
||||
assert(kbd != NULL);
|
||||
if (!kbd) {
|
||||
pr_err("%s: alloc memory fail!\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&kbd->mtx, NULL);
|
||||
fifo_init(kbd);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -35,6 +34,7 @@
|
|||
#include "types.h"
|
||||
#include "atkbdc.h"
|
||||
#include "console.h"
|
||||
#include "log.h"
|
||||
|
||||
/* mouse device commands */
|
||||
#define PS2MC_RESET_DEV 0xff
|
||||
|
@ -152,8 +152,6 @@ fifo_get(struct ps2mouse_info *mouse, uint8_t *val)
|
|||
static void
|
||||
movement_reset(struct ps2mouse_info *mouse)
|
||||
{
|
||||
/* assert(pthread_mutex_isowned_np(&mouse->mtx)); */
|
||||
|
||||
mouse->delta_x = 0;
|
||||
mouse->delta_y = 0;
|
||||
}
|
||||
|
@ -172,8 +170,6 @@ movement_get(struct ps2mouse_info *mouse)
|
|||
{
|
||||
uint8_t val0, val1, val2;
|
||||
|
||||
/* assert(pthread_mutex_isowned_np(&mouse->mtx)); */
|
||||
|
||||
val0 = PS2M_DATA_AONE;
|
||||
val0 |= mouse->status & (PS2M_DATA_LEFT_BUTTON |
|
||||
PS2M_DATA_RIGHT_BUTTON | PS2M_DATA_MID_BUTTON);
|
||||
|
@ -220,7 +216,6 @@ movement_get(struct ps2mouse_info *mouse)
|
|||
static void
|
||||
ps2mouse_reset(struct ps2mouse_info *mouse)
|
||||
{
|
||||
/* assert(pthread_mutex_isowned_np(&mouse->mtx)); */
|
||||
fifo_reset(mouse);
|
||||
movement_reset(mouse);
|
||||
mouse->status = PS2M_STS_ENABLE_DEV;
|
||||
|
@ -395,8 +390,10 @@ ps2mouse_init(struct atkbdc_base *base)
|
|||
struct ps2mouse_info *mouse;
|
||||
|
||||
mouse = calloc(1, sizeof(struct ps2mouse_info));
|
||||
|
||||
assert(mouse != NULL);
|
||||
if (!mouse) {
|
||||
pr_err("%s: alloc memory fail!\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&mouse->mtx, NULL);
|
||||
fifo_init(mouse);
|
||||
|
|
Loading…
Reference in New Issue