/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/ioctl.c

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-02 18:37:30 UTC
  • Revision ID: csa@suren.me-20160302183730-nlrgi7h3yuizcizc
Restructure driver headers

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include "../pcilib/version.h"
34
34
 
35
 
#include "config.h"                     /* Configuration for the driver */
36
 
#include "compat.h"                     /* Compatibility functions/definitions */
37
 
#include "pciDriver.h"                  /* External interface for the driver */
38
 
#include "common.h"                     /* Internal definitions for all parts */
39
 
#include "kmem.h"                       /* Internal definitions for kernel memory */
40
 
#include "umem.h"                       /* Internal definitions for user space memory */
41
 
#include "ioctl.h"                      /* Internal definitions for the ioctl part */
 
35
#include "base.h"
42
36
 
43
37
/** Declares a variable of the given type with the given name and copies it from userspace */
44
38
#define READ_FROM_USER(type, name) \
87
81
}
88
82
 
89
83
/**
90
 
 *
91
84
 * Reads/writes a byte/word/dword of the device's PCI config.
92
 
 *
93
 
 * @see pcidriver_pci_read
94
 
 * @see pcidriver_pci_write
95
 
 *
96
85
 */
97
86
static int ioctl_pci_config_read_write(pcidriver_privdata_t *privdata, unsigned int cmd, unsigned long arg)
98
87
{
103
92
    READ_FROM_USER(pci_cfg_cmd, pci_cmd);
104
93
 
105
94
    if (cmd == PCIDRIVER_IOC_PCI_CFG_RD) {
106
 
        switch (pci_cmd.size) {
 
95
      switch (pci_cmd.size) {
107
96
        case PCIDRIVER_PCI_CFG_SZ_BYTE:
108
97
            ret = pci_read_config_byte( privdata->pdev, pci_cmd.addr, &(pci_cmd.val.byte) );
109
98
            break;
115
104
            break;
116
105
        default:
117
106
            return -EINVAL;             /* Wrong size setting */
118
 
        }
 
107
      }
119
108
    } else {
120
 
        switch (pci_cmd.size) {
 
109
      switch (pci_cmd.size) {
121
110
        case PCIDRIVER_PCI_CFG_SZ_BYTE:
122
111
            ret = pci_write_config_byte( privdata->pdev, pci_cmd.addr, pci_cmd.val.byte );
123
112
            break;
130
119
        default:
131
120
            return -EINVAL;             /* Wrong size setting */
132
121
            break;
133
 
        }
 
122
      }
134
123
    }
135
124
 
136
125
    WRITE_TO_USER(pci_cfg_cmd, pci_cmd);
140
129
}
141
130
 
142
131
/**
143
 
 *
144
132
 * Gets the PCI information for the device.
145
 
 *
146
 
 * @see pcidriver_pci_info
147
 
 *
148
133
 */
149
134
static int ioctl_pci_info(pcidriver_privdata_t *privdata, unsigned long arg)
150
135
{