aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi/hpioctl.c
diff options
context:
space:
mode:
authorEliot Blennerhassett <eblennerhassett@audioscience.com>2011-04-05 04:55:47 -0400
committerTakashi Iwai <tiwai@suse.de>2011-04-05 05:50:13 -0400
commit6d0b898e9c402d6b7d0d07adacdbee2ebedafdcd (patch)
treefb6cfb6c5ef00c1efdf425654a5fd534fdf6f0e6 /sound/pci/asihpi/hpioctl.c
parentb0096a65677fa8d7e50975dc7282ce313610d9e8 (diff)
ALSA: asihpi: Simplify driver unload cleanup
Replacing subsys_delete_adapter with adapter_delete allows some special-case adapter lookup code to be removed. Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi/hpioctl.c')
-rw-r--r--sound/pci/asihpi/hpioctl.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index cd624f13ff8e..484f41189867 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -25,6 +25,7 @@ Common Linux HPI ioctl and module probe/remove functions
25#include "hpidebug.h" 25#include "hpidebug.h"
26#include "hpimsgx.h" 26#include "hpimsgx.h"
27#include "hpioctl.h" 27#include "hpioctl.h"
28#include "hpicmn.h"
28 29
29#include <linux/fs.h> 30#include <linux/fs.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
@@ -161,26 +162,24 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
161 goto out; 162 goto out;
162 } 163 }
163 164
164 pa = &adapters[hm->h.adapter_index]; 165 switch (hm->h.function) {
166 case HPI_SUBSYS_CREATE_ADAPTER:
167 case HPI_ADAPTER_DELETE:
168 /* Application must not use these functions! */
169 hr->h.size = sizeof(hr->h);
170 hr->h.error = HPI_ERROR_INVALID_OPERATION;
171 hr->h.function = hm->h.function;
172 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
173 if (uncopied_bytes)
174 err = -EFAULT;
175 else
176 err = 0;
177 goto out;
178 }
179
165 hr->h.size = res_max_size; 180 hr->h.size = res_max_size;
166 if (hm->h.object == HPI_OBJ_SUBSYSTEM) { 181 if (hm->h.object == HPI_OBJ_SUBSYSTEM) {
167 switch (hm->h.function) { 182 hpi_send_recv_f(&hm->m0, &hr->r0, file);
168 case HPI_SUBSYS_CREATE_ADAPTER:
169 case HPI_SUBSYS_DELETE_ADAPTER:
170 /* Application must not use these functions! */
171 hr->h.size = sizeof(hr->h);
172 hr->h.error = HPI_ERROR_INVALID_OPERATION;
173 hr->h.function = hm->h.function;
174 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
175 if (uncopied_bytes)
176 err = -EFAULT;
177 else
178 err = 0;
179 goto out;
180
181 default:
182 hpi_send_recv_f(&hm->m0, &hr->r0, file);
183 }
184 } else { 183 } else {
185 u16 __user *ptr = NULL; 184 u16 __user *ptr = NULL;
186 u32 size = 0; 185 u32 size = 0;
@@ -188,8 +187,9 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
188 /* -1=no data 0=read from user mem, 1=write to user mem */ 187 /* -1=no data 0=read from user mem, 1=write to user mem */
189 int wrflag = -1; 188 int wrflag = -1;
190 u32 adapter = hm->h.adapter_index; 189 u32 adapter = hm->h.adapter_index;
190 pa = &adapters[adapter];
191 191
192 if ((hm->h.adapter_index > HPI_MAX_ADAPTERS) || (!pa->type)) { 192 if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
193 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER, 193 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
194 HPI_ADAPTER_OPEN, 194 HPI_ADAPTER_OPEN,
195 HPI_ERROR_BAD_ADAPTER_NUMBER); 195 HPI_ERROR_BAD_ADAPTER_NUMBER);
@@ -395,17 +395,20 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
395 395
396 adapter.index = hr.u.s.adapter_index; 396 adapter.index = hr.u.s.adapter_index;
397 adapter.type = hr.u.s.adapter_type; 397 adapter.type = hr.u.s.adapter_type;
398
399 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
400 HPI_ADAPTER_OPEN);
398 hm.adapter_index = adapter.index; 401 hm.adapter_index = adapter.index;
402 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
399 403
400 err = hpi_adapter_open(adapter.index); 404 if (hr.error)
401 if (err)
402 goto err; 405 goto err;
403 406
404 adapter.snd_card_asihpi = NULL; 407 adapter.snd_card_asihpi = NULL;
405 /* WARNING can't init mutex in 'adapter' 408 /* WARNING can't init mutex in 'adapter'
406 * and then copy it to adapters[] ?!?! 409 * and then copy it to adapters[] ?!?!
407 */ 410 */
408 adapters[hr.u.s.adapter_index] = adapter; 411 adapters[adapter.index] = adapter;
409 mutex_init(&adapters[adapter.index].mutex); 412 mutex_init(&adapters[adapter.index].mutex);
410 pci_set_drvdata(pci_dev, &adapters[adapter.index]); 413 pci_set_drvdata(pci_dev, &adapters[adapter.index]);
411 414
@@ -440,10 +443,9 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
440 struct hpi_adapter *pa; 443 struct hpi_adapter *pa;
441 pa = pci_get_drvdata(pci_dev); 444 pa = pci_get_drvdata(pci_dev);
442 445
443 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 446 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
444 HPI_SUBSYS_DELETE_ADAPTER); 447 HPI_ADAPTER_DELETE);
445 hm.obj_index = pa->index; 448 hm.adapter_index = pa->index;
446 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
447 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 449 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
448 450
449 /* unmap PCI memory space, mapped during device init. */ 451 /* unmap PCI memory space, mapped during device init. */