21 #define SOURCEFILE_NAME "hpioctl.c"
32 #include <linux/slab.h>
34 #include <asm/uaccess.h>
35 #include <linux/pci.h>
37 #include <linux/module.h>
39 #ifdef MODULE_FIRMWARE
49 static int prealloc_stream_buf;
52 "Preallocate size for per-adapter stream buffer");
136 if (hm->
h.size >
sizeof(*hm))
137 hm->
h.size =
sizeof(*hm);
142 if (uncopied_bytes) {
159 switch (hm->
h.function) {
163 hr->
h.size =
sizeof(hr->
h);
165 hr->
h.function = hm->
h.function;
174 hr->
h.size = res_max_size;
176 hpi_send_recv_f(&hm->
m0, &hr->
r0, file);
185 pa = &adapters[hm->
h.adapter_index];
206 switch (hm->
h.function) {
210 ptr = (
u16 __user *)hm->
m0.u.d.u.data.pb_data;
211 size = hm->
m0.u.d.u.data.data_size;
219 "Realloc adapter %d stream "
220 "buffer from %zd to %d\n",
232 "HPI could not allocate "
233 "stream buffer size %d\n",
256 if (size && (wrflag == 0)) {
262 "bytes from user\n", uncopied_bytes,
266 hpi_send_recv_f(&hm->
m0, &hr->
r0, file);
268 if (size && (wrflag == 1)) {
273 "Missed %d of %d " "bytes to user\n",
274 uncopied_bytes, size);
289 if (hr->
h.size > res_max_size) {
293 hr->
h.specific_error = hr->
h.size;
294 hr->
h.size =
sizeof(hr->
h);
298 if (uncopied_bytes) {
321 memset(&adapter, 0,
sizeof(adapter));
324 "probe %04x:%04x,%04x:%04x,%04x\n", pci_dev->
vendor,
330 "pci_enable_device failed, disabling device\n");
345 for (idx = 0; idx < nm; idx++) {
356 "ioremap failed, aborting\n");
365 hm.
u.
s.resource.r.pci = &pci;
372 adapter_index = hr.
u.
s.adapter_index;
375 if (prealloc_stream_buf) {
379 "HPI could not allocate "
380 "kernel buffer size %d\n",
381 prealloc_stream_buf);
397 adapters[adapter_index] =
adapter;
399 pci_set_drvdata(pci_dev, &adapters[adapter_index]);
402 "probe succeeded for ASI%04X HPI index %d\n",
403 adapter.
adapter->type, adapter_index);
432 pa = pci_get_drvdata(pci_dev);
433 pci = pa->adapter->pci;
449 pci_set_drvdata(pci_dev,
NULL);
452 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
455 pci_dev->
devfn, pa->adapter->index);
457 memset(pa, 0,
sizeof(*pa));
465 memset(adapters, 0,
sizeof(adapters));