aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
authorEliot Blennerhassett <eblennerhassett@audioscience.com>2011-02-09 23:26:06 -0500
committerTakashi Iwai <tiwai@suse.de>2011-02-10 12:49:28 -0500
commit4704998e84b03e2d93ef8d4d03eeb7a84c0cb493 (patch)
treeacdbf55f5979fcddb39c112a10fa0e3f59edfc5a /sound/pci/asihpi
parent0a00044d26489c1907b9e8b3e633e6b9a6d2200e (diff)
ALSA: asihpi - Code cleanup.
Remove unused function. Simplify hpi_alloc_control_cache. Remove useless assignment to struct subsequently freed. Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/hpicmn.c42
-rw-r--r--sound/pci/asihpi/hpicmn.h15
2 files changed, 16 insertions, 41 deletions
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index 8346aeabee5d..4d696ab4b1f0 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -156,7 +156,7 @@ static void subsys_get_adapter(struct hpi_message *phm,
156 /* find the nCount'th nonzero adapter in array */ 156 /* find the nCount'th nonzero adapter in array */
157 for (index = 0; index < HPI_MAX_ADAPTERS; index++) { 157 for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
158 if (adapters.adapter[index].adapter_type) { 158 if (adapters.adapter[index].adapter_type) {
159 if (count == 0) 159 if (!count)
160 break; 160 break;
161 count--; 161 count--;
162 } 162 }
@@ -199,7 +199,7 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
199 &p_master_cache[byte_count]; 199 &p_master_cache[byte_count];
200 200
201 if (!info->size_in32bit_words) { 201 if (!info->size_in32bit_words) {
202 if (i == 0) { 202 if (!i) {
203 HPI_DEBUG_LOG(INFO, 203 HPI_DEBUG_LOG(INFO,
204 "adap %d cache not ready?\n", 204 "adap %d cache not ready?\n",
205 pC->adap_idx); 205 pC->adap_idx);
@@ -279,28 +279,6 @@ static short find_control(u16 control_index,
279 return 1; 279 return 1;
280} 280}
281 281
282/** Used by the kernel driver to figure out if a buffer needs mapping.
283 */
284short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
285 struct hpi_message *phm, void **p, unsigned int *pN)
286{
287 *pN = 0;
288 *p = NULL;
289 if ((phm->function == HPI_CONTROL_GET_STATE)
290 && (phm->object == HPI_OBJ_CONTROLEX)
291 ) {
292 struct hpi_control_cache_info *pI;
293
294 if (!find_control(phm->obj_index, p_cache, &pI)) {
295 HPI_DEBUG_LOG(VERBOSE,
296 "HPICMN find_control() failed for adap %d\n",
297 phm->adapter_index);
298 return 0;
299 }
300 }
301 return 0;
302}
303
304/* allow unified treatment of several string fields within struct */ 282/* allow unified treatment of several string fields within struct */
305#define HPICMN_PAD_OFS_AND_SIZE(m) {\ 283#define HPICMN_PAD_OFS_AND_SIZE(m) {\
306 offsetof(struct hpi_control_cache_pad, m), \ 284 offsetof(struct hpi_control_cache_pad, m), \
@@ -612,24 +590,24 @@ void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache,
612 } 590 }
613} 591}
614 592
615struct hpi_control_cache *hpi_alloc_control_cache(const u32 593struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
616 number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer) 594 const u32 size_in_bytes, u8 *p_dsp_control_buffer)
617{ 595{
618 struct hpi_control_cache *p_cache = 596 struct hpi_control_cache *p_cache =
619 kmalloc(sizeof(*p_cache), GFP_KERNEL); 597 kmalloc(sizeof(*p_cache), GFP_KERNEL);
620 if (!p_cache) 598 if (!p_cache)
621 return NULL; 599 return NULL;
600
622 p_cache->p_info = 601 p_cache->p_info =
623 kmalloc(sizeof(*p_cache->p_info) * number_of_controls, 602 kmalloc(sizeof(*p_cache->p_info) * control_count, GFP_KERNEL);
624 GFP_KERNEL);
625 if (!p_cache->p_info) { 603 if (!p_cache->p_info) {
626 kfree(p_cache); 604 kfree(p_cache);
627 return NULL; 605 return NULL;
628 } 606 }
607 memset(p_cache->p_info, 0, sizeof(*p_cache->p_info) * control_count);
629 p_cache->cache_size_in_bytes = size_in_bytes; 608 p_cache->cache_size_in_bytes = size_in_bytes;
630 p_cache->control_count = number_of_controls; 609 p_cache->control_count = control_count;
631 p_cache->p_cache = 610 p_cache->p_cache = p_dsp_control_buffer;
632 (struct hpi_control_cache_single *)pDSP_control_buffer;
633 p_cache->init = 0; 611 p_cache->init = 0;
634 return p_cache; 612 return p_cache;
635} 613}
@@ -638,8 +616,6 @@ void hpi_free_control_cache(struct hpi_control_cache *p_cache)
638{ 616{
639 if (p_cache) { 617 if (p_cache) {
640 kfree(p_cache->p_info); 618 kfree(p_cache->p_info);
641 p_cache->p_info = NULL;
642 p_cache->init = 0;
643 kfree(p_cache); 619 kfree(p_cache);
644 } 620 }
645} 621}
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h
index 2708c4df2c70..6db1e0ba4728 100644
--- a/sound/pci/asihpi/hpicmn.h
+++ b/sound/pci/asihpi/hpicmn.h
@@ -33,15 +33,15 @@ struct hpi_adapter_obj {
33}; 33};
34 34
35struct hpi_control_cache { 35struct hpi_control_cache {
36 u16 init; /**< indicates whether the 36 /** indicates whether the structures are initialized */
37 structures are initialized */ 37 u16 init;
38 u16 adap_idx; 38 u16 adap_idx;
39 u32 control_count; 39 u32 control_count;
40 u32 cache_size_in_bytes; 40 u32 cache_size_in_bytes;
41 struct hpi_control_cache_info 41 /** pointer to allocated memory of lookup pointers. */
42 **p_info; /**< pointer to allocated memory of 42 struct hpi_control_cache_info **p_info;
43 lookup pointers. */ 43 /** pointer to DSP's control cache. */
44 u8 *p_cache; /**< pointer to DSP's control cache. */ 44 u8 *p_cache;
45}; 45};
46 46
47struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); 47struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index);
@@ -57,6 +57,5 @@ void hpi_free_control_cache(struct hpi_control_cache *p_cache);
57 57
58void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC, 58void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC,
59 struct hpi_message *phm, struct hpi_response *phr); 59 struct hpi_message *phm, struct hpi_response *phr);
60
60u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr); 61u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr);
61short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
62 struct hpi_message *phm, void **p, unsigned int *pN);