ALSA: asihpi - Get rid of incorrect "long" types and casts.

These give incorrect results for index wrap on 64 bit.

Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Eliot Blennerhassett 2010-06-17 17:08:36 +12:00 committed by Takashi Iwai
parent e8bdb6bbab
commit 2a383cb3f1
1 changed files with 11 additions and 11 deletions

View File

@ -941,11 +941,11 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao,
} }
static long outstream_get_space_available(struct hpi_hostbuffer_status static u32 outstream_get_space_available(struct hpi_hostbuffer_status
*status) *status)
{ {
return status->size_in_bytes - ((long)(status->host_index) - return status->size_in_bytes - (status->host_index -
(long)(status->dSP_index)); status->dSP_index);
} }
static void outstream_write(struct hpi_adapter_obj *pao, static void outstream_write(struct hpi_adapter_obj *pao,
@ -954,7 +954,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
struct hpi_hw_obj *phw = pao->priv; struct hpi_hw_obj *phw = pao->priv;
struct bus_master_interface *interface = phw->p_interface_buffer; struct bus_master_interface *interface = phw->p_interface_buffer;
struct hpi_hostbuffer_status *status; struct hpi_hostbuffer_status *status;
long space_available; u32 space_available;
if (!phw->outstream_host_buffer_size[phm->obj_index]) { if (!phw->outstream_host_buffer_size[phm->obj_index]) {
/* there is no BBM buffer, write via message */ /* there is no BBM buffer, write via message */
@ -1007,7 +1007,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
} }
space_available = outstream_get_space_available(status); space_available = outstream_get_space_available(status);
if (space_available < (long)phm->u.d.u.data.data_size) { if (space_available < phm->u.d.u.data.data_size) {
phr->error = HPI_ERROR_INVALID_DATASIZE; phr->error = HPI_ERROR_INVALID_DATASIZE;
return; return;
} }
@ -1018,7 +1018,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
&& hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm->
obj_index])) { obj_index])) {
u8 *p_bbm_data; u8 *p_bbm_data;
long l_first_write; u32 l_first_write;
u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
if (hpios_locked_mem_get_virt_addr(&phw-> if (hpios_locked_mem_get_virt_addr(&phw->
@ -1248,9 +1248,9 @@ static void instream_start(struct hpi_adapter_obj *pao,
hw_message(pao, phm, phr); hw_message(pao, phm, phr);
} }
static long instream_get_bytes_available(struct hpi_hostbuffer_status *status) static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status)
{ {
return (long)(status->dSP_index) - (long)(status->host_index); return status->dSP_index - status->host_index;
} }
static void instream_read(struct hpi_adapter_obj *pao, static void instream_read(struct hpi_adapter_obj *pao,
@ -1259,9 +1259,9 @@ static void instream_read(struct hpi_adapter_obj *pao,
struct hpi_hw_obj *phw = pao->priv; struct hpi_hw_obj *phw = pao->priv;
struct bus_master_interface *interface = phw->p_interface_buffer; struct bus_master_interface *interface = phw->p_interface_buffer;
struct hpi_hostbuffer_status *status; struct hpi_hostbuffer_status *status;
long data_available; u32 data_available;
u8 *p_bbm_data; u8 *p_bbm_data;
long l_first_read; u32 l_first_read;
u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
if (!phw->instream_host_buffer_size[phm->obj_index]) { if (!phw->instream_host_buffer_size[phm->obj_index]) {
@ -1272,7 +1272,7 @@ static void instream_read(struct hpi_adapter_obj *pao,
status = &interface->instream_host_buffer_status[phm->obj_index]; status = &interface->instream_host_buffer_status[phm->obj_index];
data_available = instream_get_bytes_available(status); data_available = instream_get_bytes_available(status);
if (data_available < (long)phm->u.d.u.data.data_size) { if (data_available < phm->u.d.u.data.data_size) {
phr->error = HPI_ERROR_INVALID_DATASIZE; phr->error = HPI_ERROR_INVALID_DATASIZE;
return; return;
} }