aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acpixf.h2
-rw-r--r--include/asm-arm/arch-at91/board.h3
-rw-r--r--include/asm-arm/mach/udc_pxa2xx.h2
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/aspm.h44
-rw-r--r--include/linux/lockd/lockd.h9
-rw-r--r--include/linux/lockd/xdr.h4
-rw-r--r--include/linux/nfsd/Kbuild1
-rw-r--r--include/linux/nfsd/auth.h27
-rw-r--r--include/linux/nfsd/cache.h4
-rw-r--r--include/linux/nfsd/export.h2
-rw-r--r--include/linux/nfsd/nfsd.h5
-rw-r--r--include/linux/nfsd/syscall.h1
-rw-r--r--include/linux/nfsd/xdr.h14
-rw-r--r--include/linux/nfsd/xdr3.h16
-rw-r--r--include/linux/nfsd/xdr4.h2
-rw-r--r--include/linux/nfsd_idmap.h11
-rw-r--r--include/linux/notifier.h2
-rw-r--r--include/linux/pci-acpi.h11
-rw-r--r--include/linux/pci.h367
-rw-r--r--include/linux/pci_regs.h8
-rw-r--r--include/linux/sunrpc/cache.h4
-rw-r--r--include/linux/sunrpc/debug.h2
-rw-r--r--include/linux/sunrpc/svc.h10
-rw-r--r--include/linux/sunrpc/svc_rdma.h262
-rw-r--r--include/linux/sunrpc/svc_xprt.h159
-rw-r--r--include/linux/sunrpc/svcsock.h43
-rw-r--r--include/linux/sunrpc/xdr.h3
-rw-r--r--include/linux/suspend.h56
-rw-r--r--include/linux/suspend_ioctls.h32
-rw-r--r--include/linux/usb.h209
-rw-r--r--include/linux/usb/Kbuild11
-rw-r--r--include/linux/usb/audio.h14
-rw-r--r--include/linux/usb/cdc.h16
-rw-r--r--include/linux/usb/g_printer.h31
-rw-r--r--include/linux/usb/gadget.h123
-rw-r--r--include/linux/usb/gadgetfs.h27
-rw-r--r--include/linux/usb/iowarrior.h25
-rw-r--r--include/linux/usb/isp116x.h2
-rw-r--r--include/linux/usb/midi.h26
-rw-r--r--include/linux/usb/net2280.h32
-rw-r--r--include/linux/usb/otg.h2
-rw-r--r--include/linux/usb/serial.h160
-rw-r--r--include/linux/usb/sl811.h6
-rw-r--r--include/linux/usb_usual.h5
-rw-r--r--include/linux/usbdevice_fs.h2
46 files changed, 1241 insertions, 557 deletions
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 9512f0456ad1..b729e64d0d4c 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -335,6 +335,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
335 335
336acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void); 336acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
337 337
338acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
339
338acpi_status acpi_leave_sleep_state(u8 sleep_state); 340acpi_status acpi_leave_sleep_state(u8 sleep_state);
339 341
340#endif /* __ACXFACE_H__ */ 342#endif /* __ACXFACE_H__ */
diff --git a/include/asm-arm/arch-at91/board.h b/include/asm-arm/arch-at91/board.h
index 55b07bd5316c..dc189f01c5b3 100644
--- a/include/asm-arm/arch-at91/board.h
+++ b/include/asm-arm/arch-at91/board.h
@@ -40,7 +40,8 @@
40 /* USB Device */ 40 /* USB Device */
41struct at91_udc_data { 41struct at91_udc_data {
42 u8 vbus_pin; /* high == host powering us */ 42 u8 vbus_pin; /* high == host powering us */
43 u8 pullup_pin; /* high == D+ pulled up */ 43 u8 pullup_pin; /* active == D+ pulled up */
44 u8 pullup_active_low; /* true == pullup_pin is active low */
44}; 45};
45extern void __init at91_add_device_udc(struct at91_udc_data *data); 46extern void __init at91_add_device_udc(struct at91_udc_data *data);
46 47
diff --git a/include/asm-arm/mach/udc_pxa2xx.h b/include/asm-arm/mach/udc_pxa2xx.h
index ff0a95715a07..f191e147ea90 100644
--- a/include/asm-arm/mach/udc_pxa2xx.h
+++ b/include/asm-arm/mach/udc_pxa2xx.h
@@ -19,7 +19,9 @@ struct pxa2xx_udc_mach_info {
19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane 19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
20 * VBUS IRQ and omit the methods above. Store the GPIO number 20 * VBUS IRQ and omit the methods above. Store the GPIO number
21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits. 21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
22 * Note that sometimes the signals go through inverters...
22 */ 23 */
24 bool gpio_vbus_inverted;
23 u16 gpio_vbus; /* high == vbus present */ 25 u16 gpio_vbus; /* high == vbus present */
24 u16 gpio_pullup; /* high == pullup activated */ 26 u16 gpio_pullup; /* high == pullup activated */
25}; 27};
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 85b2482cc736..c0f9bb78727d 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -143,6 +143,7 @@ header-y += snmp.h
143header-y += sockios.h 143header-y += sockios.h
144header-y += som.h 144header-y += som.h
145header-y += sound.h 145header-y += sound.h
146header-y += suspend_ioctls.h
146header-y += taskstats.h 147header-y += taskstats.h
147header-y += telephony.h 148header-y += telephony.h
148header-y += termios.h 149header-y += termios.h
diff --git a/include/linux/aspm.h b/include/linux/aspm.h
new file mode 100644
index 000000000000..f41a69895485
--- /dev/null
+++ b/include/linux/aspm.h
@@ -0,0 +1,44 @@
1/*
2 * aspm.h
3 *
4 * PCI Express ASPM defines and function prototypes
5 *
6 * Copyright (C) 2007 Intel Corp.
7 * Zhang Yanmin (yanmin.zhang@intel.com)
8 * Shaohua Li (shaohua.li@intel.com)
9 *
10 * For more information, please consult the following manuals (look at
11 * http://www.pcisig.com/ for how to get them):
12 *
13 * PCI Express Specification
14 */
15
16#ifndef LINUX_ASPM_H
17#define LINUX_ASPM_H
18
19#include <linux/pci.h>
20
21#define PCIE_LINK_STATE_L0S 1
22#define PCIE_LINK_STATE_L1 2
23#define PCIE_LINK_STATE_CLKPM 4
24
25#ifdef CONFIG_PCIEASPM
26extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state);
30#else
31#define pcie_aspm_init_link_state(pdev) do {} while (0)
32#define pcie_aspm_exit_link_state(pdev) do {} while (0)
33#define pcie_aspm_pm_state_change(pdev) do {} while (0)
34#define pci_disable_link_state(pdev, state) do {} while (0)
35#endif
36
37#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
38extern void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev);
39extern void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev);
40#else
41#define pcie_aspm_create_sysfs_dev_files(pdev) do {} while (0)
42#define pcie_aspm_remove_sysfs_dev_files(pdev) do {} while (0)
43#endif
44#endif /* LINUX_ASPM_H */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index e2d1ce36b367..4babb2a129ac 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -173,14 +173,17 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
173/* 173/*
174 * Host cache 174 * Host cache
175 */ 175 */
176struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int); 176struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *, int, int,
177struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int); 177 const char *, unsigned int);
178struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *,
179 unsigned int);
178struct rpc_clnt * nlm_bind_host(struct nlm_host *); 180struct rpc_clnt * nlm_bind_host(struct nlm_host *);
179void nlm_rebind_host(struct nlm_host *); 181void nlm_rebind_host(struct nlm_host *);
180struct nlm_host * nlm_get_host(struct nlm_host *); 182struct nlm_host * nlm_get_host(struct nlm_host *);
181void nlm_release_host(struct nlm_host *); 183void nlm_release_host(struct nlm_host *);
182void nlm_shutdown_hosts(void); 184void nlm_shutdown_hosts(void);
183extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32); 185extern void nlm_host_rebooted(const struct sockaddr_in *, const char *,
186 unsigned int, u32);
184void nsm_release(struct nsm_handle *); 187void nsm_release(struct nsm_handle *);
185 188
186 189
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index 83a1f9f6237b..df18fa053bcd 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -29,7 +29,7 @@ struct svc_rqst;
29/* Lock info passed via NLM */ 29/* Lock info passed via NLM */
30struct nlm_lock { 30struct nlm_lock {
31 char * caller; 31 char * caller;
32 int len; /* length of "caller" */ 32 unsigned int len; /* length of "caller" */
33 struct nfs_fh fh; 33 struct nfs_fh fh;
34 struct xdr_netobj oh; 34 struct xdr_netobj oh;
35 u32 svid; 35 u32 svid;
@@ -78,7 +78,7 @@ struct nlm_res {
78 */ 78 */
79struct nlm_reboot { 79struct nlm_reboot {
80 char * mon; 80 char * mon;
81 int len; 81 unsigned int len;
82 u32 state; 82 u32 state;
83 __be32 addr; 83 __be32 addr;
84 __be32 vers; 84 __be32 vers;
diff --git a/include/linux/nfsd/Kbuild b/include/linux/nfsd/Kbuild
index d9c5455808e5..e726fc3a4375 100644
--- a/include/linux/nfsd/Kbuild
+++ b/include/linux/nfsd/Kbuild
@@ -4,4 +4,3 @@ unifdef-y += stats.h
4unifdef-y += syscall.h 4unifdef-y += syscall.h
5unifdef-y += nfsfh.h 5unifdef-y += nfsfh.h
6unifdef-y += debug.h 6unifdef-y += debug.h
7unifdef-y += auth.h
diff --git a/include/linux/nfsd/auth.h b/include/linux/nfsd/auth.h
deleted file mode 100644
index 0fb9f7212195..000000000000
--- a/include/linux/nfsd/auth.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * include/linux/nfsd/auth.h
3 *
4 * nfsd-specific authentication stuff.
5 * uid/gid mapping not yet implemented.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_AUTH_H
11#define LINUX_NFSD_AUTH_H
12
13#ifdef __KERNEL__
14
15#define nfsd_luid(rq, uid) ((u32)(uid))
16#define nfsd_lgid(rq, gid) ((u32)(gid))
17#define nfsd_ruid(rq, uid) ((u32)(uid))
18#define nfsd_rgid(rq, gid) ((u32)(gid))
19
20/*
21 * Set the current process's fsuid/fsgid etc to those of the NFS
22 * client user
23 */
24int nfsd_setuser(struct svc_rqst *, struct svc_export *);
25
26#endif /* __KERNEL__ */
27#endif /* LINUX_NFSD_AUTH_H */
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
index 007480cd6a60..7b5d784cc858 100644
--- a/include/linux/nfsd/cache.h
+++ b/include/linux/nfsd/cache.h
@@ -72,8 +72,8 @@ enum {
72 */ 72 */
73#define RC_DELAY (HZ/5) 73#define RC_DELAY (HZ/5)
74 74
75void nfsd_cache_init(void); 75int nfsd_reply_cache_init(void);
76void nfsd_cache_shutdown(void); 76void nfsd_reply_cache_shutdown(void);
77int nfsd_cache_lookup(struct svc_rqst *, int); 77int nfsd_cache_lookup(struct svc_rqst *, int);
78void nfsd_cache_update(struct svc_rqst *, int, __be32 *); 78void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
79 79
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index bcb7abafbca9..3a1687251367 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -122,7 +122,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
122/* 122/*
123 * Function declarations 123 * Function declarations
124 */ 124 */
125void nfsd_export_init(void); 125int nfsd_export_init(void);
126void nfsd_export_shutdown(void); 126void nfsd_export_shutdown(void);
127void nfsd_export_flush(void); 127void nfsd_export_flush(void);
128void exp_readlock(void); 128void exp_readlock(void);
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index 604a0d786bc6..8caf4c4f64e6 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -20,7 +20,6 @@
20#include <linux/nfsd/debug.h> 20#include <linux/nfsd/debug.h>
21#include <linux/nfsd/nfsfh.h> 21#include <linux/nfsd/nfsfh.h>
22#include <linux/nfsd/export.h> 22#include <linux/nfsd/export.h>
23#include <linux/nfsd/auth.h>
24#include <linux/nfsd/stats.h> 23#include <linux/nfsd/stats.h>
25/* 24/*
26 * nfsd version 25 * nfsd version
@@ -70,9 +69,9 @@ void nfsd_racache_shutdown(void);
70int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, 69int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
71 struct svc_export **expp); 70 struct svc_export **expp);
72__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *, 71__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
73 const char *, int, struct svc_fh *); 72 const char *, unsigned int, struct svc_fh *);
74__be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *, 73__be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
75 const char *, int, 74 const char *, unsigned int,
76 struct svc_export **, struct dentry **); 75 struct svc_export **, struct dentry **);
77__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *, 76__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
78 struct iattr *, int, time_t); 77 struct iattr *, int, time_t);
diff --git a/include/linux/nfsd/syscall.h b/include/linux/nfsd/syscall.h
index 8bcddccb6c42..4e439765b705 100644
--- a/include/linux/nfsd/syscall.h
+++ b/include/linux/nfsd/syscall.h
@@ -18,7 +18,6 @@
18#include <linux/nfsd/const.h> 18#include <linux/nfsd/const.h>
19#include <linux/nfsd/export.h> 19#include <linux/nfsd/export.h>
20#include <linux/nfsd/nfsfh.h> 20#include <linux/nfsd/nfsfh.h>
21#include <linux/nfsd/auth.h>
22 21
23/* 22/*
24 * Version of the syscall interface 23 * Version of the syscall interface
diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h
index 67885d5e6e50..a0132ef58f21 100644
--- a/include/linux/nfsd/xdr.h
+++ b/include/linux/nfsd/xdr.h
@@ -23,7 +23,7 @@ struct nfsd_sattrargs {
23struct nfsd_diropargs { 23struct nfsd_diropargs {
24 struct svc_fh fh; 24 struct svc_fh fh;
25 char * name; 25 char * name;
26 int len; 26 unsigned int len;
27}; 27};
28 28
29struct nfsd_readargs { 29struct nfsd_readargs {
@@ -43,17 +43,17 @@ struct nfsd_writeargs {
43struct nfsd_createargs { 43struct nfsd_createargs {
44 struct svc_fh fh; 44 struct svc_fh fh;
45 char * name; 45 char * name;
46 int len; 46 unsigned int len;
47 struct iattr attrs; 47 struct iattr attrs;
48}; 48};
49 49
50struct nfsd_renameargs { 50struct nfsd_renameargs {
51 struct svc_fh ffh; 51 struct svc_fh ffh;
52 char * fname; 52 char * fname;
53 int flen; 53 unsigned int flen;
54 struct svc_fh tfh; 54 struct svc_fh tfh;
55 char * tname; 55 char * tname;
56 int tlen; 56 unsigned int tlen;
57}; 57};
58 58
59struct nfsd_readlinkargs { 59struct nfsd_readlinkargs {
@@ -65,15 +65,15 @@ struct nfsd_linkargs {
65 struct svc_fh ffh; 65 struct svc_fh ffh;
66 struct svc_fh tfh; 66 struct svc_fh tfh;
67 char * tname; 67 char * tname;
68 int tlen; 68 unsigned int tlen;
69}; 69};
70 70
71struct nfsd_symlinkargs { 71struct nfsd_symlinkargs {
72 struct svc_fh ffh; 72 struct svc_fh ffh;
73 char * fname; 73 char * fname;
74 int flen; 74 unsigned int flen;
75 char * tname; 75 char * tname;
76 int tlen; 76 unsigned int tlen;
77 struct iattr attrs; 77 struct iattr attrs;
78}; 78};
79 79
diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h
index 89d9d6061a62..421eddd65a25 100644
--- a/include/linux/nfsd/xdr3.h
+++ b/include/linux/nfsd/xdr3.h
@@ -21,7 +21,7 @@ struct nfsd3_sattrargs {
21struct nfsd3_diropargs { 21struct nfsd3_diropargs {
22 struct svc_fh fh; 22 struct svc_fh fh;
23 char * name; 23 char * name;
24 int len; 24 unsigned int len;
25}; 25};
26 26
27struct nfsd3_accessargs { 27struct nfsd3_accessargs {
@@ -48,7 +48,7 @@ struct nfsd3_writeargs {
48struct nfsd3_createargs { 48struct nfsd3_createargs {
49 struct svc_fh fh; 49 struct svc_fh fh;
50 char * name; 50 char * name;
51 int len; 51 unsigned int len;
52 int createmode; 52 int createmode;
53 struct iattr attrs; 53 struct iattr attrs;
54 __be32 * verf; 54 __be32 * verf;
@@ -57,7 +57,7 @@ struct nfsd3_createargs {
57struct nfsd3_mknodargs { 57struct nfsd3_mknodargs {
58 struct svc_fh fh; 58 struct svc_fh fh;
59 char * name; 59 char * name;
60 int len; 60 unsigned int len;
61 __u32 ftype; 61 __u32 ftype;
62 __u32 major, minor; 62 __u32 major, minor;
63 struct iattr attrs; 63 struct iattr attrs;
@@ -66,10 +66,10 @@ struct nfsd3_mknodargs {
66struct nfsd3_renameargs { 66struct nfsd3_renameargs {
67 struct svc_fh ffh; 67 struct svc_fh ffh;
68 char * fname; 68 char * fname;
69 int flen; 69 unsigned int flen;
70 struct svc_fh tfh; 70 struct svc_fh tfh;
71 char * tname; 71 char * tname;
72 int tlen; 72 unsigned int tlen;
73}; 73};
74 74
75struct nfsd3_readlinkargs { 75struct nfsd3_readlinkargs {
@@ -81,15 +81,15 @@ struct nfsd3_linkargs {
81 struct svc_fh ffh; 81 struct svc_fh ffh;
82 struct svc_fh tfh; 82 struct svc_fh tfh;
83 char * tname; 83 char * tname;
84 int tlen; 84 unsigned int tlen;
85}; 85};
86 86
87struct nfsd3_symlinkargs { 87struct nfsd3_symlinkargs {
88 struct svc_fh ffh; 88 struct svc_fh ffh;
89 char * fname; 89 char * fname;
90 int flen; 90 unsigned int flen;
91 char * tname; 91 char * tname;
92 int tlen; 92 unsigned int tlen;
93 struct iattr attrs; 93 struct iattr attrs;
94}; 94};
95 95
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
index b0ddfb41c790..27bd3e38ec5a 100644
--- a/include/linux/nfsd/xdr4.h
+++ b/include/linux/nfsd/xdr4.h
@@ -441,7 +441,7 @@ void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
441void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); 441void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
442__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, 442__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
443 struct dentry *dentry, __be32 *buffer, int *countp, 443 struct dentry *dentry, __be32 *buffer, int *countp,
444 u32 *bmval, struct svc_rqst *); 444 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
445extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, 445extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
446 struct nfsd4_compound_state *, 446 struct nfsd4_compound_state *,
447 struct nfsd4_setclientid *setclid); 447 struct nfsd4_setclientid *setclid);
diff --git a/include/linux/nfsd_idmap.h b/include/linux/nfsd_idmap.h
index e82746fcad14..d4a2ac18bd4c 100644
--- a/include/linux/nfsd_idmap.h
+++ b/include/linux/nfsd_idmap.h
@@ -44,11 +44,16 @@
44#define IDMAP_NAMESZ 128 44#define IDMAP_NAMESZ 128
45 45
46#ifdef CONFIG_NFSD_V4 46#ifdef CONFIG_NFSD_V4
47void nfsd_idmap_init(void); 47int nfsd_idmap_init(void);
48void nfsd_idmap_shutdown(void); 48void nfsd_idmap_shutdown(void);
49#else 49#else
50static inline void nfsd_idmap_init(void) {}; 50static inline int nfsd_idmap_init(void)
51static inline void nfsd_idmap_shutdown(void) {}; 51{
52 return 0;
53}
54static inline void nfsd_idmap_shutdown(void)
55{
56}
52#endif 57#endif
53 58
54int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *); 59int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 5dfbc684ce7d..f4df40038f0c 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -228,6 +228,8 @@ static inline int notifier_to_errno(int ret)
228#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ 228#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */
229#define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */ 229#define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */
230#define PM_POST_SUSPEND 0x0004 /* Suspend finished */ 230#define PM_POST_SUSPEND 0x0004 /* Suspend finished */
231#define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */
232#define PM_POST_RESTORE 0x0006 /* Restore failed */
231 233
232/* Console keyboard events. 234/* Console keyboard events.
233 * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and 235 * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 936ef82ed76a..3ba25065fa96 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -48,7 +48,15 @@
48 48
49#ifdef CONFIG_ACPI 49#ifdef CONFIG_ACPI
50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags); 50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags);
51extern acpi_status pci_osc_support_set(u32 flags); 51extern acpi_status __pci_osc_support_set(u32 flags, const char *hid);
52static inline acpi_status pci_osc_support_set(u32 flags)
53{
54 return __pci_osc_support_set(flags, PCI_ROOT_HID_STRING);
55}
56static inline acpi_status pcie_osc_support_set(u32 flags)
57{
58 return __pci_osc_support_set(flags, PCI_EXPRESS_ROOT_HID_STRING);
59}
52#else 60#else
53#if !defined(AE_ERROR) 61#if !defined(AE_ERROR)
54typedef u32 acpi_status; 62typedef u32 acpi_status;
@@ -57,6 +65,7 @@ typedef u32 acpi_status;
57static inline acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) 65static inline acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
58{return AE_ERROR;} 66{return AE_ERROR;}
59static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;} 67static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;}
68static inline acpi_status pcie_osc_support_set(u32 flags) {return AE_ERROR;}
60#endif 69#endif
61 70
62#endif /* _PCI_ACPI_H_ */ 71#endif /* _PCI_ACPI_H_ */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ae1006322f80..4f96f1d94ac4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -28,7 +28,7 @@
28 * 7:3 = slot 28 * 7:3 = slot
29 * 2:0 = function 29 * 2:0 = function
30 */ 30 */
31#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) 31#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
32#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) 32#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
33#define PCI_FUNC(devfn) ((devfn) & 0x07) 33#define PCI_FUNC(devfn) ((devfn) & 0x07)
34 34
@@ -66,7 +66,6 @@ enum pci_mmap_state {
66#define PCI_DMA_FROMDEVICE 2 66#define PCI_DMA_FROMDEVICE 2
67#define PCI_DMA_NONE 3 67#define PCI_DMA_NONE 3
68 68
69#define DEVICE_COUNT_COMPATIBLE 4
70#define DEVICE_COUNT_RESOURCE 12 69#define DEVICE_COUNT_RESOURCE 12
71 70
72typedef int __bitwise pci_power_t; 71typedef int __bitwise pci_power_t;
@@ -129,6 +128,7 @@ struct pci_cap_saved_state {
129 u32 data[0]; 128 u32 data[0];
130}; 129};
131 130
131struct pcie_link_state;
132/* 132/*
133 * The pci_dev structure is used to describe PCI devices. 133 * The pci_dev structure is used to describe PCI devices.
134 */ 134 */
@@ -164,13 +164,13 @@ struct pci_dev {
164 this is D0-D3, D0 being fully functional, 164 this is D0-D3, D0 being fully functional,
165 and D3 being off. */ 165 and D3 being off. */
166 166
167#ifdef CONFIG_PCIEASPM
168 struct pcie_link_state *link_state; /* ASPM link state. */
169#endif
170
167 pci_channel_state_t error_state; /* current connectivity state */ 171 pci_channel_state_t error_state; /* current connectivity state */
168 struct device dev; /* Generic device interface */ 172 struct device dev; /* Generic device interface */
169 173
170 /* device is compatible with these IDs */
171 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];
172 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];
173
174 int cfg_size; /* Size of configuration space */ 174 int cfg_size; /* Size of configuration space */
175 175
176 /* 176 /*
@@ -219,7 +219,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
219} 219}
220 220
221static inline struct pci_cap_saved_state *pci_find_saved_cap( 221static inline struct pci_cap_saved_state *pci_find_saved_cap(
222 struct pci_dev *pci_dev,char cap) 222 struct pci_dev *pci_dev, char cap)
223{ 223{
224 struct pci_cap_saved_state *tmp; 224 struct pci_cap_saved_state *tmp;
225 struct hlist_node *pos; 225 struct hlist_node *pos;
@@ -278,13 +278,13 @@ struct pci_bus {
278 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ 278 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
279 pci_bus_flags_t bus_flags; /* Inherited by child busses */ 279 pci_bus_flags_t bus_flags; /* Inherited by child busses */
280 struct device *bridge; 280 struct device *bridge;
281 struct class_device class_dev; 281 struct device dev;
282 struct bin_attribute *legacy_io; /* legacy I/O for this bus */ 282 struct bin_attribute *legacy_io; /* legacy I/O for this bus */
283 struct bin_attribute *legacy_mem; /* legacy mem */ 283 struct bin_attribute *legacy_mem; /* legacy mem */
284}; 284};
285 285
286#define pci_bus_b(n) list_entry(n, struct pci_bus, node) 286#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
287#define to_pci_bus(n) container_of(n, struct pci_bus, class_dev) 287#define to_pci_bus(n) container_of(n, struct pci_bus, dev)
288 288
289/* 289/*
290 * Error values that may be returned by PCI functions. 290 * Error values that may be returned by PCI functions.
@@ -314,8 +314,8 @@ struct pci_raw_ops {
314extern struct pci_raw_ops *raw_pci_ops; 314extern struct pci_raw_ops *raw_pci_ops;
315 315
316struct pci_bus_region { 316struct pci_bus_region {
317 unsigned long start; 317 resource_size_t start;
318 unsigned long end; 318 resource_size_t end;
319}; 319};
320 320
321struct pci_dynids { 321struct pci_dynids {
@@ -351,11 +351,10 @@ enum pci_ers_result {
351}; 351};
352 352
353/* PCI bus error event callbacks */ 353/* PCI bus error event callbacks */
354struct pci_error_handlers 354struct pci_error_handlers {
355{
356 /* PCI bus error detected on this device */ 355 /* PCI bus error detected on this device */
357 pci_ers_result_t (*error_detected)(struct pci_dev *dev, 356 pci_ers_result_t (*error_detected)(struct pci_dev *dev,
358 enum pci_channel_state error); 357 enum pci_channel_state error);
359 358
360 /* MMIO has been re-enabled, but not DMA */ 359 /* MMIO has been re-enabled, but not DMA */
361 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); 360 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
@@ -390,7 +389,7 @@ struct pci_driver {
390 struct pci_dynids dynids; 389 struct pci_dynids dynids;
391}; 390};
392 391
393#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) 392#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
394 393
395/** 394/**
396 * PCI_DEVICE - macro used to describe a specific pci device 395 * PCI_DEVICE - macro used to describe a specific pci device
@@ -448,7 +447,7 @@ extern int no_pci_devices(void);
448 447
449void pcibios_fixup_bus(struct pci_bus *); 448void pcibios_fixup_bus(struct pci_bus *);
450int __must_check pcibios_enable_device(struct pci_dev *, int mask); 449int __must_check pcibios_enable_device(struct pci_dev *, int mask);
451char *pcibios_setup (char *str); 450char *pcibios_setup(char *str);
452 451
453/* Used only when drivers/pci/setup.c is used */ 452/* Used only when drivers/pci/setup.c is used */
454void pcibios_align_resource(void *, struct resource *, resource_size_t, 453void pcibios_align_resource(void *, struct resource *, resource_size_t,
@@ -459,8 +458,10 @@ void pcibios_update_irq(struct pci_dev *, int irq);
459 458
460extern struct pci_bus *pci_find_bus(int domain, int busnr); 459extern struct pci_bus *pci_find_bus(int domain, int busnr);
461void pci_bus_add_devices(struct pci_bus *bus); 460void pci_bus_add_devices(struct pci_bus *bus);
462struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); 461struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
463static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) 462 struct pci_ops *ops, void *sysdata);
463static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
464 void *sysdata)
464{ 465{
465 struct pci_bus *root_bus; 466 struct pci_bus *root_bus;
466 root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); 467 root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
@@ -468,15 +469,18 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s
468 pci_bus_add_devices(root_bus); 469 pci_bus_add_devices(root_bus);
469 return root_bus; 470 return root_bus;
470} 471}
471struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); 472struct pci_bus *pci_create_bus(struct device *parent, int bus,
472struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); 473 struct pci_ops *ops, void *sysdata);
474struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
475 int busnr);
473int pci_scan_slot(struct pci_bus *bus, int devfn); 476int pci_scan_slot(struct pci_bus *bus, int devfn);
474struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); 477struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
475void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); 478void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
476unsigned int pci_scan_child_bus(struct pci_bus *bus); 479unsigned int pci_scan_child_bus(struct pci_bus *bus);
477int __must_check pci_bus_add_device(struct pci_dev *dev); 480int __must_check pci_bus_add_device(struct pci_dev *dev);
478void pci_read_bridge_bases(struct pci_bus *child); 481void pci_read_bridge_bases(struct pci_bus *child);
479struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); 482struct resource *pci_find_parent_resource(const struct pci_dev *dev,
483 struct resource *res);
480int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); 484int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
481extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 485extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
482extern void pci_dev_put(struct pci_dev *dev); 486extern void pci_dev_put(struct pci_dev *dev);
@@ -489,15 +493,19 @@ extern void pci_sort_breadthfirst(void);
489/* Generic PCI functions exported to card drivers */ 493/* Generic PCI functions exported to card drivers */
490 494
491#ifdef CONFIG_PCI_LEGACY 495#ifdef CONFIG_PCI_LEGACY
492struct pci_dev __deprecated *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from); 496struct pci_dev __deprecated *pci_find_device(unsigned int vendor,
493struct pci_dev __deprecated *pci_find_slot (unsigned int bus, unsigned int devfn); 497 unsigned int device,
498 const struct pci_dev *from);
499struct pci_dev __deprecated *pci_find_slot(unsigned int bus,
500 unsigned int devfn);
494#endif /* CONFIG_PCI_LEGACY */ 501#endif /* CONFIG_PCI_LEGACY */
495 502
496int pci_find_capability (struct pci_dev *dev, int cap); 503int pci_find_capability(struct pci_dev *dev, int cap);
497int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); 504int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
498int pci_find_ext_capability (struct pci_dev *dev, int cap); 505int pci_find_ext_capability(struct pci_dev *dev, int cap);
499int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); 506int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
500int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); 507int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
508void pcie_wait_pending_transaction(struct pci_dev *dev);
501struct pci_bus *pci_find_next_bus(const struct pci_bus *from); 509struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
502 510
503struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, 511struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -505,49 +513,58 @@ struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
505struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device, 513struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device,
506 struct pci_dev *from); 514 struct pci_dev *from);
507 515
508struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 516struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
509 unsigned int ss_vendor, unsigned int ss_device, 517 unsigned int ss_vendor, unsigned int ss_device,
510 struct pci_dev *from); 518 struct pci_dev *from);
511struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); 519struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
512struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn); 520struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
513struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); 521struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
514int pci_dev_present(const struct pci_device_id *ids); 522int pci_dev_present(const struct pci_device_id *ids);
515const struct pci_device_id *pci_find_present(const struct pci_device_id *ids); 523const struct pci_device_id *pci_find_present(const struct pci_device_id *ids);
516 524
517int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); 525int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
518int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); 526 int where, u8 *val);
519int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); 527int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn,
520int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); 528 int where, u16 *val);
521int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); 529int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn,
522int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); 530 int where, u32 *val);
531int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn,
532 int where, u8 val);
533int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn,
534 int where, u16 val);
535int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
536 int where, u32 val);
523 537
524static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) 538static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
525{ 539{
526 return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); 540 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
527} 541}
528static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) 542static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
529{ 543{
530 return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); 544 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
531} 545}
532static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) 546static inline int pci_read_config_dword(struct pci_dev *dev, int where,
547 u32 *val)
533{ 548{
534 return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); 549 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
535} 550}
536static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) 551static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
537{ 552{
538 return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); 553 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
539} 554}
540static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) 555static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val)
541{ 556{
542 return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); 557 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
543} 558}
544static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) 559static inline int pci_write_config_dword(struct pci_dev *dev, int where,
560 u32 val)
545{ 561{
546 return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); 562 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
547} 563}
548 564
549int __must_check pci_enable_device(struct pci_dev *dev); 565int __must_check pci_enable_device(struct pci_dev *dev);
550int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); 566int __must_check pci_enable_device_io(struct pci_dev *dev);
567int __must_check pci_enable_device_mem(struct pci_dev *dev);
551int __must_check pci_reenable_device(struct pci_dev *); 568int __must_check pci_reenable_device(struct pci_dev *);
552int __must_check pcim_enable_device(struct pci_dev *pdev); 569int __must_check pcim_enable_device(struct pci_dev *pdev);
553void pcim_pin_device(struct pci_dev *pdev); 570void pcim_pin_device(struct pci_dev *pdev);
@@ -576,14 +593,11 @@ int pcie_set_readrq(struct pci_dev *dev, int rq);
576void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 593void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
577int __must_check pci_assign_resource(struct pci_dev *dev, int i); 594int __must_check pci_assign_resource(struct pci_dev *dev, int i);
578int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i); 595int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i);
579void pci_restore_bars(struct pci_dev *dev);
580int pci_select_bars(struct pci_dev *dev, unsigned long flags); 596int pci_select_bars(struct pci_dev *dev, unsigned long flags);
581 597
582/* ROM control related routines */ 598/* ROM control related routines */
583void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); 599void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
584void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
585void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); 600void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
586void pci_remove_rom(struct pci_dev *pdev);
587size_t pci_get_rom_size(void __iomem *rom, size_t size); 601size_t pci_get_rom_size(void __iomem *rom, size_t size);
588 602
589/* Power management related routines */ 603/* Power management related routines */
@@ -594,7 +608,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
594int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); 608int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
595 609
596/* Functions for PCI Hotplug drivers to use */ 610/* Functions for PCI Hotplug drivers to use */
597int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 611int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
598 612
599/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 613/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
600void pci_bus_assign_resources(struct pci_bus *bus); 614void pci_bus_assign_resources(struct pci_bus *bus);
@@ -631,16 +645,18 @@ static inline int __must_check pci_register_driver(struct pci_driver *driver)
631 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); 645 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
632} 646}
633 647
634void pci_unregister_driver(struct pci_driver *); 648void pci_unregister_driver(struct pci_driver *dev);
635void pci_remove_behind_bridge(struct pci_dev *); 649void pci_remove_behind_bridge(struct pci_dev *dev);
636struct pci_driver *pci_dev_driver(const struct pci_dev *); 650struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
637const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev); 651const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
638int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass); 652 struct pci_dev *dev);
653int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
654 int pass);
639 655
640void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 656void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
641 void *userdata); 657 void *userdata);
642int pci_cfg_space_size(struct pci_dev *dev); 658int pci_cfg_space_size(struct pci_dev *dev);
643unsigned char pci_bus_max_busnr(struct pci_bus* bus); 659unsigned char pci_bus_max_busnr(struct pci_bus *bus);
644 660
645/* kmem_cache style wrapper around pci_alloc_consistent() */ 661/* kmem_cache style wrapper around pci_alloc_consistent() */
646 662
@@ -669,19 +685,36 @@ struct msix_entry {
669 685
670 686
671#ifndef CONFIG_PCI_MSI 687#ifndef CONFIG_PCI_MSI
672static inline int pci_enable_msi(struct pci_dev *dev) {return -1;} 688static inline int pci_enable_msi(struct pci_dev *dev)
673static inline void pci_disable_msi(struct pci_dev *dev) {} 689{
674static inline int pci_enable_msix(struct pci_dev* dev, 690 return -1;
675 struct msix_entry *entries, int nvec) {return -1;} 691}
676static inline void pci_disable_msix(struct pci_dev *dev) {} 692
677static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {} 693static inline void pci_disable_msi(struct pci_dev *dev)
694{ }
695
696static inline int pci_enable_msix(struct pci_dev *dev,
697 struct msix_entry *entries, int nvec)
698{
699 return -1;
700}
701
702static inline void pci_disable_msix(struct pci_dev *dev)
703{ }
704
705static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev)
706{ }
707
708static inline void pci_restore_msi_state(struct pci_dev *dev)
709{ }
678#else 710#else
679extern int pci_enable_msi(struct pci_dev *dev); 711extern int pci_enable_msi(struct pci_dev *dev);
680extern void pci_disable_msi(struct pci_dev *dev); 712extern void pci_disable_msi(struct pci_dev *dev);
681extern int pci_enable_msix(struct pci_dev* dev, 713extern int pci_enable_msix(struct pci_dev *dev,
682 struct msix_entry *entries, int nvec); 714 struct msix_entry *entries, int nvec);
683extern void pci_disable_msix(struct pci_dev *dev); 715extern void pci_disable_msix(struct pci_dev *dev);
684extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 716extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
717extern void pci_restore_msi_state(struct pci_dev *dev);
685#endif 718#endif
686 719
687#ifdef CONFIG_HT_IRQ 720#ifdef CONFIG_HT_IRQ
@@ -702,7 +735,11 @@ extern void pci_unblock_user_cfg_access(struct pci_dev *dev);
702extern int pci_domains_supported; 735extern int pci_domains_supported;
703#else 736#else
704enum { pci_domains_supported = 0 }; 737enum { pci_domains_supported = 0 };
705static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } 738static inline int pci_domain_nr(struct pci_bus *bus)
739{
740 return 0;
741}
742
706static inline int pci_proc_domain(struct pci_bus *bus) 743static inline int pci_proc_domain(struct pci_bus *bus)
707{ 744{
708 return 0; 745 return 0;
@@ -716,67 +753,161 @@ static inline int pci_proc_domain(struct pci_bus *bus)
716 * these as simple inline functions to avoid hair in drivers. 753 * these as simple inline functions to avoid hair in drivers.
717 */ 754 */
718 755
719#define _PCI_NOP(o,s,t) \ 756#define _PCI_NOP(o, s, t) \
720 static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \ 757 static inline int pci_##o##_config_##s(struct pci_dev *dev, \
758 int where, t val) \
721 { return PCIBIOS_FUNC_NOT_SUPPORTED; } 759 { return PCIBIOS_FUNC_NOT_SUPPORTED; }
722#define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \ 760
723 _PCI_NOP(o,word,u16 x) \ 761#define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \
724 _PCI_NOP(o,dword,u32 x) 762 _PCI_NOP(o, word, u16 x) \
763 _PCI_NOP(o, dword, u32 x)
725_PCI_NOP_ALL(read, *) 764_PCI_NOP_ALL(read, *)
726_PCI_NOP_ALL(write,) 765_PCI_NOP_ALL(write,)
727 766
728static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) 767static inline struct pci_dev *pci_find_device(unsigned int vendor,
729{ return NULL; } 768 unsigned int device,
769 const struct pci_dev *from)
770{
771 return NULL;
772}
730 773
731static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) 774static inline struct pci_dev *pci_find_slot(unsigned int bus,
732{ return NULL; } 775 unsigned int devfn)
776{
777 return NULL;
778}
733 779
734static inline struct pci_dev *pci_get_device(unsigned int vendor, 780static inline struct pci_dev *pci_get_device(unsigned int vendor,
735 unsigned int device, struct pci_dev *from) 781 unsigned int device,
736{ return NULL; } 782 struct pci_dev *from)
783{
784 return NULL;
785}
737 786
738static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor, 787static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor,
739 unsigned int device, struct pci_dev *from) 788 unsigned int device,
740{ return NULL; } 789 struct pci_dev *from)
790{
791 return NULL;
792}
741 793
742static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 794static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
743unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) 795 unsigned int device,
744{ return NULL; } 796 unsigned int ss_vendor,
797 unsigned int ss_device,
798 struct pci_dev *from)
799{
800 return NULL;
801}
745 802
746static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) 803static inline struct pci_dev *pci_get_class(unsigned int class,
747{ return NULL; } 804 struct pci_dev *from)
805{
806 return NULL;
807}
748 808
749#define pci_dev_present(ids) (0) 809#define pci_dev_present(ids) (0)
750#define no_pci_devices() (1) 810#define no_pci_devices() (1)
751#define pci_find_present(ids) (NULL) 811#define pci_find_present(ids) (NULL)
752#define pci_dev_put(dev) do { } while (0) 812#define pci_dev_put(dev) do { } while (0)
753 813
754static inline void pci_set_master(struct pci_dev *dev) { } 814static inline void pci_set_master(struct pci_dev *dev)
755static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } 815{ }
756static inline void pci_disable_device(struct pci_dev *dev) { } 816
757static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } 817static inline int pci_enable_device(struct pci_dev *dev)
758static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} 818{
759static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;} 819 return -EIO;
760static inline int pci_register_driver(struct pci_driver *drv) { return 0;} 820}
761static inline void pci_unregister_driver(struct pci_driver *drv) { } 821
762static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } 822static inline void pci_disable_device(struct pci_dev *dev)
763static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } 823{ }
764static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } 824
825static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
826{
827 return -EIO;
828}
829
830static inline int pci_assign_resource(struct pci_dev *dev, int i)
831{
832 return -EBUSY;
833}
834
835static inline int __pci_register_driver(struct pci_driver *drv,
836 struct module *owner)
837{
838 return 0;
839}
840
841static inline int pci_register_driver(struct pci_driver *drv)
842{
843 return 0;
844}
845
846static inline void pci_unregister_driver(struct pci_driver *drv)
847{ }
848
849static inline int pci_find_capability(struct pci_dev *dev, int cap)
850{
851 return 0;
852}
853
854static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
855 int cap)
856{
857 return 0;
858}
859
860static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
861{
862 return 0;
863}
864
865static inline void pcie_wait_pending_transaction(struct pci_dev *dev)
866{ }
765 867
766/* Power management related routines */ 868/* Power management related routines */
767static inline int pci_save_state(struct pci_dev *dev) { return 0; } 869static inline int pci_save_state(struct pci_dev *dev)
768static inline int pci_restore_state(struct pci_dev *dev) { return 0; } 870{
769static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } 871 return 0;
770static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } 872}
771static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } 873
874static inline int pci_restore_state(struct pci_dev *dev)
875{
876 return 0;
877}
878
879static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
880{
881 return 0;
882}
883
884static inline pci_power_t pci_choose_state(struct pci_dev *dev,
885 pm_message_t state)
886{
887 return PCI_D0;
888}
889
890static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
891 int enable)
892{
893 return 0;
894}
895
896static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
897{
898 return -EIO;
899}
772 900
773static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; } 901static inline void pci_release_regions(struct pci_dev *dev)
774static inline void pci_release_regions(struct pci_dev *dev) { } 902{ }
775 903
776#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) 904#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
777 905
778static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } 906static inline void pci_block_user_cfg_access(struct pci_dev *dev)
779static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { } 907{ }
908
909static inline void pci_unblock_user_cfg_access(struct pci_dev *dev)
910{ }
780 911
781static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) 912static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
782{ return NULL; } 913{ return NULL; }
@@ -797,27 +928,27 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
797 928
798/* these helpers provide future and backwards compatibility 929/* these helpers provide future and backwards compatibility
799 * for accessing popular PCI BAR info */ 930 * for accessing popular PCI BAR info */
800#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) 931#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
801#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) 932#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
802#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) 933#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
803#define pci_resource_len(dev,bar) \ 934#define pci_resource_len(dev,bar) \
804 ((pci_resource_start((dev),(bar)) == 0 && \ 935 ((pci_resource_start((dev), (bar)) == 0 && \
805 pci_resource_end((dev),(bar)) == \ 936 pci_resource_end((dev), (bar)) == \
806 pci_resource_start((dev),(bar))) ? 0 : \ 937 pci_resource_start((dev), (bar))) ? 0 : \
807 \ 938 \
808 (pci_resource_end((dev),(bar)) - \ 939 (pci_resource_end((dev), (bar)) - \
809 pci_resource_start((dev),(bar)) + 1)) 940 pci_resource_start((dev), (bar)) + 1))
810 941
811/* Similar to the helpers above, these manipulate per-pci_dev 942/* Similar to the helpers above, these manipulate per-pci_dev
812 * driver-specific data. They are really just a wrapper around 943 * driver-specific data. They are really just a wrapper around
813 * the generic device structure functions of these calls. 944 * the generic device structure functions of these calls.
814 */ 945 */
815static inline void *pci_get_drvdata (struct pci_dev *pdev) 946static inline void *pci_get_drvdata(struct pci_dev *pdev)
816{ 947{
817 return dev_get_drvdata(&pdev->dev); 948 return dev_get_drvdata(&pdev->dev);
818} 949}
819 950
820static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) 951static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
821{ 952{
822 dev_set_drvdata(&pdev->dev, data); 953 dev_set_drvdata(&pdev->dev, data);
823} 954}
@@ -836,7 +967,7 @@ static inline char *pci_name(struct pci_dev *pdev)
836 */ 967 */
837#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER 968#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER
838static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, 969static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
839 const struct resource *rsrc, resource_size_t *start, 970 const struct resource *rsrc, resource_size_t *start,
840 resource_size_t *end) 971 resource_size_t *end)
841{ 972{
842 *start = rsrc->start; 973 *start = rsrc->start;
@@ -888,9 +1019,9 @@ enum pci_fixup_pass {
888 1019
889void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); 1020void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
890 1021
891void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); 1022void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
892void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); 1023void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
893void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); 1024void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
894int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); 1025int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
895void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); 1026void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
896 1027
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index c1914a8b94a9..c0c1223c9194 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -395,9 +395,17 @@
395#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ 395#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
396#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ 396#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
397#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ 397#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
398#define PCI_EXP_LNKCAP_ASPMS 0xc00 /* ASPM Support */
399#define PCI_EXP_LNKCAP_L0SEL 0x7000 /* L0s Exit Latency */
400#define PCI_EXP_LNKCAP_L1EL 0x38000 /* L1 Exit Latency */
401#define PCI_EXP_LNKCAP_CLKPM 0x40000 /* L1 Clock Power Management */
398#define PCI_EXP_LNKCTL 16 /* Link Control */ 402#define PCI_EXP_LNKCTL 16 /* Link Control */
403#define PCI_EXP_LNKCTL_RL 0x20 /* Retrain Link */
404#define PCI_EXP_LNKCTL_CCC 0x40 /* Common Clock COnfiguration */
399#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */ 405#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
400#define PCI_EXP_LNKSTA 18 /* Link Status */ 406#define PCI_EXP_LNKSTA 18 /* Link Status */
407#define PCI_EXP_LNKSTA_LT 0x800 /* Link Training */
408#define PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
401#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ 409#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
402#define PCI_EXP_SLTCTL 24 /* Slot Control */ 410#define PCI_EXP_SLTCTL 24 /* Slot Control */
403#define PCI_EXP_SLTSTA 26 /* Slot Status */ 411#define PCI_EXP_SLTSTA 26 /* Slot Status */
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index bd7a6b0a87af..03547d6abee5 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -169,8 +169,8 @@ extern int cache_check(struct cache_detail *detail,
169extern void cache_flush(void); 169extern void cache_flush(void);
170extern void cache_purge(struct cache_detail *detail); 170extern void cache_purge(struct cache_detail *detail);
171#define NEVER (0x7FFFFFFF) 171#define NEVER (0x7FFFFFFF)
172extern void cache_register(struct cache_detail *cd); 172extern int cache_register(struct cache_detail *cd);
173extern int cache_unregister(struct cache_detail *cd); 173extern void cache_unregister(struct cache_detail *cd);
174 174
175extern void qword_add(char **bpp, int *lp, char *str); 175extern void qword_add(char **bpp, int *lp, char *str);
176extern void qword_addhex(char **bpp, int *lp, char *buf, int blen); 176extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index 3912cf16361e..10709cbe96fd 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -20,7 +20,7 @@
20#define RPCDBG_BIND 0x0020 20#define RPCDBG_BIND 0x0020
21#define RPCDBG_SCHED 0x0040 21#define RPCDBG_SCHED 0x0040
22#define RPCDBG_TRANS 0x0080 22#define RPCDBG_TRANS 0x0080
23#define RPCDBG_SVCSOCK 0x0100 23#define RPCDBG_SVCXPRT 0x0100
24#define RPCDBG_SVCDSP 0x0200 24#define RPCDBG_SVCDSP 0x0200
25#define RPCDBG_MISC 0x0400 25#define RPCDBG_MISC 0x0400
26#define RPCDBG_CACHE 0x0800 26#define RPCDBG_CACHE 0x0800
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 8531a70da73d..64c771056187 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -204,7 +204,7 @@ union svc_addr_u {
204struct svc_rqst { 204struct svc_rqst {
205 struct list_head rq_list; /* idle list */ 205 struct list_head rq_list; /* idle list */
206 struct list_head rq_all; /* all threads list */ 206 struct list_head rq_all; /* all threads list */
207 struct svc_sock * rq_sock; /* socket */ 207 struct svc_xprt * rq_xprt; /* transport ptr */
208 struct sockaddr_storage rq_addr; /* peer address */ 208 struct sockaddr_storage rq_addr; /* peer address */
209 size_t rq_addrlen; 209 size_t rq_addrlen;
210 210
@@ -214,9 +214,10 @@ struct svc_rqst {
214 struct auth_ops * rq_authop; /* authentication flavour */ 214 struct auth_ops * rq_authop; /* authentication flavour */
215 u32 rq_flavor; /* pseudoflavor */ 215 u32 rq_flavor; /* pseudoflavor */
216 struct svc_cred rq_cred; /* auth info */ 216 struct svc_cred rq_cred; /* auth info */
217 struct sk_buff * rq_skbuff; /* fast recv inet buffer */ 217 void * rq_xprt_ctxt; /* transport specific context ptr */
218 struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */ 218 struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */
219 219
220 size_t rq_xprt_hlen; /* xprt header len */
220 struct xdr_buf rq_arg; 221 struct xdr_buf rq_arg;
221 struct xdr_buf rq_res; 222 struct xdr_buf rq_res;
222 struct page * rq_pages[RPCSVC_MAXPAGES]; 223 struct page * rq_pages[RPCSVC_MAXPAGES];
@@ -317,11 +318,12 @@ static inline void svc_free_res_pages(struct svc_rqst *rqstp)
317 318
318struct svc_deferred_req { 319struct svc_deferred_req {
319 u32 prot; /* protocol (UDP or TCP) */ 320 u32 prot; /* protocol (UDP or TCP) */
320 struct svc_sock *svsk; 321 struct svc_xprt *xprt;
321 struct sockaddr_storage addr; /* where reply must go */ 322 struct sockaddr_storage addr; /* where reply must go */
322 size_t addrlen; 323 size_t addrlen;
323 union svc_addr_u daddr; /* where reply must come from */ 324 union svc_addr_u daddr; /* where reply must come from */
324 struct cache_deferred_req handle; 325 struct cache_deferred_req handle;
326 size_t xprt_hlen;
325 int argslen; 327 int argslen;
326 __be32 args[0]; 328 __be32 args[0];
327}; 329};
@@ -382,6 +384,8 @@ struct svc_procedure {
382 */ 384 */
383struct svc_serv * svc_create(struct svc_program *, unsigned int, 385struct svc_serv * svc_create(struct svc_program *, unsigned int,
384 void (*shutdown)(struct svc_serv*)); 386 void (*shutdown)(struct svc_serv*));
387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
388 struct svc_pool *pool);
385int svc_create_thread(svc_thread_fn, struct svc_serv *); 389int svc_create_thread(svc_thread_fn, struct svc_serv *);
386void svc_exit_thread(struct svc_rqst *); 390void svc_exit_thread(struct svc_rqst *);
387struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 391struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
new file mode 100644
index 000000000000..c11bbcc081f9
--- /dev/null
+++ b/include/linux/sunrpc/svc_rdma.h
@@ -0,0 +1,262 @@
1/*
2 * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the BSD-type
8 * license below:
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
21 *
22 * Neither the name of the Network Appliance, Inc. nor the names of
23 * its contributors may be used to endorse or promote products
24 * derived from this software without specific prior written
25 * permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * Author: Tom Tucker <tom@opengridcomputing.com>
40 */
41
42#ifndef SVC_RDMA_H
43#define SVC_RDMA_H
44#include <linux/sunrpc/xdr.h>
45#include <linux/sunrpc/svcsock.h>
46#include <linux/sunrpc/rpc_rdma.h>
47#include <rdma/ib_verbs.h>
48#include <rdma/rdma_cm.h>
49#define SVCRDMA_DEBUG
50
51/* RPC/RDMA parameters and stats */
52extern unsigned int svcrdma_ord;
53extern unsigned int svcrdma_max_requests;
54extern unsigned int svcrdma_max_req_size;
55
56extern atomic_t rdma_stat_recv;
57extern atomic_t rdma_stat_read;
58extern atomic_t rdma_stat_write;
59extern atomic_t rdma_stat_sq_starve;
60extern atomic_t rdma_stat_rq_starve;
61extern atomic_t rdma_stat_rq_poll;
62extern atomic_t rdma_stat_rq_prod;
63extern atomic_t rdma_stat_sq_poll;
64extern atomic_t rdma_stat_sq_prod;
65
66#define RPCRDMA_VERSION 1
67
68/*
69 * Contexts are built when an RDMA request is created and are a
70 * record of the resources that can be recovered when the request
71 * completes.
72 */
73struct svc_rdma_op_ctxt {
74 struct svc_rdma_op_ctxt *next;
75 struct xdr_buf arg;
76 struct list_head dto_q;
77 enum ib_wr_opcode wr_op;
78 enum ib_wc_status wc_status;
79 u32 byte_len;
80 struct svcxprt_rdma *xprt;
81 unsigned long flags;
82 enum dma_data_direction direction;
83 int count;
84 struct ib_sge sge[RPCSVC_MAXPAGES];
85 struct page *pages[RPCSVC_MAXPAGES];
86};
87
88#define RDMACTXT_F_READ_DONE 1
89#define RDMACTXT_F_LAST_CTXT 2
90
91struct svcxprt_rdma {
92 struct svc_xprt sc_xprt; /* SVC transport structure */
93 struct rdma_cm_id *sc_cm_id; /* RDMA connection id */
94 struct list_head sc_accept_q; /* Conn. waiting accept */
95 int sc_ord; /* RDMA read limit */
96 wait_queue_head_t sc_read_wait;
97 int sc_max_sge;
98
99 int sc_sq_depth; /* Depth of SQ */
100 atomic_t sc_sq_count; /* Number of SQ WR on queue */
101
102 int sc_max_requests; /* Depth of RQ */
103 int sc_max_req_size; /* Size of each RQ WR buf */
104
105 struct ib_pd *sc_pd;
106
107 struct svc_rdma_op_ctxt *sc_ctxt_head;
108 int sc_ctxt_cnt;
109 int sc_ctxt_bump;
110 int sc_ctxt_max;
111 spinlock_t sc_ctxt_lock;
112 struct list_head sc_rq_dto_q;
113 spinlock_t sc_rq_dto_lock;
114 struct ib_qp *sc_qp;
115 struct ib_cq *sc_rq_cq;
116 struct ib_cq *sc_sq_cq;
117 struct ib_mr *sc_phys_mr; /* MR for server memory */
118
119 spinlock_t sc_lock; /* transport lock */
120
121 wait_queue_head_t sc_send_wait; /* SQ exhaustion waitlist */
122 unsigned long sc_flags;
123 struct list_head sc_dto_q; /* DTO tasklet I/O pending Q */
124 struct list_head sc_read_complete_q;
125 spinlock_t sc_read_complete_lock;
126};
127/* sc_flags */
128#define RDMAXPRT_RQ_PENDING 1
129#define RDMAXPRT_SQ_PENDING 2
130#define RDMAXPRT_CONN_PENDING 3
131
132#define RPCRDMA_LISTEN_BACKLOG 10
133/* The default ORD value is based on two outstanding full-size writes with a
134 * page size of 4k, or 32k * 2 ops / 4k = 16 outstanding RDMA_READ. */
135#define RPCRDMA_ORD (64/4)
136#define RPCRDMA_SQ_DEPTH_MULT 8
137#define RPCRDMA_MAX_THREADS 16
138#define RPCRDMA_MAX_REQUESTS 16
139#define RPCRDMA_MAX_REQ_SIZE 4096
140
141/* svc_rdma_marshal.c */
142extern void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *,
143 int *, int *);
144extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg **, struct svc_rqst *);
145extern int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *);
146extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *,
147 struct rpcrdma_msg *,
148 enum rpcrdma_errcode, u32 *);
149extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int);
150extern void svc_rdma_xdr_encode_reply_array(struct rpcrdma_write_array *, int);
151extern void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *, int,
152 u32, u64, u32);
153extern void svc_rdma_xdr_encode_reply_header(struct svcxprt_rdma *,
154 struct rpcrdma_msg *,
155 struct rpcrdma_msg *,
156 enum rpcrdma_proc);
157extern int svc_rdma_xdr_get_reply_hdr_len(struct rpcrdma_msg *);
158
159/* svc_rdma_recvfrom.c */
160extern int svc_rdma_recvfrom(struct svc_rqst *);
161
162/* svc_rdma_sendto.c */
163extern int svc_rdma_sendto(struct svc_rqst *);
164
165/* svc_rdma_transport.c */
166extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *);
167extern int svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *,
168 enum rpcrdma_errcode);
169struct page *svc_rdma_get_page(void);
170extern int svc_rdma_post_recv(struct svcxprt_rdma *);
171extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
172extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
173extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
174extern void svc_sq_reap(struct svcxprt_rdma *);
175extern void svc_rq_reap(struct svcxprt_rdma *);
176extern struct svc_xprt_class svc_rdma_class;
177extern void svc_rdma_prep_reply_hdr(struct svc_rqst *);
178
179/* svc_rdma.c */
180extern int svc_rdma_init(void);
181extern void svc_rdma_cleanup(void);
182
183/*
184 * Returns the address of the first read chunk or <nul> if no read chunk is
185 * present
186 */
187static inline struct rpcrdma_read_chunk *
188svc_rdma_get_read_chunk(struct rpcrdma_msg *rmsgp)
189{
190 struct rpcrdma_read_chunk *ch =
191 (struct rpcrdma_read_chunk *)&rmsgp->rm_body.rm_chunks[0];
192
193 if (ch->rc_discrim == 0)
194 return NULL;
195
196 return ch;
197}
198
199/*
200 * Returns the address of the first read write array element or <nul> if no
201 * write array list is present
202 */
203static inline struct rpcrdma_write_array *
204svc_rdma_get_write_array(struct rpcrdma_msg *rmsgp)
205{
206 if (rmsgp->rm_body.rm_chunks[0] != 0
207 || rmsgp->rm_body.rm_chunks[1] == 0)
208 return NULL;
209
210 return (struct rpcrdma_write_array *)&rmsgp->rm_body.rm_chunks[1];
211}
212
213/*
214 * Returns the address of the first reply array element or <nul> if no
215 * reply array is present
216 */
217static inline struct rpcrdma_write_array *
218svc_rdma_get_reply_array(struct rpcrdma_msg *rmsgp)
219{
220 struct rpcrdma_read_chunk *rch;
221 struct rpcrdma_write_array *wr_ary;
222 struct rpcrdma_write_array *rp_ary;
223
224 /* XXX: Need to fix when reply list may occur with read-list and/or
225 * write list */
226 if (rmsgp->rm_body.rm_chunks[0] != 0 ||
227 rmsgp->rm_body.rm_chunks[1] != 0)
228 return NULL;
229
230 rch = svc_rdma_get_read_chunk(rmsgp);
231 if (rch) {
232 while (rch->rc_discrim)
233 rch++;
234
235 /* The reply list follows an empty write array located
236 * at 'rc_position' here. The reply array is at rc_target.
237 */
238 rp_ary = (struct rpcrdma_write_array *)&rch->rc_target;
239
240 goto found_it;
241 }
242
243 wr_ary = svc_rdma_get_write_array(rmsgp);
244 if (wr_ary) {
245 rp_ary = (struct rpcrdma_write_array *)
246 &wr_ary->
247 wc_array[wr_ary->wc_nchunks].wc_target.rs_length;
248
249 goto found_it;
250 }
251
252 /* No read list, no write list */
253 rp_ary = (struct rpcrdma_write_array *)
254 &rmsgp->rm_body.rm_chunks[2];
255
256 found_it:
257 if (rp_ary->wc_discrim == 0)
258 return NULL;
259
260 return rp_ary;
261}
262#endif
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
new file mode 100644
index 000000000000..6fd7b016517f
--- /dev/null
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -0,0 +1,159 @@
1/*
2 * linux/include/linux/sunrpc/svc_xprt.h
3 *
4 * RPC server transport I/O
5 */
6
7#ifndef SUNRPC_SVC_XPRT_H
8#define SUNRPC_SVC_XPRT_H
9
10#include <linux/sunrpc/svc.h>
11#include <linux/module.h>
12
13struct svc_xprt_ops {
14 struct svc_xprt *(*xpo_create)(struct svc_serv *,
15 struct sockaddr *, int,
16 int);
17 struct svc_xprt *(*xpo_accept)(struct svc_xprt *);
18 int (*xpo_has_wspace)(struct svc_xprt *);
19 int (*xpo_recvfrom)(struct svc_rqst *);
20 void (*xpo_prep_reply_hdr)(struct svc_rqst *);
21 int (*xpo_sendto)(struct svc_rqst *);
22 void (*xpo_release_rqst)(struct svc_rqst *);
23 void (*xpo_detach)(struct svc_xprt *);
24 void (*xpo_free)(struct svc_xprt *);
25};
26
27struct svc_xprt_class {
28 const char *xcl_name;
29 struct module *xcl_owner;
30 struct svc_xprt_ops *xcl_ops;
31 struct list_head xcl_list;
32 u32 xcl_max_payload;
33};
34
35struct svc_xprt {
36 struct svc_xprt_class *xpt_class;
37 struct svc_xprt_ops *xpt_ops;
38 struct kref xpt_ref;
39 struct list_head xpt_list;
40 struct list_head xpt_ready;
41 unsigned long xpt_flags;
42#define XPT_BUSY 0 /* enqueued/receiving */
43#define XPT_CONN 1 /* conn pending */
44#define XPT_CLOSE 2 /* dead or dying */
45#define XPT_DATA 3 /* data pending */
46#define XPT_TEMP 4 /* connected transport */
47#define XPT_DEAD 6 /* transport closed */
48#define XPT_CHNGBUF 7 /* need to change snd/rcv buf sizes */
49#define XPT_DEFERRED 8 /* deferred request pending */
50#define XPT_OLD 9 /* used for xprt aging mark+sweep */
51#define XPT_DETACHED 10 /* detached from tempsocks list */
52#define XPT_LISTENER 11 /* listening endpoint */
53#define XPT_CACHE_AUTH 12 /* cache auth info */
54
55 struct svc_pool *xpt_pool; /* current pool iff queued */
56 struct svc_serv *xpt_server; /* service for transport */
57 atomic_t xpt_reserved; /* space on outq that is rsvd */
58 struct mutex xpt_mutex; /* to serialize sending data */
59 spinlock_t xpt_lock; /* protects sk_deferred
60 * and xpt_auth_cache */
61 void *xpt_auth_cache;/* auth cache */
62 struct list_head xpt_deferred; /* deferred requests that need
63 * to be revisted */
64 struct sockaddr_storage xpt_local; /* local address */
65 size_t xpt_locallen; /* length of address */
66 struct sockaddr_storage xpt_remote; /* remote peer's address */
67 size_t xpt_remotelen; /* length of address */
68};
69
70int svc_reg_xprt_class(struct svc_xprt_class *);
71void svc_unreg_xprt_class(struct svc_xprt_class *);
72void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
73 struct svc_serv *);
74int svc_create_xprt(struct svc_serv *, char *, unsigned short, int);
75void svc_xprt_enqueue(struct svc_xprt *xprt);
76void svc_xprt_received(struct svc_xprt *);
77void svc_xprt_put(struct svc_xprt *xprt);
78void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt);
79void svc_close_xprt(struct svc_xprt *xprt);
80void svc_delete_xprt(struct svc_xprt *xprt);
81int svc_port_is_privileged(struct sockaddr *sin);
82int svc_print_xprts(char *buf, int maxlen);
83struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int);
84int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen);
85
86static inline void svc_xprt_get(struct svc_xprt *xprt)
87{
88 kref_get(&xprt->xpt_ref);
89}
90static inline void svc_xprt_set_local(struct svc_xprt *xprt,
91 struct sockaddr *sa, int salen)
92{
93 memcpy(&xprt->xpt_local, sa, salen);
94 xprt->xpt_locallen = salen;
95}
96static inline void svc_xprt_set_remote(struct svc_xprt *xprt,
97 struct sockaddr *sa, int salen)
98{
99 memcpy(&xprt->xpt_remote, sa, salen);
100 xprt->xpt_remotelen = salen;
101}
102static inline unsigned short svc_addr_port(struct sockaddr *sa)
103{
104 unsigned short ret = 0;
105 switch (sa->sa_family) {
106 case AF_INET:
107 ret = ntohs(((struct sockaddr_in *)sa)->sin_port);
108 break;
109 case AF_INET6:
110 ret = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
111 break;
112 }
113 return ret;
114}
115
116static inline size_t svc_addr_len(struct sockaddr *sa)
117{
118 switch (sa->sa_family) {
119 case AF_INET:
120 return sizeof(struct sockaddr_in);
121 case AF_INET6:
122 return sizeof(struct sockaddr_in6);
123 }
124 return -EAFNOSUPPORT;
125}
126
127static inline unsigned short svc_xprt_local_port(struct svc_xprt *xprt)
128{
129 return svc_addr_port((struct sockaddr *)&xprt->xpt_local);
130}
131
132static inline unsigned short svc_xprt_remote_port(struct svc_xprt *xprt)
133{
134 return svc_addr_port((struct sockaddr *)&xprt->xpt_remote);
135}
136
137static inline char *__svc_print_addr(struct sockaddr *addr,
138 char *buf, size_t len)
139{
140 switch (addr->sa_family) {
141 case AF_INET:
142 snprintf(buf, len, "%u.%u.%u.%u, port=%u",
143 NIPQUAD(((struct sockaddr_in *) addr)->sin_addr),
144 ntohs(((struct sockaddr_in *) addr)->sin_port));
145 break;
146
147 case AF_INET6:
148 snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u",
149 NIP6(((struct sockaddr_in6 *) addr)->sin6_addr),
150 ntohs(((struct sockaddr_in6 *) addr)->sin6_port));
151 break;
152
153 default:
154 snprintf(buf, len, "unknown address type: %d", addr->sa_family);
155 break;
156 }
157 return buf;
158}
159#endif /* SUNRPC_SVC_XPRT_H */
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index a53e0fa855d2..206f092ad4c7 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -10,42 +10,16 @@
10#define SUNRPC_SVCSOCK_H 10#define SUNRPC_SVCSOCK_H
11 11
12#include <linux/sunrpc/svc.h> 12#include <linux/sunrpc/svc.h>
13#include <linux/sunrpc/svc_xprt.h>
13 14
14/* 15/*
15 * RPC server socket. 16 * RPC server socket.
16 */ 17 */
17struct svc_sock { 18struct svc_sock {
18 struct list_head sk_ready; /* list of ready sockets */ 19 struct svc_xprt sk_xprt;
19 struct list_head sk_list; /* list of all sockets */
20 struct socket * sk_sock; /* berkeley socket layer */ 20 struct socket * sk_sock; /* berkeley socket layer */
21 struct sock * sk_sk; /* INET layer */ 21 struct sock * sk_sk; /* INET layer */
22 22
23 struct svc_pool * sk_pool; /* current pool iff queued */
24 struct svc_serv * sk_server; /* service for this socket */
25 atomic_t sk_inuse; /* use count */
26 unsigned long sk_flags;
27#define SK_BUSY 0 /* enqueued/receiving */
28#define SK_CONN 1 /* conn pending */
29#define SK_CLOSE 2 /* dead or dying */
30#define SK_DATA 3 /* data pending */
31#define SK_TEMP 4 /* temp (TCP) socket */
32#define SK_DEAD 6 /* socket closed */
33#define SK_CHNGBUF 7 /* need to change snd/rcv buffer sizes */
34#define SK_DEFERRED 8 /* request on sk_deferred */
35#define SK_OLD 9 /* used for temp socket aging mark+sweep */
36#define SK_DETACHED 10 /* detached from tempsocks list */
37
38 atomic_t sk_reserved; /* space on outq that is reserved */
39
40 spinlock_t sk_lock; /* protects sk_deferred and
41 * sk_info_authunix */
42 struct list_head sk_deferred; /* deferred requests that need to
43 * be revisted */
44 struct mutex sk_mutex; /* to serialize sending data */
45
46 int (*sk_recvfrom)(struct svc_rqst *rqstp);
47 int (*sk_sendto)(struct svc_rqst *rqstp);
48
49 /* We keep the old state_change and data_ready CB's here */ 23 /* We keep the old state_change and data_ready CB's here */
50 void (*sk_ostate)(struct sock *); 24 void (*sk_ostate)(struct sock *);
51 void (*sk_odata)(struct sock *, int bytes); 25 void (*sk_odata)(struct sock *, int bytes);
@@ -54,21 +28,12 @@ struct svc_sock {
54 /* private TCP part */ 28 /* private TCP part */
55 int sk_reclen; /* length of record */ 29 int sk_reclen; /* length of record */
56 int sk_tcplen; /* current read length */ 30 int sk_tcplen; /* current read length */
57 time_t sk_lastrecv; /* time of last received request */
58
59 /* cache of various info for TCP sockets */
60 void *sk_info_authunix;
61
62 struct sockaddr_storage sk_local; /* local address */
63 struct sockaddr_storage sk_remote; /* remote peer's address */
64 int sk_remotelen; /* length of address */
65}; 31};
66 32
67/* 33/*
68 * Function prototypes. 34 * Function prototypes.
69 */ 35 */
70int svc_makesock(struct svc_serv *, int, unsigned short, int flags); 36void svc_close_all(struct list_head *);
71void svc_force_close_socket(struct svc_sock *);
72int svc_recv(struct svc_rqst *, long); 37int svc_recv(struct svc_rqst *, long);
73int svc_send(struct svc_rqst *); 38int svc_send(struct svc_rqst *);
74void svc_drop(struct svc_rqst *); 39void svc_drop(struct svc_rqst *);
@@ -78,6 +43,8 @@ int svc_addsock(struct svc_serv *serv,
78 int fd, 43 int fd,
79 char *name_return, 44 char *name_return,
80 int *proto); 45 int *proto);
46void svc_init_xprt_sock(void);
47void svc_cleanup_xprt_sock(void);
81 48
82/* 49/*
83 * svc_makesock socket characteristics 50 * svc_makesock socket characteristics
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 0751c9464d0f..e4057d729f03 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -112,7 +112,8 @@ struct xdr_buf {
112__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int len); 112__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int len);
113__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int len); 113__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int len);
114__be32 *xdr_encode_string(__be32 *p, const char *s); 114__be32 *xdr_encode_string(__be32 *p, const char *s);
115__be32 *xdr_decode_string_inplace(__be32 *p, char **sp, int *lenp, int maxlen); 115__be32 *xdr_decode_string_inplace(__be32 *p, char **sp, unsigned int *lenp,
116 unsigned int maxlen);
116__be32 *xdr_encode_netobj(__be32 *p, const struct xdr_netobj *); 117__be32 *xdr_encode_netobj(__be32 *p, const struct xdr_netobj *);
117__be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *); 118__be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *);
118 119
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 40280df2a3db..646ce2d068d4 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -38,18 +38,16 @@ typedef int __bitwise suspend_state_t;
38 * There is the %suspend_valid_only_mem function available that can be 38 * There is the %suspend_valid_only_mem function available that can be
39 * assigned to this if the platform only supports mem sleep. 39 * assigned to this if the platform only supports mem sleep.
40 * 40 *
41 * @set_target: Tell the platform which system sleep state is going to be 41 * @begin: Initialise a transition to given system sleep state.
42 * entered. 42 * @begin() is executed right prior to suspending devices. The information
43 * @set_target() is executed right prior to suspending devices. The 43 * conveyed to the platform code by @begin() should be disregarded by it as
44 * information conveyed to the platform code by @set_target() should be 44 * soon as @end() is executed. If @begin() fails (ie. returns nonzero),
45 * disregarded by the platform as soon as @finish() is executed and if
46 * @prepare() fails. If @set_target() fails (ie. returns nonzero),
47 * @prepare(), @enter() and @finish() will not be called by the PM core. 45 * @prepare(), @enter() and @finish() will not be called by the PM core.
48 * This callback is optional. However, if it is implemented, the argument 46 * This callback is optional. However, if it is implemented, the argument
49 * passed to @enter() is meaningless and should be ignored. 47 * passed to @enter() is redundant and should be ignored.
50 * 48 *
51 * @prepare: Prepare the platform for entering the system sleep state indicated 49 * @prepare: Prepare the platform for entering the system sleep state indicated
52 * by @set_target(). 50 * by @begin().
53 * @prepare() is called right after devices have been suspended (ie. the 51 * @prepare() is called right after devices have been suspended (ie. the
54 * appropriate .suspend() method has been executed for each device) and 52 * appropriate .suspend() method has been executed for each device) and
55 * before the nonboot CPUs are disabled (it is executed with IRQs enabled). 53 * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
@@ -57,8 +55,8 @@ typedef int __bitwise suspend_state_t;
57 * error code otherwise, in which case the system cannot enter the desired 55 * error code otherwise, in which case the system cannot enter the desired
58 * sleep state (@enter() and @finish() will not be called in that case). 56 * sleep state (@enter() and @finish() will not be called in that case).
59 * 57 *
60 * @enter: Enter the system sleep state indicated by @set_target() or 58 * @enter: Enter the system sleep state indicated by @begin() or represented by
61 * represented by the argument if @set_target() is not implemented. 59 * the argument if @begin() is not implemented.
62 * This callback is mandatory. It returns 0 on success or a negative 60 * This callback is mandatory. It returns 0 on success or a negative
63 * error code otherwise, in which case the system cannot enter the desired 61 * error code otherwise, in which case the system cannot enter the desired
64 * sleep state. 62 * sleep state.
@@ -69,13 +67,22 @@ typedef int __bitwise suspend_state_t;
69 * This callback is optional, but should be implemented by the platforms 67 * This callback is optional, but should be implemented by the platforms
70 * that implement @prepare(). If implemented, it is always called after 68 * that implement @prepare(). If implemented, it is always called after
71 * @enter() (even if @enter() fails). 69 * @enter() (even if @enter() fails).
70 *
71 * @end: Called by the PM core right after resuming devices, to indicate to
72 * the platform that the system has returned to the working state or
73 * the transition to the sleep state has been aborted.
74 * This callback is optional, but should be implemented by the platforms
75 * that implement @begin(), but platforms implementing @begin() should
76 * also provide a @end() which cleans up transitions aborted before
77 * @enter().
72 */ 78 */
73struct platform_suspend_ops { 79struct platform_suspend_ops {
74 int (*valid)(suspend_state_t state); 80 int (*valid)(suspend_state_t state);
75 int (*set_target)(suspend_state_t state); 81 int (*begin)(suspend_state_t state);
76 int (*prepare)(void); 82 int (*prepare)(void);
77 int (*enter)(suspend_state_t state); 83 int (*enter)(suspend_state_t state);
78 void (*finish)(void); 84 void (*finish)(void);
85 void (*end)(void);
79}; 86};
80 87
81#ifdef CONFIG_SUSPEND 88#ifdef CONFIG_SUSPEND
@@ -129,14 +136,17 @@ extern void mark_free_pages(struct zone *zone);
129/** 136/**
130 * struct platform_hibernation_ops - hibernation platform support 137 * struct platform_hibernation_ops - hibernation platform support
131 * 138 *
132 * The methods in this structure allow a platform to override the default 139 * The methods in this structure allow a platform to carry out special
133 * mechanism of shutting down the machine during a hibernation transition. 140 * operations required by it during a hibernation transition.
134 * 141 *
135 * All three methods must be assigned. 142 * All the methods below must be implemented.
136 * 143 *
137 * @start: Tell the platform driver that we're starting hibernation. 144 * @begin: Tell the platform driver that we're starting hibernation.
138 * Called right after shrinking memory and before freezing devices. 145 * Called right after shrinking memory and before freezing devices.
139 * 146 *
147 * @end: Called by the PM core right after resuming devices, to indicate to
148 * the platform that the system has returned to the working state.
149 *
140 * @pre_snapshot: Prepare the platform for creating the hibernation image. 150 * @pre_snapshot: Prepare the platform for creating the hibernation image.
141 * Called right after devices have been frozen and before the nonboot 151 * Called right after devices have been frozen and before the nonboot
142 * CPUs are disabled (runs with IRQs on). 152 * CPUs are disabled (runs with IRQs on).
@@ -171,7 +181,8 @@ extern void mark_free_pages(struct zone *zone);
171 * thawing devices (runs with IRQs on). 181 * thawing devices (runs with IRQs on).
172 */ 182 */
173struct platform_hibernation_ops { 183struct platform_hibernation_ops {
174 int (*start)(void); 184 int (*begin)(void);
185 void (*end)(void);
175 int (*pre_snapshot)(void); 186 int (*pre_snapshot)(void);
176 void (*finish)(void); 187 void (*finish)(void);
177 int (*prepare)(void); 188 int (*prepare)(void);
@@ -213,17 +224,8 @@ void save_processor_state(void);
213void restore_processor_state(void); 224void restore_processor_state(void);
214 225
215/* kernel/power/main.c */ 226/* kernel/power/main.c */
216extern struct blocking_notifier_head pm_chain_head; 227extern int register_pm_notifier(struct notifier_block *nb);
217 228extern int unregister_pm_notifier(struct notifier_block *nb);
218static inline int register_pm_notifier(struct notifier_block *nb)
219{
220 return blocking_notifier_chain_register(&pm_chain_head, nb);
221}
222
223static inline int unregister_pm_notifier(struct notifier_block *nb)
224{
225 return blocking_notifier_chain_unregister(&pm_chain_head, nb);
226}
227 229
228#define pm_notifier(fn, pri) { \ 230#define pm_notifier(fn, pri) { \
229 static struct notifier_block fn##_nb = \ 231 static struct notifier_block fn##_nb = \
diff --git a/include/linux/suspend_ioctls.h b/include/linux/suspend_ioctls.h
new file mode 100644
index 000000000000..2c6faec96bde
--- /dev/null
+++ b/include/linux/suspend_ioctls.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_SUSPEND_IOCTLS_H
2#define _LINUX_SUSPEND_IOCTLS_H
3
4/*
5 * This structure is used to pass the values needed for the identification
6 * of the resume swap area from a user space to the kernel via the
7 * SNAPSHOT_SET_SWAP_AREA ioctl
8 */
9struct resume_swap_area {
10 loff_t offset;
11 u_int32_t dev;
12} __attribute__((packed));
13
14#define SNAPSHOT_IOC_MAGIC '3'
15#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
16#define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2)
17#define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4)
18#define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5)
19#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
20#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
21#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
22 struct resume_swap_area)
23#define SNAPSHOT_GET_IMAGE_SIZE _IOR(SNAPSHOT_IOC_MAGIC, 14, loff_t)
24#define SNAPSHOT_PLATFORM_SUPPORT _IO(SNAPSHOT_IOC_MAGIC, 15)
25#define SNAPSHOT_POWER_OFF _IO(SNAPSHOT_IOC_MAGIC, 16)
26#define SNAPSHOT_CREATE_IMAGE _IOW(SNAPSHOT_IOC_MAGIC, 17, int)
27#define SNAPSHOT_PREF_IMAGE_SIZE _IO(SNAPSHOT_IOC_MAGIC, 18)
28#define SNAPSHOT_AVAIL_SWAP_SIZE _IOR(SNAPSHOT_IOC_MAGIC, 19, loff_t)
29#define SNAPSHOT_ALLOC_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 20, loff_t)
30#define SNAPSHOT_IOC_MAXNR 20
31
32#endif /* _LINUX_SUSPEND_IOCTLS_H */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 5fc8ff73b7bb..2372e2e6b527 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -162,19 +162,19 @@ struct usb_interface {
162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
163 163
164 struct device dev; /* interface specific device info */ 164 struct device dev; /* interface specific device info */
165 struct device *usb_dev; /* pointer to the usb class's device, if any */ 165 struct device *usb_dev;
166 int pm_usage_cnt; /* usage counter for autosuspend */ 166 int pm_usage_cnt; /* usage counter for autosuspend */
167}; 167};
168#define to_usb_interface(d) container_of(d, struct usb_interface, dev) 168#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
169#define interface_to_usbdev(intf) \ 169#define interface_to_usbdev(intf) \
170 container_of(intf->dev.parent, struct usb_device, dev) 170 container_of(intf->dev.parent, struct usb_device, dev)
171 171
172static inline void *usb_get_intfdata (struct usb_interface *intf) 172static inline void *usb_get_intfdata(struct usb_interface *intf)
173{ 173{
174 return dev_get_drvdata (&intf->dev); 174 return dev_get_drvdata(&intf->dev);
175} 175}
176 176
177static inline void usb_set_intfdata (struct usb_interface *intf, void *data) 177static inline void usb_set_intfdata(struct usb_interface *intf, void *data)
178{ 178{
179 dev_set_drvdata(&intf->dev, data); 179 dev_set_drvdata(&intf->dev, data);
180} 180}
@@ -275,9 +275,10 @@ struct usb_host_config {
275 275
276int __usb_get_extra_descriptor(char *buffer, unsigned size, 276int __usb_get_extra_descriptor(char *buffer, unsigned size,
277 unsigned char type, void **ptr); 277 unsigned char type, void **ptr);
278#define usb_get_extra_descriptor(ifpoint,type,ptr)\ 278#define usb_get_extra_descriptor(ifpoint, type, ptr) \
279 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 279 __usb_get_extra_descriptor((ifpoint)->extra, \
280 type,(void**)ptr) 280 (ifpoint)->extralen, \
281 type, (void **)ptr)
281 282
282/* ----------------------------------------------------------------------- */ 283/* ----------------------------------------------------------------------- */
283 284
@@ -318,7 +319,7 @@ struct usb_bus {
318#ifdef CONFIG_USB_DEVICEFS 319#ifdef CONFIG_USB_DEVICEFS
319 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 320 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
320#endif 321#endif
321 struct class_device *class_dev; /* class device for this bus */ 322 struct device *dev; /* device for this bus */
322 323
323#if defined(CONFIG_USB_MON) 324#if defined(CONFIG_USB_MON)
324 struct mon_bus *mon_bus; /* non-null when associated */ 325 struct mon_bus *mon_bus; /* non-null when associated */
@@ -388,7 +389,7 @@ struct usb_device {
388 unsigned can_submit:1; /* URBs may be submitted */ 389 unsigned can_submit:1; /* URBs may be submitted */
389 unsigned discon_suspended:1; /* Disconnected while suspended */ 390 unsigned discon_suspended:1; /* Disconnected while suspended */
390 unsigned have_langid:1; /* whether string_langid is valid */ 391 unsigned have_langid:1; /* whether string_langid is valid */
391 unsigned authorized:1; /* Policy has determined we can use it */ 392 unsigned authorized:1; /* Policy has said we can use it */
392 unsigned wusb:1; /* Device is Wireless USB */ 393 unsigned wusb:1; /* Device is Wireless USB */
393 int string_langid; /* language ID for strings */ 394 int string_langid; /* language ID for strings */
394 395
@@ -417,7 +418,10 @@ struct usb_device {
417 418
418 int pm_usage_cnt; /* usage counter for autosuspend */ 419 int pm_usage_cnt; /* usage counter for autosuspend */
419 u32 quirks; /* quirks of the whole device */ 420 u32 quirks; /* quirks of the whole device */
420 atomic_t urbnum; /* number of URBs submitted for the whole device */ 421 atomic_t urbnum; /* number of URBs submitted for
422 the whole device */
423
424 unsigned long active_duration; /* total time device is not suspended */
421 425
422#ifdef CONFIG_PM 426#ifdef CONFIG_PM
423 struct delayed_work autosuspend; /* for delayed autosuspends */ 427 struct delayed_work autosuspend; /* for delayed autosuspends */
@@ -425,6 +429,7 @@ struct usb_device {
425 429
426 unsigned long last_busy; /* time of last use */ 430 unsigned long last_busy; /* time of last use */
427 int autosuspend_delay; /* in jiffies */ 431 int autosuspend_delay; /* in jiffies */
432 unsigned long connect_time; /* time device was first connected */
428 433
429 unsigned auto_pm:1; /* autosuspend/resume in progress */ 434 unsigned auto_pm:1; /* autosuspend/resume in progress */
430 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ 435 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */
@@ -498,11 +503,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
498/*-------------------------------------------------------------------------*/ 503/*-------------------------------------------------------------------------*/
499 504
500/* for drivers using iso endpoints */ 505/* for drivers using iso endpoints */
501extern int usb_get_current_frame_number (struct usb_device *usb_dev); 506extern int usb_get_current_frame_number(struct usb_device *usb_dev);
502 507
503/* used these for multi-interface device registration */ 508/* used these for multi-interface device registration */
504extern int usb_driver_claim_interface(struct usb_driver *driver, 509extern int usb_driver_claim_interface(struct usb_driver *driver,
505 struct usb_interface *iface, void* priv); 510 struct usb_interface *iface, void *priv);
506 511
507/** 512/**
508 * usb_interface_claimed - returns true iff an interface is claimed 513 * usb_interface_claimed - returns true iff an interface is claimed
@@ -514,7 +519,8 @@ extern int usb_driver_claim_interface(struct usb_driver *driver,
514 * may need to explicitly claim that lock. 519 * may need to explicitly claim that lock.
515 * 520 *
516 */ 521 */
517static inline int usb_interface_claimed(struct usb_interface *iface) { 522static inline int usb_interface_claimed(struct usb_interface *iface)
523{
518 return (iface->dev.driver != NULL); 524 return (iface->dev.driver != NULL);
519} 525}
520 526
@@ -557,12 +563,11 @@ extern struct usb_host_interface *usb_altnum_to_altsetting(
557 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 563 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
558 * high speed, and a different one if they are full or low speed. 564 * high speed, and a different one if they are full or low speed.
559 */ 565 */
560static inline int usb_make_path (struct usb_device *dev, char *buf, 566static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
561 size_t size)
562{ 567{
563 int actual; 568 int actual;
564 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, 569 actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name,
565 dev->devpath); 570 dev->devpath);
566 return (actual >= (int)size) ? -1 : actual; 571 return (actual >= (int)size) ? -1 : actual;
567} 572}
568 573
@@ -608,7 +613,8 @@ static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
608 * 613 *
609 * Returns true if the endpoint is of type OUT, otherwise it returns false. 614 * Returns true if the endpoint is of type OUT, otherwise it returns false.
610 */ 615 */
611static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) 616static inline int usb_endpoint_dir_out(
617 const struct usb_endpoint_descriptor *epd)
612{ 618{
613 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 619 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
614} 620}
@@ -619,7 +625,8 @@ static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd
619 * 625 *
620 * Returns true if the endpoint is of type bulk, otherwise it returns false. 626 * Returns true if the endpoint is of type bulk, otherwise it returns false.
621 */ 627 */
622static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) 628static inline int usb_endpoint_xfer_bulk(
629 const struct usb_endpoint_descriptor *epd)
623{ 630{
624 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 631 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
625 USB_ENDPOINT_XFER_BULK); 632 USB_ENDPOINT_XFER_BULK);
@@ -631,7 +638,8 @@ static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *e
631 * 638 *
632 * Returns true if the endpoint is of type control, otherwise it returns false. 639 * Returns true if the endpoint is of type control, otherwise it returns false.
633 */ 640 */
634static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) 641static inline int usb_endpoint_xfer_control(
642 const struct usb_endpoint_descriptor *epd)
635{ 643{
636 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 644 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
637 USB_ENDPOINT_XFER_CONTROL); 645 USB_ENDPOINT_XFER_CONTROL);
@@ -644,7 +652,8 @@ static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor
644 * Returns true if the endpoint is of type interrupt, otherwise it returns 652 * Returns true if the endpoint is of type interrupt, otherwise it returns
645 * false. 653 * false.
646 */ 654 */
647static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) 655static inline int usb_endpoint_xfer_int(
656 const struct usb_endpoint_descriptor *epd)
648{ 657{
649 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 658 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
650 USB_ENDPOINT_XFER_INT); 659 USB_ENDPOINT_XFER_INT);
@@ -657,7 +666,8 @@ static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *ep
657 * Returns true if the endpoint is of type isochronous, otherwise it returns 666 * Returns true if the endpoint is of type isochronous, otherwise it returns
658 * false. 667 * false.
659 */ 668 */
660static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) 669static inline int usb_endpoint_xfer_isoc(
670 const struct usb_endpoint_descriptor *epd)
661{ 671{
662 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 672 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
663 USB_ENDPOINT_XFER_ISOC); 673 USB_ENDPOINT_XFER_ISOC);
@@ -670,7 +680,8 @@ static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *e
670 * Returns true if the endpoint has bulk transfer type and IN direction, 680 * Returns true if the endpoint has bulk transfer type and IN direction,
671 * otherwise it returns false. 681 * otherwise it returns false.
672 */ 682 */
673static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) 683static inline int usb_endpoint_is_bulk_in(
684 const struct usb_endpoint_descriptor *epd)
674{ 685{
675 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); 686 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
676} 687}
@@ -682,7 +693,8 @@ static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *
682 * Returns true if the endpoint has bulk transfer type and OUT direction, 693 * Returns true if the endpoint has bulk transfer type and OUT direction,
683 * otherwise it returns false. 694 * otherwise it returns false.
684 */ 695 */
685static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) 696static inline int usb_endpoint_is_bulk_out(
697 const struct usb_endpoint_descriptor *epd)
686{ 698{
687 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); 699 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
688} 700}
@@ -694,7 +706,8 @@ static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor
694 * Returns true if the endpoint has interrupt transfer type and IN direction, 706 * Returns true if the endpoint has interrupt transfer type and IN direction,
695 * otherwise it returns false. 707 * otherwise it returns false.
696 */ 708 */
697static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) 709static inline int usb_endpoint_is_int_in(
710 const struct usb_endpoint_descriptor *epd)
698{ 711{
699 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); 712 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
700} 713}
@@ -706,7 +719,8 @@ static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *e
706 * Returns true if the endpoint has interrupt transfer type and OUT direction, 719 * Returns true if the endpoint has interrupt transfer type and OUT direction,
707 * otherwise it returns false. 720 * otherwise it returns false.
708 */ 721 */
709static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) 722static inline int usb_endpoint_is_int_out(
723 const struct usb_endpoint_descriptor *epd)
710{ 724{
711 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); 725 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
712} 726}
@@ -718,7 +732,8 @@ static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *
718 * Returns true if the endpoint has isochronous transfer type and IN direction, 732 * Returns true if the endpoint has isochronous transfer type and IN direction,
719 * otherwise it returns false. 733 * otherwise it returns false.
720 */ 734 */
721static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) 735static inline int usb_endpoint_is_isoc_in(
736 const struct usb_endpoint_descriptor *epd)
722{ 737{
723 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); 738 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
724} 739}
@@ -730,7 +745,8 @@ static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *
730 * Returns true if the endpoint has isochronous transfer type and OUT direction, 745 * Returns true if the endpoint has isochronous transfer type and OUT direction,
731 * otherwise it returns false. 746 * otherwise it returns false.
732 */ 747 */
733static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) 748static inline int usb_endpoint_is_isoc_out(
749 const struct usb_endpoint_descriptor *epd)
734{ 750{
735 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); 751 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
736} 752}
@@ -761,8 +777,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
761 * specific device. 777 * specific device.
762 */ 778 */
763#define USB_DEVICE(vend,prod) \ 779#define USB_DEVICE(vend,prod) \
764 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ 780 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
765 .idProduct = (prod) 781 .idVendor = (vend), \
782 .idProduct = (prod)
766/** 783/**
767 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 * USB_DEVICE_VER - macro used to describe a specific usb device with a
768 * version range 785 * version range
@@ -774,10 +791,12 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
774 * This macro is used to create a struct usb_device_id that matches a 791 * This macro is used to create a struct usb_device_id that matches a
775 * specific device, with a version range. 792 * specific device, with a version range.
776 */ 793 */
777#define USB_DEVICE_VER(vend,prod,lo,hi) \ 794#define USB_DEVICE_VER(vend, prod, lo, hi) \
778 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \ 795 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
779 .idVendor = (vend), .idProduct = (prod), \ 796 .idVendor = (vend), \
780 .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 797 .idProduct = (prod), \
798 .bcdDevice_lo = (lo), \
799 .bcdDevice_hi = (hi)
781 800
782/** 801/**
783 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb 802 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb
@@ -789,8 +808,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
789 * This macro is used to create a struct usb_device_id that matches a 808 * This macro is used to create a struct usb_device_id that matches a
790 * specific interface protocol of devices. 809 * specific interface protocol of devices.
791 */ 810 */
792#define USB_DEVICE_INTERFACE_PROTOCOL(vend,prod,pr) \ 811#define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \
793 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 812 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
813 USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
794 .idVendor = (vend), \ 814 .idVendor = (vend), \
795 .idProduct = (prod), \ 815 .idProduct = (prod), \
796 .bInterfaceProtocol = (pr) 816 .bInterfaceProtocol = (pr)
@@ -804,12 +824,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
804 * This macro is used to create a struct usb_device_id that matches a 824 * This macro is used to create a struct usb_device_id that matches a
805 * specific class of devices. 825 * specific class of devices.
806 */ 826 */
807#define USB_DEVICE_INFO(cl,sc,pr) \ 827#define USB_DEVICE_INFO(cl, sc, pr) \
808 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \ 828 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, \
809 .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 829 .bDeviceClass = (cl), \
830 .bDeviceSubClass = (sc), \
831 .bDeviceProtocol = (pr)
810 832
811/** 833/**
812 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 834 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
813 * @cl: bInterfaceClass value 835 * @cl: bInterfaceClass value
814 * @sc: bInterfaceSubClass value 836 * @sc: bInterfaceSubClass value
815 * @pr: bInterfaceProtocol value 837 * @pr: bInterfaceProtocol value
@@ -817,9 +839,11 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
817 * This macro is used to create a struct usb_device_id that matches a 839 * This macro is used to create a struct usb_device_id that matches a
818 * specific class of interfaces. 840 * specific class of interfaces.
819 */ 841 */
820#define USB_INTERFACE_INFO(cl,sc,pr) \ 842#define USB_INTERFACE_INFO(cl, sc, pr) \
821 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \ 843 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \
822 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 844 .bInterfaceClass = (cl), \
845 .bInterfaceSubClass = (sc), \
846 .bInterfaceProtocol = (pr)
823 847
824/** 848/**
825 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device 849 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device
@@ -836,12 +860,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
836 * This is especially useful when explicitly matching devices that have 860 * This is especially useful when explicitly matching devices that have
837 * vendor specific bDeviceClass values, but standards-compliant interfaces. 861 * vendor specific bDeviceClass values, but standards-compliant interfaces.
838 */ 862 */
839#define USB_DEVICE_AND_INTERFACE_INFO(vend,prod,cl,sc,pr) \ 863#define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
840 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 864 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
841 | USB_DEVICE_ID_MATCH_DEVICE, \ 865 | USB_DEVICE_ID_MATCH_DEVICE, \
842 .idVendor = (vend), .idProduct = (prod), \ 866 .idVendor = (vend), \
867 .idProduct = (prod), \
843 .bInterfaceClass = (cl), \ 868 .bInterfaceClass = (cl), \
844 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 869 .bInterfaceSubClass = (sc), \
870 .bInterfaceProtocol = (pr)
845 871
846/* ----------------------------------------------------------------------- */ 872/* ----------------------------------------------------------------------- */
847 873
@@ -1119,7 +1145,7 @@ typedef void (*usb_complete_t)(struct urb *);
1119 * transferred. It will normally be the same as requested, unless 1145 * transferred. It will normally be the same as requested, unless
1120 * either an error was reported or a short read was performed. 1146 * either an error was reported or a short read was performed.
1121 * The URB_SHORT_NOT_OK transfer flag may be used to make such 1147 * The URB_SHORT_NOT_OK transfer flag may be used to make such
1122 * short reads be reported as errors. 1148 * short reads be reported as errors.
1123 * @setup_packet: Only used for control transfers, this points to eight bytes 1149 * @setup_packet: Only used for control transfers, this points to eight bytes
1124 * of setup data. Control transfers always start by sending this data 1150 * of setup data. Control transfers always start by sending this data
1125 * to the device. Then transfer_buffer is read or written, if needed. 1151 * to the device. Then transfer_buffer is read or written, if needed.
@@ -1138,7 +1164,7 @@ typedef void (*usb_complete_t)(struct urb *);
1138 * @complete: Completion handler. This URB is passed as the parameter to the 1164 * @complete: Completion handler. This URB is passed as the parameter to the
1139 * completion function. The completion function may then do what 1165 * completion function. The completion function may then do what
1140 * it likes with the URB, including resubmitting or freeing it. 1166 * it likes with the URB, including resubmitting or freeing it.
1141 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 1167 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to
1142 * collect the transfer status for each buffer. 1168 * collect the transfer status for each buffer.
1143 * 1169 *
1144 * This structure identifies USB transfer requests. URBs must be allocated by 1170 * This structure identifies USB transfer requests. URBs must be allocated by
@@ -1242,8 +1268,7 @@ typedef void (*usb_complete_t)(struct urb *);
1242 * when the urb is owned by the hcd, that is, since the call to 1268 * when the urb is owned by the hcd, that is, since the call to
1243 * usb_submit_urb() till the entry into the completion routine. 1269 * usb_submit_urb() till the entry into the completion routine.
1244 */ 1270 */
1245struct urb 1271struct urb {
1246{
1247 /* private: usb core and host controller only fields in the urb */ 1272 /* private: usb core and host controller only fields in the urb */
1248 struct kref kref; /* reference count of the URB */ 1273 struct kref kref; /* reference count of the URB */
1249 void *hcpriv; /* private data for host controller */ 1274 void *hcpriv; /* private data for host controller */
@@ -1254,10 +1279,10 @@ struct urb
1254 /* public: documented fields in the urb that can be used by drivers */ 1279 /* public: documented fields in the urb that can be used by drivers */
1255 struct list_head urb_list; /* list head for use by the urb's 1280 struct list_head urb_list; /* list head for use by the urb's
1256 * current owner */ 1281 * current owner */
1257 struct list_head anchor_list; /* the URB may be anchored by the driver */ 1282 struct list_head anchor_list; /* the URB may be anchored */
1258 struct usb_anchor *anchor; 1283 struct usb_anchor *anchor;
1259 struct usb_device *dev; /* (in) pointer to associated device */ 1284 struct usb_device *dev; /* (in) pointer to associated device */
1260 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint struct */ 1285 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
1261 unsigned int pipe; /* (in) pipe information */ 1286 unsigned int pipe; /* (in) pipe information */
1262 int status; /* (return) non-ISO status */ 1287 int status; /* (return) non-ISO status */
1263 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1288 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
@@ -1294,14 +1319,14 @@ struct urb
1294 * Initializes a control urb with the proper information needed to submit 1319 * Initializes a control urb with the proper information needed to submit
1295 * it to a device. 1320 * it to a device.
1296 */ 1321 */
1297static inline void usb_fill_control_urb (struct urb *urb, 1322static inline void usb_fill_control_urb(struct urb *urb,
1298 struct usb_device *dev, 1323 struct usb_device *dev,
1299 unsigned int pipe, 1324 unsigned int pipe,
1300 unsigned char *setup_packet, 1325 unsigned char *setup_packet,
1301 void *transfer_buffer, 1326 void *transfer_buffer,
1302 int buffer_length, 1327 int buffer_length,
1303 usb_complete_t complete_fn, 1328 usb_complete_t complete_fn,
1304 void *context) 1329 void *context)
1305{ 1330{
1306 urb->dev = dev; 1331 urb->dev = dev;
1307 urb->pipe = pipe; 1332 urb->pipe = pipe;
@@ -1325,13 +1350,13 @@ static inline void usb_fill_control_urb (struct urb *urb,
1325 * Initializes a bulk urb with the proper information needed to submit it 1350 * Initializes a bulk urb with the proper information needed to submit it
1326 * to a device. 1351 * to a device.
1327 */ 1352 */
1328static inline void usb_fill_bulk_urb (struct urb *urb, 1353static inline void usb_fill_bulk_urb(struct urb *urb,
1329 struct usb_device *dev, 1354 struct usb_device *dev,
1330 unsigned int pipe, 1355 unsigned int pipe,
1331 void *transfer_buffer, 1356 void *transfer_buffer,
1332 int buffer_length, 1357 int buffer_length,
1333 usb_complete_t complete_fn, 1358 usb_complete_t complete_fn,
1334 void *context) 1359 void *context)
1335{ 1360{
1336 urb->dev = dev; 1361 urb->dev = dev;
1337 urb->pipe = pipe; 1362 urb->pipe = pipe;
@@ -1359,14 +1384,14 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
1359 * the endpoint interval, and express polling intervals in microframes 1384 * the endpoint interval, and express polling intervals in microframes
1360 * (eight per millisecond) rather than in frames (one per millisecond). 1385 * (eight per millisecond) rather than in frames (one per millisecond).
1361 */ 1386 */
1362static inline void usb_fill_int_urb (struct urb *urb, 1387static inline void usb_fill_int_urb(struct urb *urb,
1363 struct usb_device *dev, 1388 struct usb_device *dev,
1364 unsigned int pipe, 1389 unsigned int pipe,
1365 void *transfer_buffer, 1390 void *transfer_buffer,
1366 int buffer_length, 1391 int buffer_length,
1367 usb_complete_t complete_fn, 1392 usb_complete_t complete_fn,
1368 void *context, 1393 void *context,
1369 int interval) 1394 int interval)
1370{ 1395{
1371 urb->dev = dev; 1396 urb->dev = dev;
1372 urb->pipe = pipe; 1397 urb->pipe = pipe;
@@ -1419,15 +1444,15 @@ static inline int usb_urb_dir_out(struct urb *urb)
1419 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; 1444 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1420} 1445}
1421 1446
1422void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1447void *usb_buffer_alloc(struct usb_device *dev, size_t size,
1423 gfp_t mem_flags, dma_addr_t *dma); 1448 gfp_t mem_flags, dma_addr_t *dma);
1424void usb_buffer_free (struct usb_device *dev, size_t size, 1449void usb_buffer_free(struct usb_device *dev, size_t size,
1425 void *addr, dma_addr_t dma); 1450 void *addr, dma_addr_t dma);
1426 1451
1427#if 0 1452#if 0
1428struct urb *usb_buffer_map (struct urb *urb); 1453struct urb *usb_buffer_map(struct urb *urb);
1429void usb_buffer_dmasync (struct urb *urb); 1454void usb_buffer_dmasync(struct urb *urb);
1430void usb_buffer_unmap (struct urb *urb); 1455void usb_buffer_unmap(struct urb *urb);
1431#endif 1456#endif
1432 1457
1433struct scatterlist; 1458struct scatterlist;
@@ -1499,7 +1524,7 @@ struct usb_sg_request {
1499 int status; 1524 int status;
1500 size_t bytes; 1525 size_t bytes;
1501 1526
1502 /* 1527 /*
1503 * members below are private: to usbcore, 1528 * members below are private: to usbcore,
1504 * and are not provided for driver access! 1529 * and are not provided for driver access!
1505 */ 1530 */
@@ -1517,18 +1542,18 @@ struct usb_sg_request {
1517 struct completion complete; 1542 struct completion complete;
1518}; 1543};
1519 1544
1520int usb_sg_init ( 1545int usb_sg_init(
1521 struct usb_sg_request *io, 1546 struct usb_sg_request *io,
1522 struct usb_device *dev, 1547 struct usb_device *dev,
1523 unsigned pipe, 1548 unsigned pipe,
1524 unsigned period, 1549 unsigned period,
1525 struct scatterlist *sg, 1550 struct scatterlist *sg,
1526 int nents, 1551 int nents,
1527 size_t length, 1552 size_t length,
1528 gfp_t mem_flags 1553 gfp_t mem_flags
1529); 1554);
1530void usb_sg_cancel (struct usb_sg_request *io); 1555void usb_sg_cancel(struct usb_sg_request *io);
1531void usb_sg_wait (struct usb_sg_request *io); 1556void usb_sg_wait(struct usb_sg_request *io);
1532 1557
1533 1558
1534/* ----------------------------------------------------------------------- */ 1559/* ----------------------------------------------------------------------- */
@@ -1585,21 +1610,21 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
1585 1610
1586/* Create various pipes... */ 1611/* Create various pipes... */
1587#define usb_sndctrlpipe(dev,endpoint) \ 1612#define usb_sndctrlpipe(dev,endpoint) \
1588 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1613 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
1589#define usb_rcvctrlpipe(dev,endpoint) \ 1614#define usb_rcvctrlpipe(dev,endpoint) \
1590 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1615 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1591#define usb_sndisocpipe(dev,endpoint) \ 1616#define usb_sndisocpipe(dev,endpoint) \
1592 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1617 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
1593#define usb_rcvisocpipe(dev,endpoint) \ 1618#define usb_rcvisocpipe(dev,endpoint) \
1594 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1619 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1595#define usb_sndbulkpipe(dev,endpoint) \ 1620#define usb_sndbulkpipe(dev,endpoint) \
1596 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1621 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
1597#define usb_rcvbulkpipe(dev,endpoint) \ 1622#define usb_rcvbulkpipe(dev,endpoint) \
1598 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1623 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1599#define usb_sndintpipe(dev,endpoint) \ 1624#define usb_sndintpipe(dev,endpoint) \
1600 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1625 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
1601#define usb_rcvintpipe(dev,endpoint) \ 1626#define usb_rcvintpipe(dev,endpoint) \
1602 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1627 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1603 1628
1604/*-------------------------------------------------------------------------*/ 1629/*-------------------------------------------------------------------------*/
1605 1630
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 6ce42bf9f743..b8cba1dcb2c6 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -1,6 +1,7 @@
1unifdef-y += audio.h 1header-y += audio.h
2unifdef-y += cdc.h 2header-y += cdc.h
3unifdef-y += ch9.h 3header-y += ch9.h
4unifdef-y += gadgetfs.h 4header-y += gadgetfs.h
5unifdef-y += midi.h 5header-y += midi.h
6unifdef-y += g_printer.h
6 7
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 6bd235994dc2..2dfeef16b221 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -27,13 +27,13 @@
27 27
28/* 4.3.2 Class-Specific AC Interface Descriptor */ 28/* 4.3.2 Class-Specific AC Interface Descriptor */
29struct usb_ac_header_descriptor { 29struct usb_ac_header_descriptor {
30 __u8 bLength; // 8+n 30 __u8 bLength; /* 8+n */
31 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 31 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
32 __u8 bDescriptorSubtype; // USB_MS_HEADER 32 __u8 bDescriptorSubtype; /* USB_MS_HEADER */
33 __le16 bcdADC; // 0x0100 33 __le16 bcdADC; /* 0x0100 */
34 __le16 wTotalLength; // includes Unit and Terminal desc. 34 __le16 wTotalLength; /* includes Unit and Terminal desc. */
35 __u8 bInCollection; // n 35 __u8 bInCollection; /* n */
36 __u8 baInterfaceNr[]; // [n] 36 __u8 baInterfaceNr[]; /* [n] */
37} __attribute__ ((packed)); 37} __attribute__ ((packed));
38 38
39#define USB_DT_AC_HEADER_SIZE(n) (8+(n)) 39#define USB_DT_AC_HEADER_SIZE(n) (8+(n))
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index 2204ae22c381..94ee4ecf0564 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -29,16 +29,16 @@
29 * Class-Specific descriptors ... there are a couple dozen of them 29 * Class-Specific descriptors ... there are a couple dozen of them
30 */ 30 */
31 31
32#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ 32#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
33#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ 33#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
34#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ 34#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
35#define USB_CDC_UNION_TYPE 0x06 /* union_desc */ 35#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
36#define USB_CDC_COUNTRY_TYPE 0x07 36#define USB_CDC_COUNTRY_TYPE 0x07
37#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ 37#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
38#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ 38#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
39#define USB_CDC_WHCM_TYPE 0x11 39#define USB_CDC_WHCM_TYPE 0x11
40#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ 40#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
41#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ 41#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
42#define USB_CDC_DMM_TYPE 0x14 42#define USB_CDC_DMM_TYPE 0x14
43#define USB_CDC_OBEX_TYPE 0x15 43#define USB_CDC_OBEX_TYPE 0x15
44 44
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h
new file mode 100644
index 000000000000..0c5ea1e3eb98
--- /dev/null
+++ b/include/linux/usb/g_printer.h
@@ -0,0 +1,31 @@
1/*
2 * g_printer.h -- Header file for USB Printer gadget driver
3 *
4 * Copyright (C) 2007 Craig W. Nadler
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21
22#define PRINTER_NOT_ERROR 0x08
23#define PRINTER_SELECTED 0x10
24#define PRINTER_PAPER_EMPTY 0x20
25
26/* The 'g' code is also used by gadgetfs ioctl requests.
27 * Don't add any colliding codes to either driver, and keep
28 * them in unique ranges (size 0x20 for now).
29 */
30#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
31#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c1527c2ef3cb..aa3047ff00d1 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -70,9 +70,10 @@ struct usb_ep;
70 * 70 *
71 * Bulk endpoints can use any size buffers, and can also be used for interrupt 71 * Bulk endpoints can use any size buffers, and can also be used for interrupt
72 * transfers. interrupt-only endpoints can be much less functional. 72 * transfers. interrupt-only endpoints can be much less functional.
73 *
74 * NOTE: this is analagous to 'struct urb' on the host side, except that
75 * it's thinner and promotes more pre-allocation.
73 */ 76 */
74 // NOTE this is analagous to 'struct urb' on the host side,
75 // except that it's thinner and promotes more pre-allocation.
76 77
77struct usb_request { 78struct usb_request {
78 void *buf; 79 void *buf;
@@ -168,10 +169,10 @@ struct usb_ep {
168 * 169 *
169 * returns zero, or a negative error code. 170 * returns zero, or a negative error code.
170 */ 171 */
171static inline int 172static inline int usb_ep_enable(struct usb_ep *ep,
172usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) 173 const struct usb_endpoint_descriptor *desc)
173{ 174{
174 return ep->ops->enable (ep, desc); 175 return ep->ops->enable(ep, desc);
175} 176}
176 177
177/** 178/**
@@ -186,10 +187,9 @@ usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
186 * 187 *
187 * returns zero, or a negative error code. 188 * returns zero, or a negative error code.
188 */ 189 */
189static inline int 190static inline int usb_ep_disable(struct usb_ep *ep)
190usb_ep_disable (struct usb_ep *ep)
191{ 191{
192 return ep->ops->disable (ep); 192 return ep->ops->disable(ep);
193} 193}
194 194
195/** 195/**
@@ -206,10 +206,10 @@ usb_ep_disable (struct usb_ep *ep)
206 * 206 *
207 * Returns the request, or null if one could not be allocated. 207 * Returns the request, or null if one could not be allocated.
208 */ 208 */
209static inline struct usb_request * 209static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
210usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags) 210 gfp_t gfp_flags)
211{ 211{
212 return ep->ops->alloc_request (ep, gfp_flags); 212 return ep->ops->alloc_request(ep, gfp_flags);
213} 213}
214 214
215/** 215/**
@@ -221,10 +221,10 @@ usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
221 * Caller guarantees the request is not queued, and that it will 221 * Caller guarantees the request is not queued, and that it will
222 * no longer be requeued (or otherwise used). 222 * no longer be requeued (or otherwise used).
223 */ 223 */
224static inline void 224static inline void usb_ep_free_request(struct usb_ep *ep,
225usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) 225 struct usb_request *req)
226{ 226{
227 ep->ops->free_request (ep, req); 227 ep->ops->free_request(ep, req);
228} 228}
229 229
230/** 230/**
@@ -281,10 +281,10 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
281 * report errors; errors will also be 281 * report errors; errors will also be
282 * reported when the usb peripheral is disconnected. 282 * reported when the usb peripheral is disconnected.
283 */ 283 */
284static inline int 284static inline int usb_ep_queue(struct usb_ep *ep,
285usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) 285 struct usb_request *req, gfp_t gfp_flags)
286{ 286{
287 return ep->ops->queue (ep, req, gfp_flags); 287 return ep->ops->queue(ep, req, gfp_flags);
288} 288}
289 289
290/** 290/**
@@ -301,9 +301,9 @@ usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
301 * restrictions prevent drivers from supporting configuration changes, 301 * restrictions prevent drivers from supporting configuration changes,
302 * even to configuration zero (a "chapter 9" requirement). 302 * even to configuration zero (a "chapter 9" requirement).
303 */ 303 */
304static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) 304static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
305{ 305{
306 return ep->ops->dequeue (ep, req); 306 return ep->ops->dequeue(ep, req);
307} 307}
308 308
309/** 309/**
@@ -327,10 +327,9 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
327 * transfer requests are still queued, or if the controller hardware 327 * transfer requests are still queued, or if the controller hardware
328 * (usually a FIFO) still holds bytes that the host hasn't collected. 328 * (usually a FIFO) still holds bytes that the host hasn't collected.
329 */ 329 */
330static inline int 330static inline int usb_ep_set_halt(struct usb_ep *ep)
331usb_ep_set_halt (struct usb_ep *ep)
332{ 331{
333 return ep->ops->set_halt (ep, 1); 332 return ep->ops->set_halt(ep, 1);
334} 333}
335 334
336/** 335/**
@@ -346,10 +345,9 @@ usb_ep_set_halt (struct usb_ep *ep)
346 * Note that some hardware can't support this request (like pxa2xx_udc), 345 * Note that some hardware can't support this request (like pxa2xx_udc),
347 * and accordingly can't correctly implement interface altsettings. 346 * and accordingly can't correctly implement interface altsettings.
348 */ 347 */
349static inline int 348static inline int usb_ep_clear_halt(struct usb_ep *ep)
350usb_ep_clear_halt (struct usb_ep *ep)
351{ 349{
352 return ep->ops->set_halt (ep, 0); 350 return ep->ops->set_halt(ep, 0);
353} 351}
354 352
355/** 353/**
@@ -367,11 +365,10 @@ usb_ep_clear_halt (struct usb_ep *ep)
367 * errno if the endpoint doesn't use a FIFO or doesn't support such 365 * errno if the endpoint doesn't use a FIFO or doesn't support such
368 * precise handling. 366 * precise handling.
369 */ 367 */
370static inline int 368static inline int usb_ep_fifo_status(struct usb_ep *ep)
371usb_ep_fifo_status (struct usb_ep *ep)
372{ 369{
373 if (ep->ops->fifo_status) 370 if (ep->ops->fifo_status)
374 return ep->ops->fifo_status (ep); 371 return ep->ops->fifo_status(ep);
375 else 372 else
376 return -EOPNOTSUPP; 373 return -EOPNOTSUPP;
377} 374}
@@ -385,11 +382,10 @@ usb_ep_fifo_status (struct usb_ep *ep)
385 * must never be used except when endpoint is not being used for any 382 * must never be used except when endpoint is not being used for any
386 * protocol translation. 383 * protocol translation.
387 */ 384 */
388static inline void 385static inline void usb_ep_fifo_flush(struct usb_ep *ep)
389usb_ep_fifo_flush (struct usb_ep *ep)
390{ 386{
391 if (ep->ops->fifo_flush) 387 if (ep->ops->fifo_flush)
392 ep->ops->fifo_flush (ep); 388 ep->ops->fifo_flush(ep);
393} 389}
394 390
395 391
@@ -469,10 +465,10 @@ struct usb_gadget {
469 struct device dev; 465 struct device dev;
470}; 466};
471 467
472static inline void set_gadget_data (struct usb_gadget *gadget, void *data) 468static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
473 { dev_set_drvdata (&gadget->dev, data); } 469 { dev_set_drvdata(&gadget->dev, data); }
474static inline void *get_gadget_data (struct usb_gadget *gadget) 470static inline void *get_gadget_data(struct usb_gadget *gadget)
475 { return dev_get_drvdata (&gadget->dev); } 471 { return dev_get_drvdata(&gadget->dev); }
476 472
477/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ 473/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
478#define gadget_for_each_ep(tmp,gadget) \ 474#define gadget_for_each_ep(tmp,gadget) \
@@ -511,7 +507,6 @@ static inline int gadget_is_otg(struct usb_gadget *g)
511#endif 507#endif
512} 508}
513 509
514
515/** 510/**
516 * usb_gadget_frame_number - returns the current frame number 511 * usb_gadget_frame_number - returns the current frame number
517 * @gadget: controller that reports the frame number 512 * @gadget: controller that reports the frame number
@@ -519,9 +514,9 @@ static inline int gadget_is_otg(struct usb_gadget *g)
519 * Returns the usb frame number, normally eleven bits from a SOF packet, 514 * Returns the usb frame number, normally eleven bits from a SOF packet,
520 * or negative errno if this device doesn't support this capability. 515 * or negative errno if this device doesn't support this capability.
521 */ 516 */
522static inline int usb_gadget_frame_number (struct usb_gadget *gadget) 517static inline int usb_gadget_frame_number(struct usb_gadget *gadget)
523{ 518{
524 return gadget->ops->get_frame (gadget); 519 return gadget->ops->get_frame(gadget);
525} 520}
526 521
527/** 522/**
@@ -537,11 +532,11 @@ static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
537 * even if OTG isn't otherwise in use. OTG devices may also start 532 * even if OTG isn't otherwise in use. OTG devices may also start
538 * remote wakeup even when hosts don't explicitly enable it. 533 * remote wakeup even when hosts don't explicitly enable it.
539 */ 534 */
540static inline int usb_gadget_wakeup (struct usb_gadget *gadget) 535static inline int usb_gadget_wakeup(struct usb_gadget *gadget)
541{ 536{
542 if (!gadget->ops->wakeup) 537 if (!gadget->ops->wakeup)
543 return -EOPNOTSUPP; 538 return -EOPNOTSUPP;
544 return gadget->ops->wakeup (gadget); 539 return gadget->ops->wakeup(gadget);
545} 540}
546 541
547/** 542/**
@@ -553,12 +548,11 @@ static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
553 * 548 *
554 * returns zero on success, else negative errno. 549 * returns zero on success, else negative errno.
555 */ 550 */
556static inline int 551static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
557usb_gadget_set_selfpowered (struct usb_gadget *gadget)
558{ 552{
559 if (!gadget->ops->set_selfpowered) 553 if (!gadget->ops->set_selfpowered)
560 return -EOPNOTSUPP; 554 return -EOPNOTSUPP;
561 return gadget->ops->set_selfpowered (gadget, 1); 555 return gadget->ops->set_selfpowered(gadget, 1);
562} 556}
563 557
564/** 558/**
@@ -571,12 +565,11 @@ usb_gadget_set_selfpowered (struct usb_gadget *gadget)
571 * 565 *
572 * returns zero on success, else negative errno. 566 * returns zero on success, else negative errno.
573 */ 567 */
574static inline int 568static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
575usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
576{ 569{
577 if (!gadget->ops->set_selfpowered) 570 if (!gadget->ops->set_selfpowered)
578 return -EOPNOTSUPP; 571 return -EOPNOTSUPP;
579 return gadget->ops->set_selfpowered (gadget, 0); 572 return gadget->ops->set_selfpowered(gadget, 0);
580} 573}
581 574
582/** 575/**
@@ -591,12 +584,11 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
591 * 584 *
592 * Returns zero on success, else negative errno. 585 * Returns zero on success, else negative errno.
593 */ 586 */
594static inline int 587static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)
595usb_gadget_vbus_connect(struct usb_gadget *gadget)
596{ 588{
597 if (!gadget->ops->vbus_session) 589 if (!gadget->ops->vbus_session)
598 return -EOPNOTSUPP; 590 return -EOPNOTSUPP;
599 return gadget->ops->vbus_session (gadget, 1); 591 return gadget->ops->vbus_session(gadget, 1);
600} 592}
601 593
602/** 594/**
@@ -611,12 +603,11 @@ usb_gadget_vbus_connect(struct usb_gadget *gadget)
611 * 603 *
612 * Returns zero on success, else negative errno. 604 * Returns zero on success, else negative errno.
613 */ 605 */
614static inline int 606static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
615usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
616{ 607{
617 if (!gadget->ops->vbus_draw) 608 if (!gadget->ops->vbus_draw)
618 return -EOPNOTSUPP; 609 return -EOPNOTSUPP;
619 return gadget->ops->vbus_draw (gadget, mA); 610 return gadget->ops->vbus_draw(gadget, mA);
620} 611}
621 612
622/** 613/**
@@ -629,12 +620,11 @@ usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
629 * 620 *
630 * Returns zero on success, else negative errno. 621 * Returns zero on success, else negative errno.
631 */ 622 */
632static inline int 623static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
633usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
634{ 624{
635 if (!gadget->ops->vbus_session) 625 if (!gadget->ops->vbus_session)
636 return -EOPNOTSUPP; 626 return -EOPNOTSUPP;
637 return gadget->ops->vbus_session (gadget, 0); 627 return gadget->ops->vbus_session(gadget, 0);
638} 628}
639 629
640/** 630/**
@@ -648,12 +638,11 @@ usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
648 * 638 *
649 * Returns zero on success, else negative errno. 639 * Returns zero on success, else negative errno.
650 */ 640 */
651static inline int 641static inline int usb_gadget_connect(struct usb_gadget *gadget)
652usb_gadget_connect (struct usb_gadget *gadget)
653{ 642{
654 if (!gadget->ops->pullup) 643 if (!gadget->ops->pullup)
655 return -EOPNOTSUPP; 644 return -EOPNOTSUPP;
656 return gadget->ops->pullup (gadget, 1); 645 return gadget->ops->pullup(gadget, 1);
657} 646}
658 647
659/** 648/**
@@ -671,16 +660,14 @@ usb_gadget_connect (struct usb_gadget *gadget)
671 * 660 *
672 * Returns zero on success, else negative errno. 661 * Returns zero on success, else negative errno.
673 */ 662 */
674static inline int 663static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
675usb_gadget_disconnect (struct usb_gadget *gadget)
676{ 664{
677 if (!gadget->ops->pullup) 665 if (!gadget->ops->pullup)
678 return -EOPNOTSUPP; 666 return -EOPNOTSUPP;
679 return gadget->ops->pullup (gadget, 0); 667 return gadget->ops->pullup(gadget, 0);
680} 668}
681 669
682 670
683
684/*-------------------------------------------------------------------------*/ 671/*-------------------------------------------------------------------------*/
685 672
686/** 673/**
@@ -764,7 +751,7 @@ struct usb_gadget_driver {
764 void (*suspend)(struct usb_gadget *); 751 void (*suspend)(struct usb_gadget *);
765 void (*resume)(struct usb_gadget *); 752 void (*resume)(struct usb_gadget *);
766 753
767 // FIXME support safe rmmod 754 /* FIXME support safe rmmod */
768 struct device_driver driver; 755 struct device_driver driver;
769}; 756};
770 757
@@ -790,7 +777,7 @@ struct usb_gadget_driver {
790 * the bind() functions will be in init sections. 777 * the bind() functions will be in init sections.
791 * This function must be called in a context that can sleep. 778 * This function must be called in a context that can sleep.
792 */ 779 */
793int usb_gadget_register_driver (struct usb_gadget_driver *driver); 780int usb_gadget_register_driver(struct usb_gadget_driver *driver);
794 781
795/** 782/**
796 * usb_gadget_unregister_driver - unregister a gadget driver 783 * usb_gadget_unregister_driver - unregister a gadget driver
@@ -805,7 +792,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
805 * will in in exit sections, so may not be linked in some kernels. 792 * will in in exit sections, so may not be linked in some kernels.
806 * This function must be called in a context that can sleep. 793 * This function must be called in a context that can sleep.
807 */ 794 */
808int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); 795int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
809 796
810/*-------------------------------------------------------------------------*/ 797/*-------------------------------------------------------------------------*/
811 798
@@ -838,7 +825,7 @@ struct usb_gadget_strings {
838}; 825};
839 826
840/* put descriptor for string with that id into buf (buflen >= 256) */ 827/* put descriptor for string with that id into buf (buflen >= 256) */
841int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf); 828int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf);
842 829
843/*-------------------------------------------------------------------------*/ 830/*-------------------------------------------------------------------------*/
844 831
@@ -856,10 +843,10 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
856 843
857/* utility wrapping a simple endpoint selection policy */ 844/* utility wrapping a simple endpoint selection policy */
858 845
859extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *, 846extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
860 struct usb_endpoint_descriptor *) __devinit; 847 struct usb_endpoint_descriptor *) __devinit;
861 848
862extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit; 849extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit;
863 850
864#endif /* __KERNEL__ */ 851#endif /* __KERNEL__ */
865 852
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
index e8654c338729..c291ab1af747 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/linux/usb/gadgetfs.h
@@ -36,7 +36,7 @@ enum usb_gadgetfs_event_type {
36 GADGETFS_DISCONNECT, 36 GADGETFS_DISCONNECT,
37 GADGETFS_SETUP, 37 GADGETFS_SETUP,
38 GADGETFS_SUSPEND, 38 GADGETFS_SUSPEND,
39 // and likely more ! 39 /* and likely more ! */
40}; 40};
41 41
42/* NOTE: this structure must stay the same size and layout on 42/* NOTE: this structure must stay the same size and layout on
@@ -44,21 +44,28 @@ enum usb_gadgetfs_event_type {
44 */ 44 */
45struct usb_gadgetfs_event { 45struct usb_gadgetfs_event {
46 union { 46 union {
47 // NOP, DISCONNECT, SUSPEND: nothing 47 /* NOP, DISCONNECT, SUSPEND: nothing
48 // ... some hardware can't report disconnection 48 * ... some hardware can't report disconnection
49 */
49 50
50 // CONNECT: just the speed 51 /* CONNECT: just the speed */
51 enum usb_device_speed speed; 52 enum usb_device_speed speed;
52 53
53 // SETUP: packet; DATA phase i/o precedes next event 54 /* SETUP: packet; DATA phase i/o precedes next event
54 // (setup.bmRequestType & USB_DIR_IN) flags direction 55 *(setup.bmRequestType & USB_DIR_IN) flags direction
55 // ... includes SET_CONFIGURATION, SET_INTERFACE 56 * ... includes SET_CONFIGURATION, SET_INTERFACE
57 */
56 struct usb_ctrlrequest setup; 58 struct usb_ctrlrequest setup;
57 } u; 59 } u;
58 enum usb_gadgetfs_event_type type; 60 enum usb_gadgetfs_event_type type;
59}; 61};
60 62
61 63
64/* The 'g' code is also used by printer gadget ioctl requests.
65 * Don't add any colliding codes to either driver, and keep
66 * them in unique ranges (size 0x20 for now).
67 */
68
62/* endpoint ioctls */ 69/* endpoint ioctls */
63 70
64/* IN transfers may be reported to the gadget driver as complete 71/* IN transfers may be reported to the gadget driver as complete
@@ -68,14 +75,14 @@ struct usb_gadgetfs_event {
68 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 75 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
69 * (needed for precise fault handling, when the hardware allows it) 76 * (needed for precise fault handling, when the hardware allows it)
70 */ 77 */
71#define GADGETFS_FIFO_STATUS _IO('g',1) 78#define GADGETFS_FIFO_STATUS _IO('g', 1)
72 79
73/* discards any unclaimed data in the fifo. */ 80/* discards any unclaimed data in the fifo. */
74#define GADGETFS_FIFO_FLUSH _IO('g',2) 81#define GADGETFS_FIFO_FLUSH _IO('g', 2)
75 82
76/* resets endpoint halt+toggle; used to implement set_interface. 83/* resets endpoint halt+toggle; used to implement set_interface.
77 * some hardware (like pxa2xx) can't support this. 84 * some hardware (like pxa2xx) can't support this.
78 */ 85 */
79#define GADGETFS_CLEAR_HALT _IO('g',3) 86#define GADGETFS_CLEAR_HALT _IO('g', 3)
80 87
81#endif /* __LINUX_USB_GADGETFS_H */ 88#endif /* __LINUX_USB_GADGETFS_H */
diff --git a/include/linux/usb/iowarrior.h b/include/linux/usb/iowarrior.h
index cbbe020a4f5c..de6f380e17a2 100644
--- a/include/linux/usb/iowarrior.h
+++ b/include/linux/usb/iowarrior.h
@@ -14,14 +14,23 @@
14 this information. 14 this information.
15*/ 15*/
16struct iowarrior_info { 16struct iowarrior_info {
17 __u32 vendor; /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */ 17 /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */
18 __u32 product; /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_XXXXX) */ 18 __u32 vendor;
19 __u8 serial[9]; /* the serial number of our chip (if a serial-number is not available this is empty string) */ 19 /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_X) */
20 __u32 revision; /* revision number of the chip */ 20 __u32 product;
21 __u32 speed; /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */ 21 /* the serial number of our chip (if a serial-number is not available
22 __u32 power; /* power consumption of the device in mA */ 22 * this is empty string) */
23 __u32 if_num; /* the number of the endpoint */ 23 __u8 serial[9];
24 __u32 report_size; /* size of the data-packets on this interface */ 24 /* revision number of the chip */
25 __u32 revision;
26 /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */
27 __u32 speed;
28 /* power consumption of the device in mA */
29 __u32 power;
30 /* the number of the endpoint */
31 __u32 if_num;
32 /* size of the data-packets on this interface */
33 __u32 report_size;
25}; 34};
26 35
27/* 36/*
diff --git a/include/linux/usb/isp116x.h b/include/linux/usb/isp116x.h
index 436dd8a2b64a..67d2826f34fe 100644
--- a/include/linux/usb/isp116x.h
+++ b/include/linux/usb/isp116x.h
@@ -25,5 +25,5 @@ struct isp116x_platform_data {
25 300ns delay between access to ADDR_REG and DATA_REG 25 300ns delay between access to ADDR_REG and DATA_REG
26 OE, WE MUST NOT be changed during these intervals 26 OE, WE MUST NOT be changed during these intervals
27 */ 27 */
28 void (*delay) (struct device * dev, int delay); 28 void (*delay) (struct device *dev, int delay);
29}; 29};
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
index 11a97d5ffd34..80624c562921 100644
--- a/include/linux/usb/midi.h
+++ b/include/linux/usb/midi.h
@@ -47,9 +47,9 @@ struct usb_ms_header_descriptor {
47/* 6.1.2.2 MIDI IN Jack Descriptor */ 47/* 6.1.2.2 MIDI IN Jack Descriptor */
48struct usb_midi_in_jack_descriptor { 48struct usb_midi_in_jack_descriptor {
49 __u8 bLength; 49 __u8 bLength;
50 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 50 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
51 __u8 bDescriptorSubtype; // USB_MS_MIDI_IN_JACK 51 __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */
52 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 52 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
53 __u8 bJackID; 53 __u8 bJackID;
54 __u8 iJack; 54 __u8 iJack;
55} __attribute__ ((packed)); 55} __attribute__ ((packed));
@@ -64,12 +64,12 @@ struct usb_midi_source_pin {
64/* 6.1.2.3 MIDI OUT Jack Descriptor */ 64/* 6.1.2.3 MIDI OUT Jack Descriptor */
65struct usb_midi_out_jack_descriptor { 65struct usb_midi_out_jack_descriptor {
66 __u8 bLength; 66 __u8 bLength;
67 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 67 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
68 __u8 bDescriptorSubtype; // USB_MS_MIDI_OUT_JACK 68 __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */
69 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 69 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
70 __u8 bJackID; 70 __u8 bJackID;
71 __u8 bNrInputPins; // p 71 __u8 bNrInputPins; /* p */
72 struct usb_midi_source_pin pins[]; // [p] 72 struct usb_midi_source_pin pins[]; /* [p] */
73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */ 73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */
74} __attribute__ ((packed)); 74} __attribute__ ((packed));
75 75
@@ -90,11 +90,11 @@ struct usb_midi_out_jack_descriptor_##p { \
90 90
91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */ 91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
92struct usb_ms_endpoint_descriptor { 92struct usb_ms_endpoint_descriptor {
93 __u8 bLength; // 4+n 93 __u8 bLength; /* 4+n */
94 __u8 bDescriptorType; // USB_DT_CS_ENDPOINT 94 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
95 __u8 bDescriptorSubtype; // USB_MS_GENERAL 95 __u8 bDescriptorSubtype; /* USB_MS_GENERAL */
96 __u8 bNumEmbMIDIJack; // n 96 __u8 bNumEmbMIDIJack; /* n */
97 __u8 baAssocJackID[]; // [n] 97 __u8 baAssocJackID[]; /* [n] */
98} __attribute__ ((packed)); 98} __attribute__ ((packed));
99 99
100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n)) 100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index c602f884f182..ec897cb844ab 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -37,7 +37,7 @@
37 37
38/* main registers, BAR0 + 0x0000 */ 38/* main registers, BAR0 + 0x0000 */
39struct net2280_regs { 39struct net2280_regs {
40 // offset 0x0000 40 /* offset 0x0000 */
41 u32 devinit; 41 u32 devinit;
42#define LOCAL_CLOCK_FREQUENCY 8 42#define LOCAL_CLOCK_FREQUENCY 8
43#define FORCE_PCI_RESET 7 43#define FORCE_PCI_RESET 7
@@ -61,7 +61,7 @@ struct net2280_regs {
61#define EEPROM_WRITE_DATA 0 61#define EEPROM_WRITE_DATA 0
62 u32 eeclkfreq; 62 u32 eeclkfreq;
63 u32 _unused0; 63 u32 _unused0;
64 // offset 0x0010 64 /* offset 0x0010 */
65 65
66 u32 pciirqenb0; /* interrupt PCI master ... */ 66 u32 pciirqenb0; /* interrupt PCI master ... */
67#define SETUP_PACKET_INTERRUPT_ENABLE 7 67#define SETUP_PACKET_INTERRUPT_ENABLE 7
@@ -131,7 +131,7 @@ struct net2280_regs {
131#define RESUME_INTERRUPT_ENABLE 1 131#define RESUME_INTERRUPT_ENABLE 1
132#define SOF_INTERRUPT_ENABLE 0 132#define SOF_INTERRUPT_ENABLE 0
133 133
134 // offset 0x0020 134 /* offset 0x0020 */
135 u32 _unused1; 135 u32 _unused1;
136 u32 usbirqenb1; 136 u32 usbirqenb1;
137#define USB_INTERRUPT_ENABLE 31 137#define USB_INTERRUPT_ENABLE 31
@@ -195,7 +195,7 @@ struct net2280_regs {
195#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2 195#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2
196#define RESUME_INTERRUPT 1 196#define RESUME_INTERRUPT 1
197#define SOF_INTERRUPT 0 197#define SOF_INTERRUPT 0
198 // offset 0x0030 198 /* offset 0x0030 */
199 u32 idxaddr; 199 u32 idxaddr;
200 u32 idxdata; 200 u32 idxdata;
201 u32 fifoctl; 201 u32 fifoctl;
@@ -204,7 +204,7 @@ struct net2280_regs {
204#define PCI_BASE2_SELECT 2 204#define PCI_BASE2_SELECT 2
205#define FIFO_CONFIGURATION_SELECT 0 205#define FIFO_CONFIGURATION_SELECT 0
206 u32 _unused2; 206 u32 _unused2;
207 // offset 0x0040 207 /* offset 0x0040 */
208 u32 memaddr; 208 u32 memaddr;
209#define START 28 209#define START 28
210#define DIRECTION 27 210#define DIRECTION 27
@@ -213,7 +213,7 @@ struct net2280_regs {
213 u32 memdata0; 213 u32 memdata0;
214 u32 memdata1; 214 u32 memdata1;
215 u32 _unused3; 215 u32 _unused3;
216 // offset 0x0050 216 /* offset 0x0050 */
217 u32 gpioctl; 217 u32 gpioctl;
218#define GPIO3_LED_SELECT 12 218#define GPIO3_LED_SELECT 12
219#define GPIO3_INTERRUPT_ENABLE 11 219#define GPIO3_INTERRUPT_ENABLE 11
@@ -237,7 +237,7 @@ struct net2280_regs {
237 237
238/* usb control, BAR0 + 0x0080 */ 238/* usb control, BAR0 + 0x0080 */
239struct net2280_usb_regs { 239struct net2280_usb_regs {
240 // offset 0x0080 240 /* offset 0x0080 */
241 u32 stdrsp; 241 u32 stdrsp;
242#define STALL_UNSUPPORTED_REQUESTS 31 242#define STALL_UNSUPPORTED_REQUESTS 31
243#define SET_TEST_MODE 16 243#define SET_TEST_MODE 16
@@ -275,7 +275,7 @@ struct net2280_usb_regs {
275#define PME_WAKEUP_ENABLE 2 275#define PME_WAKEUP_ENABLE 2
276#define DEVICE_REMOTE_WAKEUP_ENABLE 1 276#define DEVICE_REMOTE_WAKEUP_ENABLE 1
277#define SELF_POWERED_STATUS 0 277#define SELF_POWERED_STATUS 0
278 // offset 0x0090 278 /* offset 0x0090 */
279 u32 usbstat; 279 u32 usbstat;
280#define HIGH_SPEED 7 280#define HIGH_SPEED 7
281#define FULL_SPEED 6 281#define FULL_SPEED 6
@@ -291,7 +291,7 @@ struct net2280_usb_regs {
291#define TERMINATION_SELECT 0 291#define TERMINATION_SELECT 0
292 u32 setup0123; 292 u32 setup0123;
293 u32 setup4567; 293 u32 setup4567;
294 // offset 0x0090 294 /* offset 0x0090 */
295 u32 _unused0; 295 u32 _unused0;
296 u32 ouraddr; 296 u32 ouraddr;
297#define FORCE_IMMEDIATE 7 297#define FORCE_IMMEDIATE 7
@@ -301,7 +301,7 @@ struct net2280_usb_regs {
301 301
302/* pci control, BAR0 + 0x0100 */ 302/* pci control, BAR0 + 0x0100 */
303struct net2280_pci_regs { 303struct net2280_pci_regs {
304 // offset 0x0100 304 /* offset 0x0100 */
305 u32 pcimstctl; 305 u32 pcimstctl;
306#define PCI_ARBITER_PARK_SELECT 13 306#define PCI_ARBITER_PARK_SELECT 13
307#define PCI_MULTI LEVEL_ARBITER 12 307#define PCI_MULTI LEVEL_ARBITER 12
@@ -331,7 +331,7 @@ struct net2280_pci_regs {
331 * that can be loaded into some of these registers. 331 * that can be loaded into some of these registers.
332 */ 332 */
333struct net2280_dma_regs { /* [11.7] */ 333struct net2280_dma_regs { /* [11.7] */
334 // offset 0x0180, 0x01a0, 0x01c0, 0x01e0, 334 /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */
335 u32 dmactl; 335 u32 dmactl;
336#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25 336#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25
337#define DMA_CLEAR_COUNT_ENABLE 21 337#define DMA_CLEAR_COUNT_ENABLE 21
@@ -355,7 +355,7 @@ struct net2280_dma_regs { /* [11.7] */
355#define DMA_ABORT 1 355#define DMA_ABORT 1
356#define DMA_START 0 356#define DMA_START 0
357 u32 _unused0 [2]; 357 u32 _unused0 [2];
358 // offset 0x0190, 0x01b0, 0x01d0, 0x01f0, 358 /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
359 u32 dmacount; 359 u32 dmacount;
360#define VALID_BIT 31 360#define VALID_BIT 31
361#define DMA_DIRECTION 30 361#define DMA_DIRECTION 30
@@ -371,9 +371,9 @@ struct net2280_dma_regs { /* [11.7] */
371/* dedicated endpoint registers, BAR0 + 0x0200 */ 371/* dedicated endpoint registers, BAR0 + 0x0200 */
372 372
373struct net2280_dep_regs { /* [11.8] */ 373struct net2280_dep_regs { /* [11.8] */
374 // offset 0x0200, 0x0210, 0x220, 0x230, 0x240 374 /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */
375 u32 dep_cfg; 375 u32 dep_cfg;
376 // offset 0x0204, 0x0214, 0x224, 0x234, 0x244 376 /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
377 u32 dep_rsp; 377 u32 dep_rsp;
378 u32 _unused [2]; 378 u32 _unused [2];
379} __attribute__ ((packed)); 379} __attribute__ ((packed));
@@ -383,7 +383,7 @@ struct net2280_dep_regs { /* [11.8] */
383 * ep0 reserved for control; E and F have only 64 bytes of fifo 383 * ep0 reserved for control; E and F have only 64 bytes of fifo
384 */ 384 */
385struct net2280_ep_regs { /* [11.9] */ 385struct net2280_ep_regs { /* [11.9] */
386 // offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 386 /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */
387 u32 ep_cfg; 387 u32 ep_cfg;
388#define ENDPOINT_BYTE_COUNT 16 388#define ENDPOINT_BYTE_COUNT 16
389#define ENDPOINT_ENABLE 10 389#define ENDPOINT_ENABLE 10
@@ -435,7 +435,7 @@ struct net2280_ep_regs { /* [11.9] */
435#define DATA_PACKET_TRANSMITTED_INTERRUPT 2 435#define DATA_PACKET_TRANSMITTED_INTERRUPT 2
436#define DATA_OUT_PING_TOKEN_INTERRUPT 1 436#define DATA_OUT_PING_TOKEN_INTERRUPT 1
437#define DATA_IN_TOKEN_INTERRUPT 0 437#define DATA_IN_TOKEN_INTERRUPT 0
438 // offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 438 /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
439 u32 ep_avail; 439 u32 ep_avail;
440 u32 ep_data; 440 u32 ep_data;
441 u32 _unused0 [2]; 441 u32 _unused0 [2];
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 9897f7a818c5..e007074ebe41 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -1,4 +1,4 @@
1// include/linux/usb/otg.h 1/* USB OTG (On The Go) defines */
2 2
3/* 3/*
4 * These APIs may be used between USB controllers. USB device drivers 4 * These APIs may be used between USB controllers. USB device drivers
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 488ce128885c..21b4a1c6f585 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -20,7 +20,8 @@
20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
22 22
23#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */ 23/* The maximum number of ports one device can grab at once */
24#define MAX_NUM_PORTS 8
24 25
25/* parity check flag */ 26/* parity check flag */
26#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 27#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
@@ -61,29 +62,29 @@
61 * ports of a device. 62 * ports of a device.
62 */ 63 */
63struct usb_serial_port { 64struct usb_serial_port {
64 struct usb_serial * serial; 65 struct usb_serial *serial;
65 struct tty_struct * tty; 66 struct tty_struct *tty;
66 spinlock_t lock; 67 spinlock_t lock;
67 struct mutex mutex; 68 struct mutex mutex;
68 unsigned char number; 69 unsigned char number;
69 70
70 unsigned char * interrupt_in_buffer; 71 unsigned char *interrupt_in_buffer;
71 struct urb * interrupt_in_urb; 72 struct urb *interrupt_in_urb;
72 __u8 interrupt_in_endpointAddress; 73 __u8 interrupt_in_endpointAddress;
73 74
74 unsigned char * interrupt_out_buffer; 75 unsigned char *interrupt_out_buffer;
75 int interrupt_out_size; 76 int interrupt_out_size;
76 struct urb * interrupt_out_urb; 77 struct urb *interrupt_out_urb;
77 __u8 interrupt_out_endpointAddress; 78 __u8 interrupt_out_endpointAddress;
78 79
79 unsigned char * bulk_in_buffer; 80 unsigned char *bulk_in_buffer;
80 int bulk_in_size; 81 int bulk_in_size;
81 struct urb * read_urb; 82 struct urb *read_urb;
82 __u8 bulk_in_endpointAddress; 83 __u8 bulk_in_endpointAddress;
83 84
84 unsigned char * bulk_out_buffer; 85 unsigned char *bulk_out_buffer;
85 int bulk_out_size; 86 int bulk_out_size;
86 struct urb * write_urb; 87 struct urb *write_urb;
87 int write_urb_busy; 88 int write_urb_busy;
88 __u8 bulk_out_endpointAddress; 89 __u8 bulk_out_endpointAddress;
89 90
@@ -92,17 +93,19 @@ struct usb_serial_port {
92 int open_count; 93 int open_count;
93 char throttled; 94 char throttled;
94 char throttle_req; 95 char throttle_req;
96 char console;
95 struct device dev; 97 struct device dev;
96}; 98};
97#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) 99#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
98 100
99/* get and set the port private data pointer helper functions */ 101/* get and set the port private data pointer helper functions */
100static inline void *usb_get_serial_port_data (struct usb_serial_port *port) 102static inline void *usb_get_serial_port_data(struct usb_serial_port *port)
101{ 103{
102 return dev_get_drvdata(&port->dev); 104 return dev_get_drvdata(&port->dev);
103} 105}
104 106
105static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data) 107static inline void usb_set_serial_port_data(struct usb_serial_port *port,
108 void *data)
106{ 109{
107 dev_set_drvdata(&port->dev, data); 110 dev_set_drvdata(&port->dev, data);
108} 111}
@@ -125,9 +128,10 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void
125 * usb_set_serial_data() to access this. 128 * usb_set_serial_data() to access this.
126 */ 129 */
127struct usb_serial { 130struct usb_serial {
128 struct usb_device * dev; 131 struct usb_device *dev;
129 struct usb_serial_driver * type; 132 struct usb_serial_driver *type;
130 struct usb_interface * interface; 133 struct usb_interface *interface;
134 unsigned char disconnected;
131 unsigned char minor; 135 unsigned char minor;
132 unsigned char num_ports; 136 unsigned char num_ports;
133 unsigned char num_port_pointers; 137 unsigned char num_port_pointers;
@@ -135,29 +139,30 @@ struct usb_serial {
135 char num_interrupt_out; 139 char num_interrupt_out;
136 char num_bulk_in; 140 char num_bulk_in;
137 char num_bulk_out; 141 char num_bulk_out;
138 struct usb_serial_port * port[MAX_NUM_PORTS]; 142 struct usb_serial_port *port[MAX_NUM_PORTS];
139 struct kref kref; 143 struct kref kref;
140 void * private; 144 struct mutex disc_mutex;
145 void *private;
141}; 146};
142#define to_usb_serial(d) container_of(d, struct usb_serial, kref) 147#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
143 148
144#define NUM_DONT_CARE 99 149#define NUM_DONT_CARE 99
145 150
146/* get and set the serial private data pointer helper functions */ 151/* get and set the serial private data pointer helper functions */
147static inline void *usb_get_serial_data (struct usb_serial *serial) 152static inline void *usb_get_serial_data(struct usb_serial *serial)
148{ 153{
149 return serial->private; 154 return serial->private;
150} 155}
151 156
152static inline void usb_set_serial_data (struct usb_serial *serial, void *data) 157static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
153{ 158{
154 serial->private = data; 159 serial->private = data;
155} 160}
156 161
157/** 162/**
158 * usb_serial_driver - describes a usb serial driver 163 * usb_serial_driver - describes a usb serial driver
159 * @description: pointer to a string that describes this driver. This string used 164 * @description: pointer to a string that describes this driver. This string
160 * in the syslog messages when a device is inserted or removed. 165 * used in the syslog messages when a device is inserted or removed.
161 * @id_table: pointer to a list of usb_device_id structures that define all 166 * @id_table: pointer to a list of usb_device_id structures that define all
162 * of the devices this structure can support. 167 * of the devices this structure can support.
163 * @num_interrupt_in: If a device doesn't have this many interrupt-in 168 * @num_interrupt_in: If a device doesn't have this many interrupt-in
@@ -218,82 +223,91 @@ struct usb_serial_driver {
218 struct usb_driver *usb_driver; 223 struct usb_driver *usb_driver;
219 struct usb_dynids dynids; 224 struct usb_dynids dynids;
220 225
221 int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); 226 int (*probe)(struct usb_serial *serial, const struct usb_device_id *id);
222 int (*attach) (struct usb_serial *serial); 227 int (*attach)(struct usb_serial *serial);
223 int (*calc_num_ports) (struct usb_serial *serial); 228 int (*calc_num_ports) (struct usb_serial *serial);
224 229
225 void (*shutdown) (struct usb_serial *serial); 230 void (*shutdown)(struct usb_serial *serial);
226 231
227 int (*port_probe) (struct usb_serial_port *port); 232 int (*port_probe)(struct usb_serial_port *port);
228 int (*port_remove) (struct usb_serial_port *port); 233 int (*port_remove)(struct usb_serial_port *port);
229 234
230 int (*suspend) (struct usb_serial *serial, pm_message_t message); 235 int (*suspend)(struct usb_serial *serial, pm_message_t message);
231 int (*resume) (struct usb_serial *serial); 236 int (*resume)(struct usb_serial *serial);
232 237
233 /* serial function calls */ 238 /* serial function calls */
234 int (*open) (struct usb_serial_port *port, struct file * filp); 239 int (*open)(struct usb_serial_port *port, struct file *filp);
235 void (*close) (struct usb_serial_port *port, struct file * filp); 240 void (*close)(struct usb_serial_port *port, struct file *filp);
236 int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count); 241 int (*write)(struct usb_serial_port *port, const unsigned char *buf,
237 int (*write_room) (struct usb_serial_port *port); 242 int count);
238 int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 243 int (*write_room)(struct usb_serial_port *port);
239 void (*set_termios) (struct usb_serial_port *port, struct ktermios * old); 244 int (*ioctl)(struct usb_serial_port *port, struct file *file,
240 void (*break_ctl) (struct usb_serial_port *port, int break_state); 245 unsigned int cmd, unsigned long arg);
241 int (*chars_in_buffer) (struct usb_serial_port *port); 246 void (*set_termios)(struct usb_serial_port *port, struct ktermios *old);
242 void (*throttle) (struct usb_serial_port *port); 247 void (*break_ctl)(struct usb_serial_port *port, int break_state);
243 void (*unthrottle) (struct usb_serial_port *port); 248 int (*chars_in_buffer)(struct usb_serial_port *port);
244 int (*tiocmget) (struct usb_serial_port *port, struct file *file); 249 void (*throttle)(struct usb_serial_port *port);
245 int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 250 void (*unthrottle)(struct usb_serial_port *port);
251 int (*tiocmget)(struct usb_serial_port *port, struct file *file);
252 int (*tiocmset)(struct usb_serial_port *port, struct file *file,
253 unsigned int set, unsigned int clear);
246 254
247 void (*read_int_callback)(struct urb *urb); 255 void (*read_int_callback)(struct urb *urb);
248 void (*write_int_callback)(struct urb *urb); 256 void (*write_int_callback)(struct urb *urb);
249 void (*read_bulk_callback)(struct urb *urb); 257 void (*read_bulk_callback)(struct urb *urb);
250 void (*write_bulk_callback)(struct urb *urb); 258 void (*write_bulk_callback)(struct urb *urb);
251}; 259};
252#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver) 260#define to_usb_serial_driver(d) \
261 container_of(d, struct usb_serial_driver, driver)
253 262
254extern int usb_serial_register(struct usb_serial_driver *driver); 263extern int usb_serial_register(struct usb_serial_driver *driver);
255extern void usb_serial_deregister(struct usb_serial_driver *driver); 264extern void usb_serial_deregister(struct usb_serial_driver *driver);
256extern void usb_serial_port_softint(struct usb_serial_port *port); 265extern void usb_serial_port_softint(struct usb_serial_port *port);
257 266
258extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 267extern int usb_serial_probe(struct usb_interface *iface,
268 const struct usb_device_id *id);
259extern void usb_serial_disconnect(struct usb_interface *iface); 269extern void usb_serial_disconnect(struct usb_interface *iface);
260 270
261extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 271extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
262extern int usb_serial_resume(struct usb_interface *intf); 272extern int usb_serial_resume(struct usb_interface *intf);
263 273
264extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); 274extern int ezusb_writememory(struct usb_serial *serial, int address,
265extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); 275 unsigned char *data, int length, __u8 bRequest);
276extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit);
266 277
267/* USB Serial console functions */ 278/* USB Serial console functions */
268#ifdef CONFIG_USB_SERIAL_CONSOLE 279#ifdef CONFIG_USB_SERIAL_CONSOLE
269extern void usb_serial_console_init (int debug, int minor); 280extern void usb_serial_console_init(int debug, int minor);
270extern void usb_serial_console_exit (void); 281extern void usb_serial_console_exit(void);
271extern void usb_serial_console_disconnect(struct usb_serial *serial); 282extern void usb_serial_console_disconnect(struct usb_serial *serial);
272#else 283#else
273static inline void usb_serial_console_init (int debug, int minor) { } 284static inline void usb_serial_console_init(int debug, int minor) { }
274static inline void usb_serial_console_exit (void) { } 285static inline void usb_serial_console_exit(void) { }
275static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} 286static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
276#endif 287#endif
277 288
278/* Functions needed by other parts of the usbserial core */ 289/* Functions needed by other parts of the usbserial core */
279extern struct usb_serial *usb_serial_get_by_index (unsigned int minor); 290extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
280extern void usb_serial_put(struct usb_serial *serial); 291extern void usb_serial_put(struct usb_serial *serial);
281extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); 292extern int usb_serial_generic_open(struct usb_serial_port *port,
282extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); 293 struct file *filp);
283extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); 294extern int usb_serial_generic_write(struct usb_serial_port *port,
284extern int usb_serial_generic_resume (struct usb_serial *serial); 295 const unsigned char *buf, int count);
285extern int usb_serial_generic_write_room (struct usb_serial_port *port); 296extern void usb_serial_generic_close(struct usb_serial_port *port,
286extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); 297 struct file *filp);
287extern void usb_serial_generic_read_bulk_callback (struct urb *urb); 298extern int usb_serial_generic_resume(struct usb_serial *serial);
288extern void usb_serial_generic_write_bulk_callback (struct urb *urb); 299extern int usb_serial_generic_write_room(struct usb_serial_port *port);
289extern void usb_serial_generic_throttle (struct usb_serial_port *port); 300extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port);
290extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); 301extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
291extern void usb_serial_generic_shutdown (struct usb_serial *serial); 302extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
292extern int usb_serial_generic_register (int debug); 303extern void usb_serial_generic_throttle(struct usb_serial_port *port);
293extern void usb_serial_generic_deregister (void); 304extern void usb_serial_generic_unthrottle(struct usb_serial_port *port);
294 305extern void usb_serial_generic_shutdown(struct usb_serial *serial);
295extern int usb_serial_bus_register (struct usb_serial_driver *device); 306extern int usb_serial_generic_register(int debug);
296extern void usb_serial_bus_deregister (struct usb_serial_driver *device); 307extern void usb_serial_generic_deregister(void);
308
309extern int usb_serial_bus_register(struct usb_serial_driver *device);
310extern void usb_serial_bus_deregister(struct usb_serial_driver *device);
297 311
298extern struct usb_serial_driver usb_serial_generic_device; 312extern struct usb_serial_driver usb_serial_generic_device;
299extern struct bus_type usb_serial_bus_type; 313extern struct bus_type usb_serial_bus_type;
@@ -307,16 +321,22 @@ static inline void usb_serial_debug_data(int debug,
307 int i; 321 int i;
308 322
309 if (debug) { 323 if (debug) {
310 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size); 324 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ",
325 function, size);
311 for (i = 0; i < size; ++i) 326 for (i = 0; i < size; ++i)
312 printk ("%.2x ", data[i]); 327 printk("%.2x ", data[i]);
313 printk ("\n"); 328 printk("\n");
314 } 329 }
315} 330}
316 331
317/* Use our own dbg macro */ 332/* Use our own dbg macro */
318#undef dbg 333#undef dbg
319#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0) 334#define dbg(format, arg...) \
335 do { \
336 if (debug) \
337 printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \
338 ## arg); \
339 } while (0)
320 340
321 341
322 342
diff --git a/include/linux/usb/sl811.h b/include/linux/usb/sl811.h
index 397ee3b3d7f3..877373da410d 100644
--- a/include/linux/usb/sl811.h
+++ b/include/linux/usb/sl811.h
@@ -19,8 +19,8 @@ struct sl811_platform_data {
19 /* pulse sl811 nRST (probably with a GPIO) */ 19 /* pulse sl811 nRST (probably with a GPIO) */
20 void (*reset)(struct device *dev); 20 void (*reset)(struct device *dev);
21 21
22 // some boards need something like these: 22 /* some boards need something like these: */
23 // int (*check_overcurrent)(struct device *dev); 23 /* int (*check_overcurrent)(struct device *dev); */
24 // void (*clock_enable)(struct device *dev, int is_on); 24 /* void (*clock_enable)(struct device *dev, int is_on); */
25}; 25};
26 26
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index a417b09b8b3d..cee0623b3c7b 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -80,10 +80,9 @@ enum { US_DO_ALL_FLAGS };
80#define US_SC_UFI 0x04 /* Floppy */ 80#define US_SC_UFI 0x04 /* Floppy */
81#define US_SC_8070 0x05 /* Removable media */ 81#define US_SC_8070 0x05 /* Removable media */
82#define US_SC_SCSI 0x06 /* Transparent */ 82#define US_SC_SCSI 0x06 /* Transparent */
83#define US_SC_ISD200 0x07 /* ISD200 ATA */ 83#define US_SC_LOCKABLE 0x07 /* Password-protected */
84#define US_SC_MIN US_SC_RBC
85#define US_SC_MAX US_SC_ISD200
86 84
85#define US_SC_ISD200 0xf0 /* ISD200 ATA */
87#define US_SC_DEVICE 0xff /* Use device's value */ 86#define US_SC_DEVICE 0xff /* Use device's value */
88 87
89/* Protocols */ 88/* Protocols */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 8ca5a7fbc9ec..17cb108b7db0 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -104,7 +104,7 @@ struct usbdevfs_urb {
104 int error_count; 104 int error_count;
105 unsigned int signr; /* signal to be sent on completion, 105 unsigned int signr; /* signal to be sent on completion,
106 or 0 if none should be sent. */ 106 or 0 if none should be sent. */
107 void *usercontext; 107 void __user *usercontext;
108 struct usbdevfs_iso_packet_desc iso_frame_desc[0]; 108 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
109}; 109};
110 110