HV: vpic: take unsigned port and width in i/o handlers

Port I/O handlers are expected to accept unsigned port address and width which
have type uint16_t and size_t accordingly. The internal handlers in vpic, on the
other hand, declares signed addresses and width in their prototypes. This patch
enforces unsignedness of addresses and widths in these handlers.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Junjie Mao 2018-06-28 19:11:31 +08:00 committed by lijinxia
parent 255786bb99
commit be90e42cfa

View File

@ -673,7 +673,7 @@ void vpic_intr_accepted(struct vm *vm, uint32_t vector)
} }
static int vpic_read(struct vpic *vpic, struct pic *pic, static int vpic_read(struct vpic *vpic, struct pic *pic,
int port, uint32_t *eax) uint16_t port, uint32_t *eax)
{ {
int pin; int pin;
@ -709,7 +709,7 @@ static int vpic_read(struct vpic *vpic, struct pic *pic,
} }
static int vpic_write(struct vpic *vpic, struct pic *pic, static int vpic_write(struct vpic *vpic, struct pic *pic,
int port, uint32_t *eax) uint16_t port, uint32_t *eax)
{ {
int error; int error;
uint8_t val; uint8_t val;
@ -754,8 +754,8 @@ static int vpic_write(struct vpic *vpic, struct pic *pic,
return error; return error;
} }
static int vpic_master_handler(struct vm *vm, bool in, int port, int bytes, static int vpic_master_handler(struct vm *vm, bool in, uint16_t port,
uint32_t *eax) size_t bytes, uint32_t *eax)
{ {
struct vpic *vpic; struct vpic *vpic;
struct pic *pic; struct pic *pic;
@ -763,7 +763,7 @@ static int vpic_master_handler(struct vm *vm, bool in, int port, int bytes,
vpic = vm_pic(vm); vpic = vm_pic(vm);
pic = &vpic->pic[0]; pic = &vpic->pic[0];
if (bytes != 1) if (bytes != 1U)
return -1; return -1;
if (in) if (in)
@ -777,7 +777,7 @@ static uint32_t vpic_master_io_read(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = 0; uint32_t val = 0;
if (vpic_master_handler(vm, true, (int)addr, (int)width, &val) < 0) if (vpic_master_handler(vm, true, addr, width, &val) < 0)
pr_err("pic master read port 0x%x width=%d failed\n", pr_err("pic master read port 0x%x width=%d failed\n",
addr, width); addr, width);
return val; return val;
@ -788,13 +788,13 @@ static void vpic_master_io_write(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = v; uint32_t val = v;
if (vpic_master_handler(vm, false, (int)addr, (int)width, &val) < 0) if (vpic_master_handler(vm, false, addr, width, &val) < 0)
pr_err("%s: write port 0x%x width=%d value 0x%x failed\n", pr_err("%s: write port 0x%x width=%d value 0x%x failed\n",
__func__, addr, width, val); __func__, addr, width, val);
} }
static int vpic_slave_handler(struct vm *vm, bool in, int port, int bytes, static int vpic_slave_handler(struct vm *vm, bool in, uint16_t port,
uint32_t *eax) size_t bytes, uint32_t *eax)
{ {
struct vpic *vpic; struct vpic *vpic;
struct pic *pic; struct pic *pic;
@ -802,7 +802,7 @@ static int vpic_slave_handler(struct vm *vm, bool in, int port, int bytes,
vpic = vm_pic(vm); vpic = vm_pic(vm);
pic = &vpic->pic[1]; pic = &vpic->pic[1];
if (bytes != 1) if (bytes != 1U)
return -1; return -1;
if (in) if (in)
@ -816,7 +816,7 @@ static uint32_t vpic_slave_io_read(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = 0; uint32_t val = 0;
if (vpic_slave_handler(vm, true, (int)addr, (int)width, &val) < 0) if (vpic_slave_handler(vm, true, addr, width, &val) < 0)
pr_err("pic slave read port 0x%x width=%d failed\n", pr_err("pic slave read port 0x%x width=%d failed\n",
addr, width); addr, width);
return val; return val;
@ -827,12 +827,12 @@ static void vpic_slave_io_write(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = v; uint32_t val = v;
if (vpic_slave_handler(vm, false, (int)addr, (int)width, &val) < 0) if (vpic_slave_handler(vm, false, addr, width, &val) < 0)
pr_err("%s: write port 0x%x width=%d value 0x%x failed\n", pr_err("%s: write port 0x%x width=%d value 0x%x failed\n",
__func__, addr, width, val); __func__, addr, width, val);
} }
static int vpic_elc_handler(struct vm *vm, bool in, int port, int bytes, static int vpic_elc_handler(struct vm *vm, bool in, uint16_t port, size_t bytes,
uint32_t *eax) uint32_t *eax)
{ {
struct vpic *vpic; struct vpic *vpic;
@ -841,7 +841,7 @@ static int vpic_elc_handler(struct vm *vm, bool in, int port, int bytes,
vpic = vm_pic(vm); vpic = vm_pic(vm);
is_master = (port == IO_ELCR1); is_master = (port == IO_ELCR1);
if (bytes != 1) if (bytes != 1U)
return -1; return -1;
VPIC_LOCK(vpic); VPIC_LOCK(vpic);
@ -878,7 +878,7 @@ static uint32_t vpic_elc_io_read(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = 0; uint32_t val = 0;
if (vpic_elc_handler(vm, true, (int)addr, (int)width, &val) < 0) if (vpic_elc_handler(vm, true, addr, width, &val) < 0)
pr_err("pic elc read port 0x%x width=%d failed", addr, width); pr_err("pic elc read port 0x%x width=%d failed", addr, width);
return val; return val;
} }
@ -888,7 +888,7 @@ static void vpic_elc_io_write(__unused struct vm_io_handler *hdlr,
{ {
uint32_t val = v; uint32_t val = v;
if (vpic_elc_handler(vm, false, (int)addr, (int)width, &val) < 0) if (vpic_elc_handler(vm, false, addr, width, &val) < 0)
pr_err("%s: write port 0x%x width=%d value 0x%x failed\n", pr_err("%s: write port 0x%x width=%d value 0x%x failed\n",
__func__, addr, width, val); __func__, addr, width, val);
} }