diff options
Diffstat (limited to 'sound/pci/asihpi/hpioctl.c')
-rw-r--r-- | sound/pci/asihpi/hpioctl.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index cd624f13ff8e..d8e7047512f8 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); |
@@ -317,7 +317,7 @@ out: | |||
317 | int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | 317 | int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, |
318 | const struct pci_device_id *pci_id) | 318 | const struct pci_device_id *pci_id) |
319 | { | 319 | { |
320 | int err, idx, nm; | 320 | int idx, nm; |
321 | unsigned int memlen; | 321 | unsigned int memlen; |
322 | struct hpi_message hm; | 322 | struct hpi_message hm; |
323 | struct hpi_response hr; | 323 | struct hpi_response hr; |
@@ -351,11 +351,8 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
351 | nm = HPI_MAX_ADAPTER_MEM_SPACES; | 351 | nm = HPI_MAX_ADAPTER_MEM_SPACES; |
352 | 352 | ||
353 | for (idx = 0; idx < nm; idx++) { | 353 | for (idx = 0; idx < nm; idx++) { |
354 | HPI_DEBUG_LOG(INFO, "resource %d %s %08llx-%08llx %04llx\n", | 354 | HPI_DEBUG_LOG(INFO, "resource %d %pR\n", idx, |
355 | idx, pci_dev->resource[idx].name, | 355 | &pci_dev->resource[idx]); |
356 | (unsigned long long)pci_resource_start(pci_dev, idx), | ||
357 | (unsigned long long)pci_resource_end(pci_dev, idx), | ||
358 | (unsigned long long)pci_resource_flags(pci_dev, idx)); | ||
359 | 356 | ||
360 | if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { | 357 | if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { |
361 | memlen = pci_resource_len(pci_dev, idx); | 358 | memlen = pci_resource_len(pci_dev, idx); |
@@ -395,17 +392,20 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
395 | 392 | ||
396 | adapter.index = hr.u.s.adapter_index; | 393 | adapter.index = hr.u.s.adapter_index; |
397 | adapter.type = hr.u.s.adapter_type; | 394 | adapter.type = hr.u.s.adapter_type; |
395 | |||
396 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, | ||
397 | HPI_ADAPTER_OPEN); | ||
398 | hm.adapter_index = adapter.index; | 398 | hm.adapter_index = adapter.index; |
399 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); | ||
399 | 400 | ||
400 | err = hpi_adapter_open(adapter.index); | 401 | if (hr.error) |
401 | if (err) | ||
402 | goto err; | 402 | goto err; |
403 | 403 | ||
404 | adapter.snd_card_asihpi = NULL; | 404 | adapter.snd_card_asihpi = NULL; |
405 | /* WARNING can't init mutex in 'adapter' | 405 | /* WARNING can't init mutex in 'adapter' |
406 | * and then copy it to adapters[] ?!?! | 406 | * and then copy it to adapters[] ?!?! |
407 | */ | 407 | */ |
408 | adapters[hr.u.s.adapter_index] = adapter; | 408 | adapters[adapter.index] = adapter; |
409 | mutex_init(&adapters[adapter.index].mutex); | 409 | mutex_init(&adapters[adapter.index].mutex); |
410 | pci_set_drvdata(pci_dev, &adapters[adapter.index]); | 410 | pci_set_drvdata(pci_dev, &adapters[adapter.index]); |
411 | 411 | ||
@@ -440,10 +440,9 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) | |||
440 | struct hpi_adapter *pa; | 440 | struct hpi_adapter *pa; |
441 | pa = pci_get_drvdata(pci_dev); | 441 | pa = pci_get_drvdata(pci_dev); |
442 | 442 | ||
443 | hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, | 443 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, |
444 | HPI_SUBSYS_DELETE_ADAPTER); | 444 | HPI_ADAPTER_DELETE); |
445 | hm.obj_index = pa->index; | 445 | hm.adapter_index = pa->index; |
446 | hm.adapter_index = HPI_ADAPTER_INDEX_INVALID; | ||
447 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); | 446 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); |
448 | 447 | ||
449 | /* unmap PCI memory space, mapped during device init. */ | 448 | /* unmap PCI memory space, mapped during device init. */ |