~ubuntu-branches/ubuntu/jaunty/ndiswrapper/jaunty

« back to all changes in this revision

Viewing changes to driver/pnp.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-11-21 14:17:35 UTC
  • mfrom: (1.2.11 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081121141735-hzymcfoy3up8hego
Tags: 1.53-2ubuntu1
* Merge with Debian; remaining changes:
  - Build for lpia.
  - debian/control:
    + Update description to point out that the kernel source package is
      not required with the standard Ubuntu kernel.
    + Change the Maintainer address.
  - debian/control:
    + Drop ndiswrapper-source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "wrapndis.h"
19
19
#include "loader.h"
20
20
 
21
 
extern struct semaphore loader_mutex;
 
21
/* Functions callable from the NDIS driver */
 
22
wstdcall NTSTATUS pdoDispatchDeviceControl(struct device_object *pdo,
 
23
                                           struct irp *irp);
 
24
wstdcall NTSTATUS pdoDispatchPnp(struct device_object *pdo, struct irp *irp);
 
25
wstdcall NTSTATUS pdoDispatchPower(struct device_object *pdo, struct irp *irp);
22
26
 
23
27
static NTSTATUS start_pdo(struct device_object *pdo)
24
28
{
33
37
        if (ntoskernel_init_device(wd))
34
38
                EXIT1(return STATUS_FAILURE);
35
39
        if (wrap_is_usb_bus(wd->dev_bus)) {
36
 
#ifdef CONFIG_USB
 
40
#ifdef ENABLE_USB
37
41
                if (usb_init_device(wd)) {
38
42
                        ntoskernel_exit_device(wd);
39
43
                        EXIT1(return STATUS_FAILURE);
176
180
                wd->pci.pdev = NULL;
177
181
                pci_set_drvdata(pdev, NULL);
178
182
        } else if (wrap_is_usb_bus(wd->dev_bus)) {
179
 
#ifdef CONFIG_USB
 
183
#ifdef ENABLE_USB
180
184
                usb_exit_device(wd);
181
185
#endif
182
186
        }
186
190
        return;
187
191
}
188
192
 
189
 
wstdcall NTSTATUS IoSendIrpTopDev(struct device_object *dev_obj, ULONG major_fn,
190
 
                                 ULONG minor_fn, struct io_stack_location *sl)
 
193
static NTSTATUS IoSendIrpTopDev(struct device_object *dev_obj, ULONG major_fn,
 
194
                                ULONG minor_fn, struct io_stack_location *sl)
191
195
{
192
196
        NTSTATUS status;
193
197
        struct nt_event event;
223
227
 
224
228
        DUMP_IRP(irp);
225
229
        irp_sl = IoGetCurrentIrpStackLocation(irp);
226
 
#ifdef CONFIG_USB
 
230
#ifdef ENABLE_USB
227
231
        status = wrap_submit_irp(pdo, irp);
228
232
        IOTRACE("status: %08X", status);
229
233
        if (status != STATUS_PENDING)
241
245
        struct io_stack_location *irp_sl;
242
246
        struct wrap_device *wd;
243
247
        NTSTATUS status;
244
 
#ifdef CONFIG_USB
 
248
#ifdef ENABLE_USB
245
249
        struct usbd_bus_interface_usbdi *usb_intf;
246
250
#endif
247
251
 
262
266
                status = STATUS_SUCCESS;
263
267
                break;
264
268
        case IRP_MN_QUERY_INTERFACE:
265
 
#ifdef CONFIG_USB
 
269
#ifdef ENABLE_USB
266
270
                if (!wrap_is_usb_bus(wd->dev_bus)) {
267
271
                        status = STATUS_NOT_IMPLEMENTED;
268
272
                        break;
332
336
                        TRACE2("resuming %p", wd);
333
337
                        if (wrap_is_pci_bus(wd->dev_bus)) {
334
338
                                pdev = wd->pci.pdev;
335
 
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
336
339
                                pci_restore_state(pdev);
337
 
#else
338
 
                                pci_restore_state(pdev, wd->pci.pci_state);
339
 
#endif
340
340
                                if (wd->pci.wake_state == PowerDeviceD3) {
341
341
                                        pci_enable_wake(wd->pci.pdev,
342
342
                                                        PCI_D3hot, 0);
345
345
                                }
346
346
                                pci_set_power_state(pdev, PCI_D0);
347
347
                        } else { // usb device
348
 
#ifdef CONFIG_USB
 
348
#ifdef ENABLE_USB
349
349
                                wrap_resume_urbs(wd);
350
350
#endif
351
351
                        }
353
353
                        TRACE2("suspending device %p", wd);
354
354
                        if (wrap_is_pci_bus(wd->dev_bus)) {
355
355
                                pdev = wd->pci.pdev;
356
 
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
357
356
                                pci_save_state(pdev);
358
 
#else
359
 
                                pci_save_state(pdev, wd->pci.pci_state);
360
 
#endif
361
357
                                TRACE2("%d", wd->pci.wake_state);
362
358
                                if (wd->pci.wake_state == PowerDeviceD3) {
363
359
                                        pci_enable_wake(wd->pci.pdev,
367
363
                                }
368
364
                                pci_set_power_state(pdev, PCI_D3hot);
369
365
                        } else { // usb device
370
 
#ifdef CONFIG_USB
 
366
#ifdef ENABLE_USB
371
367
                                wrap_suspend_urbs(wd);
372
368
#endif
373
369
                        }
388
384
}
389
385
WIN_FUNC_DECL(pdoDispatchPower,2)
390
386
 
391
 
NTSTATUS pnp_set_device_power_state(struct wrap_device *wd,
392
 
                                    enum device_power_state state)
 
387
static NTSTATUS pnp_set_device_power_state(struct wrap_device *wd,
 
388
                                           enum device_power_state state)
393
389
{
394
390
        NTSTATUS status;
395
391
        struct device_object *pdo;
654
650
        return pnp_set_device_power_state(wd, PowerDeviceD0);
655
651
}
656
652
 
657
 
#ifdef CONFIG_USB
658
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 
653
#ifdef ENABLE_USB
659
654
int wrap_pnp_start_usb_device(struct usb_interface *intf,
660
655
                              const struct usb_device_id *usb_id)
661
 
#else
662
 
void *wrap_pnp_start_usb_device(struct usb_device *udev,
663
 
                                unsigned int ifnum,
664
 
                                const struct usb_device_id *usb_id)
665
 
#endif
666
656
{
667
657
        struct wrap_device *wd;
668
658
        int ret;
669
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
670
659
        struct usb_device *udev = interface_to_usbdev(intf);
671
 
#else
672
 
        struct usb_interface *intf = usb_ifnum_to_if(udev, ifnum);
673
 
#endif
674
660
        ENTER1("%04x, %04x, %04x", udev->descriptor.idVendor,
675
661
               udev->descriptor.idProduct, udev->descriptor.bDeviceClass);
676
662
 
686
672
                struct load_device load_device;
687
673
 
688
674
                load_device.bus = WRAP_USB_BUS;
689
 
                load_device.vendor = udev->descriptor.idVendor;
690
 
                load_device.device = udev->descriptor.idProduct;
 
675
                load_device.vendor = le16_to_cpu(udev->descriptor.idVendor);
 
676
                load_device.device = le16_to_cpu(udev->descriptor.idProduct);
691
677
                load_device.subvendor = 0;
692
678
                load_device.subdevice = 0;
693
679
                wd = load_wrap_device(&load_device);
707
693
        }
708
694
 
709
695
        TRACE2("ret: %d", ret);
710
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
711
696
        if (ret)
712
697
                EXIT1(return ret);
713
698
        else
714
699
                return 0;
715
 
#else
716
 
        if (ret)
717
 
                return NULL;
718
 
        else
719
 
                return wd;
720
 
#endif
721
700
}
722
701
 
723
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
724
702
void __devexit wrap_pnp_remove_usb_device(struct usb_interface *intf)
725
703
{
726
704
        struct wrap_device *wd;
761
739
        return 0;
762
740
}
763
741
 
764
 
#else
765
 
 
766
 
void __devexit wrap_pnp_remove_usb_device(struct usb_device *udev, void *ptr)
767
 
{
768
 
        struct wrap_device *wd = ptr;
769
 
        struct usb_interface *intf;
770
 
 
771
 
        ENTER1("%p, %p", udev, wd);
772
 
        if (wd == NULL)
773
 
                EXIT1(return);
774
 
        intf = wd->usb.intf;
775
 
        wd->usb.intf = NULL;
776
 
        pnp_remove_device(wd);
777
 
}
778
 
#endif
779
 
 
780
742
#endif // USB