Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[cascardo/linux.git] / sound / pci / asihpi / hpicmn.c
index bd47521..7ed5c26 100644 (file)
@@ -1,7 +1,7 @@
 /******************************************************************************
 
     AudioScience HPI driver
-    Copyright (C) 1997-2010  AudioScience Inc. <support@audioscience.com>
+    Copyright (C) 1997-2011  AudioScience Inc. <support@audioscience.com>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of version 2 of the GNU General Public License as
@@ -68,7 +68,7 @@ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
 u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
 {
        u16 retval = 0;
-       /*HPI_ASSERT(pao->wAdapterType); */
+       /*HPI_ASSERT(pao->type); */
 
        hpios_alistlock_lock(&adapters);
 
@@ -77,13 +77,13 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
                goto unlock;
        }
 
-       if (adapters.adapter[pao->index].adapter_type) {
+       if (adapters.adapter[pao->index].type) {
                int a;
                for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
-                       if (!adapters.adapter[a].adapter_type) {
+                       if (!adapters.adapter[a].type) {
                                HPI_DEBUG_LOG(WARNING,
                                        "ASI%X duplicate index %d moved to %d\n",
-                                       pao->adapter_type, pao->index, a);
+                                       pao->type, pao->index, a);
                                pao->index = a;
                                break;
                        }
@@ -104,13 +104,13 @@ unlock:
 
 void hpi_delete_adapter(struct hpi_adapter_obj *pao)
 {
-       if (!pao->adapter_type) {
+       if (!pao->type) {
                HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
                return;
        }
 
        hpios_alistlock_lock(&adapters);
-       if (adapters.adapter[pao->index].adapter_type)
+       if (adapters.adapter[pao->index].type)
                adapters.gw_num_adapters--;
        memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
        hpios_alistlock_unlock(&adapters);
@@ -132,7 +132,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
        }
 
        pao = &adapters.adapter[adapter_index];
-       if (pao->adapter_type != 0) {
+       if (pao->type != 0) {
                /*
                   HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n",
                   wAdapterIndex);
@@ -165,7 +165,7 @@ static void subsys_get_adapter(struct hpi_message *phm,
 
        /* find the nCount'th nonzero adapter in array */
        for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
-               if (adapters.adapter[index].adapter_type) {
+               if (adapters.adapter[index].type) {
                        if (!count)
                                break;
                        count--;
@@ -174,11 +174,11 @@ static void subsys_get_adapter(struct hpi_message *phm,
 
        if (index < HPI_MAX_ADAPTERS) {
                phr->u.s.adapter_index = adapters.adapter[index].index;
-               phr->u.s.adapter_type = adapters.adapter[index].adapter_type;
+               phr->u.s.adapter_type = adapters.adapter[index].type;
        } else {
                phr->u.s.adapter_index = 0;
                phr->u.s.adapter_type = 0;
-               phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
+               phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
        }
 }
 
@@ -324,6 +324,8 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
        }
 
        phr->error = 0;
+       phr->specific_error = 0;
+       phr->version = 0;
 
        /* set the default response size */
        response_size =
@@ -531,8 +533,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
                found ? "Cached" : "Uncached", phm->adapter_index,
                pI->control_index, pI->control_type, phm->u.c.attribute);
 
-       if (found)
+       if (found) {
                phr->size = (u16)response_size;
+               phr->type = HPI_TYPE_RESPONSE;
+               phr->object = phm->object;
+               phr->function = phm->function;
+       }
 
        return found;
 }
@@ -631,7 +637,7 @@ struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
        if (!p_cache)
                return NULL;
 
-       p_cache->p_info = kzalloc(sizeof(*p_cache->p_info) * control_count,
+       p_cache->p_info = kcalloc(control_count, sizeof(*p_cache->p_info),
                                  GFP_KERNEL);
        if (!p_cache->p_info) {
                kfree(p_cache);