Bug
        
                          [В начало]
Ошибка # 46
Показать/спрятать трассу ошибок|            Error trace     
         {    95     struct kernel_symbol {   unsigned long value;   const char *name; } ;    33     struct module ;    19     typedef signed char __s8;    20     typedef unsigned char __u8;    22     typedef short __s16;    23     typedef unsigned short __u16;    25     typedef int __s32;    26     typedef unsigned int __u32;    30     typedef unsigned long long __u64;    16     typedef unsigned char u8;    18     typedef short s16;    19     typedef unsigned short u16;    21     typedef int s32;    22     typedef unsigned int u32;    24     typedef long long s64;    25     typedef unsigned long long u64;    14     typedef long __kernel_long_t;    15     typedef unsigned long __kernel_ulong_t;    27     typedef int __kernel_pid_t;    48     typedef unsigned int __kernel_uid32_t;    49     typedef unsigned int __kernel_gid32_t;    71     typedef __kernel_ulong_t __kernel_size_t;    72     typedef __kernel_long_t __kernel_ssize_t;    87     typedef long long __kernel_loff_t;    88     typedef __kernel_long_t __kernel_time_t;    89     typedef __kernel_long_t __kernel_clock_t;    90     typedef int __kernel_timer_t;    91     typedef int __kernel_clockid_t;    32     typedef __u16 __le16;    34     typedef __u32 __le32;    12     typedef __u32 __kernel_dev_t;    15     typedef __kernel_dev_t dev_t;    18     typedef unsigned short umode_t;    21     typedef __kernel_pid_t pid_t;    26     typedef __kernel_clockid_t clockid_t;    29     typedef _Bool bool;    31     typedef __kernel_uid32_t uid_t;    32     typedef __kernel_gid32_t gid_t;    45     typedef __kernel_loff_t loff_t;    54     typedef __kernel_size_t size_t;    59     typedef __kernel_ssize_t ssize_t;    69     typedef __kernel_time_t time_t;   102     typedef __s32 int32_t;   108     typedef __u32 uint32_t;   133     typedef unsigned long sector_t;   134     typedef unsigned long blkcnt_t;   147     typedef u64 dma_addr_t;   158     typedef unsigned int gfp_t;   159     typedef unsigned int fmode_t;   160     typedef unsigned int oom_flags_t;   178     struct __anonstruct_atomic_t_6 {   int counter; } ;   178     typedef struct __anonstruct_atomic_t_6 atomic_t;   183     struct __anonstruct_atomic64_t_7 {   long counter; } ;   183     typedef struct __anonstruct_atomic64_t_7 atomic64_t;   184     struct list_head {   struct list_head *next;   struct list_head *prev; } ;   189     struct hlist_node ;   189     struct hlist_head {   struct hlist_node *first; } ;   193     struct hlist_node {   struct hlist_node *next;   struct hlist_node **pprev; } ;   204     struct callback_head {   struct callback_head *next;   void (*func)(struct callback_head *); } ;    65     struct pt_regs {   unsigned long r15;   unsigned long r14;   unsigned long r13;   unsigned long r12;   unsigned long bp;   unsigned long bx;   unsigned long r11;   unsigned long r10;   unsigned long r9;   unsigned long r8;   unsigned long ax;   unsigned long cx;   unsigned long dx;   unsigned long si;   unsigned long di;   unsigned long orig_ax;   unsigned long ip;   unsigned long cs;   unsigned long flags;   unsigned long sp;   unsigned long ss; } ;    59     struct __anonstruct_ldv_1016_9 {   unsigned int a;   unsigned int b; } ;    59     struct __anonstruct_ldv_1031_10 {   u16 limit0;   u16 base0;   unsigned char base1;   unsigned char type;   unsigned char s;   unsigned char dpl;   unsigned char p;   unsigned char limit;   unsigned char avl;   unsigned char l;   unsigned char d;   unsigned char g;   unsigned char base2; } ;    59     union __anonunion_ldv_1032_8 {   struct __anonstruct_ldv_1016_9 ldv_1016;   struct __anonstruct_ldv_1031_10 ldv_1031; } ;    59     struct desc_struct {   union __anonunion_ldv_1032_8 ldv_1032; } ;    15     typedef unsigned long pgdval_t;    16     typedef unsigned long pgprotval_t;    20     struct pgprot {   pgprotval_t pgprot; } ;   242     typedef struct pgprot pgprot_t;   244     struct __anonstruct_pgd_t_12 {   pgdval_t pgd; } ;   244     typedef struct __anonstruct_pgd_t_12 pgd_t;   332     struct page ;   332     typedef struct page *pgtable_t;   340     struct file ;   353     struct seq_file ;   390     struct thread_struct ;   392     struct mm_struct ;   393     struct task_struct ;   394     struct cpumask ;   327     struct arch_spinlock ;    18     typedef u16 __ticket_t;    19     typedef u32 __ticketpair_t;    20     struct __raw_tickets {   __ticket_t head;   __ticket_t tail; } ;    32     union __anonunion_ldv_1452_15 {   __ticketpair_t head_tail;   struct __raw_tickets tickets; } ;    32     struct arch_spinlock {   union __anonunion_ldv_1452_15 ldv_1452; } ;    33     typedef struct arch_spinlock arch_spinlock_t;    34     struct qrwlock {   atomic_t cnts;   arch_spinlock_t lock; } ;    14     typedef struct qrwlock arch_rwlock_t;   142     typedef void (*ctor_fn_t)();    48     struct device ;   400     struct file_operations ;   412     struct completion ;   416     struct pid ;   527     struct bug_entry {   int bug_addr_disp;   int file_disp;   unsigned short line;   unsigned short flags; } ;   102     struct timespec ;   127     struct kernel_vm86_regs {   struct pt_regs pt;   unsigned short es;   unsigned short __esh;   unsigned short ds;   unsigned short __dsh;   unsigned short fs;   unsigned short __fsh;   unsigned short gs;   unsigned short __gsh; } ;    79     union __anonunion_ldv_3000_20 {   struct pt_regs *regs;   struct kernel_vm86_regs *vm86; } ;    79     struct math_emu_info {   long ___orig_eip;   union __anonunion_ldv_3000_20 ldv_3000; } ;   306     struct cpumask {   unsigned long bits[128U]; } ;    14     typedef struct cpumask cpumask_t;   671     typedef struct cpumask *cpumask_var_t;   162     struct seq_operations ;   294     struct i387_fsave_struct {   u32 cwd;   u32 swd;   u32 twd;   u32 fip;   u32 fcs;   u32 foo;   u32 fos;   u32 st_space[20U];   u32 status; } ;   312     struct __anonstruct_ldv_5307_25 {   u64 rip;   u64 rdp; } ;   312     struct __anonstruct_ldv_5313_26 {   u32 fip;   u32 fcs;   u32 foo;   u32 fos; } ;   312     union __anonunion_ldv_5314_24 {   struct __anonstruct_ldv_5307_25 ldv_5307;   struct __anonstruct_ldv_5313_26 ldv_5313; } ;   312     union __anonunion_ldv_5323_27 {   u32 padding1[12U];   u32 sw_reserved[12U]; } ;   312     struct i387_fxsave_struct {   u16 cwd;   u16 swd;   u16 twd;   u16 fop;   union __anonunion_ldv_5314_24 ldv_5314;   u32 mxcsr;   u32 mxcsr_mask;   u32 st_space[32U];   u32 xmm_space[64U];   u32 padding[12U];   union __anonunion_ldv_5323_27 ldv_5323; } ;   346     struct i387_soft_struct {   u32 cwd;   u32 swd;   u32 twd;   u32 fip;   u32 fcs;   u32 foo;   u32 fos;   u32 st_space[20U];   u8 ftop;   u8 changed;   u8 lookahead;   u8 no_update;   u8 rm;   u8 alimit;   struct math_emu_info *info;   u32 entry_eip; } ;   367     struct ymmh_struct {   u32 ymmh_space[64U]; } ;   372     struct lwp_struct {   u8 reserved[128U]; } ;   377     struct bndregs_struct {   u64 bndregs[8U]; } ;   381     struct bndcsr_struct {   u64 cfg_reg_u;   u64 status_reg; } ;   386     struct xsave_hdr_struct {   u64 xstate_bv;   u64 reserved1[2U];   u64 reserved2[5U]; } ;   392     struct xsave_struct {   struct i387_fxsave_struct i387;   struct xsave_hdr_struct xsave_hdr;   struct ymmh_struct ymmh;   struct lwp_struct lwp;   struct bndregs_struct bndregs;   struct bndcsr_struct bndcsr; } ;   401     union thread_xstate {   struct i387_fsave_struct fsave;   struct i387_fxsave_struct fxsave;   struct i387_soft_struct soft;   struct xsave_struct xsave; } ;   409     struct fpu {   unsigned int last_cpu;   unsigned int has_fpu;   union thread_xstate *state; } ;   465     struct kmem_cache ;   466     struct perf_event ;   467     struct thread_struct {   struct desc_struct tls_array[3U];   unsigned long sp0;   unsigned long sp;   unsigned long usersp;   unsigned short es;   unsigned short ds;   unsigned short fsindex;   unsigned short gsindex;   unsigned long fs;   unsigned long gs;   struct perf_event *ptrace_bps[4U];   unsigned long debugreg6;   unsigned long ptrace_dr7;   unsigned long cr2;   unsigned long trap_nr;   unsigned long error_code;   struct fpu fpu;   unsigned long *io_bitmap_ptr;   unsigned long iopl;   unsigned int io_bitmap_max;   unsigned char fpu_counter; } ;    23     typedef atomic64_t atomic_long_t;    35     struct lockdep_map ;    55     struct stack_trace {   unsigned int nr_entries;   unsigned int max_entries;   unsigned long *entries;   int skip; } ;    26     struct lockdep_subclass_key {   char __one_byte; } ;    53     struct lock_class_key {   struct lockdep_subclass_key subkeys[8U]; } ;    59     struct lock_class {   struct list_head hash_entry;   struct list_head lock_entry;   struct lockdep_subclass_key *key;   unsigned int subclass;   unsigned int dep_gen_id;   unsigned long usage_mask;   struct stack_trace usage_traces[13U];   struct list_head locks_after;   struct list_head locks_before;   unsigned int version;   unsigned long ops;   const char *name;   int name_version;   unsigned long contention_point[4U];   unsigned long contending_point[4U]; } ;   144     struct lockdep_map {   struct lock_class_key *key;   struct lock_class *class_cache[2U];   const char *name;   int cpu;   unsigned long ip; } ;   205     struct held_lock {   u64 prev_chain_key;   unsigned long acquire_ip;   struct lockdep_map *instance;   struct lockdep_map *nest_lock;   u64 waittime_stamp;   u64 holdtime_stamp;   unsigned short class_idx;   unsigned char irq_context;   unsigned char trylock;   unsigned char read;   unsigned char check;   unsigned char hardirqs_off;   unsigned short references; } ;   530     struct raw_spinlock {   arch_spinlock_t raw_lock;   unsigned int magic;   unsigned int owner_cpu;   void *owner;   struct lockdep_map dep_map; } ;    32     typedef struct raw_spinlock raw_spinlock_t;    33     struct __anonstruct_ldv_6364_31 {   u8 __padding[24U];   struct lockdep_map dep_map; } ;    33     union __anonunion_ldv_6365_30 {   struct raw_spinlock rlock;   struct __anonstruct_ldv_6364_31 ldv_6364; } ;    33     struct spinlock {   union __anonunion_ldv_6365_30 ldv_6365; } ;    76     typedef struct spinlock spinlock_t;    23     struct __anonstruct_rwlock_t_32 {   arch_rwlock_t raw_lock;   unsigned int magic;   unsigned int owner_cpu;   void *owner;   struct lockdep_map dep_map; } ;    23     typedef struct __anonstruct_rwlock_t_32 rwlock_t;   412     struct seqcount {   unsigned int sequence;   struct lockdep_map dep_map; } ;    51     typedef struct seqcount seqcount_t;   433     struct timespec {   __kernel_time_t tv_sec;   long tv_nsec; } ;    83     struct user_namespace ;    22     struct __anonstruct_kuid_t_34 {   uid_t val; } ;    22     typedef struct __anonstruct_kuid_t_34 kuid_t;    27     struct __anonstruct_kgid_t_35 {   gid_t val; } ;    27     typedef struct __anonstruct_kgid_t_35 kgid_t;   127     struct kstat {   u64 ino;   dev_t dev;   umode_t mode;   unsigned int nlink;   kuid_t uid;   kgid_t gid;   dev_t rdev;   loff_t size;   struct timespec atime;   struct timespec mtime;   struct timespec ctime;   unsigned long blksize;   unsigned long long blocks; } ;    34     struct __wait_queue_head {   spinlock_t lock;   struct list_head task_list; } ;    39     typedef struct __wait_queue_head wait_queue_head_t;    98     struct __anonstruct_nodemask_t_36 {   unsigned long bits[16U]; } ;    98     typedef struct __anonstruct_nodemask_t_36 nodemask_t;   814     struct optimistic_spin_queue ;   815     struct mutex {   atomic_t count;   spinlock_t wait_lock;   struct list_head wait_list;   struct task_struct *owner;   const char *name;   void *magic;   struct lockdep_map dep_map; } ;    68     struct mutex_waiter {   struct list_head list;   struct task_struct *task;   void *magic; } ;   178     struct rw_semaphore ;   179     struct rw_semaphore {   long count;   raw_spinlock_t wait_lock;   struct list_head wait_list;   struct task_struct *owner;   struct optimistic_spin_queue *osq;   struct lockdep_map dep_map; } ;   174     struct completion {   unsigned int done;   wait_queue_head_t wait; } ;   105     struct llist_node ;    64     struct llist_node {   struct llist_node *next; } ;   323     union ktime {   s64 tv64; } ;    59     typedef union ktime ktime_t;   412     struct tvec_base ;   413     struct timer_list {   struct list_head entry;   unsigned long expires;   struct tvec_base *base;   void (*function)(unsigned long);   unsigned long data;   int slack;   int start_pid;   void *start_site;   char start_comm[16U];   struct lockdep_map lockdep_map; } ;   254     struct hrtimer ;   255     enum hrtimer_restart ;   266     struct workqueue_struct ;   267     struct work_struct ;    53     struct work_struct {   atomic_long_t data;   struct list_head entry;   void (*func)(struct work_struct *);   struct lockdep_map lockdep_map; } ;   106     struct delayed_work {   struct work_struct work;   struct timer_list timer;   struct workqueue_struct *wq;   int cpu; } ;    58     struct pm_message {   int event; } ;    64     typedef struct pm_message pm_message_t;    65     struct dev_pm_ops {   int (*prepare)(struct device *);   void (*complete)(struct device *);   int (*suspend)(struct device *);   int (*resume)(struct device *);   int (*freeze)(struct device *);   int (*thaw)(struct device *);   int (*poweroff)(struct device *);   int (*restore)(struct device *);   int (*suspend_late)(struct device *);   int (*resume_early)(struct device *);   int (*freeze_late)(struct device *);   int (*thaw_early)(struct device *);   int (*poweroff_late)(struct device *);   int (*restore_early)(struct device *);   int (*suspend_noirq)(struct device *);   int (*resume_noirq)(struct device *);   int (*freeze_noirq)(struct device *);   int (*thaw_noirq)(struct device *);   int (*poweroff_noirq)(struct device *);   int (*restore_noirq)(struct device *);   int (*runtime_suspend)(struct device *);   int (*runtime_resume)(struct device *);   int (*runtime_idle)(struct device *); } ;   320     enum rpm_status {   RPM_ACTIVE = 0,   RPM_RESUMING = 1,   RPM_SUSPENDED = 2,   RPM_SUSPENDING = 3 } ;   327     enum rpm_request {   RPM_REQ_NONE = 0,   RPM_REQ_IDLE = 1,   RPM_REQ_SUSPEND = 2,   RPM_REQ_AUTOSUSPEND = 3,   RPM_REQ_RESUME = 4 } ;   335     struct wakeup_source ;   546     struct pm_subsys_data {   spinlock_t lock;   unsigned int refcount;   struct list_head clock_list; } ;   553     struct dev_pm_qos ;   553     struct dev_pm_info {   pm_message_t power_state;   unsigned char can_wakeup;   unsigned char async_suspend;   bool is_prepared;   bool is_suspended;   bool is_noirq_suspended;   bool is_late_suspended;   bool ignore_children;   bool early_init;   bool direct_complete;   spinlock_t lock;   struct list_head entry;   struct completion completion;   struct wakeup_source *wakeup;   bool wakeup_path;   bool syscore;   struct timer_list suspend_timer;   unsigned long timer_expires;   struct work_struct work;   wait_queue_head_t wait_queue;   atomic_t usage_count;   atomic_t child_count;   unsigned char disable_depth;   unsigned char idle_notification;   unsigned char request_pending;   unsigned char deferred_resume;   unsigned char run_wake;   unsigned char runtime_auto;   unsigned char no_callbacks;   unsigned char irq_safe;   unsigned char use_autosuspend;   unsigned char timer_autosuspends;   unsigned char memalloc_noio;   enum rpm_request request;   enum rpm_status runtime_status;   int runtime_error;   int autosuspend_delay;   unsigned long last_busy;   unsigned long active_jiffies;   unsigned long suspended_jiffies;   unsigned long accounting_timestamp;   struct pm_subsys_data *subsys_data;   void (*set_latency_tolerance)(struct device *, s32 );   struct dev_pm_qos *qos; } ;   614     struct dev_pm_domain {   struct dev_pm_ops ops; } ;    22     struct __anonstruct_mm_context_t_101 {   void *ldt;   int size;   unsigned short ia32_compat;   struct mutex lock;   void *vdso; } ;    22     typedef struct __anonstruct_mm_context_t_101 mm_context_t;    18     struct rb_node {   unsigned long __rb_parent_color;   struct rb_node *rb_right;   struct rb_node *rb_left; } ;    40     struct rb_root {   struct rb_node *rb_node; } ;    87     struct vm_area_struct ;   835     struct nsproxy ;    37     struct cred ;    24     struct inode ;    58     struct arch_uprobe_task {   unsigned long saved_scratch_register;   unsigned int saved_trap_nr;   unsigned int saved_tf; } ;    66     enum uprobe_task_state {   UTASK_RUNNING = 0,   UTASK_SSTEP = 1,   UTASK_SSTEP_ACK = 2,   UTASK_SSTEP_TRAPPED = 3 } ;    73     struct __anonstruct_ldv_13972_136 {   struct arch_uprobe_task autask;   unsigned long vaddr; } ;    73     struct __anonstruct_ldv_13976_137 {   struct callback_head dup_xol_work;   unsigned long dup_xol_addr; } ;    73     union __anonunion_ldv_13977_135 {   struct __anonstruct_ldv_13972_136 ldv_13972;   struct __anonstruct_ldv_13976_137 ldv_13976; } ;    73     struct uprobe ;    73     struct return_instance ;    73     struct uprobe_task {   enum uprobe_task_state state;   union __anonunion_ldv_13977_135 ldv_13977;   struct uprobe *active_uprobe;   unsigned long xol_vaddr;   struct return_instance *return_instances;   unsigned int depth; } ;    94     struct xol_area ;    95     struct uprobes_state {   struct xol_area *xol_area; } ;   133     struct address_space ;   134     union __anonunion_ldv_14086_138 {   struct address_space *mapping;   void *s_mem; } ;   134     union __anonunion_ldv_14092_140 {   unsigned long index;   void *freelist;   bool pfmemalloc; } ;   134     struct __anonstruct_ldv_14102_144 {   unsigned short inuse;   unsigned short objects;   unsigned char frozen; } ;   134     union __anonunion_ldv_14104_143 {   atomic_t _mapcount;   struct __anonstruct_ldv_14102_144 ldv_14102;   int units; } ;   134     struct __anonstruct_ldv_14106_142 {   union __anonunion_ldv_14104_143 ldv_14104;   atomic_t _count; } ;   134     union __anonunion_ldv_14108_141 {   unsigned long counters;   struct __anonstruct_ldv_14106_142 ldv_14106;   unsigned int active; } ;   134     struct __anonstruct_ldv_14109_139 {   union __anonunion_ldv_14092_140 ldv_14092;   union __anonunion_ldv_14108_141 ldv_14108; } ;   134     struct __anonstruct_ldv_14116_146 {   struct page *next;   int pages;   int pobjects; } ;   134     struct slab ;   134     union __anonunion_ldv_14121_145 {   struct list_head lru;   struct __anonstruct_ldv_14116_146 ldv_14116;   struct slab *slab_page;   struct callback_head callback_head;   pgtable_t pmd_huge_pte; } ;   134     union __anonunion_ldv_14127_147 {   unsigned long private;   spinlock_t *ptl;   struct kmem_cache *slab_cache;   struct page *first_page; } ;   134     struct page {   unsigned long flags;   union __anonunion_ldv_14086_138 ldv_14086;   struct __anonstruct_ldv_14109_139 ldv_14109;   union __anonunion_ldv_14121_145 ldv_14121;   union __anonunion_ldv_14127_147 ldv_14127;   unsigned long debug_flags; } ;   187     struct page_frag {   struct page *page;   __u32 offset;   __u32 size; } ;   239     struct __anonstruct_linear_149 {   struct rb_node rb;   unsigned long rb_subtree_last; } ;   239     union __anonunion_shared_148 {   struct __anonstruct_linear_149 linear;   struct list_head nonlinear; } ;   239     struct anon_vma ;   239     struct vm_operations_struct ;   239     struct mempolicy ;   239     struct vm_area_struct {   unsigned long vm_start;   unsigned long vm_end;   struct vm_area_struct *vm_next;   struct vm_area_struct *vm_prev;   struct rb_node vm_rb;   unsigned long rb_subtree_gap;   struct mm_struct *vm_mm;   pgprot_t vm_page_prot;   unsigned long vm_flags;   union __anonunion_shared_148 shared;   struct list_head anon_vma_chain;   struct anon_vma *anon_vma;   const struct vm_operations_struct *vm_ops;   unsigned long vm_pgoff;   struct file *vm_file;   void *vm_private_data;   struct mempolicy *vm_policy; } ;   311     struct core_thread {   struct task_struct *task;   struct core_thread *next; } ;   317     struct core_state {   atomic_t nr_threads;   struct core_thread dumper;   struct completion startup; } ;   330     struct task_rss_stat {   int events;   int count[3U]; } ;   338     struct mm_rss_stat {   atomic_long_t count[3U]; } ;   343     struct kioctx_table ;   344     struct linux_binfmt ;   344     struct mmu_notifier_mm ;   344     struct mm_struct {   struct vm_area_struct *mmap;   struct rb_root mm_rb;   u32 vmacache_seqnum;   unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);   unsigned long mmap_base;   unsigned long mmap_legacy_base;   unsigned long task_size;   unsigned long highest_vm_end;   pgd_t *pgd;   atomic_t mm_users;   atomic_t mm_count;   atomic_long_t nr_ptes;   int map_count;   spinlock_t page_table_lock;   struct rw_semaphore mmap_sem;   struct list_head mmlist;   unsigned long hiwater_rss;   unsigned long hiwater_vm;   unsigned long total_vm;   unsigned long locked_vm;   unsigned long pinned_vm;   unsigned long shared_vm;   unsigned long exec_vm;   unsigned long stack_vm;   unsigned long def_flags;   unsigned long start_code;   unsigned long end_code;   unsigned long start_data;   unsigned long end_data;   unsigned long start_brk;   unsigned long brk;   unsigned long start_stack;   unsigned long arg_start;   unsigned long arg_end;   unsigned long env_start;   unsigned long env_end;   unsigned long saved_auxv[46U];   struct mm_rss_stat rss_stat;   struct linux_binfmt *binfmt;   cpumask_var_t cpu_vm_mask_var;   mm_context_t context;   unsigned long flags;   struct core_state *core_state;   spinlock_t ioctx_lock;   struct kioctx_table *ioctx_table;   struct task_struct *owner;   struct file *exe_file;   struct mmu_notifier_mm *mmu_notifier_mm;   struct cpumask cpumask_allocation;   unsigned long numa_next_scan;   unsigned long numa_scan_offset;   int numa_scan_seq;   bool tlb_flush_pending;   struct uprobes_state uprobes_state; } ;    15     typedef __u64 Elf64_Addr;    16     typedef __u16 Elf64_Half;    20     typedef __u32 Elf64_Word;    21     typedef __u64 Elf64_Xword;   190     struct elf64_sym {   Elf64_Word st_name;   unsigned char st_info;   unsigned char st_other;   Elf64_Half st_shndx;   Elf64_Addr st_value;   Elf64_Xword st_size; } ;   198     typedef struct elf64_sym Elf64_Sym;    48     union __anonunion_ldv_14490_153 {   unsigned long bitmap[4U];   struct callback_head callback_head; } ;    48     struct idr_layer {   int prefix;   int layer;   struct idr_layer *ary[256U];   int count;   union __anonunion_ldv_14490_153 ldv_14490; } ;    41     struct idr {   struct idr_layer *hint;   struct idr_layer *top;   int layers;   int cur;   spinlock_t lock;   int id_free_cnt;   struct idr_layer *id_free; } ;   124     struct ida_bitmap {   long nr_busy;   unsigned long bitmap[15U]; } ;   153     struct ida {   struct idr idr;   struct ida_bitmap *free_bitmap; } ;   185     struct dentry ;   186     struct iattr ;   187     struct super_block ;   188     struct file_system_type ;   189     struct kernfs_open_node ;   190     struct kernfs_iattrs ;   213     struct kernfs_root ;   213     struct kernfs_elem_dir {   unsigned long subdirs;   struct rb_root children;   struct kernfs_root *root; } ;    85     struct kernfs_node ;    85     struct kernfs_elem_symlink {   struct kernfs_node *target_kn; } ;    89     struct kernfs_ops ;    89     struct kernfs_elem_attr {   const struct kernfs_ops *ops;   struct kernfs_open_node *open;   loff_t size; } ;    95     union __anonunion_ldv_14634_154 {   struct kernfs_elem_dir dir;   struct kernfs_elem_symlink symlink;   struct kernfs_elem_attr attr; } ;    95     struct kernfs_node {   atomic_t count;   atomic_t active;   struct lockdep_map dep_map;   struct kernfs_node *parent;   const char *name;   struct rb_node rb;   const void *ns;   unsigned int hash;   union __anonunion_ldv_14634_154 ldv_14634;   void *priv;   unsigned short flags;   umode_t mode;   unsigned int ino;   struct kernfs_iattrs *iattr; } ;   137     struct kernfs_syscall_ops {   int (*remount_fs)(struct kernfs_root *, int *, char *);   int (*show_options)(struct seq_file *, struct kernfs_root *);   int (*mkdir)(struct kernfs_node *, const char *, umode_t );   int (*rmdir)(struct kernfs_node *);   int (*rename)(struct kernfs_node *, struct kernfs_node *, const char *); } ;   154     struct kernfs_root {   struct kernfs_node *kn;   unsigned int flags;   struct ida ino_ida;   struct kernfs_syscall_ops *syscall_ops;   struct list_head supers;   wait_queue_head_t deactivate_waitq; } ;   170     struct kernfs_open_file {   struct kernfs_node *kn;   struct file *file;   void *priv;   struct mutex mutex;   int event;   struct list_head list;   size_t atomic_write_len;   bool mmapped;   const struct vm_operations_struct *vm_ops; } ;   186     struct kernfs_ops {   int (*seq_show)(struct seq_file *, void *);   void * (*seq_start)(struct seq_file *, loff_t *);   void * (*seq_next)(struct seq_file *, void *, loff_t *);   void (*seq_stop)(struct seq_file *, void *);   ssize_t  (*read)(struct kernfs_open_file *, char *, size_t , loff_t );   size_t atomic_write_len;   ssize_t  (*write)(struct kernfs_open_file *, char *, size_t , loff_t );   int (*mmap)(struct kernfs_open_file *, struct vm_area_struct *);   struct lock_class_key lockdep_key; } ;   462     struct sock ;   463     struct kobject ;   464     enum kobj_ns_type {   KOBJ_NS_TYPE_NONE = 0,   KOBJ_NS_TYPE_NET = 1,   KOBJ_NS_TYPES = 2 } ;   470     struct kobj_ns_type_operations {   enum kobj_ns_type type;   bool  (*current_may_mount)();   void * (*grab_current_ns)();   const void * (*netlink_ns)(struct sock *);   const void * (*initial_ns)();   void (*drop_ns)(void *); } ;    59     struct bin_attribute ;    60     struct attribute {   const char *name;   umode_t mode;   bool ignore_lockdep;   struct lock_class_key *key;   struct lock_class_key skey; } ;    37     struct attribute_group {   const char *name;   umode_t  (*is_visible)(struct kobject *, struct attribute *, int);   struct attribute **attrs;   struct bin_attribute **bin_attrs; } ;    67     struct bin_attribute {   struct attribute attr;   size_t size;   void *private;   ssize_t  (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t );   ssize_t  (*write)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t );   int (*mmap)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *); } ;   131     struct sysfs_ops {   ssize_t  (*show)(struct kobject *, struct attribute *, char *);   ssize_t  (*store)(struct kobject *, struct attribute *, const char *, size_t ); } ;   470     struct kref {   atomic_t refcount; } ;    52     struct kset ;    52     struct kobj_type ;    52     struct kobject {   const char *name;   struct list_head entry;   struct kobject *parent;   struct kset *kset;   struct kobj_type *ktype;   struct kernfs_node *sd;   struct kref kref;   struct delayed_work release;   unsigned char state_initialized;   unsigned char state_in_sysfs;   unsigned char state_add_uevent_sent;   unsigned char state_remove_uevent_sent;   unsigned char uevent_suppress; } ;   114     struct kobj_type {   void (*release)(struct kobject *);   const struct sysfs_ops *sysfs_ops;   struct attribute **default_attrs;   const struct kobj_ns_type_operations * (*child_ns_type)(struct kobject *);   const void * (*namespace)(struct kobject *); } ;   122     struct kobj_uevent_env {   char *argv[3U];   char *envp[32U];   int envp_idx;   char buf[2048U];   int buflen; } ;   130     struct kset_uevent_ops {   const int (*filter)(struct kset *, struct kobject *);   const const char * (*name)(struct kset *, struct kobject *);   const int (*uevent)(struct kset *, struct kobject *, struct kobj_uevent_env *); } ;   147     struct kset {   struct list_head list;   spinlock_t list_lock;   struct kobject kobj;   const struct kset_uevent_ops *uevent_ops; } ;   222     struct kernel_param ;   227     struct kernel_param_ops {   unsigned int flags;   int (*set)(const char *, const struct kernel_param *);   int (*get)(char *, const struct kernel_param *);   void (*free)(void *); } ;    58     struct kparam_string ;    58     struct kparam_array ;    58     union __anonunion_ldv_15312_155 {   void *arg;   const struct kparam_string *str;   const struct kparam_array *arr; } ;    58     struct kernel_param {   const char *name;   const struct kernel_param_ops *ops;   u16 perm;   s16 level;   union __anonunion_ldv_15312_155 ldv_15312; } ;    70     struct kparam_string {   unsigned int maxlen;   char *string; } ;    76     struct kparam_array {   unsigned int max;   unsigned int elemsize;   unsigned int *num;   const struct kernel_param_ops *ops;   void *elem; } ;   461     struct mod_arch_specific { } ;    36     struct module_param_attrs ;    36     struct module_kobject {   struct kobject kobj;   struct module *mod;   struct kobject *drivers_dir;   struct module_param_attrs *mp;   struct completion *kobj_completion; } ;    46     struct module_attribute {   struct attribute attr;   ssize_t  (*show)(struct module_attribute *, struct module_kobject *, char *);   ssize_t  (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t );   void (*setup)(struct module *, const char *);   int (*test)(struct module *);   void (*free)(struct module *); } ;    72     struct exception_table_entry ;   205     enum module_state {   MODULE_STATE_LIVE = 0,   MODULE_STATE_COMING = 1,   MODULE_STATE_GOING = 2,   MODULE_STATE_UNFORMED = 3 } ;   212     struct module_ref {   unsigned long incs;   unsigned long decs; } ;   226     struct module_sect_attrs ;   226     struct module_notes_attrs ;   226     struct tracepoint ;   226     struct ftrace_event_call ;   226     struct module {   enum module_state state;   struct list_head list;   char name[56U];   struct module_kobject mkobj;   struct module_attribute *modinfo_attrs;   const char *version;   const char *srcversion;   struct kobject *holders_dir;   const struct kernel_symbol *syms;   const unsigned long *crcs;   unsigned int num_syms;   struct kernel_param *kp;   unsigned int num_kp;   unsigned int num_gpl_syms;   const struct kernel_symbol *gpl_syms;   const unsigned long *gpl_crcs;   const struct kernel_symbol *unused_syms;   const unsigned long *unused_crcs;   unsigned int num_unused_syms;   unsigned int num_unused_gpl_syms;   const struct kernel_symbol *unused_gpl_syms;   const unsigned long *unused_gpl_crcs;   bool sig_ok;   const struct kernel_symbol *gpl_future_syms;   const unsigned long *gpl_future_crcs;   unsigned int num_gpl_future_syms;   unsigned int num_exentries;   struct exception_table_entry *extable;   int (*init)();   void *module_init;   void *module_core;   unsigned int init_size;   unsigned int core_size;   unsigned int init_text_size;   unsigned int core_text_size;   unsigned int init_ro_size;   unsigned int core_ro_size;   struct mod_arch_specific arch;   unsigned int taints;   unsigned int num_bugs;   struct list_head bug_list;   struct bug_entry *bug_table;   Elf64_Sym *symtab;   Elf64_Sym *core_symtab;   unsigned int num_symtab;   unsigned int core_num_syms;   char *strtab;   char *core_strtab;   struct module_sect_attrs *sect_attrs;   struct module_notes_attrs *notes_attrs;   char *args;   void *percpu;   unsigned int percpu_size;   unsigned int num_tracepoints;   const struct tracepoint **tracepoints_ptrs;   unsigned int num_trace_bprintk_fmt;   const char **trace_bprintk_fmt_start;   struct ftrace_event_call **trace_events;   unsigned int num_trace_events;   struct list_head source_list;   struct list_head target_list;   void (*exit)();   struct module_ref *refptr;   ctor_fn_t  (**ctors)();   unsigned int num_ctors; } ;    13     typedef unsigned long kernel_ulong_t;   186     struct acpi_device_id {   __u8 id[9U];   kernel_ulong_t driver_data; } ;   219     struct of_device_id {   char name[32U];   char type[32U];   char compatible[128U];   const void *data; } ;   253     struct usb_device_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __le16 bcdUSB;   __u8 bDeviceClass;   __u8 bDeviceSubClass;   __u8 bDeviceProtocol;   __u8 bMaxPacketSize0;   __le16 idVendor;   __le16 idProduct;   __le16 bcdDevice;   __u8 iManufacturer;   __u8 iProduct;   __u8 iSerialNumber;   __u8 bNumConfigurations; } ;   275     struct usb_config_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __le16 wTotalLength;   __u8 bNumInterfaces;   __u8 bConfigurationValue;   __u8 iConfiguration;   __u8 bmAttributes;   __u8 bMaxPower; } ;   343     struct usb_interface_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bInterfaceNumber;   __u8 bAlternateSetting;   __u8 bNumEndpoints;   __u8 bInterfaceClass;   __u8 bInterfaceSubClass;   __u8 bInterfaceProtocol;   __u8 iInterface; } ;   363     struct usb_endpoint_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bEndpointAddress;   __u8 bmAttributes;   __le16 wMaxPacketSize;   __u8 bInterval;   __u8 bRefresh;   __u8 bSynchAddress; } ;   613     struct usb_ss_ep_comp_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bMaxBurst;   __u8 bmAttributes;   __le16 wBytesPerInterval; } ;   692     struct usb_interface_assoc_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bFirstInterface;   __u8 bInterfaceCount;   __u8 bFunctionClass;   __u8 bFunctionSubClass;   __u8 bFunctionProtocol;   __u8 iFunction; } ;   751     struct usb_bos_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __le16 wTotalLength;   __u8 bNumDeviceCaps; } ;   801     struct usb_ext_cap_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bDevCapabilityType;   __le32 bmAttributes; } ;   811     struct usb_ss_cap_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bDevCapabilityType;   __u8 bmAttributes;   __le16 wSpeedSupported;   __u8 bFunctionalitySupport;   __u8 bU1devExitLat;   __le16 bU2DevExitLat; } ;   840     struct usb_ss_container_id_descriptor {   __u8 bLength;   __u8 bDescriptorType;   __u8 bDevCapabilityType;   __u8 bReserved;   __u8 ContainerID[16U]; } ;   905     enum usb_device_speed {   USB_SPEED_UNKNOWN = 0,   USB_SPEED_LOW = 1,   USB_SPEED_FULL = 2,   USB_SPEED_HIGH = 3,   USB_SPEED_WIRELESS = 4,   USB_SPEED_SUPER = 5 } ;   914     enum usb_device_state {   USB_STATE_NOTATTACHED = 0,   USB_STATE_ATTACHED = 1,   USB_STATE_POWERED = 2,   USB_STATE_RECONNECTING = 3,   USB_STATE_UNAUTHENTICATED = 4,   USB_STATE_DEFAULT = 5,   USB_STATE_ADDRESS = 6,   USB_STATE_CONFIGURED = 7,   USB_STATE_SUSPENDED = 8 } ;   359     struct proc_dir_entry ;    62     struct exception_table_entry {   int insn;   int fixup; } ;    61     struct timerqueue_node {   struct rb_node node;   ktime_t expires; } ;    12     struct timerqueue_head {   struct rb_root head;   struct timerqueue_node *next; } ;    50     struct hrtimer_clock_base ;    51     struct hrtimer_cpu_base ;    60     enum hrtimer_restart {   HRTIMER_NORESTART = 0,   HRTIMER_RESTART = 1 } ;    65     struct hrtimer {   struct timerqueue_node node;   ktime_t _softexpires;   enum hrtimer_restart  (*function)(struct hrtimer *);   struct hrtimer_clock_base *base;   unsigned long state;   int start_pid;   void *start_site;   char start_comm[16U]; } ;   132     struct hrtimer_clock_base {   struct hrtimer_cpu_base *cpu_base;   int index;   clockid_t clockid;   struct timerqueue_head active;   ktime_t resolution;   ktime_t  (*get_time)();   ktime_t softirq_time;   ktime_t offset; } ;   163     struct hrtimer_cpu_base {   raw_spinlock_t lock;   unsigned int active_bases;   unsigned int clock_was_set;   ktime_t expires_next;   int hres_active;   int hang_detected;   unsigned long nr_events;   unsigned long nr_retries;   unsigned long nr_hangs;   ktime_t max_hang_time;   struct hrtimer_clock_base clock_base[4U]; } ;   663     struct klist_node ;    37     struct klist_node {   void *n_klist;   struct list_head n_node;   struct kref n_ref; } ;    67     struct path ;    68     struct seq_file {   char *buf;   size_t size;   size_t from;   size_t count;   size_t pad_until;   loff_t index;   loff_t read_pos;   u64 version;   struct mutex lock;   const struct seq_operations *op;   int poll_event;   struct user_namespace *user_ns;   void *private; } ;    35     struct seq_operations {   void * (*start)(struct seq_file *, loff_t *);   void (*stop)(struct seq_file *, void *);   void * (*next)(struct seq_file *, void *, loff_t *);   int (*show)(struct seq_file *, void *); } ;   196     struct pinctrl ;   197     struct pinctrl_state ;   194     struct dev_pin_info {   struct pinctrl *p;   struct pinctrl_state *default_state;   struct pinctrl_state *sleep_state;   struct pinctrl_state *idle_state; } ;    42     struct dma_map_ops ;    42     struct dev_archdata {   struct dma_map_ops *dma_ops;   void *iommu; } ;    14     struct device_private ;    15     struct device_driver ;    16     struct driver_private ;    17     struct class ;    18     struct subsys_private ;    19     struct bus_type ;    20     struct device_node ;    21     struct iommu_ops ;    22     struct iommu_group ;    60     struct device_attribute ;    60     struct bus_type {   const char *name;   const char *dev_name;   struct device *dev_root;   struct device_attribute *dev_attrs;   const struct attribute_group **bus_groups;   const struct attribute_group **dev_groups;   const struct attribute_group **drv_groups;   int (*match)(struct device *, struct device_driver *);   int (*uevent)(struct device *, struct kobj_uevent_env *);   int (*probe)(struct device *);   int (*remove)(struct device *);   void (*shutdown)(struct device *);   int (*online)(struct device *);   int (*offline)(struct device *);   int (*suspend)(struct device *, pm_message_t );   int (*resume)(struct device *);   const struct dev_pm_ops *pm;   struct iommu_ops *iommu_ops;   struct subsys_private *p;   struct lock_class_key lock_key; } ;   138     struct device_type ;   195     struct device_driver {   const char *name;   struct bus_type *bus;   struct module *owner;   const char *mod_name;   bool suppress_bind_attrs;   const struct of_device_id *of_match_table;   const struct acpi_device_id *acpi_match_table;   int (*probe)(struct device *);   int (*remove)(struct device *);   void (*shutdown)(struct device *);   int (*suspend)(struct device *, pm_message_t );   int (*resume)(struct device *);   const struct attribute_group **groups;   const struct dev_pm_ops *pm;   struct driver_private *p; } ;   321     struct class_attribute ;   321     struct class {   const char *name;   struct module *owner;   struct class_attribute *class_attrs;   const struct attribute_group **dev_groups;   struct kobject *dev_kobj;   int (*dev_uevent)(struct device *, struct kobj_uevent_env *);   char * (*devnode)(struct device *, umode_t *);   void (*class_release)(struct class *);   void (*dev_release)(struct device *);   int (*suspend)(struct device *, pm_message_t );   int (*resume)(struct device *);   const struct kobj_ns_type_operations *ns_type;   const void * (*namespace)(struct device *);   const struct dev_pm_ops *pm;   struct subsys_private *p; } ;   414     struct class_attribute {   struct attribute attr;   ssize_t  (*show)(struct class *, struct class_attribute *, char *);   ssize_t  (*store)(struct class *, struct class_attribute *, const char *, size_t ); } ;   482     struct device_type {   const char *name;   const struct attribute_group **groups;   int (*uevent)(struct device *, struct kobj_uevent_env *);   char * (*devnode)(struct device *, umode_t *, kuid_t *, kgid_t *);   void (*release)(struct device *);   const struct dev_pm_ops *pm; } ;   510     struct device_attribute {   struct attribute attr;   ssize_t  (*show)(struct device *, struct device_attribute *, char *);   ssize_t  (*store)(struct device *, struct device_attribute *, const char *, size_t ); } ;   640     struct device_dma_parameters {   unsigned int max_segment_size;   unsigned long segment_boundary_mask; } ;   649     struct acpi_device ;   650     struct acpi_dev_node {   struct acpi_device *companion; } ;   656     struct dma_coherent_mem ;   656     struct cma ;   656     struct device {   struct device *parent;   struct device_private *p;   struct kobject kobj;   const char *init_name;   const struct device_type *type;   struct mutex mutex;   struct bus_type *bus;   struct device_driver *driver;   void *platform_data;   void *driver_data;   struct dev_pm_info power;   struct dev_pm_domain *pm_domain;   struct dev_pin_info *pins;   int numa_node;   u64 *dma_mask;   u64 coherent_dma_mask;   unsigned long dma_pfn_offset;   struct device_dma_parameters *dma_parms;   struct list_head dma_pools;   struct dma_coherent_mem *dma_mem;   struct cma *cma_area;   struct dev_archdata archdata;   struct device_node *of_node;   struct acpi_dev_node acpi_node;   dev_t devt;   u32 id;   spinlock_t devres_lock;   struct list_head devres_head;   struct klist_node knode_class;   struct class *class;   const struct attribute_group **groups;   void (*release)(struct device *);   struct iommu_group *iommu_group;   bool offline_disabled;   bool offline; } ;   803     struct wakeup_source {   const char *name;   struct list_head entry;   spinlock_t lock;   struct timer_list timer;   unsigned long timer_expires;   ktime_t total_time;   ktime_t max_time;   ktime_t last_time;   ktime_t start_prevent_time;   ktime_t prevent_sleep_time;   unsigned long event_count;   unsigned long active_count;   unsigned long relax_count;   unsigned long expire_count;   unsigned long wakeup_count;   bool active;   bool autosleep_enabled; } ;    93     struct hlist_bl_node ;    93     struct hlist_bl_head {   struct hlist_bl_node *first; } ;    36     struct hlist_bl_node {   struct hlist_bl_node *next;   struct hlist_bl_node **pprev; } ;   114     struct __anonstruct_ldv_19539_162 {   spinlock_t lock;   unsigned int count; } ;   114     union __anonunion_ldv_19540_161 {   struct __anonstruct_ldv_19539_162 ldv_19539; } ;   114     struct lockref {   union __anonunion_ldv_19540_161 ldv_19540; } ;    49     struct nameidata ;    50     struct vfsmount ;    51     struct __anonstruct_ldv_19563_164 {   u32 hash;   u32 len; } ;    51     union __anonunion_ldv_19565_163 {   struct __anonstruct_ldv_19563_164 ldv_19563;   u64 hash_len; } ;    51     struct qstr {   union __anonunion_ldv_19565_163 ldv_19565;   const unsigned char *name; } ;    90     struct dentry_operations ;    90     union __anonunion_d_u_165 {   struct list_head d_child;   struct callback_head d_rcu; } ;    90     struct dentry {   unsigned int d_flags;   seqcount_t d_seq;   struct hlist_bl_node d_hash;   struct dentry *d_parent;   struct qstr d_name;   struct inode *d_inode;   unsigned char d_iname[32U];   struct lockref d_lockref;   const struct dentry_operations *d_op;   struct super_block *d_sb;   unsigned long d_time;   void *d_fsdata;   struct list_head d_lru;   union __anonunion_d_u_165 d_u;   struct list_head d_subdirs;   struct hlist_node d_alias; } ;   142     struct dentry_operations {   int (*d_revalidate)(struct dentry *, unsigned int);   int (*d_weak_revalidate)(struct dentry *, unsigned int);   int (*d_hash)(const struct dentry *, struct qstr *);   int (*d_compare)(const struct dentry *, const struct dentry *, unsigned int, const char *, const struct qstr *);   int (*d_delete)(const struct dentry *);   void (*d_release)(struct dentry *);   void (*d_prune)(struct dentry *);   void (*d_iput)(struct dentry *, struct inode *);   char * (*d_dname)(struct dentry *, char *, int);   struct vfsmount * (*d_automount)(struct path *);   int (*d_manage)(struct dentry *, bool ); } ;   477     struct path {   struct vfsmount *mnt;   struct dentry *dentry; } ;    27     struct list_lru_node {   spinlock_t lock;   struct list_head list;   long nr_items; } ;    30     struct list_lru {   struct list_lru_node *node;   nodemask_t active_nodes; } ;    58     struct __anonstruct_ldv_19926_167 {   struct radix_tree_node *parent;   void *private_data; } ;    58     union __anonunion_ldv_19928_166 {   struct __anonstruct_ldv_19926_167 ldv_19926;   struct callback_head callback_head; } ;    58     struct radix_tree_node {   unsigned int path;   unsigned int count;   union __anonunion_ldv_19928_166 ldv_19928;   struct list_head private_list;   void *slots[64U];   unsigned long tags[3U][1U]; } ;   105     struct radix_tree_root {   unsigned int height;   gfp_t gfp_mask;   struct radix_tree_node *rnode; } ;   428     enum pid_type {   PIDTYPE_PID = 0,   PIDTYPE_PGID = 1,   PIDTYPE_SID = 2,   PIDTYPE_MAX = 3 } ;   435     struct pid_namespace ;   435     struct upid {   int nr;   struct pid_namespace *ns;   struct hlist_node pid_chain; } ;    56     struct pid {   atomic_t count;   unsigned int level;   struct hlist_head tasks[3U];   struct callback_head rcu;   struct upid numbers[1U]; } ;    68     struct pid_link {   struct hlist_node node;   struct pid *pid; } ;    22     struct kernel_cap_struct {   __u32 cap[2U]; } ;    25     typedef struct kernel_cap_struct kernel_cap_t;    45     struct fiemap_extent {   __u64 fe_logical;   __u64 fe_physical;   __u64 fe_length;   __u64 fe_reserved64[2U];   __u32 fe_flags;   __u32 fe_reserved[3U]; } ;    38     struct shrink_control {   gfp_t gfp_mask;   unsigned long nr_to_scan;   nodemask_t nodes_to_scan;   int nid; } ;    26     struct shrinker {   unsigned long int (*count_objects)(struct shrinker *, struct shrink_control *);   unsigned long int (*scan_objects)(struct shrinker *, struct shrink_control *);   int seeks;   long batch;   unsigned long flags;   struct list_head list;   atomic_long_t *nr_deferred; } ;    70     enum migrate_mode {   MIGRATE_ASYNC = 0,   MIGRATE_SYNC_LIGHT = 1,   MIGRATE_SYNC = 2 } ;    30     struct block_device ;    31     struct io_context ;    59     struct export_operations ;    61     struct iovec ;    62     struct kiocb ;    63     struct pipe_inode_info ;    64     struct poll_table_struct ;    65     struct kstatfs ;    66     struct swap_info_struct ;    67     struct iov_iter ;    69     struct iattr {   unsigned int ia_valid;   umode_t ia_mode;   kuid_t ia_uid;   kgid_t ia_gid;   loff_t ia_size;   struct timespec ia_atime;   struct timespec ia_mtime;   struct timespec ia_ctime;   struct file *ia_file; } ;   253     struct percpu_counter {   raw_spinlock_t lock;   s64 count;   struct list_head list;   s32 *counters; } ;   176     struct fs_disk_quota {   __s8 d_version;   __s8 d_flags;   __u16 d_fieldmask;   __u32 d_id;   __u64 d_blk_hardlimit;   __u64 d_blk_softlimit;   __u64 d_ino_hardlimit;   __u64 d_ino_softlimit;   __u64 d_bcount;   __u64 d_icount;   __s32 d_itimer;   __s32 d_btimer;   __u16 d_iwarns;   __u16 d_bwarns;   __s32 d_padding2;   __u64 d_rtb_hardlimit;   __u64 d_rtb_softlimit;   __u64 d_rtbcount;   __s32 d_rtbtimer;   __u16 d_rtbwarns;   __s16 d_padding3;   char d_padding4[8U]; } ;    76     struct fs_qfilestat {   __u64 qfs_ino;   __u64 qfs_nblks;   __u32 qfs_nextents; } ;   151     typedef struct fs_qfilestat fs_qfilestat_t;   152     struct fs_quota_stat {   __s8 qs_version;   __u16 qs_flags;   __s8 qs_pad;   fs_qfilestat_t qs_uquota;   fs_qfilestat_t qs_gquota;   __u32 qs_incoredqs;   __s32 qs_btimelimit;   __s32 qs_itimelimit;   __s32 qs_rtbtimelimit;   __u16 qs_bwarnlimit;   __u16 qs_iwarnlimit; } ;   166     struct fs_qfilestatv {   __u64 qfs_ino;   __u64 qfs_nblks;   __u32 qfs_nextents;   __u32 qfs_pad; } ;   196     struct fs_quota_statv {   __s8 qs_version;   __u8 qs_pad1;   __u16 qs_flags;   __u32 qs_incoredqs;   struct fs_qfilestatv qs_uquota;   struct fs_qfilestatv qs_gquota;   struct fs_qfilestatv qs_pquota;   __s32 qs_btimelimit;   __s32 qs_itimelimit;   __s32 qs_rtbtimelimit;   __u16 qs_bwarnlimit;   __u16 qs_iwarnlimit;   __u64 qs_pad2[8U]; } ;   212     struct dquot ;    19     typedef __kernel_uid32_t projid_t;    23     struct __anonstruct_kprojid_t_169 {   projid_t val; } ;    23     typedef struct __anonstruct_kprojid_t_169 kprojid_t;   119     struct if_dqinfo {   __u64 dqi_bgrace;   __u64 dqi_igrace;   __u32 dqi_flags;   __u32 dqi_valid; } ;   152     enum quota_type {   USRQUOTA = 0,   GRPQUOTA = 1,   PRJQUOTA = 2 } ;    60     typedef long long qsize_t;    61     union __anonunion_ldv_20748_170 {   kuid_t uid;   kgid_t gid;   kprojid_t projid; } ;    61     struct kqid {   union __anonunion_ldv_20748_170 ldv_20748;   enum quota_type type; } ;   178     struct mem_dqblk {   qsize_t dqb_bhardlimit;   qsize_t dqb_bsoftlimit;   qsize_t dqb_curspace;   qsize_t dqb_rsvspace;   qsize_t dqb_ihardlimit;   qsize_t dqb_isoftlimit;   qsize_t dqb_curinodes;   time_t dqb_btime;   time_t dqb_itime; } ;   200     struct quota_format_type ;   201     struct mem_dqinfo {   struct quota_format_type *dqi_format;   int dqi_fmt_id;   struct list_head dqi_dirty_list;   unsigned long dqi_flags;   unsigned int dqi_bgrace;   unsigned int dqi_igrace;   qsize_t dqi_maxblimit;   qsize_t dqi_maxilimit;   void *dqi_priv; } ;   264     struct dquot {   struct hlist_node dq_hash;   struct list_head dq_inuse;   struct list_head dq_free;   struct list_head dq_dirty;   struct mutex dq_lock;   atomic_t dq_count;   wait_queue_head_t dq_wait_unused;   struct super_block *dq_sb;   struct kqid dq_id;   loff_t dq_off;   unsigned long dq_flags;   struct mem_dqblk dq_dqb; } ;   291     struct quota_format_ops {   int (*check_quota_file)(struct super_block *, int);   int (*read_file_info)(struct super_block *, int);   int (*write_file_info)(struct super_block *, int);   int (*free_file_info)(struct super_block *, int);   int (*read_dqblk)(struct dquot *);   int (*commit_dqblk)(struct dquot *);   int (*release_dqblk)(struct dquot *); } ;   302     struct dquot_operations {   int (*write_dquot)(struct dquot *);   struct dquot * (*alloc_dquot)(struct super_block *, int);   void (*destroy_dquot)(struct dquot *);   int (*acquire_dquot)(struct dquot *);   int (*release_dquot)(struct dquot *);   int (*mark_dirty)(struct dquot *);   int (*write_info)(struct super_block *, int);   qsize_t * (*get_reserved_space)(struct inode *); } ;   316     struct quotactl_ops {   int (*quota_on)(struct super_block *, int, int, struct path *);   int (*quota_on_meta)(struct super_block *, int, int);   int (*quota_off)(struct super_block *, int);   int (*quota_sync)(struct super_block *, int);   int (*get_info)(struct super_block *, int, struct if_dqinfo *);   int (*set_info)(struct super_block *, int, struct if_dqinfo *);   int (*get_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *);   int (*set_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *);   int (*get_xstate)(struct super_block *, struct fs_quota_stat *);   int (*set_xstate)(struct super_block *, unsigned int, int);   int (*get_xstatev)(struct super_block *, struct fs_quota_statv *);   int (*rm_xquota)(struct super_block *, unsigned int); } ;   334     struct quota_format_type {   int qf_fmt_id;   const struct quota_format_ops *qf_ops;   struct module *qf_owner;   struct quota_format_type *qf_next; } ;   380     struct quota_info {   unsigned int flags;   struct mutex dqio_mutex;   struct mutex dqonoff_mutex;   struct rw_semaphore dqptr_sem;   struct inode *files[2U];   struct mem_dqinfo info[2U];   const struct quota_format_ops *ops[2U]; } ;   411     struct writeback_control ;   323     struct address_space_operations {   int (*writepage)(struct page *, struct writeback_control *);   int (*readpage)(struct file *, struct page *);   int (*writepages)(struct address_space *, struct writeback_control *);   int (*set_page_dirty)(struct page *);   int (*readpages)(struct file *, struct address_space *, struct list_head *, unsigned int);   int (*write_begin)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page **, void **);   int (*write_end)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page *, void *);   sector_t  (*bmap)(struct address_space *, sector_t );   void (*invalidatepage)(struct page *, unsigned int, unsigned int);   int (*releasepage)(struct page *, gfp_t );   void (*freepage)(struct page *);   ssize_t  (*direct_IO)(int, struct kiocb *, struct iov_iter *, loff_t );   int (*get_xip_mem)(struct address_space *, unsigned long, int, void **, unsigned long *);   int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode );   int (*launder_page)(struct page *);   int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long);   void (*is_dirty_writeback)(struct page *, bool *, bool *);   int (*error_remove_page)(struct address_space *, struct page *);   int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *);   void (*swap_deactivate)(struct file *); } ;   382     struct backing_dev_info ;   383     struct address_space {   struct inode *host;   struct radix_tree_root page_tree;   spinlock_t tree_lock;   unsigned int i_mmap_writable;   struct rb_root i_mmap;   struct list_head i_mmap_nonlinear;   struct mutex i_mmap_mutex;   unsigned long nrpages;   unsigned long nrshadows;   unsigned long writeback_index;   const struct address_space_operations *a_ops;   unsigned long flags;   struct backing_dev_info *backing_dev_info;   spinlock_t private_lock;   struct list_head private_list;   void *private_data; } ;   405     struct request_queue ;   406     struct hd_struct ;   406     struct gendisk ;   406     struct block_device {   dev_t bd_dev;   int bd_openers;   struct inode *bd_inode;   struct super_block *bd_super;   struct mutex bd_mutex;   struct list_head bd_inodes;   void *bd_claiming;   void *bd_holder;   int bd_holders;   bool bd_write_holder;   struct list_head bd_holder_disks;   struct block_device *bd_contains;   unsigned int bd_block_size;   struct hd_struct *bd_part;   unsigned int bd_part_count;   int bd_invalidated;   struct gendisk *bd_disk;   struct request_queue *bd_queue;   struct list_head bd_list;   unsigned long bd_private;   int bd_fsfreeze_count;   struct mutex bd_fsfreeze_mutex; } ;   478     struct posix_acl ;   479     struct inode_operations ;   479     union __anonunion_ldv_21164_173 {   const unsigned int i_nlink;   unsigned int __i_nlink; } ;   479     union __anonunion_ldv_21184_174 {   struct hlist_head i_dentry;   struct callback_head i_rcu; } ;   479     struct file_lock ;   479     struct cdev ;   479     union __anonunion_ldv_21201_175 {   struct pipe_inode_info *i_pipe;   struct block_device *i_bdev;   struct cdev *i_cdev; } ;   479     struct inode {   umode_t i_mode;   unsigned short i_opflags;   kuid_t i_uid;   kgid_t i_gid;   unsigned int i_flags;   struct posix_acl *i_acl;   struct posix_acl *i_default_acl;   const struct inode_operations *i_op;   struct super_block *i_sb;   struct address_space *i_mapping;   void *i_security;   unsigned long i_ino;   union __anonunion_ldv_21164_173 ldv_21164;   dev_t i_rdev;   loff_t i_size;   struct timespec i_atime;   struct timespec i_mtime;   struct timespec i_ctime;   spinlock_t i_lock;   unsigned short i_bytes;   unsigned int i_blkbits;   blkcnt_t i_blocks;   unsigned long i_state;   struct mutex i_mutex;   unsigned long dirtied_when;   struct hlist_node i_hash;   struct list_head i_wb_list;   struct list_head i_lru;   struct list_head i_sb_list;   union __anonunion_ldv_21184_174 ldv_21184;   u64 i_version;   atomic_t i_count;   atomic_t i_dio_count;   atomic_t i_writecount;   atomic_t i_readcount;   const struct file_operations *i_fop;   struct file_lock *i_flock;   struct address_space i_data;   struct dquot *i_dquot[2U];   struct list_head i_devices;   union __anonunion_ldv_21201_175 ldv_21201;   __u32 i_generation;   __u32 i_fsnotify_mask;   struct hlist_head i_fsnotify_marks;   void *i_private; } ;   715     struct fown_struct {   rwlock_t lock;   struct pid *pid;   enum pid_type pid_type;   kuid_t uid;   kuid_t euid;   int signum; } ;   723     struct file_ra_state {   unsigned long start;   unsigned int size;   unsigned int async_size;   unsigned int ra_pages;   unsigned int mmap_miss;   loff_t prev_pos; } ;   746     union __anonunion_f_u_176 {   struct llist_node fu_llist;   struct callback_head fu_rcuhead; } ;   746     struct file {   union __anonunion_f_u_176 f_u;   struct path f_path;   struct inode *f_inode;   const struct file_operations *f_op;   spinlock_t f_lock;   atomic_long_t f_count;   unsigned int f_flags;   fmode_t f_mode;   struct mutex f_pos_lock;   loff_t f_pos;   struct fown_struct f_owner;   const struct cred *f_cred;   struct file_ra_state f_ra;   u64 f_version;   void *f_security;   void *private_data;   struct list_head f_ep_links;   struct list_head f_tfile_llink;   struct address_space *f_mapping; } ;   836     struct files_struct ;   836     typedef struct files_struct *fl_owner_t;   837     struct file_lock_operations {   void (*fl_copy_lock)(struct file_lock *, struct file_lock *);   void (*fl_release_private)(struct file_lock *); } ;   842     struct lock_manager_operations {   int (*lm_compare_owner)(struct file_lock *, struct file_lock *);   unsigned long int (*lm_owner_key)(struct file_lock *);   void (*lm_notify)(struct file_lock *);   int (*lm_grant)(struct file_lock *, struct file_lock *, int);   void (*lm_break)(struct file_lock *);   int (*lm_change)(struct file_lock **, int); } ;   860     struct nlm_lockowner ;   861     struct nfs_lock_info {   u32 state;   struct nlm_lockowner *owner;   struct list_head list; } ;    14     struct nfs4_lock_state ;    15     struct nfs4_lock_info {   struct nfs4_lock_state *owner; } ;    19     struct fasync_struct ;    19     struct __anonstruct_afs_178 {   struct list_head link;   int state; } ;    19     union __anonunion_fl_u_177 {   struct nfs_lock_info nfs_fl;   struct nfs4_lock_info nfs4_fl;   struct __anonstruct_afs_178 afs; } ;    19     struct file_lock {   struct file_lock *fl_next;   struct hlist_node fl_link;   struct list_head fl_block;   fl_owner_t fl_owner;   unsigned int fl_flags;   unsigned char fl_type;   unsigned int fl_pid;   int fl_link_cpu;   struct pid *fl_nspid;   wait_queue_head_t fl_wait;   struct file *fl_file;   loff_t fl_start;   loff_t fl_end;   struct fasync_struct *fl_fasync;   unsigned long fl_break_time;   unsigned long fl_downgrade_time;   const struct file_lock_operations *fl_ops;   const struct lock_manager_operations *fl_lmops;   union __anonunion_fl_u_177 fl_u; } ;   963     struct fasync_struct {   spinlock_t fa_lock;   int magic;   int fa_fd;   struct fasync_struct *fa_next;   struct file *fa_file;   struct callback_head fa_rcu; } ;  1157     struct sb_writers {   struct percpu_counter counter[3U];   wait_queue_head_t wait;   int frozen;   wait_queue_head_t wait_unfrozen;   struct lockdep_map lock_map[3U]; } ;  1173     struct super_operations ;  1173     struct xattr_handler ;  1173     struct mtd_info ;  1173     struct super_block {   struct list_head s_list;   dev_t s_dev;   unsigned char s_blocksize_bits;   unsigned long s_blocksize;   loff_t s_maxbytes;   struct file_system_type *s_type;   const struct super_operations *s_op;   const struct dquot_operations *dq_op;   const struct quotactl_ops *s_qcop;   const struct export_operations *s_export_op;   unsigned long s_flags;   unsigned long s_magic;   struct dentry *s_root;   struct rw_semaphore s_umount;   int s_count;   atomic_t s_active;   void *s_security;   const struct xattr_handler **s_xattr;   struct list_head s_inodes;   struct hlist_bl_head s_anon;   struct list_head s_mounts;   struct block_device *s_bdev;   struct backing_dev_info *s_bdi;   struct mtd_info *s_mtd;   struct hlist_node s_instances;   struct quota_info s_dquot;   struct sb_writers s_writers;   char s_id[32U];   u8 s_uuid[16U];   void *s_fs_info;   unsigned int s_max_links;   fmode_t s_mode;   u32 s_time_gran;   struct mutex s_vfs_rename_mutex;   char *s_subtype;   char *s_options;   const struct dentry_operations *s_d_op;   int cleancache_poolid;   struct shrinker s_shrink;   atomic_long_t s_remove_count;   int s_readonly_remount;   struct workqueue_struct *s_dio_done_wq;   struct list_lru s_dentry_lru;   struct list_lru s_inode_lru;   struct callback_head rcu; } ;  1403     struct fiemap_extent_info {   unsigned int fi_flags;   unsigned int fi_extents_mapped;   unsigned int fi_extents_max;   struct fiemap_extent *fi_extents_start; } ;  1441     struct dir_context {   int (*actor)(void *, const char *, int, loff_t , u64 , unsigned int);   loff_t pos; } ;  1446     struct file_operations {   struct module *owner;   loff_t  (*llseek)(struct file *, loff_t , int);   ssize_t  (*read)(struct file *, char *, size_t , loff_t *);   ssize_t  (*write)(struct file *, const char *, size_t , loff_t *);   ssize_t  (*aio_read)(struct kiocb *, const struct iovec *, unsigned long, loff_t );   ssize_t  (*aio_write)(struct kiocb *, const struct iovec *, unsigned long, loff_t );   ssize_t  (*read_iter)(struct kiocb *, struct iov_iter *);   ssize_t  (*write_iter)(struct kiocb *, struct iov_iter *);   int (*iterate)(struct file *, struct dir_context *);   unsigned int (*poll)(struct file *, struct poll_table_struct *);   long int (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);   long int (*compat_ioctl)(struct file *, unsigned int, unsigned long);   int (*mmap)(struct file *, struct vm_area_struct *);   int (*open)(struct inode *, struct file *);   int (*flush)(struct file *, fl_owner_t );   int (*release)(struct inode *, struct file *);   int (*fsync)(struct file *, loff_t , loff_t , int);   int (*aio_fsync)(struct kiocb *, int);   int (*fasync)(int, struct file *, int);   int (*lock)(struct file *, int, struct file_lock *);   ssize_t  (*sendpage)(struct file *, struct page *, int, size_t , loff_t *, int);   unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);   int (*check_flags)(int);   int (*flock)(struct file *, int, struct file_lock *);   ssize_t  (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t , unsigned int);   ssize_t  (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t , unsigned int);   int (*setlease)(struct file *, long, struct file_lock **);   long int (*fallocate)(struct file *, int, loff_t , loff_t );   int (*show_fdinfo)(struct seq_file *, struct file *); } ;  1488     struct inode_operations {   struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int);   void * (*follow_link)(struct dentry *, struct nameidata *);   int (*permission)(struct inode *, int);   struct posix_acl * (*get_acl)(struct inode *, int);   int (*readlink)(struct dentry *, char *, int);   void (*put_link)(struct dentry *, struct nameidata *, void *);   int (*create)(struct inode *, struct dentry *, umode_t , bool );   int (*link)(struct dentry *, struct inode *, struct dentry *);   int (*unlink)(struct inode *, struct dentry *);   int (*symlink)(struct inode *, struct dentry *, const char *);   int (*mkdir)(struct inode *, struct dentry *, umode_t );   int (*rmdir)(struct inode *, struct dentry *);   int (*mknod)(struct inode *, struct dentry *, umode_t , dev_t );   int (*rename)(struct inode *, struct dentry *, struct inode *, struct dentry *);   int (*rename2)(struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int);   int (*setattr)(struct dentry *, struct iattr *);   int (*getattr)(struct vfsmount *, struct dentry *, struct kstat *);   int (*setxattr)(struct dentry *, const char *, const void *, size_t , int);   ssize_t  (*getxattr)(struct dentry *, const char *, void *, size_t );   ssize_t  (*listxattr)(struct dentry *, char *, size_t );   int (*removexattr)(struct dentry *, const char *);   int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 , u64 );   int (*update_time)(struct inode *, struct timespec *, int);   int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned int, umode_t , int *);   int (*tmpfile)(struct inode *, struct dentry *, umode_t );   int (*set_acl)(struct inode *, struct posix_acl *, int); } ;  1535     struct super_operations {   struct inode * (*alloc_inode)(struct super_block *);   void (*destroy_inode)(struct inode *);   void (*dirty_inode)(struct inode *, int);   int (*write_inode)(struct inode *, struct writeback_control *);   int (*drop_inode)(struct inode *);   void (*evict_inode)(struct inode *);   void (*put_super)(struct super_block *);   int (*sync_fs)(struct super_block *, int);   int (*freeze_fs)(struct super_block *);   int (*unfreeze_fs)(struct super_block *);   int (*statfs)(struct dentry *, struct kstatfs *);   int (*remount_fs)(struct super_block *, int *, char *);   void (*umount_begin)(struct super_block *);   int (*show_options)(struct seq_file *, struct dentry *);   int (*show_devname)(struct seq_file *, struct dentry *);   int (*show_path)(struct seq_file *, struct dentry *);   int (*show_stats)(struct seq_file *, struct dentry *);   ssize_t  (*quota_read)(struct super_block *, int, char *, size_t , loff_t );   ssize_t  (*quota_write)(struct super_block *, int, const char *, size_t , loff_t );   int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t );   long int (*nr_cached_objects)(struct super_block *, int);   long int (*free_cached_objects)(struct super_block *, long, int); } ;  1749     struct file_system_type {   const char *name;   int fs_flags;   struct dentry * (*mount)(struct file_system_type *, int, const char *, void *);   void (*kill_sb)(struct super_block *);   struct module *owner;   struct file_system_type *next;   struct hlist_head fs_supers;   struct lock_class_key s_lock_key;   struct lock_class_key s_umount_key;   struct lock_class_key s_vfs_rename_key;   struct lock_class_key s_writers_key[3U];   struct lock_class_key i_lock_key;   struct lock_class_key i_mutex_key;   struct lock_class_key i_mutex_dir_key; } ;    84     struct plist_node {   int prio;   struct list_head prio_list;   struct list_head node_list; } ;     4     typedef unsigned long cputime_t;    25     struct sem_undo_list ;    25     struct sysv_sem {   struct sem_undo_list *undo_list; } ;    24     struct __anonstruct_sigset_t_179 {   unsigned long sig[1U]; } ;    24     typedef struct __anonstruct_sigset_t_179 sigset_t;    25     struct siginfo ;    17     typedef void __signalfn_t(int);    18     typedef __signalfn_t *__sighandler_t;    20     typedef void __restorefn_t();    21     typedef __restorefn_t *__sigrestore_t;    34     union sigval {   int sival_int;   void *sival_ptr; } ;    10     typedef union sigval sigval_t;    11     struct __anonstruct__kill_181 {   __kernel_pid_t _pid;   __kernel_uid32_t _uid; } ;    11     struct __anonstruct__timer_182 {   __kernel_timer_t _tid;   int _overrun;   char _pad[0U];   sigval_t _sigval;   int _sys_private; } ;    11     struct __anonstruct__rt_183 {   __kernel_pid_t _pid;   __kernel_uid32_t _uid;   sigval_t _sigval; } ;    11     struct __anonstruct__sigchld_184 {   __kernel_pid_t _pid;   __kernel_uid32_t _uid;   int _status;   __kernel_clock_t _utime;   __kernel_clock_t _stime; } ;    11     struct __anonstruct__sigfault_185 {   void *_addr;   short _addr_lsb; } ;    11     struct __anonstruct__sigpoll_186 {   long _band;   int _fd; } ;    11     struct __anonstruct__sigsys_187 {   void *_call_addr;   int _syscall;   unsigned int _arch; } ;    11     union __anonunion__sifields_180 {   int _pad[28U];   struct __anonstruct__kill_181 _kill;   struct __anonstruct__timer_182 _timer;   struct __anonstruct__rt_183 _rt;   struct __anonstruct__sigchld_184 _sigchld;   struct __anonstruct__sigfault_185 _sigfault;   struct __anonstruct__sigpoll_186 _sigpoll;   struct __anonstruct__sigsys_187 _sigsys; } ;    11     struct siginfo {   int si_signo;   int si_errno;   int si_code;   union __anonunion__sifields_180 _sifields; } ;   109     typedef struct siginfo siginfo_t;    11     struct user_struct ;    21     struct sigpending {   struct list_head list;   sigset_t signal; } ;   246     struct sigaction {   __sighandler_t sa_handler;   unsigned long sa_flags;   __sigrestore_t sa_restorer;   sigset_t sa_mask; } ;   260     struct k_sigaction {   struct sigaction sa; } ;    46     struct seccomp_filter ;    47     struct seccomp {   int mode;   struct seccomp_filter *filter; } ;    40     struct rt_mutex_waiter ;    41     struct rlimit {   __kernel_ulong_t rlim_cur;   __kernel_ulong_t rlim_max; } ;    11     struct task_io_accounting {   u64 rchar;   u64 wchar;   u64 syscr;   u64 syscw;   u64 read_bytes;   u64 write_bytes;   u64 cancelled_write_bytes; } ;    45     struct latency_record {   unsigned long backtrace[12U];   unsigned int count;   unsigned long time;   unsigned long max; } ;    39     struct assoc_array_ptr ;    39     struct assoc_array {   struct assoc_array_ptr *root;   unsigned long nr_leaves_on_tree; } ;    31     typedef int32_t key_serial_t;    34     typedef uint32_t key_perm_t;    35     struct key ;    36     struct signal_struct ;    37     struct key_type ;    41     struct keyring_index_key {   struct key_type *type;   const char *description;   size_t desc_len; } ;   123     union __anonunion_ldv_24022_190 {   struct list_head graveyard_link;   struct rb_node serial_node; } ;   123     struct key_user ;   123     union __anonunion_ldv_24030_191 {   time_t expiry;   time_t revoked_at; } ;   123     struct __anonstruct_ldv_24043_193 {   struct key_type *type;   char *description; } ;   123     union __anonunion_ldv_24044_192 {   struct keyring_index_key index_key;   struct __anonstruct_ldv_24043_193 ldv_24043; } ;   123     union __anonunion_type_data_194 {   struct list_head link;   unsigned long x[2U];   void *p[2U];   int reject_error; } ;   123     union __anonunion_payload_196 {   unsigned long value;   void *rcudata;   void *data;   void *data2[2U]; } ;   123     union __anonunion_ldv_24059_195 {   union __anonunion_payload_196 payload;   struct assoc_array keys; } ;   123     struct key {   atomic_t usage;   key_serial_t serial;   union __anonunion_ldv_24022_190 ldv_24022;   struct rw_semaphore sem;   struct key_user *user;   void *security;   union __anonunion_ldv_24030_191 ldv_24030;   time_t last_used_at;   kuid_t uid;   kgid_t gid;   key_perm_t perm;   unsigned short quotalen;   unsigned short datalen;   unsigned long flags;   union __anonunion_ldv_24044_192 ldv_24044;   union __anonunion_type_data_194 type_data;   union __anonunion_ldv_24059_195 ldv_24059; } ;   356     struct audit_context ;    27     struct group_info {   atomic_t usage;   int ngroups;   int nblocks;   kgid_t small_block[32U];   kgid_t *blocks[0U]; } ;    78     struct cred {   atomic_t usage;   atomic_t subscribers;   void *put_addr;   unsigned int magic;   kuid_t uid;   kgid_t gid;   kuid_t suid;   kgid_t sgid;   kuid_t euid;   kgid_t egid;   kuid_t fsuid;   kgid_t fsgid;   unsigned int securebits;   kernel_cap_t cap_inheritable;   kernel_cap_t cap_permitted;   kernel_cap_t cap_effective;   kernel_cap_t cap_bset;   unsigned char jit_keyring;   struct key *session_keyring;   struct key *process_keyring;   struct key *thread_keyring;   struct key *request_key_auth;   void *security;   struct user_struct *user;   struct user_namespace *user_ns;   struct group_info *group_info;   struct callback_head rcu; } ;   125     struct futex_pi_state ;   126     struct robust_list_head ;   127     struct bio_list ;   128     struct fs_struct ;   129     struct perf_event_context ;   130     struct blk_plug ;   180     struct cfs_rq ;   181     struct task_group ;   426     struct sighand_struct {   atomic_t count;   struct k_sigaction action[64U];   spinlock_t siglock;   wait_queue_head_t signalfd_wqh; } ;   465     struct pacct_struct {   int ac_flag;   long ac_exitcode;   unsigned long ac_mem;   cputime_t ac_utime;   cputime_t ac_stime;   unsigned long ac_minflt;   unsigned long ac_majflt; } ;   473     struct cpu_itimer {   cputime_t expires;   cputime_t incr;   u32 error;   u32 incr_error; } ;   480     struct cputime {   cputime_t utime;   cputime_t stime; } ;   492     struct task_cputime {   cputime_t utime;   cputime_t stime;   unsigned long long sum_exec_runtime; } ;   512     struct thread_group_cputimer {   struct task_cputime cputime;   int running;   raw_spinlock_t lock; } ;   554     struct autogroup ;   555     struct tty_struct ;   555     struct taskstats ;   555     struct tty_audit_buf ;   555     struct signal_struct {   atomic_t sigcnt;   atomic_t live;   int nr_threads;   struct list_head thread_head;   wait_queue_head_t wait_chldexit;   struct task_struct *curr_target;   struct sigpending shared_pending;   int group_exit_code;   int notify_count;   struct task_struct *group_exit_task;   int group_stop_count;   unsigned int flags;   unsigned char is_child_subreaper;   unsigned char has_child_subreaper;   int posix_timer_id;   struct list_head posix_timers;   struct hrtimer real_timer;   struct pid *leader_pid;   ktime_t it_real_incr;   struct cpu_itimer it[2U];   struct thread_group_cputimer cputimer;   struct task_cputime cputime_expires;   struct list_head cpu_timers[3U];   struct pid *tty_old_pgrp;   int leader;   struct tty_struct *tty;   struct autogroup *autogroup;   cputime_t utime;   cputime_t stime;   cputime_t cutime;   cputime_t cstime;   cputime_t gtime;   cputime_t cgtime;   struct cputime prev_cputime;   unsigned long nvcsw;   unsigned long nivcsw;   unsigned long cnvcsw;   unsigned long cnivcsw;   unsigned long min_flt;   unsigned long maj_flt;   unsigned long cmin_flt;   unsigned long cmaj_flt;   unsigned long inblock;   unsigned long oublock;   unsigned long cinblock;   unsigned long coublock;   unsigned long maxrss;   unsigned long cmaxrss;   struct task_io_accounting ioac;   unsigned long long sum_sched_runtime;   struct rlimit rlim[16U];   struct pacct_struct pacct;   struct taskstats *stats;   unsigned int audit_tty;   unsigned int audit_tty_log_passwd;   struct tty_audit_buf *tty_audit_buf;   struct rw_semaphore group_rwsem;   oom_flags_t oom_flags;   short oom_score_adj;   short oom_score_adj_min;   struct mutex cred_guard_mutex; } ;   735     struct user_struct {   atomic_t __count;   atomic_t processes;   atomic_t sigpending;   atomic_t inotify_watches;   atomic_t inotify_devs;   atomic_t fanotify_listeners;   atomic_long_t epoll_watches;   unsigned long mq_bytes;   unsigned long locked_shm;   struct key *uid_keyring;   struct key *session_keyring;   struct hlist_node uidhash_node;   kuid_t uid;   atomic_long_t locked_vm; } ;   778     struct reclaim_state ;   779     struct sched_info {   unsigned long pcount;   unsigned long long run_delay;   unsigned long long last_arrival;   unsigned long long last_queued; } ;   794     struct task_delay_info {   spinlock_t lock;   unsigned int flags;   struct timespec blkio_start;   struct timespec blkio_end;   u64 blkio_delay;   u64 swapin_delay;   u32 blkio_count;   u32 swapin_count;   struct timespec freepages_start;   struct timespec freepages_end;   u64 freepages_delay;   u32 freepages_count; } ;  1061     struct load_weight {   unsigned long weight;   u32 inv_weight; } ;  1069     struct sched_avg {   u32 runnable_avg_sum;   u32 runnable_avg_period;   u64 last_runnable_update;   s64 decay_count;   unsigned long load_avg_contrib; } ;  1081     struct sched_statistics {   u64 wait_start;   u64 wait_max;   u64 wait_count;   u64 wait_sum;   u64 iowait_count;   u64 iowait_sum;   u64 sleep_start;   u64 sleep_max;   s64 sum_sleep_runtime;   u64 block_start;   u64 block_max;   u64 exec_max;   u64 slice_max;   u64 nr_migrations_cold;   u64 nr_failed_migrations_affine;   u64 nr_failed_migrations_running;   u64 nr_failed_migrations_hot;   u64 nr_forced_migrations;   u64 nr_wakeups;   u64 nr_wakeups_sync;   u64 nr_wakeups_migrate;   u64 nr_wakeups_local;   u64 nr_wakeups_remote;   u64 nr_wakeups_affine;   u64 nr_wakeups_affine_attempts;   u64 nr_wakeups_passive;   u64 nr_wakeups_idle; } ;  1116     struct sched_entity {   struct load_weight load;   struct rb_node run_node;   struct list_head group_node;   unsigned int on_rq;   u64 exec_start;   u64 sum_exec_runtime;   u64 vruntime;   u64 prev_sum_exec_runtime;   u64 nr_migrations;   struct sched_statistics statistics;   int depth;   struct sched_entity *parent;   struct cfs_rq *cfs_rq;   struct cfs_rq *my_q;   struct sched_avg avg; } ;  1148     struct rt_rq ;  1148     struct sched_rt_entity {   struct list_head run_list;   unsigned long timeout;   unsigned long watchdog_stamp;   unsigned int time_slice;   struct sched_rt_entity *back;   struct sched_rt_entity *parent;   struct rt_rq *rt_rq;   struct rt_rq *my_q; } ;  1164     struct sched_dl_entity {   struct rb_node rb_node;   u64 dl_runtime;   u64 dl_deadline;   u64 dl_period;   u64 dl_bw;   s64 runtime;   u64 deadline;   unsigned int flags;   int dl_throttled;   int dl_new;   int dl_boosted;   int dl_yielded;   struct hrtimer dl_timer; } ;  1222     struct mem_cgroup ;  1222     struct memcg_batch_info {   int do_batch;   struct mem_cgroup *memcg;   unsigned long nr_pages;   unsigned long memsw_nr_pages; } ;  1643     struct memcg_oom_info {   struct mem_cgroup *memcg;   gfp_t gfp_mask;   int order;   unsigned char may_oom; } ;  1650     struct sched_class ;  1650     struct css_set ;  1650     struct compat_robust_list_head ;  1650     struct numa_group ;  1650     struct task_struct {   volatile long state;   void *stack;   atomic_t usage;   unsigned int flags;   unsigned int ptrace;   struct llist_node wake_entry;   int on_cpu;   struct task_struct *last_wakee;   unsigned long wakee_flips;   unsigned long wakee_flip_decay_ts;   int wake_cpu;   int on_rq;   int prio;   int static_prio;   int normal_prio;   unsigned int rt_priority;   const struct sched_class *sched_class;   struct sched_entity se;   struct sched_rt_entity rt;   struct task_group *sched_task_group;   struct sched_dl_entity dl;   struct hlist_head preempt_notifiers;   unsigned int policy;   int nr_cpus_allowed;   cpumask_t cpus_allowed;   struct sched_info sched_info;   struct list_head tasks;   struct plist_node pushable_tasks;   struct rb_node pushable_dl_tasks;   struct mm_struct *mm;   struct mm_struct *active_mm;   unsigned char brk_randomized;   u32 vmacache_seqnum;   struct vm_area_struct *vmacache[4U];   struct task_rss_stat rss_stat;   int exit_state;   int exit_code;   int exit_signal;   int pdeath_signal;   unsigned int jobctl;   unsigned int personality;   unsigned char in_execve;   unsigned char in_iowait;   unsigned char no_new_privs;   unsigned char sched_reset_on_fork;   unsigned char sched_contributes_to_load;   pid_t pid;   pid_t tgid;   struct task_struct *real_parent;   struct task_struct *parent;   struct list_head children;   struct list_head sibling;   struct task_struct *group_leader;   struct list_head ptraced;   struct list_head ptrace_entry;   struct pid_link pids[3U];   struct list_head thread_group;   struct list_head thread_node;   struct completion *vfork_done;   int *set_child_tid;   int *clear_child_tid;   cputime_t utime;   cputime_t stime;   cputime_t utimescaled;   cputime_t stimescaled;   cputime_t gtime;   struct cputime prev_cputime;   unsigned long nvcsw;   unsigned long nivcsw;   struct timespec start_time;   struct timespec real_start_time;   unsigned long min_flt;   unsigned long maj_flt;   struct task_cputime cputime_expires;   struct list_head cpu_timers[3U];   const struct cred *real_cred;   const struct cred *cred;   char comm[16U];   int link_count;   int total_link_count;   struct sysv_sem sysvsem;   unsigned long last_switch_count;   struct thread_struct thread;   struct fs_struct *fs;   struct files_struct *files;   struct nsproxy *nsproxy;   struct signal_struct *signal;   struct sighand_struct *sighand;   sigset_t blocked;   sigset_t real_blocked;   sigset_t saved_sigmask;   struct sigpending pending;   unsigned long sas_ss_sp;   size_t sas_ss_size;   int (*notifier)(void *);   void *notifier_data;   sigset_t *notifier_mask;   struct callback_head *task_works;   struct audit_context *audit_context;   kuid_t loginuid;   unsigned int sessionid;   struct seccomp seccomp;   u32 parent_exec_id;   u32 self_exec_id;   spinlock_t alloc_lock;   raw_spinlock_t pi_lock;   struct rb_root pi_waiters;   struct rb_node *pi_waiters_leftmost;   struct rt_mutex_waiter *pi_blocked_on;   struct task_struct *pi_top_task;   struct mutex_waiter *blocked_on;   unsigned int irq_events;   unsigned long hardirq_enable_ip;   unsigned long hardirq_disable_ip;   unsigned int hardirq_enable_event;   unsigned int hardirq_disable_event;   int hardirqs_enabled;   int hardirq_context;   unsigned long softirq_disable_ip;   unsigned long softirq_enable_ip;   unsigned int softirq_disable_event;   unsigned int softirq_enable_event;   int softirqs_enabled;   int softirq_context;   u64 curr_chain_key;   int lockdep_depth;   unsigned int lockdep_recursion;   struct held_lock held_locks[48U];   gfp_t lockdep_reclaim_gfp;   void *journal_info;   struct bio_list *bio_list;   struct blk_plug *plug;   struct reclaim_state *reclaim_state;   struct backing_dev_info *backing_dev_info;   struct io_context *io_context;   unsigned long ptrace_message;   siginfo_t *last_siginfo;   struct task_io_accounting ioac;   u64 acct_rss_mem1;   u64 acct_vm_mem1;   cputime_t acct_timexpd;   nodemask_t mems_allowed;   seqcount_t mems_allowed_seq;   int cpuset_mem_spread_rotor;   int cpuset_slab_spread_rotor;   struct css_set *cgroups;   struct list_head cg_list;   struct robust_list_head *robust_list;   struct compat_robust_list_head *compat_robust_list;   struct list_head pi_state_list;   struct futex_pi_state *pi_state_cache;   struct perf_event_context *perf_event_ctxp[2U];   struct mutex perf_event_mutex;   struct list_head perf_event_list;   struct mempolicy *mempolicy;   short il_next;   short pref_node_fork;   int numa_scan_seq;   unsigned int numa_scan_period;   unsigned int numa_scan_period_max;   int numa_preferred_nid;   unsigned long numa_migrate_retry;   u64 node_stamp;   u64 last_task_numa_placement;   u64 last_sum_exec_runtime;   struct callback_head numa_work;   struct list_head numa_entry;   struct numa_group *numa_group;   unsigned long *numa_faults_memory;   unsigned long total_numa_faults;   unsigned long *numa_faults_buffer_memory;   unsigned long *numa_faults_cpu;   unsigned long *numa_faults_buffer_cpu;   unsigned long numa_faults_locality[2U];   unsigned long numa_pages_migrated;   struct callback_head rcu;   struct pipe_inode_info *splice_pipe;   struct page_frag task_frag;   struct task_delay_info *delays;   int make_it_fail;   int nr_dirtied;   int nr_dirtied_pause;   unsigned long dirty_paused_when;   int latency_record_count;   struct latency_record latency_record[32U];   unsigned long timer_slack_ns;   unsigned long default_timer_slack_ns;   unsigned long trace;   unsigned long trace_recursion;   struct memcg_batch_info memcg_batch;   unsigned int memcg_kmem_skip_account;   struct memcg_oom_info memcg_oom;   struct uprobe_task *utask;   unsigned int sequential_io;   unsigned int sequential_io_avg; } ;   272     struct usb_device ;   274     struct wusb_dev ;   275     struct ep_device ;   276     struct usb_host_endpoint {   struct usb_endpoint_descriptor desc;   struct usb_ss_ep_comp_descriptor ss_ep_comp;   struct list_head urb_list;   void *hcpriv;   struct ep_device *ep_dev;   unsigned char *extra;   int extralen;   int enabled;   int streams; } ;    77     struct usb_host_interface {   struct usb_interface_descriptor desc;   int extralen;   unsigned char *extra;   struct usb_host_endpoint *endpoint;   char *string; } ;    92     enum usb_interface_condition {   USB_INTERFACE_UNBOUND = 0,   USB_INTERFACE_BINDING = 1,   USB_INTERFACE_BOUND = 2,   USB_INTERFACE_UNBINDING = 3 } ;    99     struct usb_interface {   struct usb_host_interface *altsetting;   struct usb_host_interface *cur_altsetting;   unsigned int num_altsetting;   struct usb_interface_assoc_descriptor *intf_assoc;   int minor;   enum usb_interface_condition condition;   unsigned char sysfs_files_created;   unsigned char ep_devs_created;   unsigned char unregistering;   unsigned char needs_remote_wakeup;   unsigned char needs_altsetting0;   unsigned char needs_binding;   unsigned char reset_running;   unsigned char resetting_device;   struct device dev;   struct device *usb_dev;   atomic_t pm_usage_cnt;   struct work_struct reset_ws; } ;   206     struct usb_interface_cache {   unsigned int num_altsetting;   struct kref ref;   struct usb_host_interface altsetting[0U]; } ;   235     struct usb_host_config {   struct usb_config_descriptor desc;   char *string;   struct usb_interface_assoc_descriptor *intf_assoc[16U];   struct usb_interface *interface[32U];   struct usb_interface_cache *intf_cache[32U];   unsigned char *extra;   int extralen; } ;   299     struct usb_host_bos {   struct usb_bos_descriptor *desc;   struct usb_ext_cap_descriptor *ext_cap;   struct usb_ss_cap_descriptor *ss_cap;   struct usb_ss_container_id_descriptor *ss_id; } ;   311     struct usb_devmap {   unsigned long devicemap[2U]; } ;   323     struct mon_bus ;   323     struct usb_bus {   struct device *controller;   int busnum;   const char *bus_name;   u8 uses_dma;   u8 uses_pio_for_control;   u8 otg_port;   unsigned char is_b_host;   unsigned char b_hnp_enable;   unsigned char no_stop_on_short;   unsigned char no_sg_constraint;   unsigned int sg_tablesize;   int devnum_next;   struct usb_devmap devmap;   struct usb_device *root_hub;   struct usb_bus *hs_companion;   struct list_head bus_list;   struct mutex usb_address0_mutex;   int bandwidth_allocated;   int bandwidth_int_reqs;   int bandwidth_isoc_reqs;   unsigned int resuming_ports;   struct mon_bus *mon_bus;   int monitored; } ;   374     struct usb_tt ;   375     enum usb_device_removable {   USB_DEVICE_REMOVABLE_UNKNOWN = 0,   USB_DEVICE_REMOVABLE = 1,   USB_DEVICE_FIXED = 2 } ;   388     struct usb2_lpm_parameters {   unsigned int besl;   int timeout; } ;   409     struct usb3_lpm_parameters {   unsigned int mel;   unsigned int pel;   unsigned int sel;   int timeout; } ;   448     struct usb_device {   int devnum;   char devpath[16U];   u32 route;   enum usb_device_state state;   enum usb_device_speed speed;   struct usb_tt *tt;   int ttport;   unsigned int toggle[2U];   struct usb_device *parent;   struct usb_bus *bus;   struct usb_host_endpoint ep0;   struct device dev;   struct usb_device_descriptor descriptor;   struct usb_host_bos *bos;   struct usb_host_config *config;   struct usb_host_config *actconfig;   struct usb_host_endpoint *ep_in[16U];   struct usb_host_endpoint *ep_out[16U];   char **rawdescriptors;   unsigned short bus_mA;   u8 portnum;   u8 level;   unsigned char can_submit;   unsigned char persist_enabled;   unsigned char have_langid;   unsigned char authorized;   unsigned char authenticated;   unsigned char wusb;   unsigned char lpm_capable;   unsigned char usb2_hw_lpm_capable;   unsigned char usb2_hw_lpm_besl_capable;   unsigned char usb2_hw_lpm_enabled;   unsigned char usb2_hw_lpm_allowed;   unsigned char usb3_lpm_enabled;   int string_langid;   char *product;   char *manufacturer;   char *serial;   struct list_head filelist;   int maxchild;   u32 quirks;   atomic_t urbnum;   unsigned long active_duration;   unsigned long connect_time;   unsigned char do_remote_wakeup;   unsigned char reset_resume;   unsigned char port_is_suspended;   struct wusb_dev *wusb_dev;   int slot_id;   enum usb_device_removable removable;   struct usb2_lpm_parameters l1_params;   struct usb3_lpm_parameters u1_params;   struct usb3_lpm_parameters u2_params;   unsigned int lpm_disable_count; } ;  1179     struct usb_iso_packet_descriptor {   unsigned int offset;   unsigned int length;   unsigned int actual_length;   int status; } ;  1221     struct urb ;  1222     struct usb_anchor {   struct list_head urb_list;   wait_queue_head_t wait;   spinlock_t lock;   atomic_t suspend_wakeups;   unsigned char poisoned; } ;  1241     struct scatterlist ;  1241     struct urb {   struct kref kref;   void *hcpriv;   atomic_t use_count;   atomic_t reject;   int unlinked;   struct list_head urb_list;   struct list_head anchor_list;   struct usb_anchor *anchor;   struct usb_device *dev;   struct usb_host_endpoint *ep;   unsigned int pipe;   unsigned int stream_id;   int status;   unsigned int transfer_flags;   void *transfer_buffer;   dma_addr_t transfer_dma;   struct scatterlist *sg;   int num_mapped_sgs;   int num_sgs;   u32 transfer_buffer_length;   u32 actual_length;   unsigned char *setup_packet;   dma_addr_t setup_dma;   int start_frame;   int number_of_packets;   int interval;   int error_count;   void *context;   void (*complete)(struct urb *);   struct usb_iso_packet_descriptor iso_frame_desc[0U]; } ;    80     struct snd_card ;    89     struct snd_info_entry ;    89     struct snd_shutdown_f_ops ;    89     struct snd_mixer_oss ;    89     struct snd_card {   int number;   char id[16U];   char driver[16U];   char shortname[32U];   char longname[80U];   char mixername[80U];   char components[128U];   struct module *module;   void *private_data;   void (*private_free)(struct snd_card *);   struct list_head devices;   unsigned int last_numid;   struct rw_semaphore controls_rwsem;   rwlock_t ctl_files_rwlock;   int controls_count;   int user_ctl_count;   struct list_head controls;   struct list_head ctl_files;   struct snd_info_entry *proc_root;   struct snd_info_entry *proc_id;   struct proc_dir_entry *proc_root_link;   struct list_head files_list;   struct snd_shutdown_f_ops *s_f_ops;   spinlock_t files_lock;   int shutdown;   struct completion *release_completion;   struct device *dev;   struct device card_dev;   bool registered;   unsigned int power_state;   struct mutex power_lock;   wait_queue_head_t power_sleep;   struct snd_mixer_oss *mixer_oss;   int mixer_oss_change_count; } ;   959     struct snd_seq_device {   struct snd_card *card;   int device;   char id[32U];   char name[80U];   int argsize;   void *driver_data;   int status;   void *private_data;   void (*private_free)(struct snd_seq_device *);   struct list_head list; } ;    74     struct snd_rawmidi ;    75     struct snd_rawmidi_substream ;    76     struct snd_seq_port_info ;    77     struct snd_rawmidi_ops {   int (*open)(struct snd_rawmidi_substream *);   int (*close)(struct snd_rawmidi_substream *);   void (*trigger)(struct snd_rawmidi_substream *, int);   void (*drain)(struct snd_rawmidi_substream *); } ;    58     struct snd_rawmidi_global_ops {   int (*dev_register)(struct snd_rawmidi *);   int (*dev_unregister)(struct snd_rawmidi *);   void (*get_port_info)(struct snd_rawmidi *, int, struct snd_seq_port_info *); } ;    64     struct snd_rawmidi_runtime {   struct snd_rawmidi_substream *substream;   unsigned char drain;   unsigned char oss;   unsigned char *buffer;   size_t buffer_size;   size_t appl_ptr;   size_t hw_ptr;   size_t avail_min;   size_t avail;   size_t xruns;   spinlock_t lock;   wait_queue_head_t sleep;   void (*event)(struct snd_rawmidi_substream *);   struct work_struct event_work;   void *private_data;   void (*private_free)(struct snd_rawmidi_substream *); } ;    89     struct snd_rawmidi_str ;    89     struct snd_rawmidi_substream {   struct list_head list;   int stream;   int number;   unsigned char opened;   unsigned char append;   unsigned char active_sensing;   int use_count;   size_t bytes;   struct snd_rawmidi *rmidi;   struct snd_rawmidi_str *pstr;   char name[32U];   struct snd_rawmidi_runtime *runtime;   struct pid *pid;   struct snd_rawmidi_ops *ops; } ;   113     struct snd_rawmidi_str {   unsigned int substream_count;   unsigned int substream_opened;   struct list_head substreams; } ;   119     struct snd_rawmidi {   struct snd_card *card;   struct list_head list;   unsigned int device;   unsigned int info_flags;   char id[64U];   char name[80U];   int ossreg;   struct snd_rawmidi_global_ops *ops;   struct snd_rawmidi_str streams[2U];   void *private_data;   void (*private_free)(struct snd_rawmidi *);   struct mutex open_mutex;   wait_queue_head_t open_wait;   struct snd_info_entry *dev;   struct snd_info_entry *proc_entry;   struct snd_seq_device *seq_dev; } ;   185     struct midi_buffer {   unsigned char *buf;   int size;   int split;   int pos_read;   int pos_write;   int full;   int command_prev; } ;    36     struct usb_line6 ;    36     struct snd_line6_midi {   struct usb_line6 *line6;   struct snd_rawmidi_substream *substream_receive;   struct snd_rawmidi_substream *substream_transmit;   int num_active_send_urbs;   spinlock_t send_urb_lock;   spinlock_t midi_transmit_lock;   wait_queue_head_t send_wait;   struct midi_buffer midibuf_in;   struct midi_buffer midibuf_out; } ;    73     struct line6_properties {   int device_bit;   const char *id;   const char *name;   int capabilities; } ;   101     struct snd_line6_pcm ;   101     struct usb_line6 {   struct usb_device *usbdev;   int product;   const struct line6_properties *properties;   int interface_number;   int interval;   int max_packet_size;   struct device *ifcdev;   struct snd_card *card;   struct snd_line6_pcm *line6pcm;   struct snd_line6_midi *line6midi;   int ep_control_read;   int ep_control_write;   struct urb *urb_listen;   unsigned char *buffer_listen;   unsigned char *buffer_message;   int message_length; } ;    12     typedef unsigned long pteval_t;    18     struct __anonstruct_pte_t_11 {   pteval_t pte; } ;    18     typedef struct __anonstruct_pte_t_11 pte_t;   167     struct notifier_block ;    51     struct notifier_block {   int (*notifier_call)(struct notifier_block *, unsigned long, void *);   struct notifier_block *next;   int priority; } ;    63     struct blocking_notifier_head {   struct rw_semaphore rwsem;   struct notifier_block *head; } ;    12     struct plist_head {   struct list_head node_list; } ;   368     struct kmem_cache_cpu {   void **freelist;   unsigned long tid;   struct page *page;   struct page *partial;   unsigned int stat[26U]; } ;    48     struct kmem_cache_order_objects {   unsigned long x; } ;    58     struct memcg_cache_params ;    58     struct kmem_cache_node ;    58     struct kmem_cache {   struct kmem_cache_cpu *cpu_slab;   unsigned long flags;   unsigned long min_partial;   int size;   int object_size;   int offset;   int cpu_partial;   struct kmem_cache_order_objects oo;   struct kmem_cache_order_objects max;   struct kmem_cache_order_objects min;   gfp_t allocflags;   int refcount;   void (*ctor)(void *);   int inuse;   int align;   int reserved;   const char *name;   struct list_head list;   struct kobject kobj;   struct memcg_cache_params *memcg_params;   int max_attr_size;   struct kset *memcg_kset;   int remote_node_defrag_ratio;   struct kmem_cache_node *node[1024U]; } ;   501     struct __anonstruct_ldv_26718_199 {   struct callback_head callback_head;   struct kmem_cache *memcg_caches[0U]; } ;   501     struct __anonstruct_ldv_26724_200 {   struct mem_cgroup *memcg;   struct list_head list;   struct kmem_cache *root_cache;   atomic_t nr_pages; } ;   501     union __anonunion_ldv_26725_198 {   struct __anonstruct_ldv_26718_199 ldv_26718;   struct __anonstruct_ldv_26724_200 ldv_26724; } ;   501     struct memcg_cache_params {   bool is_root_cache;   union __anonunion_ldv_26725_198 ldv_26725; } ;   144     typedef unsigned long snd_pcm_uframes_t;   145     typedef long snd_pcm_sframes_t;   169     typedef int snd_pcm_access_t;   177     typedef int snd_pcm_format_t;   247     typedef int snd_pcm_subformat_t;   269     typedef int snd_pcm_state_t;   276     union snd_pcm_sync_id {   unsigned char id[16U];   unsigned short id16[8U];   unsigned int id32[4U]; } ;   309     typedef int snd_pcm_hw_param_t;   310     struct snd_interval {   unsigned int min;   unsigned int max;   unsigned char openmin;   unsigned char openmax;   unsigned char integer;   unsigned char empty; } ;   352     struct snd_mask {   __u32 bits[8U]; } ;   358     struct snd_pcm_hw_params {   unsigned int flags;   struct snd_mask masks[3U];   struct snd_mask mres[5U];   struct snd_interval intervals[12U];   struct snd_interval ires[9U];   unsigned int rmask;   unsigned int cmask;   unsigned int info;   unsigned int msbits;   unsigned int rate_num;   unsigned int rate_den;   snd_pcm_uframes_t fifo_size;   unsigned char reserved[64U]; } ;   419     struct snd_pcm_mmap_status {   snd_pcm_state_t state;   int pad1;   snd_pcm_uframes_t hw_ptr;   struct timespec tstamp;   snd_pcm_state_t suspended_state;   struct timespec audio_tstamp; } ;   428     struct snd_pcm_mmap_control {   snd_pcm_uframes_t appl_ptr;   snd_pcm_uframes_t avail_min; } ;   959     struct snd_dma_device {   int type;   struct device *dev; } ;    36     struct snd_dma_buffer {   struct snd_dma_device dev;   unsigned char *area;   dma_addr_t addr;   size_t bytes;   void *private_data; } ;    32     struct poll_table_struct {   void (*_qproc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);   unsigned long _key; } ;   188     struct vm_fault {   unsigned int flags;   unsigned long pgoff;   void *virtual_address;   struct page *page;   unsigned long max_pgoff;   pte_t *pte; } ;   221     struct vm_operations_struct {   void (*open)(struct vm_area_struct *);   void (*close)(struct vm_area_struct *);   int (*fault)(struct vm_area_struct *, struct vm_fault *);   void (*map_pages)(struct vm_area_struct *, struct vm_fault *);   int (*page_mkwrite)(struct vm_area_struct *, struct vm_fault *);   int (*access)(struct vm_area_struct *, unsigned long, void *, int, int);   const char * (*name)(struct vm_area_struct *);   int (*set_policy)(struct vm_area_struct *, struct mempolicy *);   struct mempolicy * (*get_policy)(struct vm_area_struct *, unsigned long);   int (*migrate)(struct vm_area_struct *, const nodemask_t *, const nodemask_t *, unsigned long);   int (*remap_pages)(struct vm_area_struct *, unsigned long, unsigned long, unsigned long); } ;    84     struct pm_qos_request {   struct plist_node node;   int pm_qos_class;   struct delayed_work work; } ;    48     struct pm_qos_flags_request {   struct list_head node;   s32 flags; } ;    53     enum dev_pm_qos_req_type {   DEV_PM_QOS_RESUME_LATENCY = 1,   DEV_PM_QOS_LATENCY_TOLERANCE = 2,   DEV_PM_QOS_FLAGS = 3 } ;    59     union __anonunion_data_216 {   struct plist_node pnode;   struct pm_qos_flags_request flr; } ;    59     struct dev_pm_qos_request {   enum dev_pm_qos_req_type type;   union __anonunion_data_216 data;   struct device *dev; } ;    68     enum pm_qos_type {   PM_QOS_UNITIALIZED = 0,   PM_QOS_MAX = 1,   PM_QOS_MIN = 2 } ;    74     struct pm_qos_constraints {   struct plist_head list;   s32 target_value;   s32 default_value;   s32 no_constraint_value;   enum pm_qos_type type;   struct blocking_notifier_head *notifiers; } ;    88     struct pm_qos_flags {   struct list_head list;   s32 effective_flags; } ;    93     struct dev_pm_qos {   struct pm_qos_constraints resume_latency;   struct pm_qos_constraints latency_tolerance;   struct pm_qos_flags flags;   struct dev_pm_qos_request *resume_latency_req;   struct dev_pm_qos_request *latency_tolerance_req;   struct dev_pm_qos_request *flags_req; } ;   220     struct snd_pcm_oss_setup {   char *task_name;   unsigned char disable;   unsigned char direct;   unsigned char block;   unsigned char nonblock;   unsigned char partialfrag;   unsigned char nosilence;   unsigned char buggyptr;   unsigned int periods;   unsigned int period_size;   struct snd_pcm_oss_setup *next; } ;    38     struct snd_pcm_plugin ;    38     struct snd_pcm_oss_runtime {   unsigned char params;   unsigned char prepare;   unsigned char trigger;   unsigned char sync_trigger;   int rate;   int format;   unsigned int channels;   unsigned int fragshift;   unsigned int maxfrags;   unsigned int subdivision;   size_t period_bytes;   size_t period_frames;   size_t period_ptr;   unsigned int periods;   size_t buffer_bytes;   size_t bytes;   size_t mmap_bytes;   char *buffer;   size_t buffer_used;   struct mutex params_lock;   struct snd_pcm_plugin *plugin_first;   struct snd_pcm_plugin *plugin_last;   unsigned int prev_hw_ptr_period; } ;    66     struct snd_pcm_substream ;    70     struct snd_pcm_oss_substream {   unsigned char oss;   struct snd_pcm_oss_setup setup; } ;    75     struct snd_pcm_oss_stream {   struct snd_pcm_oss_setup *setup_list;   struct mutex setup_mutex;   struct snd_info_entry *proc_entry; } ;    82     struct snd_pcm_oss {   int reg;   unsigned int reg_mask; } ;    88     struct snd_pcm_hardware {   unsigned int info;   u64 formats;   unsigned int rates;   unsigned int rate_min;   unsigned int rate_max;   unsigned int channels_min;   unsigned int channels_max;   size_t buffer_bytes_max;   size_t period_bytes_min;   size_t period_bytes_max;   unsigned int periods_min;   unsigned int periods_max;   size_t fifo_size; } ;    60     struct snd_pcm_ops {   int (*open)(struct snd_pcm_substream *);   int (*close)(struct snd_pcm_substream *);   int (*ioctl)(struct snd_pcm_substream *, unsigned int, void *);   int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);   int (*hw_free)(struct snd_pcm_substream *);   int (*prepare)(struct snd_pcm_substream *);   int (*trigger)(struct snd_pcm_substream *, int);   snd_pcm_uframes_t  (*pointer)(struct snd_pcm_substream *);   int (*wall_clock)(struct snd_pcm_substream *, struct timespec *);   int (*copy)(struct snd_pcm_substream *, int, snd_pcm_uframes_t , void *, snd_pcm_uframes_t );   int (*silence)(struct snd_pcm_substream *, int, snd_pcm_uframes_t , snd_pcm_uframes_t );   struct page * (*page)(struct snd_pcm_substream *, unsigned long);   int (*mmap)(struct snd_pcm_substream *, struct vm_area_struct *);   int (*ack)(struct snd_pcm_substream *); } ;   214     struct snd_pcm_hw_rule ;   217     struct snd_pcm_hw_rule {   unsigned int cond;   int (*func)(struct snd_pcm_hw_params *, struct snd_pcm_hw_rule *);   int var;   int deps[4U];   void *private; } ;   226     struct snd_pcm_hw_constraints {   struct snd_mask masks[3U];   struct snd_interval intervals[12U];   unsigned int rules_num;   unsigned int rules_all;   struct snd_pcm_hw_rule *rules; } ;   253     struct snd_ratden {   unsigned int num_min;   unsigned int num_max;   unsigned int num_step;   unsigned int den; } ;   263     struct snd_pcm_hw_constraint_ratdens {   int nrats;   struct snd_ratden *rats; } ;   274     struct snd_pcm_hwptr_log ;   275     struct snd_pcm_runtime {   struct snd_pcm_substream *trigger_master;   struct timespec trigger_tstamp;   int overrange;   snd_pcm_uframes_t avail_max;   snd_pcm_uframes_t hw_ptr_base;   snd_pcm_uframes_t hw_ptr_interrupt;   unsigned long hw_ptr_jiffies;   unsigned long hw_ptr_buffer_jiffies;   snd_pcm_sframes_t delay;   u64 hw_ptr_wrap;   snd_pcm_access_t access;   snd_pcm_format_t format;   snd_pcm_subformat_t subformat;   unsigned int rate;   unsigned int channels;   snd_pcm_uframes_t period_size;   unsigned int periods;   snd_pcm_uframes_t buffer_size;   snd_pcm_uframes_t min_align;   size_t byte_align;   unsigned int frame_bits;   unsigned int sample_bits;   unsigned int info;   unsigned int rate_num;   unsigned int rate_den;   unsigned char no_period_wakeup;   int tstamp_mode;   unsigned int period_step;   snd_pcm_uframes_t start_threshold;   snd_pcm_uframes_t stop_threshold;   snd_pcm_uframes_t silence_threshold;   snd_pcm_uframes_t silence_size;   snd_pcm_uframes_t boundary;   snd_pcm_uframes_t silence_start;   snd_pcm_uframes_t silence_filled;   union snd_pcm_sync_id sync;   struct snd_pcm_mmap_status *status;   struct snd_pcm_mmap_control *control;   snd_pcm_uframes_t twake;   wait_queue_head_t sleep;   wait_queue_head_t tsleep;   struct fasync_struct *fasync;   void *private_data;   void (*private_free)(struct snd_pcm_runtime *);   struct snd_pcm_hardware hw;   struct snd_pcm_hw_constraints hw_constraints;   void (*transfer_ack_begin)(struct snd_pcm_substream *);   void (*transfer_ack_end)(struct snd_pcm_substream *);   unsigned int timer_resolution;   int tstamp_type;   unsigned char *dma_area;   dma_addr_t dma_addr;   size_t dma_bytes;   struct snd_dma_buffer *dma_buffer_p;   struct snd_pcm_oss_runtime oss;   struct snd_pcm_hwptr_log *hwptr_log; } ;   364     struct snd_pcm_group {   spinlock_t lock;   struct list_head substreams;   int count; } ;   371     struct snd_pcm ;   371     struct snd_pcm_str ;   371     struct snd_timer ;   371     struct snd_pcm_substream {   struct snd_pcm *pcm;   struct snd_pcm_str *pstr;   void *private_data;   int number;   char name[32U];   int stream;   struct pm_qos_request latency_pm_qos_req;   size_t buffer_bytes_max;   struct snd_dma_buffer dma_buffer;   size_t dma_max;   const struct snd_pcm_ops *ops;   struct snd_pcm_runtime *runtime;   struct snd_timer *timer;   unsigned char timer_running;   struct snd_pcm_substream *next;   struct list_head link_list;   struct snd_pcm_group self_group;   struct snd_pcm_group *group;   void *file;   int ref_count;   atomic_t mmap_count;   unsigned int f_flags;   void (*pcm_release)(struct snd_pcm_substream *);   struct pid *pid;   struct snd_pcm_oss_substream oss;   struct snd_info_entry *proc_root;   struct snd_info_entry *proc_info_entry;   struct snd_info_entry *proc_hw_params_entry;   struct snd_info_entry *proc_sw_params_entry;   struct snd_info_entry *proc_status_entry;   struct snd_info_entry *proc_prealloc_entry;   struct snd_info_entry *proc_prealloc_max_entry;   unsigned char hw_opened; } ;   421     struct snd_kcontrol ;   421     struct snd_pcm_str {   int stream;   struct snd_pcm *pcm;   unsigned int substream_count;   unsigned int substream_opened;   struct snd_pcm_substream *substream;   struct snd_pcm_oss_stream oss;   struct snd_info_entry *proc_root;   struct snd_info_entry *proc_info_entry;   unsigned int xrun_debug;   struct snd_info_entry *proc_xrun_debug_entry;   struct snd_kcontrol *chmap_kctl; } ;   446     struct snd_pcm {   struct snd_card *card;   struct list_head list;   int device;   unsigned int info_flags;   unsigned short dev_class;   unsigned short dev_subclass;   char id[64U];   char name[80U];   struct snd_pcm_str streams[2U];   struct mutex open_mutex;   wait_queue_head_t open_wait;   void *private_data;   void (*private_free)(struct snd_pcm *);   struct device *dev;   bool internal;   struct snd_pcm_oss oss; } ;   109     struct line6_pcm_properties {   struct snd_pcm_hardware snd_line6_playback_hw;   struct snd_pcm_hardware snd_line6_capture_hw;   struct snd_pcm_hw_constraint_ratdens snd_line6_rates;   int bytes_per_frame; } ;   181     struct snd_line6_pcm {   struct usb_line6 *line6;   struct line6_pcm_properties *properties;   struct snd_pcm *pcm;   struct urb *urb_audio_out[2U];   struct urb *urb_audio_in[2U];   unsigned char *buffer_out;   unsigned char *buffer_in;   unsigned char *prev_fbuf;   int prev_fsize;   snd_pcm_uframes_t pos_out;   unsigned int bytes_out;   unsigned int count_out;   unsigned int period_out;   snd_pcm_uframes_t pos_out_done;   unsigned int bytes_in;   unsigned int count_in;   unsigned int period_in;   snd_pcm_uframes_t pos_in_done;   unsigned long active_urb_out;   int max_packet_size;   int ep_audio_read;   int ep_audio_write;   unsigned long active_urb_in;   unsigned long unlink_urb_out;   unsigned long unlink_urb_in;   spinlock_t lock_audio_out;   spinlock_t lock_audio_in;   spinlock_t lock_trigger;   int volume_playback[2U];   int volume_monitor;   int impulse_volume;   int impulse_period;   int impulse_count;   unsigned long flags;   int last_frame_in;   int last_frame_out; } ;   219     struct _ddebug {   const char *modname;   const char *function;   const char *filename;   const char *format;   unsigned int lineno;   unsigned char flags; } ;    39     struct usb_device_id {   __u16 match_flags;   __u16 idVendor;   __u16 idProduct;   __u16 bcdDevice_lo;   __u16 bcdDevice_hi;   __u8 bDeviceClass;   __u8 bDeviceSubClass;   __u8 bDeviceProtocol;   __u8 bInterfaceClass;   __u8 bInterfaceSubClass;   __u8 bInterfaceProtocol;   __u8 bInterfaceNumber;   kernel_ulong_t driver_info; } ;    48     struct usb_line6_pod {   struct usb_line6 line6;   int monitor_level;   struct timer_list startup_timer;   struct work_struct startup_work;   int startup_progress;   int serial_number;   int firmware_version;   int device_id; } ;   100     struct usb_line6_podhd {   struct usb_line6 line6; } ;    28     struct usb_line6_toneport {   struct usb_line6 line6;   int source;   int serial_number;   int firmware_version;   struct timer_list timer; } ;    61     struct usb_line6_variax {   struct usb_line6 line6;   unsigned char *buffer_activate;   struct work_struct startup_work;   struct timer_list startup_timer1;   struct timer_list startup_timer2;   int startup_progress; } ;   118     struct message {   struct usb_line6 *line6;   const char *buffer;   int size;   int done; } ;  1529     typedef struct usb_device *ldv_func_ret_type;  1540     typedef struct usb_device *ldv_func_ret_type___0;    12     struct __wait_queue ;    12     typedef struct __wait_queue wait_queue_t;    15     struct __wait_queue {   unsigned int flags;   void *private;   int (*func)(wait_queue_t *, unsigned int, int, void *);   struct list_head task_list; } ;   662     enum snd_device_type {   SNDRV_DEV_LOWLEVEL = 0,   SNDRV_DEV_CONTROL = 1,   SNDRV_DEV_INFO = 2,   SNDRV_DEV_BUS = 3,   SNDRV_DEV_CODEC = 4,   SNDRV_DEV_PCM = 5,   SNDRV_DEV_COMPRESS = 6,   SNDRV_DEV_RAWMIDI = 7,   SNDRV_DEV_TIMER = 8,   SNDRV_DEV_SEQUENCER = 9,   SNDRV_DEV_HWDEP = 10,   SNDRV_DEV_JACK = 11 } ;   677     enum snd_device_state {   SNDRV_DEV_BUILD = 0,   SNDRV_DEV_REGISTERED = 1,   SNDRV_DEV_DISCONNECTED = 2 } ;   683     struct snd_device ;   684     struct snd_device_ops {   int (*dev_free)(struct snd_device *);   int (*dev_register)(struct snd_device *);   int (*dev_disconnect)(struct snd_device *); } ;    80     struct snd_device {   struct list_head list;   struct snd_card *card;   enum snd_device_state state;   enum snd_device_type type;   void *device_data;   struct snd_device_ops *ops; } ;   470     struct snd_aes_iec958 {   unsigned char status[24U];   unsigned char subcode[147U];   unsigned char pad;   unsigned char dig_subframe[4U]; } ;   779     typedef int snd_ctl_elem_type_t;   789     typedef int snd_ctl_elem_iface_t;   790     struct snd_ctl_elem_id {   unsigned int numid;   snd_ctl_elem_iface_t iface;   unsigned int device;   unsigned int subdevice;   unsigned char name[44U];   unsigned int index; } ;   842     struct __anonstruct_integer_204 {   long min;   long max;   long step; } ;   842     struct __anonstruct_integer64_205 {   long long min;   long long max;   long long step; } ;   842     struct __anonstruct_enumerated_206 {   unsigned int items;   unsigned int item;   char name[64U];   __u64 names_ptr;   unsigned int names_length; } ;   842     union __anonunion_value_203 {   struct __anonstruct_integer_204 integer;   struct __anonstruct_integer64_205 integer64;   struct __anonstruct_enumerated_206 enumerated;   unsigned char reserved[128U]; } ;   842     union __anonunion_dimen_207 {   unsigned short d[4U];   unsigned short *d_ptr; } ;   842     struct snd_ctl_elem_info {   struct snd_ctl_elem_id id;   snd_ctl_elem_type_t type;   unsigned int access;   unsigned int count;   __kernel_pid_t owner;   union __anonunion_value_203 value;   union __anonunion_dimen_207 dimen;   unsigned char reserved[56U]; } ;   875     union __anonunion_integer_209 {   long value[128U];   long *value_ptr; } ;   875     union __anonunion_integer64_210 {   long long value[64U];   long long *value_ptr; } ;   875     union __anonunion_enumerated_211 {   unsigned int item[128U];   unsigned int *item_ptr; } ;   875     union __anonunion_bytes_212 {   unsigned char data[512U];   unsigned char *data_ptr; } ;   875     union __anonunion_value_208 {   union __anonunion_integer_209 integer;   union __anonunion_integer64_210 integer64;   union __anonunion_enumerated_211 enumerated;   union __anonunion_bytes_212 bytes;   struct snd_aes_iec958 iec958; } ;   875     struct snd_ctl_elem_value {   struct snd_ctl_elem_id id;   unsigned char indirect;   union __anonunion_value_208 value;   struct timespec tstamp;   unsigned char reserved[112U]; } ;    30     typedef int snd_kcontrol_info_t(struct snd_kcontrol *, struct snd_ctl_elem_info *);    31     typedef int snd_kcontrol_get_t(struct snd_kcontrol *, struct snd_ctl_elem_value *);    32     typedef int snd_kcontrol_put_t(struct snd_kcontrol *, struct snd_ctl_elem_value *);    33     typedef int snd_kcontrol_tlv_rw_t(struct snd_kcontrol *, int, unsigned int, unsigned int *);    34     union __anonunion_tlv_215 {   snd_kcontrol_tlv_rw_t *c;   const unsigned int *p; } ;    34     struct snd_kcontrol_new {   snd_ctl_elem_iface_t iface;   unsigned int device;   unsigned int subdevice;   const unsigned char *name;   unsigned int index;   unsigned int access;   unsigned int count;   snd_kcontrol_info_t *info;   snd_kcontrol_get_t *get;   snd_kcontrol_put_t *put;   union __anonunion_tlv_215 tlv;   unsigned long private_value; } ;    56     struct snd_ctl_file ;    56     struct snd_kcontrol_volatile {   struct snd_ctl_file *owner;   unsigned int access; } ;    61     union __anonunion_tlv_216 {   snd_kcontrol_tlv_rw_t *c;   const unsigned int *p; } ;    61     struct snd_kcontrol {   struct list_head list;   struct snd_ctl_elem_id id;   unsigned int count;   snd_kcontrol_info_t *info;   snd_kcontrol_get_t *get;   snd_kcontrol_put_t *put;   union __anonunion_tlv_216 tlv;   unsigned long private_value;   void *private_data;   void (*private_free)(struct snd_kcontrol *);   struct snd_kcontrol_volatile vd[0U]; } ;    86     struct snd_ctl_file {   struct list_head list;   struct snd_card *card;   struct pid *pid;   int prefer_pcm_subdevice;   int prefer_rawmidi_subdevice;   wait_queue_head_t change_sleep;   spinlock_t read_lock;   struct fasync_struct *fasync;   int subscribed;   struct list_head events; } ;   110     struct __anonstruct_toneport_source_info_216 {   const char *name;   int code; } ;    33     extern struct module __this_module;   388     int sprintf(char *, const char *, ...);    62     char * strcpy(char *, const char *);    86     const char * kobject_name(const struct kobject *kobj);   806     const char * dev_name(const struct device *dev);   281     int snd_card_new(struct device *, int, const char *, struct module *, int, struct snd_card **);   285     int snd_card_disconnect(struct snd_card *);   286     int snd_card_free(struct snd_card *);   289     int snd_card_register(struct snd_card *);    17     void line6_cleanup_audio(struct usb_line6 *line6);    18     int line6_init_audio(struct usb_line6 *line6);    19     int line6_register_audio(struct usb_line6 *line6);     1     void * __builtin_memcpy(void *, const void *, unsigned long);    72     void set_bit(long nr, volatile unsigned long *addr);   110     void clear_bit(long nr, volatile unsigned long *addr);   204     int test_and_set_bit(long nr, volatile unsigned long *addr);   250     int test_and_clear_bit(long nr, volatile unsigned long *addr);   308     int constant_test_bit(long nr, const volatile unsigned long *addr);   314     int variable_test_bit(long nr, const volatile unsigned long *addr);   396     int ffs(int x);    53     unsigned long int find_first_zero_bit(const unsigned long *, unsigned long);    88     void __bad_percpu_size();    10     extern struct task_struct *current_task;    12     struct task_struct * get_current();    11     void __xchg_wrong_size();    32     unsigned long int _raw_spin_lock_irqsave(raw_spinlock_t *);    43     void _raw_spin_unlock_irqrestore(raw_spinlock_t *, unsigned long);   290     raw_spinlock_t * spinlock_check(spinlock_t *lock);   356     void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags);  1042     int dev_err(const struct device *, const char *, ...);   377     long int schedule_timeout(long);  1581     struct urb * usb_alloc_urb(int, gfp_t );  1585     int usb_submit_urb(struct urb *, gfp_t );  1586     int usb_unlink_urb(struct urb *);  1784     unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint);   144     void kfree(const void *);   334     void __snd_printk(unsigned int, const char *, int, const char *, ...);   761     const struct snd_mask * hw_param_mask_c(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);   767     const struct snd_interval * hw_param_interval_c(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);   823     int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *, unsigned int, snd_pcm_hw_param_t , struct snd_pcm_hw_constraint_ratdens *);   867     int snd_pcm_format_physical_width(snd_pcm_format_t );   877     int snd_pcm_lib_ioctl(struct snd_pcm_substream *, unsigned int, void *);   887     void snd_pcm_period_elapsed(struct snd_pcm_substream *);   952     int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *, size_t );   953     int snd_pcm_lib_free_pages(struct snd_pcm_substream *);    90     unsigned int snd_mask_min(const struct snd_mask *mask);   350     unsigned int params_period_bytes(const struct snd_pcm_hw_params *p);   376     int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd);   377     int snd_line6_prepare(struct snd_pcm_substream *substream);   379     int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels);   380     int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels);    20     struct snd_pcm_ops snd_line6_capture_ops;    22     void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize);    24     void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length);    26     int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm);    27     void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm);    28     int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm);    29     void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm);    30     void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm);    32     void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm);    33     int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd);    43     int submit_audio_in_urb(struct snd_line6_pcm *line6pcm);   224     void audio_in_callback(struct urb *urb);   293     int snd_line6_capture_open(struct snd_pcm_substream *substream);   311     int snd_line6_capture_close(struct snd_pcm_substream *substream);   317     int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params);   352     int snd_line6_capture_hw_free(struct snd_pcm_substream *substream);   399     snd_pcm_uframes_t  snd_line6_capture_pointer(struct snd_pcm_substream *substream);   407     struct snd_pcm_ops snd_line6_capture_ops = { &snd_line6_capture_open, &snd_line6_capture_close, &snd_pcm_lib_ioctl, &snd_line6_capture_hw_params, &snd_line6_capture_hw_free, &snd_line6_prepare, &snd_line6_trigger, &snd_line6_capture_pointer, 0, 0, 0, 0, 0, 0 };   467     void ldv_check_final_state();   470     void ldv_check_return_value(int);   476     void ldv_initialize();   479     void ldv_handler_precall();   482     int nondet_int();   485     int LDV_IN_INTERRUPT = 0;   488     void ldv_main1_sequence_infinite_withcheck_stateful();     1     long int __builtin_expect(long exp, long c);   139     int printk(const char *, ...);    53     int __dynamic_dev_dbg(struct _ddebug *, const struct device *, const char *, ...);    34     void * __memcpy(void *, const void *, size_t );   120     void * kmemdup(const void *, size_t , gfp_t );   144     void __wake_up(wait_queue_head_t *, unsigned int, int, void *);    77     extern volatile unsigned long jiffies;    94     void init_timer_key(struct timer_list *, unsigned int, const char *, struct lock_class_key *);   240     void add_timer(struct timer_list *);   207     int sysfs_create_link(struct kobject *, struct kobject *, const char *);   212     void sysfs_remove_link(struct kobject *, const char *);   837     void * dev_get_drvdata(const struct device *dev);   842     void dev_set_drvdata(struct device *dev, void *data);  1048     int _dev_info(const struct device *, const char *, ...);   194     void * usb_get_intfdata(struct usb_interface *intf);   199     void usb_set_intfdata(struct usb_interface *intf, void *data);   204     struct usb_interface * usb_get_intf(struct usb_interface *);   205     void usb_put_intf(struct usb_interface *);   595     struct usb_device * ldv_interface_to_usbdev_15(struct usb_interface *intf);   595     struct usb_device * interface_to_usbdev(struct usb_interface *intf);   605     struct usb_device * usb_get_dev(struct usb_device *);   607     struct usb_device * ldv_usb_get_dev_16(struct usb_device *ldv_func_arg1);   609     void usb_put_dev(struct usb_device *);   612     void ldv_usb_put_dev_17(struct usb_device *ldv_func_arg1);  1552     void usb_fill_int_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, void *transfer_buffer, int buffer_length, void (*complete_fn)(struct urb *), void *context, int interval);  1582     void usb_free_urb(struct urb *);  1587     void usb_kill_urb(struct urb *);  1656     int usb_control_msg(struct usb_device *, unsigned int, __u8 , __u8 , __u16 , __u16 , void *, __u16 , int);  1659     int usb_interrupt_msg(struct usb_device *, unsigned int, void *, int, int *, int);  1676     int usb_set_interface(struct usb_device *, int, int);    14     void ldv_interface_to_usbdev();    15     void ldv_usb_get_dev();    16     void ldv_usb_put_dev();   315     void * __kmalloc(size_t , gfp_t );   445     void * kmalloc(size_t size, gfp_t flags);   637     void * kzalloc(size_t size, gfp_t flags);   164     void snd_power_change_state(struct snd_card *card, unsigned int state);    27     int line6_midibuf_ignore(struct midi_buffer *this, int length);    29     int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, int length);    35     int line6_midibuf_write(struct midi_buffer *this, unsigned char *data, int length);    69     void line6_midi_receive(struct usb_line6 *line6, unsigned char *data, int length);    69     const unsigned char line6_midi_id[3U];    72     const int SYSEX_EXTRA_SIZE = 7;   189     char * line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, int size);   191     ssize_t  line6_nop_read(struct device *dev, struct device_attribute *attr, char *buf);   193     int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen);   195     int line6_read_serial_number(struct usb_line6 *line6, int *serial_number);   197     int line6_send_program(struct usb_line6 *line6, u8 value);   198     int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, int size);   200     int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size);   202     int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int size);   206     void line6_start_timer(struct timer_list *timer, unsigned int msecs, void (*function)(unsigned long), unsigned long data);   209     int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value);   211     int line6_version_request_async(struct usb_line6 *line6);   212     int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen);   507     int snd_pcm_suspend_all(struct snd_pcm *);   378     void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm);    95     void line6_pod_disconnect(struct usb_interface *interface);    96     int line6_pod_init(struct usb_interface *interface, struct usb_line6_pod *pod);    98     void line6_pod_process_message(struct usb_line6_pod *pod);    26     void line6_podhd_disconnect(struct usb_interface *interface);    27     int line6_podhd_init(struct usb_interface *interface, struct usb_line6_podhd *podhd);    47     void line6_toneport_disconnect(struct usb_interface *interface);    48     int line6_toneport_init(struct usb_interface *interface, struct usb_line6_toneport *toneport);    50     void line6_toneport_reset_resume(struct usb_line6_toneport *toneport);    67     void line6_variax_disconnect(struct usb_interface *interface);    68     int line6_variax_init(struct usb_interface *interface, struct usb_line6_variax *variax);    70     void line6_variax_process_message(struct usb_line6_variax *variax);    51     const struct usb_device_id line6_id_table[21U] = { { 3U, 3649U, 16976U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 17986U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16978U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 18256U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 20561U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 20567U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 20568U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16717U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16723U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16720U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16721U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16714U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16715U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 20548U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 18000U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 20560U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16711U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16705U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 16706U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL }, { 3U, 3649U, 21325U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0UL } };    75     const struct usb_device_id __mod_usb__line6_id_table_device_table = {  };    82     const struct line6_properties line6_properties_table[20U] = { { 1, "BassPODxt", "BassPODxt", 7 }, { 2, "BassPODxtLive", "BassPODxt Live", 7 }, { 4, "BassPODxtPro", "BassPODxt Pro", 7 }, { 8, "GuitarPort", "GuitarPort", 2 }, { 16, "PocketPOD", "Pocket POD", 1 }, { 32, "PODHD300", "POD HD300", 7 }, { 64, "PODHD400", "POD HD400", 7 }, { 128, "PODHD500", "POD HD500", 7 }, { 256, "PODStudioGX", "POD Studio GX", 2 }, { 512, "PODStudioUX1", "POD Studio UX1", 2 }, { 1024, "PODStudioUX2", "POD Studio UX2", 2 }, { 2048, "PODX3", "POD X3", 2 }, { 4096, "PODX3Live", "POD X3 Live", 2 }, { 8192, "PODxt", "PODxt", 7 }, { 16384, "PODxtLive", "PODxt Live", 7 }, { 32768, "PODxtPro", "PODxt Pro", 7 }, { 65536, "TonePortGX", "TonePort GX", 2 }, { 131072, "TonePortUX1", "TonePort UX1", 2 }, { 262144, "TonePortUX2", "TonePort UX2", 2 }, { 524288, "Variax", "Variax Workbench", 1 } };   109     const unsigned char line6_midi_id[3U] = { 0U, 1U, 12U };   117     const char line6_request_version[6U] = { -16, 126, 127, 6, 1, -9 };   134     void line6_data_received(struct urb *urb);   135     int line6_send_raw_message_async_part(struct message *msg, struct urb *urb);   141     int line6_start_listen(struct usb_line6 *line6);   157     void line6_stop_listen(struct usb_line6 *line6);   197     void line6_async_request_sent(struct urb *urb);   598     void line6_destruct(struct usb_interface *interface);   625     int line6_probe(struct usb_interface *interface, const struct usb_device_id *id);  1014     void line6_disconnect(struct usb_interface *interface);  1106     int line6_suspend(struct usb_interface *interface, pm_message_t message);  1128     int line6_resume(struct usb_interface *interface);  1142     int line6_reset_resume(struct usb_interface *interface);  1203     void ldv_check_return_value_probe(int retval);  1218     void ldv_main2_sequence_infinite_withcheck_stateful();    24     void INIT_LIST_HEAD(struct list_head *list);    93     void __raw_spin_lock_init(raw_spinlock_t *, const char *, struct lock_class_key *);    68     void __init_waitqueue_head(wait_queue_head_t *, const char *, struct lock_class_key *);   823     long int prepare_to_wait_event(wait_queue_head_t *, wait_queue_t *, int);   824     void finish_wait(wait_queue_head_t *, wait_queue_t *);   381     void schedule();   301     int snd_device_new(struct snd_card *, enum snd_device_type , void *, struct snd_device_ops *);   152     int snd_rawmidi_new(struct snd_card *, char *, int, int, int, struct snd_rawmidi **);   155     void snd_rawmidi_set_ops(struct snd_rawmidi *, int, struct snd_rawmidi_ops *);   160     int snd_rawmidi_receive(struct snd_rawmidi_substream *, const unsigned char *, int);   163     int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *, unsigned char *, int);   165     int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *, int);    25     int line6_midibuf_bytes_free(struct midi_buffer *this);    26     void line6_midibuf_destroy(struct midi_buffer *this);    28     int line6_midibuf_init(struct midi_buffer *this, int size, int split);    68     int line6_init_midi(struct usb_line6 *line6);    43     int send_midi_async(struct usb_line6 *line6, unsigned char *data, int length);    60     void line6_midi_transmit(struct snd_rawmidi_substream *substream);    99     void midi_sent(struct urb *urb);   172     int line6_midi_output_open(struct snd_rawmidi_substream *substream);   177     int line6_midi_output_close(struct snd_rawmidi_substream *substream);   182     void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, int up___0);   198     void line6_midi_output_drain(struct snd_rawmidi_substream *substream);   208     int line6_midi_input_open(struct snd_rawmidi_substream *substream);   213     int line6_midi_input_close(struct snd_rawmidi_substream *substream);   218     void line6_midi_input_trigger(struct snd_rawmidi_substream *substream, int up___0);   230     struct snd_rawmidi_ops line6_midi_output_ops = { &line6_midi_output_open, &line6_midi_output_close, &line6_midi_output_trigger, &line6_midi_output_drain };   237     struct snd_rawmidi_ops line6_midi_input_ops = { &line6_midi_input_open, &line6_midi_input_close, &line6_midi_input_trigger, 0 };   246     void line6_cleanup_midi(struct snd_rawmidi *rmidi);   251     int snd_line6_new_midi(struct snd_line6_midi *line6midi);   278     int snd_line6_midi_free(struct snd_device *device);   377     void ldv_main3_sequence_infinite_withcheck_stateful();    45     int __dynamic_pr_debug(struct _ddebug *, const char *, ...);    24     int line6_midibuf_bytes_used(struct midi_buffer *this);    31     void line6_midibuf_reset(struct midi_buffer *this);    32     int line6_midibuf_skip_message(struct midi_buffer *this, unsigned short mask);    34     void line6_midibuf_status(struct midi_buffer *this);    32     int midibuf_message_length(unsigned char code);    52     int midibuf_is_empty(struct midi_buffer *this);    57     int midibuf_is_full(struct midi_buffer *this);   315     int kstrtoint(const char *, unsigned int, int *);    71     void warn_slowpath_null(const char *, const int);    13     void __cmpxchg_wrong_size();    22     void _raw_spin_lock(raw_spinlock_t *);    39     void _raw_spin_unlock(raw_spinlock_t *);    22     void _raw_read_lock_irq(rwlock_t *);    34     void _raw_read_unlock_irq(rwlock_t *);   301     void spin_lock(spinlock_t *lock);   341     void spin_unlock(spinlock_t *lock);   603     int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd);   559     int device_create_file(struct device *, const struct device_attribute *);   561     void device_remove_file(struct device *, const struct device_attribute *);  1819     __u16  usb_maxpacket(struct usb_device *udev, int pipe, int is_out);   112     struct snd_kcontrol * snd_ctl_new1(const struct snd_kcontrol_new *, void *);   114     int snd_ctl_add(struct snd_card *, struct snd_kcontrol *);   481     int snd_pcm_new(struct snd_card *, const char *, int, int, int, struct snd_pcm **);   495     extern rwlock_t snd_pcm_link_rwlock;   503     int snd_pcm_stop(struct snd_pcm_substream *, snd_pcm_state_t );   552     void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);   558     void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);   579     int snd_pcm_running(struct snd_pcm_substream *substream);   873     void snd_pcm_set_ops(struct snd_pcm *, int, const struct snd_pcm_ops *);   949     int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *, int, void *, size_t , size_t );   374     int line6_init_pcm(struct usb_line6 *line6, struct line6_pcm_properties *properties);    30     struct snd_pcm_ops snd_line6_playback_ops;    32     int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm);    33     void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm);    34     int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm);    35     void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm);    36     void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm);    38     void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm);    39     int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd);    43     struct snd_line6_pcm * dev2pcm(struct device *dev);    54     ssize_t  impulse_volume_show(struct device *dev, struct device_attribute *attr, char *buf);    63     ssize_t  impulse_volume_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);    84     struct device_attribute dev_attr_impulse_volume = { { "impulse_volume", 420U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &impulse_volume_show, &impulse_volume_store };    89     ssize_t  impulse_period_show(struct device *dev, struct device_attribute *attr, char *buf);    98     ssize_t  impulse_period_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);   112     struct device_attribute dev_attr_impulse_period = { { "impulse_period", 420U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &impulse_period_show, &impulse_period_store };   116     bool  test_flags(unsigned long flags0, unsigned long flags1, unsigned long mask);   290     int snd_line6_control_playback_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);   301     int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   314     int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   332     struct snd_kcontrol_new line6_control_playback = { 2, 0U, 0U, (const unsigned char *)"PCM Playback Volume", 0U, 3U, 0U, &snd_line6_control_playback_info, &snd_line6_control_playback_get, &snd_line6_control_playback_put, { 0 }, 0UL };   345     void line6_cleanup_pcm(struct snd_pcm *pcm);   368     int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm);   399     int snd_line6_pcm_free(struct snd_device *device);   407     void pcm_disconnect_substream(struct snd_pcm_substream *substream);   632     void ldv_main5_sequence_infinite_withcheck_stateful();    55     void * memset(void *, int, size_t );    44     void change_volume(struct urb *urb_out, int *volume, int bytes_per_frame);    86     void create_impulse_test_signal(struct snd_line6_pcm *line6pcm, struct urb *urb_out, int bytes_per_frame);   131     void add_monitor_signal(struct urb *urb_out, unsigned char *signal, int volume, int bytes_per_frame);   157     int submit_audio_out_urb(struct snd_line6_pcm *line6pcm);   381     void audio_out_callback(struct urb *urb);   446     int snd_line6_playback_open(struct snd_pcm_substream *substream);   463     int snd_line6_playback_close(struct snd_pcm_substream *substream);   469     int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params);   504     int snd_line6_playback_hw_free(struct snd_pcm_substream *substream);   559     snd_pcm_uframes_t  snd_line6_playback_pointer(struct snd_pcm_substream *substream);   567     struct snd_pcm_ops snd_line6_playback_ops = { &snd_line6_playback_open, &snd_line6_playback_close, &snd_pcm_lib_ioctl, &snd_line6_playback_hw_params, &snd_line6_playback_hw_free, &snd_line6_prepare, &snd_line6_trigger, &snd_line6_playback_pointer, 0, 0, 0, 0, 0, 0 };   648     void ldv_main6_sequence_infinite_withcheck_stateful();    60     int memcmp(const void *, const void *, size_t );   279     void lockdep_init_map(struct lockdep_map *, const char *, struct lock_class_key *, int);   175     int del_timer(struct timer_list *);   180     void __init_work(struct work_struct *, int);   355     extern struct workqueue_struct *system_wq;   431     bool  queue_work_on(int, struct workqueue_struct *, struct work_struct *);   447     bool  cancel_work_sync(struct work_struct *);   471     bool  queue_work(struct workqueue_struct *wq, struct work_struct *work);   530     bool  schedule_work(struct work_struct *work);    71     const int SYSEX_DATA_OFS = 6;    99     void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param, u8 value);    78     struct snd_ratden pod_ratden = { 78125U, 78125U, 1U, 2U };    85     struct line6_pcm_properties pod_pcm_properties = { { 5046531U, 4294967296ULL, 2147483648U, 39062U, 39063U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 4522243U, 4294967296ULL, 2147483648U, 39062U, 39063U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 1, &pod_ratden }, 6 };   133     const char pod_version_header[5U] = { -14, 126, 127, 6, 2 };   138     void pod_startup2(unsigned long data);   139     void pod_startup3(struct usb_line6_pod *pod);   141     char * pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code, int size);   190     int pod_set_system_param_int(struct usb_line6_pod *pod, int value, int code);   212     ssize_t  serial_number_show(struct device *dev, struct device_attribute *attr, char *buf);   224     ssize_t  firmware_version_show(struct device *dev, struct device_attribute *attr, char *buf);   237     ssize_t  device_id_show(struct device *dev, struct device_attribute *attr, char *buf);   253     void pod_startup1(struct usb_line6_pod *pod);   281     void pod_startup4(struct work_struct *work);   297     struct device_attribute dev_attr_device_id = { { "device_id", 292U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &device_id_show, 0 };   298     struct device_attribute dev_attr_firmware_version = { { "firmware_version", 292U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &firmware_version_show, 0 };   299     struct device_attribute dev_attr_serial_number = { { "serial_number", 292U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &serial_number_show, 0 };   302     int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);   313     int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   324     int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   340     struct snd_kcontrol_new pod_control_monitor = { 2, 0U, 0U, (const unsigned char *)"Monitor Playback Volume", 0U, 3U, 0U, &snd_pod_control_monitor_info, &snd_pod_control_monitor_get, &snd_pod_control_monitor_put, { 0 }, 0UL };   353     void pod_destruct(struct usb_interface *interface);   368     int pod_create_files2(struct device *dev);   381     int pod_try_init(struct usb_interface *interface, struct usb_line6_pod *pod);   514     void ldv_main7_sequence_infinite_withcheck_stateful();   132     unsigned long int get_seconds();   245     int del_timer_sync(struct timer_list *);    39     int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);    43     struct snd_ratden toneport_ratden = { 44100U, 44100U, 1U, 1U };    50     struct line6_pcm_properties toneport_pcm_properties = { { 5046531U, 4ULL, 2147483648U, 44100U, 44100U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 4522243U, 4ULL, 2147483648U, 44100U, 44100U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 1, &toneport_ratden }, 4 };   104     int led_red = 0;   105     int led_green = 38;   110     const struct __anonstruct_toneport_source_info_216 toneport_source_info[4U] = { { "Microphone", 2561 }, { "Line", 2049 }, { "Instrument", 2817 }, { "Inst & Mic", 2305 } };   117     bool  toneport_has_led(short product);   125     void toneport_update_led(struct device *dev);   140     ssize_t  toneport_set_led_red(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);   154     ssize_t  toneport_set_led_green(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);   169     struct device_attribute dev_attr_led_red = { { "led_red", 420U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &line6_nop_read, &toneport_set_led_red };   171     struct device_attribute dev_attr_led_green = { { "led_green", 420U, 0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &line6_nop_read, &toneport_set_led_green };   190     int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);   201     int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   211     int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   230     int snd_toneport_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);   249     int snd_toneport_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   260     int snd_toneport_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);   280     void toneport_start_pcm(unsigned long arg);   289     struct snd_kcontrol_new toneport_control_monitor = { 2, 0U, 0U, (const unsigned char *)"Monitor Playback Volume", 0U, 3U, 0U, &snd_toneport_monitor_info, &snd_toneport_monitor_get, &snd_toneport_monitor_put, { 0 }, 0UL };   300     struct snd_kcontrol_new toneport_control_source = { 2, 0U, 0U, (const unsigned char *)"PCM Capture Source", 0U, 3U, 0U, &snd_toneport_source_info, &snd_toneport_source_get, &snd_toneport_source_put, { 0 }, 0UL };   313     void toneport_destruct(struct usb_interface *interface);   325     void toneport_setup(struct usb_line6_toneport *toneport);   357     int toneport_try_init(struct usb_interface *interface, struct usb_line6_toneport *toneport);   516     void ldv_main8_sequence_infinite_withcheck_stateful();    40     const char variax_init_version[12U] = { -16, 126, 127, 6, 2, 0, 1, 12, 7, 0, 0, 0 };    48     const char variax_init_done[7U] = { -16, 0, 1, 12, 7, 0, 107 };    52     const char variax_activate[9U] = { -16, 0, 1, 12, 7, 0, 42, 1, -9 };    58     void variax_startup2(unsigned long data);    59     void variax_startup4(unsigned long data);    60     void variax_startup5(unsigned long data);    62     void variax_activate_async(struct usb_line6_variax *variax, int a);    76     void variax_startup1(struct usb_line6_variax *variax);   102     void variax_startup3(struct usb_line6_variax *variax);   135     void variax_startup6(struct work_struct *work);   174     void variax_destruct(struct usb_interface *interface);   192     int variax_try_init(struct usb_interface *interface, struct usb_line6_variax *variax);    39     struct snd_ratden podhd_ratden = { 48000U, 48000U, 1U, 1U };    46     struct line6_pcm_properties podhd_pcm_properties = { { 5046531U, 4294967296ULL, 128U, 48000U, 48000U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 4522243U, 4294967296ULL, 128U, 48000U, 48000U, 2U, 2U, 60000UL, 64UL, 8192UL, 1U, 1024U, 0UL }, { 1, &podhd_ratden }, 6 };    97     void podhd_destruct(struct usb_interface *interface);   109     int podhd_try_init(struct usb_interface *interface, struct usb_line6_podhd *podhd);   210     void ldv_main10_sequence_infinite_withcheck_stateful();    10     void ldv_error();    59     void __builtin_trap();     7     bool  ldv_is_err(const void *ptr);    14     void * ldv_err_ptr(long error);    21     long int ldv_ptr_err(const void *ptr);    28     bool  ldv_is_err_or_null(const void *ptr);    19     int ldv_usb_dev_state = 0;           return ;         }        {      1220     struct usb_interface *var_group1;  1221     const struct usb_device_id *var_line6_probe_17_p1;  1222     int res_line6_probe_17;  1223     pm_message_t var_line6_suspend_19_p1;  1224     int ldv_s_line6_driver_usb_driver;  1225     int tmp;  1226     int tmp___0;  1325     ldv_s_line6_driver_usb_driver = 0;  1315     LDV_IN_INTERRUPT = 1;  1324     ldv_initialize() { /* Function call is skipped due to function is undefined */}  1328     goto ldv_32297;  1328     tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}  1331     goto ldv_32296;  1329     ldv_32296:;  1332     tmp = nondet_int() { /* Function call is skipped due to function is undefined */}  1332     switch (tmp)          {   627       int devtype;   628       struct usb_device *usbdev;   629       struct usb_line6 *line6;   630       const struct line6_properties *properties;   631       int interface_number;   632       int alternate;   633       int product;   634       int size;   635       int ep_read;   636       int ep_write;   637       int ret;   638       u16 idVendor;   639       u16 idProduct;   640       int tmp;   641       void *tmp___0;   642       struct usb_host_endpoint *ep;   643       unsigned int epnum;   644       unsigned int tmp___1;   645       void *tmp___2;   646       void *tmp___3;   632       alternate = 0;   634       size = 0;   635       ep_read = 0;   635       ep_write = 0;             {  1529         ldv_func_ret_type ldv_func_res;  1530         struct usb_device *tmp;  1531         ldv_func_res = tmp;             }  651       devtype = 20;   651       goto ldv_32101;   651       tmp = devtype;   651       devtype = devtype - 1;   653       goto ldv_32100;   652       ldv_32100:;   652       idVendor = usbdev->descriptor.idVendor;   653       idProduct = usbdev->descriptor.idProduct;   657       goto ldv_32099;   666       properties = ((const struct line6_properties *)(&line6_properties_table)) + ((unsigned long)devtype);   667       _dev_info((const struct device *)(&(interface->dev)), "Line6 %s found\n", properties->name) { /* Function call is skipped due to function is undefined */}   668       product = (int)(usbdev->descriptor.idProduct);   671       interface_number = (int)(interface->cur_altsetting->desc.bInterfaceNumber);   673       switch (product)681 switch (interface_number) }  1350     ldv_check_return_value(res_line6_probe_17) { /* Function call is skipped due to function is undefined */}  1360     ldv_s_line6_driver_usb_driver = ldv_s_line6_driver_usb_driver + 1;  1366     goto ldv_32290;  1489     ldv_32290:;  1490     ldv_32297:;  1328     tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}  1331     goto ldv_32296;  1329     ldv_32296:;  1332     tmp = nondet_int() { /* Function call is skipped due to function is undefined */}  1332     switch (tmp) 1383     ldv_handler_precall() { /* Function call is skipped due to function is undefined */}           {  1108       struct usb_line6 *line6;  1109       void *tmp;  1110       struct snd_line6_pcm *line6pcm;  1108       line6 = (struct usb_line6 *)tmp;  1109       line6pcm = line6->line6pcm;             {   166         card->power_state = state;   167         __wake_up(&(card->power_sleep), 3U, 1, (void *)0) { /* Function call is skipped due to function is undefined */}             } 1113       int __CPAchecker_TMP_0 = (int)(line6->properties->capabilities);             {           }  159         usb_kill_urb(line6->urb_listen) { /* Function call is skipped due to function is undefined */}             } 1390     ldv_s_line6_driver_usb_driver = ldv_s_line6_driver_usb_driver + 1;  1396     goto ldv_32290;  1489     ldv_32290:;  1490     ldv_32297:;  1328     tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}  1331     goto ldv_32296;  1329     ldv_32296:;  1332     tmp = nondet_int() { /* Function call is skipped due to function is undefined */}  1332     switch (tmp) 1413     ldv_handler_precall() { /* Function call is skipped due to function is undefined */}           {  1130       struct usb_line6 *line6;  1131       void *tmp;  1130       line6 = (struct usb_line6 *)tmp;  1132       int __CPAchecker_TMP_0 = (int)(line6->properties->capabilities);             {   143         int err;   144         unsigned int tmp;   145         unsigned int __CPAchecker_TMP_0 = (unsigned int)(line6->ep_control_read);   145         void *__CPAchecker_TMP_1 = (void *)(line6->buffer_listen);   145         -usb_fill_int_urb(line6->urb_listen, line6->usbdev, tmp | 1073741952U, __CPAchecker_TMP_1, 32, &line6_data_received, (void *)line6, line6->interval)               {  1557           int __val;  1558           int __min;  1559           int __max;  1561           urb->dev = dev;  1562           urb->pipe = pipe;  1563           urb->transfer_buffer = transfer_buffer;  1564           urb->transfer_buffer_length = (u32 )buffer_length;  1565           urb->complete = complete_fn;  1566           urb->context = context;  1568           unsigned int __CPAchecker_TMP_0 = (unsigned int)(dev->speed);  1568           unsigned int __CPAchecker_TMP_1 = (unsigned int)(dev->speed);  1574           urb->interval = interval;  1577           urb->start_frame = -1;               }  149         line6->urb_listen->actual_length = 0U;   150         err = usb_submit_urb(line6->urb_listen, 32U) { /* Function call is skipped due to function is undefined */}             }            {           }  166         card->power_state = state;   167         __wake_up(&(card->power_sleep), 3U, 1, (void *)0) { /* Function call is skipped due to function is undefined */}             } 1420     ldv_s_line6_driver_usb_driver = ldv_s_line6_driver_usb_driver + 1;  1426     goto ldv_32290;  1489     ldv_32290:;  1490     ldv_32297:;  1328     tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}  1331     goto ldv_32296;  1329     ldv_32296:;  1332     tmp = nondet_int() { /* Function call is skipped due to function is undefined */}  1332     switch (tmp) 1443     ldv_handler_precall() { /* Function call is skipped due to function is undefined */}           {  1144       struct usb_line6 *line6;  1145       void *tmp;  1146       int tmp___0;  1144       line6 = (struct usb_line6 *)tmp;  1146       switch ((int)(line6->usbdev->descriptor.idProduct))            {           } 1130         struct usb_line6 *line6;  1131         void *tmp;  1130         line6 = (struct usb_line6 *)tmp;  1132         int __CPAchecker_TMP_0 = (int)(line6->properties->capabilities);               {   143           int err;   144           unsigned int tmp;   145           unsigned int __CPAchecker_TMP_0 = (unsigned int)(line6->ep_control_read);   145           void *__CPAchecker_TMP_1 = (void *)(line6->buffer_listen);   145           -usb_fill_int_urb(line6->urb_listen, line6->usbdev, tmp | 1073741952U, __CPAchecker_TMP_1, 32, &line6_data_received, (void *)line6, line6->interval)                 {  1557             int __val;  1558             int __min;  1559             int __max;  1561             urb->dev = dev;  1562             urb->pipe = pipe;  1563             urb->transfer_buffer = transfer_buffer;  1564             urb->transfer_buffer_length = (u32 )buffer_length;  1565             urb->complete = complete_fn;  1566             urb->context = context;  1568             unsigned int __CPAchecker_TMP_0 = (unsigned int)(dev->speed);  1568             unsigned int __CPAchecker_TMP_1 = (unsigned int)(dev->speed);  1574             urb->interval = interval;  1577             urb->start_frame = -1;                 }  149           line6->urb_listen->actual_length = 0U;   150           err = usb_submit_urb(line6->urb_listen, 32U) { /* Function call is skipped due to function is undefined */}               }              {             }  166           card->power_state = state;   167           __wake_up(&(card->power_sleep), 3U, 1, (void *)0) { /* Function call is skipped due to function is undefined */}               } 1450     ldv_s_line6_driver_usb_driver = ldv_s_line6_driver_usb_driver + 1;  1456     goto ldv_32290;  1489     ldv_32290:;  1490     ldv_32297:;  1328     tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}  1331     goto ldv_32296;  1329     ldv_32296:;  1332     tmp = nondet_int() { /* Function call is skipped due to function is undefined */}  1332     switch (tmp) 1472     ldv_handler_precall() { /* Function call is skipped due to function is undefined */}           {         } 1016       struct usb_line6 *line6;  1017       struct usb_device *usbdev;  1018       int interface_number;  1019       void *tmp;             {  1529         ldv_func_ret_type ldv_func_res;  1530         struct usb_device *tmp;  1531         ldv_func_res = tmp;             } 1028       sysfs_remove_link(&(interface->dev.kobj), "usb_device") { /* Function call is skipped due to function is undefined */}  1030       interface_number = (int)(interface->cur_altsetting->desc.bInterfaceNumber);  1031       line6 = (struct usb_line6 *)tmp;  1034       unsigned long __CPAchecker_TMP_0 = (unsigned long)(line6->urb_listen);  1037       unsigned long __CPAchecker_TMP_1 = (unsigned long)(line6->usbdev);  1038       const struct device *__CPAchecker_TMP_2 = (const struct device *)(line6->ifcdev);  1038       dev_err(__CPAchecker_TMP_2, "driver bug: inconsistent usb device\n") { /* Function call is skipped due to function is undefined */}  1041       switch ((int)(line6->usbdev->descriptor.idProduct))1079 fall through 1080 fall through 1081 fall through             {   452         struct usb_line6_toneport *toneport;   453         u16 idProduct;   454         void *tmp;   455         bool tmp___0;   456         struct snd_line6_pcm *line6pcm;   458         toneport = (struct usb_line6_toneport *)tmp;   459         del_timer_sync(&(toneport->timer)) { /* Function call is skipped due to function is undefined */}   460         idProduct = toneport->line6.usbdev->descriptor.idProduct;   463         device_remove_file(&(interface->dev), (const struct device_attribute *)(&dev_attr_led_red)) { /* Function call is skipped due to function is undefined */}   464         device_remove_file(&(interface->dev), (const struct device_attribute *)(&dev_attr_led_green)) { /* Function call is skipped due to function is undefined */}   468         line6pcm = toneport->line6.line6pcm;               {             }  315           struct usb_line6_toneport *toneport;   316           void *tmp;   315           toneport = (struct usb_line6_toneport *)tmp;               } 1084       goto ldv_32208;  1090       _dev_info((const struct device *)(&(interface->dev)), "Line6 %s now disconnected\n", line6->properties->name) { /* Function call is skipped due to function is undefined */}             {   600         struct usb_line6 *line6;   601         void *tmp;   604         line6 = (struct usb_line6 *)tmp;   609         const void *__CPAchecker_TMP_0 = (const void *)(line6->buffer_message);   609         kfree(__CPAchecker_TMP_0) { /* Function call is skipped due to function is undefined */}   610         const void *__CPAchecker_TMP_1 = (const void *)(line6->buffer_listen);   610         kfree(__CPAchecker_TMP_1) { /* Function call is skipped due to function is undefined */}   613         usb_free_urb(line6->urb_listen) { /* Function call is skipped due to function is undefined */}               { }   619         kfree((const void *)line6) { /* Function call is skipped due to function is undefined */}             } 1097       usb_put_intf(interface) { /* Function call is skipped due to function is undefined */}           } |              Source code         
     1 
    2 #include <linux/kernel.h>
    3 bool ldv_is_err(const void *ptr);
    4 bool ldv_is_err_or_null(const void *ptr);
    5 void* ldv_err_ptr(long error);
    6 long ldv_ptr_err(const void *ptr);
    7 
    8 #include <linux/kernel.h>
    9 #include <linux/module.h>
   10 
   11 #include <linux/usb.h>
   12 
   13 // Provide model function prototypes before their usage.
   14 void ldv_interface_to_usbdev(void);
   15 void ldv_usb_get_dev(void);
   16 void ldv_usb_put_dev(void);
   17 /*
   18  * Line6 Linux USB driver - 0.9.1beta
   19  *
   20  * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
   21  *
   22  *	This program is free software; you can redistribute it and/or
   23  *	modify it under the terms of the GNU General Public License as
   24  *	published by the Free Software Foundation, version 2.
   25  *
   26  */
   27 
   28 #include <sound/core.h>
   29 #include <sound/initval.h>
   30 #include <linux/export.h>
   31 
   32 #include "driver.h"
   33 #include "audio.h"
   34 
   35 /*
   36 	Initialize the Line6 USB audio system.
   37 */
   38 int line6_init_audio(struct usb_line6 *line6)
   39 {
   40 	struct snd_card *card;
   41 	int err;
   42 
   43 	err = snd_card_new(line6->ifcdev,
   44 			   SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
   45 			   THIS_MODULE, 0, &card);
   46 	if (err < 0)
   47 		return err;
   48 
   49 	line6->card = card;
   50 
   51 	strcpy(card->id, line6->properties->id);
   52 	strcpy(card->driver, DRIVER_NAME);
   53 	strcpy(card->shortname, line6->properties->name);
   54 	/* longname is 80 chars - see asound.h */
   55 	sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
   56 		dev_name(line6->ifcdev));
   57 	return 0;
   58 }
   59 
   60 /*
   61 	Register the Line6 USB audio system.
   62 */
   63 int line6_register_audio(struct usb_line6 *line6)
   64 {
   65 	int err;
   66 
   67 	err = snd_card_register(line6->card);
   68 	if (err < 0)
   69 		return err;
   70 
   71 	return 0;
   72 }
   73 
   74 /*
   75 	Cleanup the Line6 USB audio system.
   76 */
   77 void line6_cleanup_audio(struct usb_line6 *line6)
   78 {
   79 	struct snd_card *card = line6->card;
   80 
   81 	if (card == NULL)
   82 		return;
   83 
   84 	snd_card_disconnect(card);
   85 	snd_card_free(card);
   86 	line6->card = NULL;
   87 }                 1 
    2 #include <linux/kernel.h>
    3 bool ldv_is_err(const void *ptr);
    4 bool ldv_is_err_or_null(const void *ptr);
    5 void* ldv_err_ptr(long error);
    6 long ldv_ptr_err(const void *ptr);
    7 
    8 #include <linux/kernel.h>
    9 #include <linux/module.h>
   10 
   11 #include <linux/usb.h>
   12 
   13 // Provide model function prototypes before their usage.
   14 void ldv_interface_to_usbdev(void);
   15 void ldv_usb_get_dev(void);
   16 void ldv_usb_put_dev(void);
   17 
   18 /*
   19  * Line6 Linux USB driver - 0.9.1beta
   20  *
   21  * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
   22  *
   23  *	This program is free software; you can redistribute it and/or
   24  *	modify it under the terms of the GNU General Public License as
   25  *	published by the Free Software Foundation, version 2.
   26  *
   27  */
   28 
   29 #include <linux/kernel.h>
   30 #include <linux/module.h>
   31 #include <linux/slab.h>
   32 #include <linux/usb.h>
   33 
   34 #include "audio.h"
   35 #include "capture.h"
   36 #include "driver.h"
   37 #include "midi.h"
   38 #include "playback.h"
   39 #include "pod.h"
   40 #include "podhd.h"
   41 #include "revision.h"
   42 #include "toneport.h"
   43 #include "usbdefs.h"
   44 #include "variax.h"
   45 
   46 #define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
   47 #define DRIVER_DESC    "Line6 USB Driver"
   48 #define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
   49 
   50 /* table of devices that work with this driver */
   51 static const struct usb_device_id line6_id_table[] = {
   52 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT)},
   53 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE)},
   54 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO)},
   55 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT)},
   56 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD)},
   57 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODHD300)},
   58 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODHD400)},
   59 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODHD500)},
   60 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_GX)},
   61 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX1)},
   62 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX2)},
   63 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3)},
   64 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE)},
   65 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT)},
   66 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE)},
   67 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO)},
   68 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX)},
   69 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1)},
   70 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2)},
   71 	{USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX)},
   72 	{},
   73 };
   74 
   75 MODULE_DEVICE_TABLE(usb, line6_id_table);
   76 
   77 #define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
   78 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
   79 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
   80 
   81 /* *INDENT-OFF* */
   82 static const struct line6_properties line6_properties_table[] = {
   83 	L6PROP(BASSPODXT,     "BassPODxt",     "BassPODxt",        CTRL_PCM_HW),
   84 	L6PROP(BASSPODXTLIVE, "BassPODxtLive", "BassPODxt Live",   CTRL_PCM_HW),
   85 	L6PROP(BASSPODXTPRO,  "BassPODxtPro",  "BassPODxt Pro",    CTRL_PCM_HW),
   86 	L6PROP(GUITARPORT,    "GuitarPort",    "GuitarPort",       PCM),
   87 	L6PROP(POCKETPOD,     "PocketPOD",     "Pocket POD",       CONTROL),
   88 	L6PROP(PODHD300,      "PODHD300",      "POD HD300",        CTRL_PCM_HW),
   89 	L6PROP(PODHD400,      "PODHD400",      "POD HD400",        CTRL_PCM_HW),
   90 	L6PROP(PODHD500,      "PODHD500",      "POD HD500",        CTRL_PCM_HW),
   91 	L6PROP(PODSTUDIO_GX,  "PODStudioGX",   "POD Studio GX",    PCM),
   92 	L6PROP(PODSTUDIO_UX1, "PODStudioUX1",  "POD Studio UX1",   PCM),
   93 	L6PROP(PODSTUDIO_UX2, "PODStudioUX2",  "POD Studio UX2",   PCM),
   94 	L6PROP(PODX3,         "PODX3",         "POD X3",           PCM),
   95 	L6PROP(PODX3LIVE,     "PODX3Live",     "POD X3 Live",      PCM),
   96 	L6PROP(PODXT,         "PODxt",         "PODxt",            CTRL_PCM_HW),
   97 	L6PROP(PODXTLIVE,     "PODxtLive",     "PODxt Live",       CTRL_PCM_HW),
   98 	L6PROP(PODXTPRO,      "PODxtPro",      "PODxt Pro",        CTRL_PCM_HW),
   99 	L6PROP(TONEPORT_GX,   "TonePortGX",    "TonePort GX",      PCM),
  100 	L6PROP(TONEPORT_UX1,  "TonePortUX1",   "TonePort UX1",     PCM),
  101 	L6PROP(TONEPORT_UX2,  "TonePortUX2",   "TonePort UX2",     PCM),
  102 	L6PROP(VARIAX,        "Variax",        "Variax Workbench", CONTROL),
  103 };
  104 /* *INDENT-ON* */
  105 
  106 /*
  107 	This is Line6's MIDI manufacturer ID.
  108 */
  109 const unsigned char line6_midi_id[] = {
  110 	0x00, 0x01, 0x0c
  111 };
  112 
  113 /*
  114 	Code to request version of POD, Variax interface
  115 	(and maybe other devices).
  116 */
  117 static const char line6_request_version[] = {
  118 	0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
  119 };
  120 
  121 /**
  122 	 Class for asynchronous messages.
  123 */
  124 struct message {
  125 	struct usb_line6 *line6;
  126 	const char *buffer;
  127 	int size;
  128 	int done;
  129 };
  130 
  131 /*
  132 	Forward declarations.
  133 */
  134 static void line6_data_received(struct urb *urb);
  135 static int line6_send_raw_message_async_part(struct message *msg,
  136 					     struct urb *urb);
  137 
  138 /*
  139 	Start to listen on endpoint.
  140 */
  141 static int line6_start_listen(struct usb_line6 *line6)
  142 {
  143 	int err;
  144 
  145 	usb_fill_int_urb(line6->urb_listen, line6->usbdev,
  146 			 usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
  147 			 line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
  148 			 line6_data_received, line6, line6->interval);
  149 	line6->urb_listen->actual_length = 0;
  150 	err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC);
  151 	return err;
  152 }
  153 
  154 /*
  155 	Stop listening on endpoint.
  156 */
  157 static void line6_stop_listen(struct usb_line6 *line6)
  158 {
  159 	usb_kill_urb(line6->urb_listen);
  160 }
  161 
  162 /*
  163 	Send raw message in pieces of wMaxPacketSize bytes.
  164 */
  165 int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
  166 			   int size)
  167 {
  168 	int i, done = 0;
  169 
  170 	for (i = 0; i < size; i += line6->max_packet_size) {
  171 		int partial;
  172 		const char *frag_buf = buffer + i;
  173 		int frag_size = min(line6->max_packet_size, size - i);
  174 		int retval;
  175 
  176 		retval = usb_interrupt_msg(line6->usbdev,
  177 					usb_sndintpipe(line6->usbdev,
  178 						line6->ep_control_write),
  179 					(char *)frag_buf, frag_size,
  180 					&partial, LINE6_TIMEOUT * HZ);
  181 
  182 		if (retval) {
  183 			dev_err(line6->ifcdev,
  184 				"usb_interrupt_msg failed (%d)\n", retval);
  185 			break;
  186 		}
  187 
  188 		done += frag_size;
  189 	}
  190 
  191 	return done;
  192 }
  193 
  194 /*
  195 	Notification of completion of asynchronous request transmission.
  196 */
  197 static void line6_async_request_sent(struct urb *urb)
  198 {
  199 	struct message *msg = (struct message *)urb->context;
  200 
  201 	if (msg->done >= msg->size) {
  202 		usb_free_urb(urb);
  203 		kfree(msg);
  204 	} else
  205 		line6_send_raw_message_async_part(msg, urb);
  206 }
  207 
  208 /*
  209 	Asynchronously send part of a raw message.
  210 */
  211 static int line6_send_raw_message_async_part(struct message *msg,
  212 					     struct urb *urb)
  213 {
  214 	int retval;
  215 	struct usb_line6 *line6 = msg->line6;
  216 	int done = msg->done;
  217 	int bytes = min(msg->size - done, line6->max_packet_size);
  218 
  219 	usb_fill_int_urb(urb, line6->usbdev,
  220 			 usb_sndintpipe(line6->usbdev, line6->ep_control_write),
  221 			 (char *)msg->buffer + done, bytes,
  222 			 line6_async_request_sent, msg, line6->interval);
  223 
  224 	msg->done += bytes;
  225 	retval = usb_submit_urb(urb, GFP_ATOMIC);
  226 
  227 	if (retval < 0) {
  228 		dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n",
  229 			__func__, retval);
  230 		usb_free_urb(urb);
  231 		kfree(msg);
  232 		return retval;
  233 	}
  234 
  235 	return 0;
  236 }
  237 
  238 /*
  239 	Setup and start timer.
  240 */
  241 void line6_start_timer(struct timer_list *timer, unsigned int msecs,
  242 		       void (*function)(unsigned long), unsigned long data)
  243 {
  244 	setup_timer(timer, function, data);
  245 	timer->expires = jiffies + msecs * HZ / 1000;
  246 	add_timer(timer);
  247 }
  248 
  249 /*
  250 	Asynchronously send raw message.
  251 */
  252 int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
  253 				 int size)
  254 {
  255 	struct message *msg;
  256 	struct urb *urb;
  257 
  258 	/* create message: */
  259 	msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
  260 	if (msg == NULL)
  261 		return -ENOMEM;
  262 
  263 	/* create URB: */
  264 	urb = usb_alloc_urb(0, GFP_ATOMIC);
  265 
  266 	if (urb == NULL) {
  267 		kfree(msg);
  268 		dev_err(line6->ifcdev, "Out of memory\n");
  269 		return -ENOMEM;
  270 	}
  271 
  272 	/* set message data: */
  273 	msg->line6 = line6;
  274 	msg->buffer = buffer;
  275 	msg->size = size;
  276 	msg->done = 0;
  277 
  278 	/* start sending: */
  279 	return line6_send_raw_message_async_part(msg, urb);
  280 }
  281 
  282 /*
  283 	Send asynchronous device version request.
  284 */
  285 int line6_version_request_async(struct usb_line6 *line6)
  286 {
  287 	char *buffer;
  288 	int retval;
  289 
  290 	buffer = kmemdup(line6_request_version,
  291 			sizeof(line6_request_version), GFP_ATOMIC);
  292 	if (buffer == NULL) {
  293 		dev_err(line6->ifcdev, "Out of memory");
  294 		return -ENOMEM;
  295 	}
  296 
  297 	retval = line6_send_raw_message_async(line6, buffer,
  298 					      sizeof(line6_request_version));
  299 	kfree(buffer);
  300 	return retval;
  301 }
  302 
  303 /*
  304 	Send sysex message in pieces of wMaxPacketSize bytes.
  305 */
  306 int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
  307 			     int size)
  308 {
  309 	return line6_send_raw_message(line6, buffer,
  310 				      size + SYSEX_EXTRA_SIZE) -
  311 	    SYSEX_EXTRA_SIZE;
  312 }
  313 
  314 /*
  315 	Allocate buffer for sysex message and prepare header.
  316 	@param code sysex message code
  317 	@param size number of bytes between code and sysex end
  318 */
  319 char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
  320 			       int size)
  321 {
  322 	char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC);
  323 
  324 	if (!buffer)
  325 		return NULL;
  326 
  327 	buffer[0] = LINE6_SYSEX_BEGIN;
  328 	memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id));
  329 	buffer[sizeof(line6_midi_id) + 1] = code1;
  330 	buffer[sizeof(line6_midi_id) + 2] = code2;
  331 	buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END;
  332 	return buffer;
  333 }
  334 
  335 /*
  336 	Notification of data received from the Line6 device.
  337 */
  338 static void line6_data_received(struct urb *urb)
  339 {
  340 	struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
  341 	struct midi_buffer *mb = &line6->line6midi->midibuf_in;
  342 	int done;
  343 
  344 	if (urb->status == -ESHUTDOWN)
  345 		return;
  346 
  347 	done =
  348 	    line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
  349 
  350 	if (done < urb->actual_length) {
  351 		line6_midibuf_ignore(mb, done);
  352 		dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n",
  353 			done, urb->actual_length);
  354 	}
  355 
  356 	for (;;) {
  357 		done =
  358 		    line6_midibuf_read(mb, line6->buffer_message,
  359 				       LINE6_MESSAGE_MAXLEN);
  360 
  361 		if (done == 0)
  362 			break;
  363 
  364 		line6->message_length = done;
  365 		line6_midi_receive(line6, line6->buffer_message, done);
  366 
  367 		switch (le16_to_cpu(line6->usbdev->descriptor.idProduct)) {
  368 		case LINE6_DEVID_BASSPODXT:
  369 		case LINE6_DEVID_BASSPODXTLIVE:
  370 		case LINE6_DEVID_BASSPODXTPRO:
  371 		case LINE6_DEVID_PODXT:
  372 		case LINE6_DEVID_PODXTPRO:
  373 		case LINE6_DEVID_POCKETPOD:
  374 			line6_pod_process_message((struct usb_line6_pod *)
  375 						  line6);
  376 			break;
  377 
  378 		case LINE6_DEVID_PODHD300:
  379 		case LINE6_DEVID_PODHD400:
  380 		case LINE6_DEVID_PODHD500:
  381 			break; /* let userspace handle MIDI */
  382 
  383 		case LINE6_DEVID_PODXTLIVE:
  384 			switch (line6->interface_number) {
  385 			case PODXTLIVE_INTERFACE_POD:
  386 				line6_pod_process_message((struct usb_line6_pod
  387 							   *)line6);
  388 				break;
  389 
  390 			case PODXTLIVE_INTERFACE_VARIAX:
  391 				line6_variax_process_message((struct
  392 							      usb_line6_variax
  393 							      *)line6);
  394 				break;
  395 
  396 			default:
  397 				dev_err(line6->ifcdev,
  398 					"PODxt Live interface %d not supported\n",
  399 					line6->interface_number);
  400 			}
  401 			break;
  402 
  403 		case LINE6_DEVID_VARIAX:
  404 			line6_variax_process_message((struct usb_line6_variax *)
  405 						     line6);
  406 			break;
  407 
  408 		default:
  409 			MISSING_CASE;
  410 		}
  411 	}
  412 
  413 	line6_start_listen(line6);
  414 }
  415 
  416 /*
  417 	Send channel number (i.e., switch to a different sound).
  418 */
  419 int line6_send_program(struct usb_line6 *line6, u8 value)
  420 {
  421 	int retval;
  422 	unsigned char *buffer;
  423 	int partial;
  424 
  425 	buffer = kmalloc(2, GFP_KERNEL);
  426 	if (!buffer)
  427 		return -ENOMEM;
  428 
  429 	buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
  430 	buffer[1] = value;
  431 
  432 	retval = usb_interrupt_msg(line6->usbdev,
  433 				   usb_sndintpipe(line6->usbdev,
  434 						  line6->ep_control_write),
  435 				   buffer, 2, &partial, LINE6_TIMEOUT * HZ);
  436 
  437 	if (retval)
  438 		dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
  439 			retval);
  440 
  441 	kfree(buffer);
  442 	return retval;
  443 }
  444 
  445 /*
  446 	Transmit Line6 control parameter.
  447 */
  448 int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value)
  449 {
  450 	int retval;
  451 	unsigned char *buffer;
  452 	int partial;
  453 
  454 	buffer = kmalloc(3, GFP_KERNEL);
  455 	if (!buffer)
  456 		return -ENOMEM;
  457 
  458 	buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST;
  459 	buffer[1] = param;
  460 	buffer[2] = value;
  461 
  462 	retval = usb_interrupt_msg(line6->usbdev,
  463 				   usb_sndintpipe(line6->usbdev,
  464 						  line6->ep_control_write),
  465 				   buffer, 3, &partial, LINE6_TIMEOUT * HZ);
  466 
  467 	if (retval)
  468 		dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
  469 			retval);
  470 
  471 	kfree(buffer);
  472 	return retval;
  473 }
  474 
  475 /*
  476 	Read data from device.
  477 */
  478 int line6_read_data(struct usb_line6 *line6, int address, void *data,
  479 		    size_t datalen)
  480 {
  481 	struct usb_device *usbdev = line6->usbdev;
  482 	int ret;
  483 	unsigned char len;
  484 
  485 	/* query the serial number: */
  486 	ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
  487 			      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  488 			      (datalen << 8) | 0x21, address,
  489 			      NULL, 0, LINE6_TIMEOUT * HZ);
  490 
  491 	if (ret < 0) {
  492 		dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
  493 		return ret;
  494 	}
  495 
  496 	/* Wait for data length. We'll get 0xff until length arrives. */
  497 	do {
  498 		ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
  499 				      USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  500 				      USB_DIR_IN,
  501 				      0x0012, 0x0000, &len, 1,
  502 				      LINE6_TIMEOUT * HZ);
  503 		if (ret < 0) {
  504 			dev_err(line6->ifcdev,
  505 				"receive length failed (error %d)\n", ret);
  506 			return ret;
  507 		}
  508 	} while (len == 0xff);
  509 
  510 	if (len != datalen) {
  511 		/* should be equal or something went wrong */
  512 		dev_err(line6->ifcdev,
  513 			"length mismatch (expected %d, got %d)\n",
  514 			(int)datalen, (int)len);
  515 		return -EINVAL;
  516 	}
  517 
  518 	/* receive the result: */
  519 	ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
  520 			      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  521 			      0x0013, 0x0000, data, datalen,
  522 			      LINE6_TIMEOUT * HZ);
  523 
  524 	if (ret < 0) {
  525 		dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
  526 		return ret;
  527 	}
  528 
  529 	return 0;
  530 }
  531 
  532 /*
  533 	Write data to device.
  534 */
  535 int line6_write_data(struct usb_line6 *line6, int address, void *data,
  536 		     size_t datalen)
  537 {
  538 	struct usb_device *usbdev = line6->usbdev;
  539 	int ret;
  540 	unsigned char status;
  541 
  542 	ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
  543 			      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  544 			      0x0022, address, data, datalen,
  545 			      LINE6_TIMEOUT * HZ);
  546 
  547 	if (ret < 0) {
  548 		dev_err(line6->ifcdev,
  549 			"write request failed (error %d)\n", ret);
  550 		return ret;
  551 	}
  552 
  553 	do {
  554 		ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
  555 				      0x67,
  556 				      USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  557 				      USB_DIR_IN,
  558 				      0x0012, 0x0000,
  559 				      &status, 1, LINE6_TIMEOUT * HZ);
  560 
  561 		if (ret < 0) {
  562 			dev_err(line6->ifcdev,
  563 				"receiving status failed (error %d)\n", ret);
  564 			return ret;
  565 		}
  566 	} while (status == 0xff);
  567 
  568 	if (status != 0) {
  569 		dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
  570 		return -EINVAL;
  571 	}
  572 
  573 	return 0;
  574 }
  575 
  576 /*
  577 	Read Line6 device serial number.
  578 	(POD, TonePort, GuitarPort)
  579 */
  580 int line6_read_serial_number(struct usb_line6 *line6, int *serial_number)
  581 {
  582 	return line6_read_data(line6, 0x80d0, serial_number,
  583 			       sizeof(*serial_number));
  584 }
  585 
  586 /*
  587 	No operation (i.e., unsupported).
  588 */
  589 ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
  590 		       char *buf)
  591 {
  592 	return 0;
  593 }
  594 
  595 /*
  596 	Generic destructor.
  597 */
  598 static void line6_destruct(struct usb_interface *interface)
  599 {
  600 	struct usb_line6 *line6;
  601 
  602 	if (interface == NULL)
  603 		return;
  604 	line6 = usb_get_intfdata(interface);
  605 	if (line6 == NULL)
  606 		return;
  607 
  608 	/* free buffer memory first: */
  609 	kfree(line6->buffer_message);
  610 	kfree(line6->buffer_listen);
  611 
  612 	/* then free URBs: */
  613 	usb_free_urb(line6->urb_listen);
  614 
  615 	/* make sure the device isn't destructed twice: */
  616 	usb_set_intfdata(interface, NULL);
  617 
  618 	/* free interface data: */
  619 	kfree(line6);
  620 }
  621 
  622 /*
  623 	Probe USB device.
  624 */
  625 static int line6_probe(struct usb_interface *interface,
  626 		       const struct usb_device_id *id)
  627 {
  628 	int devtype;
  629 	struct usb_device *usbdev;
  630 	struct usb_line6 *line6;
  631 	const struct line6_properties *properties;
  632 	int interface_number, alternate = 0;
  633 	int product;
  634 	int size = 0;
  635 	int ep_read = 0, ep_write = 0;
  636 	int ret;
  637 
  638 	if (interface == NULL)
  639 		return -ENODEV;
  640 	usbdev = interface_to_usbdev(interface);
  641 	if (usbdev == NULL)
  642 		return -ENODEV;
  643 
  644 	/* we don't handle multiple configurations */
  645 	if (usbdev->descriptor.bNumConfigurations != 1) {
  646 		ret = -ENODEV;
  647 		goto err_put;
  648 	}
  649 
  650 	/* check vendor and product id */
  651 	for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) {
  652 		u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor);
  653 		u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
  654 
  655 		if (idVendor == line6_id_table[devtype].idVendor &&
  656 		    idProduct == line6_id_table[devtype].idProduct)
  657 			break;
  658 	}
  659 
  660 	if (devtype < 0) {
  661 		ret = -ENODEV;
  662 		goto err_put;
  663 	}
  664 
  665 	/* initialize device info: */
  666 	properties = &line6_properties_table[devtype];
  667 	dev_info(&interface->dev, "Line6 %s found\n", properties->name);
  668 	product = le16_to_cpu(usbdev->descriptor.idProduct);
  669 
  670 	/* query interface number */
  671 	interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
  672 
  673 	switch (product) {
  674 	case LINE6_DEVID_BASSPODXTLIVE:
  675 	case LINE6_DEVID_PODXTLIVE:
  676 	case LINE6_DEVID_VARIAX:
  677 		alternate = 1;
  678 		break;
  679 
  680 	case LINE6_DEVID_POCKETPOD:
  681 		switch (interface_number) {
  682 		case 0:
  683 			return 0;	/* this interface has no endpoints */
  684 		case 1:
  685 			alternate = 0;
  686 			break;
  687 		default:
  688 			MISSING_CASE;
  689 		}
  690 		break;
  691 
  692 	case LINE6_DEVID_PODHD500:
  693 	case LINE6_DEVID_PODX3:
  694 	case LINE6_DEVID_PODX3LIVE:
  695 		switch (interface_number) {
  696 		case 0:
  697 			alternate = 1;
  698 			break;
  699 		case 1:
  700 			alternate = 0;
  701 			break;
  702 		default:
  703 			MISSING_CASE;
  704 		}
  705 		break;
  706 
  707 	case LINE6_DEVID_BASSPODXT:
  708 	case LINE6_DEVID_BASSPODXTPRO:
  709 	case LINE6_DEVID_PODXT:
  710 	case LINE6_DEVID_PODXTPRO:
  711 	case LINE6_DEVID_PODHD300:
  712 	case LINE6_DEVID_PODHD400:
  713 		alternate = 5;
  714 		break;
  715 
  716 	case LINE6_DEVID_GUITARPORT:
  717 	case LINE6_DEVID_PODSTUDIO_GX:
  718 	case LINE6_DEVID_PODSTUDIO_UX1:
  719 	case LINE6_DEVID_TONEPORT_GX:
  720 	case LINE6_DEVID_TONEPORT_UX1:
  721 		alternate = 2;	/* 1..4 seem to be ok */
  722 		break;
  723 
  724 	case LINE6_DEVID_TONEPORT_UX2:
  725 	case LINE6_DEVID_PODSTUDIO_UX2:
  726 		switch (interface_number) {
  727 		case 0:
  728 			/* defaults to 44.1kHz, 16-bit */
  729 			alternate = 2;
  730 			break;
  731 		case 1:
  732 			/* don't know yet what this is ...
  733 			   alternate = 1;
  734 			   break;
  735 			 */
  736 			return -ENODEV;
  737 		default:
  738 			MISSING_CASE;
  739 		}
  740 		break;
  741 
  742 	default:
  743 		MISSING_CASE;
  744 		ret = -ENODEV;
  745 		goto err_put;
  746 	}
  747 
  748 	ret = usb_set_interface(usbdev, interface_number, alternate);
  749 	if (ret < 0) {
  750 		dev_err(&interface->dev, "set_interface failed\n");
  751 		goto err_put;
  752 	}
  753 
  754 	/* initialize device data based on product id: */
  755 	switch (product) {
  756 	case LINE6_DEVID_BASSPODXT:
  757 	case LINE6_DEVID_BASSPODXTLIVE:
  758 	case LINE6_DEVID_BASSPODXTPRO:
  759 	case LINE6_DEVID_PODXT:
  760 	case LINE6_DEVID_PODXTPRO:
  761 		size = sizeof(struct usb_line6_pod);
  762 		ep_read = 0x84;
  763 		ep_write = 0x03;
  764 		break;
  765 
  766 	case LINE6_DEVID_PODHD300:
  767 	case LINE6_DEVID_PODHD400:
  768 		size = sizeof(struct usb_line6_podhd);
  769 		ep_read = 0x84;
  770 		ep_write = 0x03;
  771 		break;
  772 
  773 	case LINE6_DEVID_PODHD500:
  774 		size = sizeof(struct usb_line6_podhd);
  775 		ep_read = 0x81;
  776 		ep_write = 0x01;
  777 		break;
  778 
  779 	case LINE6_DEVID_POCKETPOD:
  780 		size = sizeof(struct usb_line6_pod);
  781 		ep_read = 0x82;
  782 		ep_write = 0x02;
  783 		break;
  784 
  785 	case LINE6_DEVID_PODX3:
  786 	case LINE6_DEVID_PODX3LIVE:
  787 		/* currently unused! */
  788 		size = sizeof(struct usb_line6_pod);
  789 		ep_read = 0x81;
  790 		ep_write = 0x01;
  791 		break;
  792 
  793 	case LINE6_DEVID_PODSTUDIO_GX:
  794 	case LINE6_DEVID_PODSTUDIO_UX1:
  795 	case LINE6_DEVID_PODSTUDIO_UX2:
  796 	case LINE6_DEVID_TONEPORT_GX:
  797 	case LINE6_DEVID_TONEPORT_UX1:
  798 	case LINE6_DEVID_TONEPORT_UX2:
  799 	case LINE6_DEVID_GUITARPORT:
  800 		size = sizeof(struct usb_line6_toneport);
  801 		/* these don't have a control channel */
  802 		break;
  803 
  804 	case LINE6_DEVID_PODXTLIVE:
  805 		switch (interface_number) {
  806 		case PODXTLIVE_INTERFACE_POD:
  807 			size = sizeof(struct usb_line6_pod);
  808 			ep_read = 0x84;
  809 			ep_write = 0x03;
  810 			break;
  811 
  812 		case PODXTLIVE_INTERFACE_VARIAX:
  813 			size = sizeof(struct usb_line6_variax);
  814 			ep_read = 0x86;
  815 			ep_write = 0x05;
  816 			break;
  817 
  818 		default:
  819 			ret = -ENODEV;
  820 			goto err_put;
  821 		}
  822 		break;
  823 
  824 	case LINE6_DEVID_VARIAX:
  825 		size = sizeof(struct usb_line6_variax);
  826 		ep_read = 0x82;
  827 		ep_write = 0x01;
  828 		break;
  829 
  830 	default:
  831 		MISSING_CASE;
  832 		ret = -ENODEV;
  833 		goto err_put;
  834 	}
  835 
  836 	if (size == 0) {
  837 		dev_err(&interface->dev,
  838 			"driver bug: interface data size not set\n");
  839 		ret = -ENODEV;
  840 		goto err_put;
  841 	}
  842 
  843 	line6 = kzalloc(size, GFP_KERNEL);
  844 	if (line6 == NULL) {
  845 		ret = -ENODEV;
  846 		goto err_put;
  847 	}
  848 
  849 	/* store basic data: */
  850 	line6->interface_number = interface_number;
  851 	line6->properties = properties;
  852 	line6->usbdev = usbdev;
  853 	line6->ifcdev = &interface->dev;
  854 	line6->ep_control_read = ep_read;
  855 	line6->ep_control_write = ep_write;
  856 	line6->product = product;
  857 
  858 	/* get data from endpoint descriptor (see usb_maxpacket): */
  859 	{
  860 		struct usb_host_endpoint *ep;
  861 		unsigned epnum =
  862 		    usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read));
  863 		ep = usbdev->ep_in[epnum];
  864 
  865 		if (ep != NULL) {
  866 			line6->interval = ep->desc.bInterval;
  867 			line6->max_packet_size =
  868 			    le16_to_cpu(ep->desc.wMaxPacketSize);
  869 		} else {
  870 			line6->interval = LINE6_FALLBACK_INTERVAL;
  871 			line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE;
  872 			dev_err(line6->ifcdev,
  873 				"endpoint not available, using fallback values");
  874 		}
  875 	}
  876 
  877 	usb_set_intfdata(interface, line6);
  878 
  879 	if (properties->capabilities & LINE6_BIT_CONTROL) {
  880 		/* initialize USB buffers: */
  881 		line6->buffer_listen =
  882 		    kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL);
  883 		if (line6->buffer_listen == NULL) {
  884 			ret = -ENOMEM;
  885 			goto err_destruct;
  886 		}
  887 
  888 		line6->buffer_message =
  889 		    kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL);
  890 		if (line6->buffer_message == NULL) {
  891 			ret = -ENOMEM;
  892 			goto err_destruct;
  893 		}
  894 
  895 		line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL);
  896 
  897 		if (line6->urb_listen == NULL) {
  898 			dev_err(&interface->dev, "Out of memory\n");
  899 			line6_destruct(interface);
  900 			ret = -ENOMEM;
  901 			goto err_destruct;
  902 		}
  903 
  904 		ret = line6_start_listen(line6);
  905 		if (ret < 0) {
  906 			dev_err(&interface->dev, "%s: usb_submit_urb failed\n",
  907 				__func__);
  908 			goto err_destruct;
  909 		}
  910 	}
  911 
  912 	/* initialize device data based on product id: */
  913 	switch (product) {
  914 	case LINE6_DEVID_BASSPODXT:
  915 	case LINE6_DEVID_BASSPODXTLIVE:
  916 	case LINE6_DEVID_BASSPODXTPRO:
  917 	case LINE6_DEVID_POCKETPOD:
  918 	case LINE6_DEVID_PODX3:
  919 	case LINE6_DEVID_PODX3LIVE:
  920 	case LINE6_DEVID_PODXT:
  921 	case LINE6_DEVID_PODXTPRO:
  922 		ret = line6_pod_init(interface, (struct usb_line6_pod *)line6);
  923 		break;
  924 
  925 	case LINE6_DEVID_PODHD300:
  926 	case LINE6_DEVID_PODHD400:
  927 	case LINE6_DEVID_PODHD500:
  928 		ret = line6_podhd_init(interface,
  929 				       (struct usb_line6_podhd *)line6);
  930 		break;
  931 
  932 	case LINE6_DEVID_PODXTLIVE:
  933 		switch (interface_number) {
  934 		case PODXTLIVE_INTERFACE_POD:
  935 			ret =
  936 			    line6_pod_init(interface,
  937 					   (struct usb_line6_pod *)line6);
  938 			break;
  939 
  940 		case PODXTLIVE_INTERFACE_VARIAX:
  941 			ret =
  942 			    line6_variax_init(interface,
  943 					      (struct usb_line6_variax *)line6);
  944 			break;
  945 
  946 		default:
  947 			dev_err(&interface->dev,
  948 				"PODxt Live interface %d not supported\n",
  949 				interface_number);
  950 			ret = -ENODEV;
  951 		}
  952 
  953 		break;
  954 
  955 	case LINE6_DEVID_VARIAX:
  956 		ret =
  957 		    line6_variax_init(interface,
  958 				      (struct usb_line6_variax *)line6);
  959 		break;
  960 
  961 	case LINE6_DEVID_PODSTUDIO_GX:
  962 	case LINE6_DEVID_PODSTUDIO_UX1:
  963 	case LINE6_DEVID_PODSTUDIO_UX2:
  964 	case LINE6_DEVID_TONEPORT_GX:
  965 	case LINE6_DEVID_TONEPORT_UX1:
  966 	case LINE6_DEVID_TONEPORT_UX2:
  967 	case LINE6_DEVID_GUITARPORT:
  968 		ret =
  969 		    line6_toneport_init(interface,
  970 					(struct usb_line6_toneport *)line6);
  971 		break;
  972 
  973 	default:
  974 		MISSING_CASE;
  975 		ret = -ENODEV;
  976 	}
  977 
  978 	if (ret < 0)
  979 		goto err_destruct;
  980 
  981 	ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj,
  982 				"usb_device");
  983 	if (ret < 0)
  984 		goto err_destruct;
  985 
  986 	/* creation of additional special files should go here */
  987 
  988 	dev_info(&interface->dev, "Line6 %s now attached\n",
  989 		 line6->properties->name);
  990 
  991 	switch (product) {
  992 	case LINE6_DEVID_PODX3:
  993 	case LINE6_DEVID_PODX3LIVE:
  994 		dev_info(&interface->dev,
  995 			 "NOTE: the Line6 %s is detected, but not yet supported\n",
  996 			 line6->properties->name);
  997 	}
  998 
  999 	/* increment reference counters: */
 1000 	usb_get_intf(interface);
 1001 	usb_get_dev(usbdev);
 1002 
 1003 	return 0;
 1004 
 1005 err_destruct:
 1006 	line6_destruct(interface);
 1007 err_put:
 1008 	return ret;
 1009 }
 1010 
 1011 /*
 1012 	Line6 device disconnected.
 1013 */
 1014 static void line6_disconnect(struct usb_interface *interface)
 1015 {
 1016 	struct usb_line6 *line6;
 1017 	struct usb_device *usbdev;
 1018 	int interface_number;
 1019 
 1020 	if (interface == NULL)
 1021 		return;
 1022 	usbdev = interface_to_usbdev(interface);
 1023 	if (usbdev == NULL)
 1024 		return;
 1025 
 1026 	/* removal of additional special files should go here */
 1027 
 1028 	sysfs_remove_link(&interface->dev.kobj, "usb_device");
 1029 
 1030 	interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
 1031 	line6 = usb_get_intfdata(interface);
 1032 
 1033 	if (line6 != NULL) {
 1034 		if (line6->urb_listen != NULL)
 1035 			line6_stop_listen(line6);
 1036 
 1037 		if (usbdev != line6->usbdev)
 1038 			dev_err(line6->ifcdev,
 1039 				"driver bug: inconsistent usb device\n");
 1040 
 1041 		switch (le16_to_cpu(line6->usbdev->descriptor.idProduct)) {
 1042 		case LINE6_DEVID_BASSPODXT:
 1043 		case LINE6_DEVID_BASSPODXTLIVE:
 1044 		case LINE6_DEVID_BASSPODXTPRO:
 1045 		case LINE6_DEVID_POCKETPOD:
 1046 		case LINE6_DEVID_PODX3:
 1047 		case LINE6_DEVID_PODX3LIVE:
 1048 		case LINE6_DEVID_PODXT:
 1049 		case LINE6_DEVID_PODXTPRO:
 1050 			line6_pod_disconnect(interface);
 1051 			break;
 1052 
 1053 		case LINE6_DEVID_PODHD300:
 1054 		case LINE6_DEVID_PODHD400:
 1055 		case LINE6_DEVID_PODHD500:
 1056 			line6_podhd_disconnect(interface);
 1057 			break;
 1058 
 1059 		case LINE6_DEVID_PODXTLIVE:
 1060 			switch (interface_number) {
 1061 			case PODXTLIVE_INTERFACE_POD:
 1062 				line6_pod_disconnect(interface);
 1063 				break;
 1064 
 1065 			case PODXTLIVE_INTERFACE_VARIAX:
 1066 				line6_variax_disconnect(interface);
 1067 				break;
 1068 			}
 1069 
 1070 			break;
 1071 
 1072 		case LINE6_DEVID_VARIAX:
 1073 			line6_variax_disconnect(interface);
 1074 			break;
 1075 
 1076 		case LINE6_DEVID_PODSTUDIO_GX:
 1077 		case LINE6_DEVID_PODSTUDIO_UX1:
 1078 		case LINE6_DEVID_PODSTUDIO_UX2:
 1079 		case LINE6_DEVID_TONEPORT_GX:
 1080 		case LINE6_DEVID_TONEPORT_UX1:
 1081 		case LINE6_DEVID_TONEPORT_UX2:
 1082 		case LINE6_DEVID_GUITARPORT:
 1083 			line6_toneport_disconnect(interface);
 1084 			break;
 1085 
 1086 		default:
 1087 			MISSING_CASE;
 1088 		}
 1089 
 1090 		dev_info(&interface->dev, "Line6 %s now disconnected\n",
 1091 			 line6->properties->name);
 1092 	}
 1093 
 1094 	line6_destruct(interface);
 1095 
 1096 	/* decrement reference counters: */
 1097 	usb_put_intf(interface);
 1098 	usb_put_dev(usbdev);
 1099 }
 1100 
 1101 #ifdef CONFIG_PM
 1102 
 1103 /*
 1104 	Suspend Line6 device.
 1105 */
 1106 static int line6_suspend(struct usb_interface *interface, pm_message_t message)
 1107 {
 1108 	struct usb_line6 *line6 = usb_get_intfdata(interface);
 1109 	struct snd_line6_pcm *line6pcm = line6->line6pcm;
 1110 
 1111 	snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot);
 1112 
 1113 	if (line6->properties->capabilities & LINE6_BIT_CONTROL)
 1114 		line6_stop_listen(line6);
 1115 
 1116 	if (line6pcm != NULL) {
 1117 		snd_pcm_suspend_all(line6pcm->pcm);
 1118 		line6_pcm_disconnect(line6pcm);
 1119 		line6pcm->flags = 0;
 1120 	}
 1121 
 1122 	return 0;
 1123 }
 1124 
 1125 /*
 1126 	Resume Line6 device.
 1127 */
 1128 static int line6_resume(struct usb_interface *interface)
 1129 {
 1130 	struct usb_line6 *line6 = usb_get_intfdata(interface);
 1131 
 1132 	if (line6->properties->capabilities & LINE6_BIT_CONTROL)
 1133 		line6_start_listen(line6);
 1134 
 1135 	snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0);
 1136 	return 0;
 1137 }
 1138 
 1139 /*
 1140 	Resume Line6 device after reset.
 1141 */
 1142 static int line6_reset_resume(struct usb_interface *interface)
 1143 {
 1144 	struct usb_line6 *line6 = usb_get_intfdata(interface);
 1145 
 1146 	switch (le16_to_cpu(line6->usbdev->descriptor.idProduct)) {
 1147 	case LINE6_DEVID_PODSTUDIO_GX:
 1148 	case LINE6_DEVID_PODSTUDIO_UX1:
 1149 	case LINE6_DEVID_PODSTUDIO_UX2:
 1150 	case LINE6_DEVID_TONEPORT_GX:
 1151 	case LINE6_DEVID_TONEPORT_UX1:
 1152 	case LINE6_DEVID_TONEPORT_UX2:
 1153 	case LINE6_DEVID_GUITARPORT:
 1154 		line6_toneport_reset_resume((struct usb_line6_toneport *)line6);
 1155 	}
 1156 
 1157 	return line6_resume(interface);
 1158 }
 1159 
 1160 #endif /* CONFIG_PM */
 1161 
 1162 static struct usb_driver line6_driver = {
 1163 	.name = DRIVER_NAME,
 1164 	.probe = line6_probe,
 1165 	.disconnect = line6_disconnect,
 1166 #ifdef CONFIG_PM
 1167 	.suspend = line6_suspend,
 1168 	.resume = line6_resume,
 1169 	.reset_resume = line6_reset_resume,
 1170 #endif
 1171 	.id_table = line6_id_table,
 1172 };
 1173 
 1174 module_usb_driver(line6_driver);
 1175 
 1176 MODULE_AUTHOR(DRIVER_AUTHOR);
 1177 MODULE_DESCRIPTION(DRIVER_DESC);
 1178 MODULE_LICENSE("GPL");
 1179 MODULE_VERSION(DRIVER_VERSION);
 1180 
 1181 
 1182 
 1183 
 1184 
 1185 /* LDV_COMMENT_BEGIN_MAIN */
 1186 #ifdef LDV_MAIN2_sequence_infinite_withcheck_stateful
 1187 
 1188 /*###########################################################################*/
 1189 
 1190 /*############## Driver Environment Generator 0.2 output ####################*/
 1191 
 1192 /*###########################################################################*/
 1193 
 1194 
 1195 
 1196 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */
 1197 void ldv_check_final_state(void);
 1198 
 1199 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */
 1200 void ldv_check_return_value(int res);
 1201 
 1202 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */
 1203 void ldv_check_return_value_probe(int res);
 1204 
 1205 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */
 1206 void ldv_initialize(void);
 1207 
 1208 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */
 1209 void ldv_handler_precall(void);
 1210 
 1211 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */
 1212 int nondet_int(void);
 1213 
 1214 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */
 1215 int LDV_IN_INTERRUPT;
 1216 
 1217 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */
 1218 void ldv_main2_sequence_infinite_withcheck_stateful(void) {
 1219 
 1220 
 1221 
 1222 	/* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */
 1223 	/*============================= VARIABLE DECLARATION PART   =============================*/
 1224 	/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1225 	/* content: static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id)*/
 1226 	/* LDV_COMMENT_BEGIN_PREP */
 1227 	#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1228 	#define DRIVER_DESC    "Line6 USB Driver"
 1229 	#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1230 	#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1231 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1232 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1233 	/* LDV_COMMENT_END_PREP */
 1234 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "line6_probe" */
 1235 	struct usb_interface * var_group1;
 1236 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "line6_probe" */
 1237 	const struct usb_device_id * var_line6_probe_17_p1;
 1238 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "line6_probe" */
 1239 	static int res_line6_probe_17;
 1240 	/* LDV_COMMENT_BEGIN_PREP */
 1241 	#ifdef CONFIG_PM
 1242 	#endif 
 1243 	#ifdef CONFIG_PM
 1244 	#endif
 1245 	/* LDV_COMMENT_END_PREP */
 1246 	/* content: static void line6_disconnect(struct usb_interface *interface)*/
 1247 	/* LDV_COMMENT_BEGIN_PREP */
 1248 	#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1249 	#define DRIVER_DESC    "Line6 USB Driver"
 1250 	#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1251 	#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1252 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1253 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1254 	/* LDV_COMMENT_END_PREP */
 1255 	/* LDV_COMMENT_BEGIN_PREP */
 1256 	#ifdef CONFIG_PM
 1257 	#endif 
 1258 	#ifdef CONFIG_PM
 1259 	#endif
 1260 	/* LDV_COMMENT_END_PREP */
 1261 	/* content: static int line6_suspend(struct usb_interface *interface, pm_message_t message)*/
 1262 	/* LDV_COMMENT_BEGIN_PREP */
 1263 	#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1264 	#define DRIVER_DESC    "Line6 USB Driver"
 1265 	#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1266 	#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1267 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1268 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1269 	#ifdef CONFIG_PM
 1270 	/* LDV_COMMENT_END_PREP */
 1271 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "line6_suspend" */
 1272 	pm_message_t  var_line6_suspend_19_p1;
 1273 	/* LDV_COMMENT_BEGIN_PREP */
 1274 	#endif 
 1275 	#ifdef CONFIG_PM
 1276 	#endif
 1277 	/* LDV_COMMENT_END_PREP */
 1278 	/* content: static int line6_resume(struct usb_interface *interface)*/
 1279 	/* LDV_COMMENT_BEGIN_PREP */
 1280 	#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1281 	#define DRIVER_DESC    "Line6 USB Driver"
 1282 	#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1283 	#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1284 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1285 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1286 	#ifdef CONFIG_PM
 1287 	/* LDV_COMMENT_END_PREP */
 1288 	/* LDV_COMMENT_BEGIN_PREP */
 1289 	#endif 
 1290 	#ifdef CONFIG_PM
 1291 	#endif
 1292 	/* LDV_COMMENT_END_PREP */
 1293 	/* content: static int line6_reset_resume(struct usb_interface *interface)*/
 1294 	/* LDV_COMMENT_BEGIN_PREP */
 1295 	#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1296 	#define DRIVER_DESC    "Line6 USB Driver"
 1297 	#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1298 	#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1299 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1300 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1301 	#ifdef CONFIG_PM
 1302 	/* LDV_COMMENT_END_PREP */
 1303 	/* LDV_COMMENT_BEGIN_PREP */
 1304 	#endif 
 1305 	#ifdef CONFIG_PM
 1306 	#endif
 1307 	/* LDV_COMMENT_END_PREP */
 1308 
 1309 
 1310 
 1311 
 1312 	/* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */
 1313 	/* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */
 1314 	/*============================= VARIABLE INITIALIZING PART  =============================*/
 1315 	LDV_IN_INTERRUPT=1;
 1316 
 1317 
 1318 
 1319 
 1320 	/* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */
 1321 	/* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */
 1322 	/*============================= FUNCTION CALL SECTION       =============================*/
 1323 	/* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */
 1324 	ldv_initialize();
 1325 	int ldv_s_line6_driver_usb_driver = 0;
 1326 
 1327 
 1328 	while(  nondet_int()
 1329 		|| !(ldv_s_line6_driver_usb_driver == 0)
 1330 	) {
 1331 
 1332 		switch(nondet_int()) {
 1333 
 1334 			case 0: {
 1335 
 1336 				/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1337 				if(ldv_s_line6_driver_usb_driver==0) {
 1338 
 1339 				/* content: static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id)*/
 1340 				/* LDV_COMMENT_BEGIN_PREP */
 1341 				#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1342 				#define DRIVER_DESC    "Line6 USB Driver"
 1343 				#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1344 				#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1345 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1346 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1347 				/* LDV_COMMENT_END_PREP */
 1348 				/* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "line6_driver". Standart function test for correct return result. */
 1349 				res_line6_probe_17 = line6_probe( var_group1, var_line6_probe_17_p1);
 1350 				 ldv_check_return_value(res_line6_probe_17);
 1351 				 ldv_check_return_value_probe(res_line6_probe_17);
 1352 				 if(res_line6_probe_17) 
 1353 					goto ldv_module_exit;
 1354 				/* LDV_COMMENT_BEGIN_PREP */
 1355 				#ifdef CONFIG_PM
 1356 				#endif 
 1357 				#ifdef CONFIG_PM
 1358 				#endif
 1359 				/* LDV_COMMENT_END_PREP */
 1360 				ldv_s_line6_driver_usb_driver++;
 1361 
 1362 				}
 1363 
 1364 			}
 1365 
 1366 			break;
 1367 			case 1: {
 1368 
 1369 				/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1370 				if(ldv_s_line6_driver_usb_driver==1) {
 1371 
 1372 				/* content: static int line6_suspend(struct usb_interface *interface, pm_message_t message)*/
 1373 				/* LDV_COMMENT_BEGIN_PREP */
 1374 				#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1375 				#define DRIVER_DESC    "Line6 USB Driver"
 1376 				#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1377 				#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1378 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1379 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1380 				#ifdef CONFIG_PM
 1381 				/* LDV_COMMENT_END_PREP */
 1382 				/* LDV_COMMENT_FUNCTION_CALL Function from field "suspend" from driver structure with callbacks "line6_driver" */
 1383 				ldv_handler_precall();
 1384 				line6_suspend( var_group1, var_line6_suspend_19_p1);
 1385 				/* LDV_COMMENT_BEGIN_PREP */
 1386 				#endif 
 1387 				#ifdef CONFIG_PM
 1388 				#endif
 1389 				/* LDV_COMMENT_END_PREP */
 1390 				ldv_s_line6_driver_usb_driver++;
 1391 
 1392 				}
 1393 
 1394 			}
 1395 
 1396 			break;
 1397 			case 2: {
 1398 
 1399 				/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1400 				if(ldv_s_line6_driver_usb_driver==2) {
 1401 
 1402 				/* content: static int line6_resume(struct usb_interface *interface)*/
 1403 				/* LDV_COMMENT_BEGIN_PREP */
 1404 				#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1405 				#define DRIVER_DESC    "Line6 USB Driver"
 1406 				#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1407 				#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1408 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1409 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1410 				#ifdef CONFIG_PM
 1411 				/* LDV_COMMENT_END_PREP */
 1412 				/* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "line6_driver" */
 1413 				ldv_handler_precall();
 1414 				line6_resume( var_group1);
 1415 				/* LDV_COMMENT_BEGIN_PREP */
 1416 				#endif 
 1417 				#ifdef CONFIG_PM
 1418 				#endif
 1419 				/* LDV_COMMENT_END_PREP */
 1420 				ldv_s_line6_driver_usb_driver++;
 1421 
 1422 				}
 1423 
 1424 			}
 1425 
 1426 			break;
 1427 			case 3: {
 1428 
 1429 				/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1430 				if(ldv_s_line6_driver_usb_driver==3) {
 1431 
 1432 				/* content: static int line6_reset_resume(struct usb_interface *interface)*/
 1433 				/* LDV_COMMENT_BEGIN_PREP */
 1434 				#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1435 				#define DRIVER_DESC    "Line6 USB Driver"
 1436 				#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1437 				#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1438 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1439 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1440 				#ifdef CONFIG_PM
 1441 				/* LDV_COMMENT_END_PREP */
 1442 				/* LDV_COMMENT_FUNCTION_CALL Function from field "reset_resume" from driver structure with callbacks "line6_driver" */
 1443 				ldv_handler_precall();
 1444 				line6_reset_resume( var_group1);
 1445 				/* LDV_COMMENT_BEGIN_PREP */
 1446 				#endif 
 1447 				#ifdef CONFIG_PM
 1448 				#endif
 1449 				/* LDV_COMMENT_END_PREP */
 1450 				ldv_s_line6_driver_usb_driver++;
 1451 
 1452 				}
 1453 
 1454 			}
 1455 
 1456 			break;
 1457 			case 4: {
 1458 
 1459 				/** STRUCT: struct type: usb_driver, struct name: line6_driver **/
 1460 				if(ldv_s_line6_driver_usb_driver==4) {
 1461 
 1462 				/* content: static void line6_disconnect(struct usb_interface *interface)*/
 1463 				/* LDV_COMMENT_BEGIN_PREP */
 1464 				#define DRIVER_AUTHOR  "Markus Grabner <grabner@icg.tugraz.at>"
 1465 				#define DRIVER_DESC    "Line6 USB Driver"
 1466 				#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
 1467 				#define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
 1468 	{.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
 1469 	 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
 1470 				/* LDV_COMMENT_END_PREP */
 1471 				/* LDV_COMMENT_FUNCTION_CALL Function from field "disconnect" from driver structure with callbacks "line6_driver" */
 1472 				ldv_handler_precall();
 1473 				line6_disconnect( var_group1);
 1474 				/* LDV_COMMENT_BEGIN_PREP */
 1475 				#ifdef CONFIG_PM
 1476 				#endif 
 1477 				#ifdef CONFIG_PM
 1478 				#endif
 1479 				/* LDV_COMMENT_END_PREP */
 1480 				ldv_s_line6_driver_usb_driver=0;
 1481 
 1482 				}
 1483 
 1484 			}
 1485 
 1486 			break;
 1487 			default: break;
 1488 
 1489 		}
 1490 
 1491 	}
 1492 
 1493 	ldv_module_exit: 
 1494 
 1495 	/* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */
 1496 	ldv_final: ldv_check_final_state();
 1497 
 1498 	/* LDV_COMMENT_END_FUNCTION_CALL_SECTION */
 1499 	return;
 1500 
 1501 }
 1502 #endif
 1503 
 1504 /* LDV_COMMENT_END_MAIN */                 1 
    2 #include <linux/kernel.h>
    3 bool ldv_is_err(const void *ptr);
    4 bool ldv_is_err_or_null(const void *ptr);
    5 void* ldv_err_ptr(long error);
    6 long ldv_ptr_err(const void *ptr);
    7 
    8 #include <linux/kernel.h>
    9 #include <linux/module.h>
   10 
   11 #include <linux/usb.h>
   12 
   13 // Provide model function prototypes before their usage.
   14 void ldv_interface_to_usbdev(void);
   15 void ldv_usb_get_dev(void);
   16 void ldv_usb_put_dev(void);
   17 
   18 /*
   19  * Line6 Linux USB driver - 0.9.1beta
   20  *
   21  * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
   22  *                         Emil Myhrman (emil.myhrman@gmail.com)
   23  *
   24  *	This program is free software; you can redistribute it and/or
   25  *	modify it under the terms of the GNU General Public License as
   26  *	published by the Free Software Foundation, version 2.
   27  *
   28  */
   29 
   30 #include <linux/wait.h>
   31 #include <sound/control.h>
   32 
   33 #include "audio.h"
   34 #include "capture.h"
   35 #include "driver.h"
   36 #include "playback.h"
   37 #include "toneport.h"
   38 
   39 static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
   40 
   41 #define TONEPORT_PCM_DELAY 1
   42 
   43 static struct snd_ratden toneport_ratden = {
   44 	.num_min = 44100,
   45 	.num_max = 44100,
   46 	.num_step = 1,
   47 	.den = 1
   48 };
   49 
   50 static struct line6_pcm_properties toneport_pcm_properties = {
   51 	.snd_line6_playback_hw = {
   52 				  .info = (SNDRV_PCM_INFO_MMAP |
   53 					   SNDRV_PCM_INFO_INTERLEAVED |
   54 					   SNDRV_PCM_INFO_BLOCK_TRANSFER |
   55 					   SNDRV_PCM_INFO_MMAP_VALID |
   56 					   SNDRV_PCM_INFO_PAUSE |
   57 #ifdef CONFIG_PM
   58 					   SNDRV_PCM_INFO_RESUME |
   59 #endif
   60 					   SNDRV_PCM_INFO_SYNC_START),
   61 				  .formats = SNDRV_PCM_FMTBIT_S16_LE,
   62 				  .rates = SNDRV_PCM_RATE_KNOT,
   63 				  .rate_min = 44100,
   64 				  .rate_max = 44100,
   65 				  .channels_min = 2,
   66 				  .channels_max = 2,
   67 				  .buffer_bytes_max = 60000,
   68 				  .period_bytes_min = 64,
   69 				  .period_bytes_max = 8192,
   70 				  .periods_min = 1,
   71 				  .periods_max = 1024},
   72 	.snd_line6_capture_hw = {
   73 				 .info = (SNDRV_PCM_INFO_MMAP |
   74 					  SNDRV_PCM_INFO_INTERLEAVED |
   75 					  SNDRV_PCM_INFO_BLOCK_TRANSFER |
   76 					  SNDRV_PCM_INFO_MMAP_VALID |
   77 #ifdef CONFIG_PM
   78 					  SNDRV_PCM_INFO_RESUME |
   79 #endif
   80 					  SNDRV_PCM_INFO_SYNC_START),
   81 				 .formats = SNDRV_PCM_FMTBIT_S16_LE,
   82 				 .rates = SNDRV_PCM_RATE_KNOT,
   83 				 .rate_min = 44100,
   84 				 .rate_max = 44100,
   85 				 .channels_min = 2,
   86 				 .channels_max = 2,
   87 				 .buffer_bytes_max = 60000,
   88 				 .period_bytes_min = 64,
   89 				 .period_bytes_max = 8192,
   90 				 .periods_min = 1,
   91 				 .periods_max = 1024},
   92 	.snd_line6_rates = {
   93 			    .nrats = 1,
   94 			    .rats = &toneport_ratden},
   95 	.bytes_per_frame = 4
   96 };
   97 
   98 /*
   99 	For the led on Guitarport.
  100 	Brightness goes from 0x00 to 0x26. Set a value above this to have led
  101 	blink.
  102 	(void cmd_0x02(byte red, byte green)
  103 */
  104 static int led_red = 0x00;
  105 static int led_green = 0x26;
  106 
  107 static const struct {
  108 	const char *name;
  109 	int code;
  110 } toneport_source_info[] = {
  111 	{"Microphone", 0x0a01},
  112 	{"Line", 0x0801},
  113 	{"Instrument", 0x0b01},
  114 	{"Inst & Mic", 0x0901}
  115 };
  116 
  117 static bool toneport_has_led(short product)
  118 {
  119 	return
  120 	    (product == LINE6_DEVID_GUITARPORT) ||
  121 	    (product == LINE6_DEVID_TONEPORT_GX);
  122 	/* add your device here if you are missing support for the LEDs */
  123 }
  124 
  125 static void toneport_update_led(struct device *dev)
  126 {
  127 	struct usb_interface *interface = to_usb_interface(dev);
  128 	struct usb_line6_toneport *tp = usb_get_intfdata(interface);
  129 	struct usb_line6 *line6;
  130 
  131 	if (!tp)
  132 		return;
  133 
  134 	line6 = &tp->line6;
  135 	if (line6)
  136 		toneport_send_cmd(line6->usbdev, (led_red << 8) | 0x0002,
  137 				  led_green);
  138 }
  139 
  140 static ssize_t toneport_set_led_red(struct device *dev,
  141 				    struct device_attribute *attr,
  142 				    const char *buf, size_t count)
  143 {
  144 	int retval;
  145 
  146 	retval = kstrtoint(buf, 10, &led_red);
  147 	if (retval)
  148 		return retval;
  149 
  150 	toneport_update_led(dev);
  151 	return count;
  152 }
  153 
  154 static ssize_t toneport_set_led_green(struct device *dev,
  155 				      struct device_attribute *attr,
  156 				      const char *buf, size_t count)
  157 {
  158 	int retval;
  159 
  160 	retval = kstrtoint(buf, 10, &led_green);
  161 	if (retval)
  162 		return retval;
  163 
  164 	toneport_update_led(dev);
  165 	return count;
  166 }
  167 
  168 static DEVICE_ATTR(led_red, S_IWUSR | S_IRUGO, line6_nop_read,
  169 		   toneport_set_led_red);
  170 static DEVICE_ATTR(led_green, S_IWUSR | S_IRUGO, line6_nop_read,
  171 		   toneport_set_led_green);
  172 
  173 static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
  174 {
  175 	int ret;
  176 
  177 	ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
  178 			      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  179 			      cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
  180 
  181 	if (ret < 0) {
  182 		dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
  183 		return ret;
  184 	}
  185 
  186 	return 0;
  187 }
  188 
  189 /* monitor info callback */
  190 static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol,
  191 				     struct snd_ctl_elem_info *uinfo)
  192 {
  193 	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  194 	uinfo->count = 1;
  195 	uinfo->value.integer.min = 0;
  196 	uinfo->value.integer.max = 256;
  197 	return 0;
  198 }
  199 
  200 /* monitor get callback */
  201 static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol,
  202 				    struct snd_ctl_elem_value *ucontrol)
  203 {
  204 	struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  205 
  206 	ucontrol->value.integer.value[0] = line6pcm->volume_monitor;
  207 	return 0;
  208 }
  209 
  210 /* monitor put callback */
  211 static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
  212 				    struct snd_ctl_elem_value *ucontrol)
  213 {
  214 	struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  215 
  216 	if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
  217 		return 0;
  218 
  219 	line6pcm->volume_monitor = ucontrol->value.integer.value[0];
  220 
  221 	if (line6pcm->volume_monitor > 0)
  222 		line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_MONITOR);
  223 	else
  224 		line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
  225 
  226 	return 1;
  227 }
  228 
  229 /* source info callback */
  230 static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
  231 				    struct snd_ctl_elem_info *uinfo)
  232 {
  233 	const int size = ARRAY_SIZE(toneport_source_info);
  234 
  235 	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  236 	uinfo->count = 1;
  237 	uinfo->value.enumerated.items = size;
  238 
  239 	if (uinfo->value.enumerated.item >= size)
  240 		uinfo->value.enumerated.item = size - 1;
  241 
  242 	strcpy(uinfo->value.enumerated.name,
  243 	       toneport_source_info[uinfo->value.enumerated.item].name);
  244 
  245 	return 0;
  246 }
  247 
  248 /* source get callback */
  249 static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
  250 				   struct snd_ctl_elem_value *ucontrol)
  251 {
  252 	struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  253 	struct usb_line6_toneport *toneport =
  254 	    (struct usb_line6_toneport *)line6pcm->line6;
  255 	ucontrol->value.enumerated.item[0] = toneport->source;
  256 	return 0;
  257 }
  258 
  259 /* source put callback */
  260 static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
  261 				   struct snd_ctl_elem_value *ucontrol)
  262 {
  263 	struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  264 	struct usb_line6_toneport *toneport =
  265 	    (struct usb_line6_toneport *)line6pcm->line6;
  266 	unsigned int source;
  267 
  268 	source = ucontrol->value.enumerated.item[0];
  269 	if (source >= ARRAY_SIZE(toneport_source_info))
  270 		return -EINVAL;
  271 	if (source == toneport->source)
  272 		return 0;
  273 
  274 	toneport->source = source;
  275 	toneport_send_cmd(toneport->line6.usbdev,
  276 			  toneport_source_info[source].code, 0x0000);
  277 	return 1;
  278 }
  279 
  280 static void toneport_start_pcm(unsigned long arg)
  281 {
  282 	struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg;
  283 	struct usb_line6 *line6 = &toneport->line6;
  284 
  285 	line6_pcm_acquire(line6->line6pcm, LINE6_BITS_PCM_MONITOR);
  286 }
  287 
  288 /* control definition */
  289 static struct snd_kcontrol_new toneport_control_monitor = {
  290 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  291 	.name = "Monitor Playback Volume",
  292 	.index = 0,
  293 	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  294 	.info = snd_toneport_monitor_info,
  295 	.get = snd_toneport_monitor_get,
  296 	.put = snd_toneport_monitor_put
  297 };
  298 
  299 /* source selector definition */
  300 static struct snd_kcontrol_new toneport_control_source = {
  301 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  302 	.name = "PCM Capture Source",
  303 	.index = 0,
  304 	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  305 	.info = snd_toneport_source_info,
  306 	.get = snd_toneport_source_get,
  307 	.put = snd_toneport_source_put
  308 };
  309 
  310 /*
  311 	Toneport destructor.
  312 */
  313 static void toneport_destruct(struct usb_interface *interface)
  314 {
  315 	struct usb_line6_toneport *toneport = usb_get_intfdata(interface);
  316 
  317 	if (toneport == NULL)
  318 		return;
  319 	line6_cleanup_audio(&toneport->line6);
  320 }
  321 
  322 /*
  323 	Setup Toneport device.
  324 */
  325 static void toneport_setup(struct usb_line6_toneport *toneport)
  326 {
  327 	int ticks;
  328 	struct usb_line6 *line6 = &toneport->line6;
  329 	struct usb_device *usbdev = line6->usbdev;
  330 	u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
  331 
  332 	/* sync time on device with host: */
  333 	ticks = (int)get_seconds();
  334 	line6_write_data(line6, 0x80c6, &ticks, 4);
  335 
  336 	/* enable device: */
  337 	toneport_send_cmd(usbdev, 0x0301, 0x0000);
  338 
  339 	/* initialize source select: */
  340 	switch (le16_to_cpu(usbdev->descriptor.idProduct)) {
  341 	case LINE6_DEVID_TONEPORT_UX1:
  342 	case LINE6_DEVID_TONEPORT_UX2:
  343 	case LINE6_DEVID_PODSTUDIO_UX1:
  344 	case LINE6_DEVID_PODSTUDIO_UX2:
  345 		toneport_send_cmd(usbdev,
  346 				  toneport_source_info[toneport->source].code,
  347 				  0x0000);
  348 	}
  349 
  350 	if (toneport_has_led(idProduct))
  351 		toneport_update_led(&usbdev->dev);
  352 }
  353 
  354 /*
  355 	 Try to init Toneport device.
  356 */
  357 static int toneport_try_init(struct usb_interface *interface,
  358 			     struct usb_line6_toneport *toneport)
  359 {
  360 	int err;
  361 	struct usb_line6 *line6 = &toneport->line6;
  362 	struct usb_device *usbdev = line6->usbdev;
  363 	u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
  364 
  365 	if ((interface == NULL) || (toneport == NULL))
  366 		return -ENODEV;
  367 
  368 	/* initialize audio system: */
  369 	err = line6_init_audio(line6);
  370 	if (err < 0)
  371 		return err;
  372 
  373 	/* initialize PCM subsystem: */
  374 	err = line6_init_pcm(line6, &toneport_pcm_properties);
  375 	if (err < 0)
  376 		return err;
  377 
  378 	/* register monitor control: */
  379 	err = snd_ctl_add(line6->card,
  380 			  snd_ctl_new1(&toneport_control_monitor,
  381 				       line6->line6pcm));
  382 	if (err < 0)
  383 		return err;
  384 
  385 	/* register source select control: */
  386 	switch (le16_to_cpu(usbdev->descriptor.idProduct)) {
  387 	case LINE6_DEVID_TONEPORT_UX1:
  388 	case LINE6_DEVID_TONEPORT_UX2:
  389 	case LINE6_DEVID_PODSTUDIO_UX1:
  390 	case LINE6_DEVID_PODSTUDIO_UX2:
  391 		err =
  392 		    snd_ctl_add(line6->card,
  393 				snd_ctl_new1(&toneport_control_source,
  394 					     line6->line6pcm));
  395 		if (err < 0)
  396 			return err;
  397 	}
  398 
  399 	/* register audio system: */
  400 	err = line6_register_audio(line6);
  401 	if (err < 0)
  402 		return err;
  403 
  404 	line6_read_serial_number(line6, &toneport->serial_number);
  405 	line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
  406 
  407 	if (toneport_has_led(idProduct)) {
  408 		CHECK_RETURN(device_create_file
  409 			     (&interface->dev, &dev_attr_led_red));
  410 		CHECK_RETURN(device_create_file
  411 			     (&interface->dev, &dev_attr_led_green));
  412 	}
  413 
  414 	toneport_setup(toneport);
  415 
  416 	init_timer(&toneport->timer);
  417 	toneport->timer.expires = jiffies + TONEPORT_PCM_DELAY * HZ;
  418 	toneport->timer.function = toneport_start_pcm;
  419 	toneport->timer.data = (unsigned long)toneport;
  420 	add_timer(&toneport->timer);
  421 
  422 	return 0;
  423 }
  424 
  425 /*
  426 	 Init Toneport device (and clean up in case of failure).
  427 */
  428 int line6_toneport_init(struct usb_interface *interface,
  429 			struct usb_line6_toneport *toneport)
  430 {
  431 	int err = toneport_try_init(interface, toneport);
  432 
  433 	if (err < 0)
  434 		toneport_destruct(interface);
  435 
  436 	return err;
  437 }
  438 
  439 /*
  440 	Resume Toneport device after reset.
  441 */
  442 void line6_toneport_reset_resume(struct usb_line6_toneport *toneport)
  443 {
  444 	toneport_setup(toneport);
  445 }
  446 
  447 /*
  448 	Toneport device disconnected.
  449 */
  450 void line6_toneport_disconnect(struct usb_interface *interface)
  451 {
  452 	struct usb_line6_toneport *toneport;
  453 	u16 idProduct;
  454 
  455 	if (interface == NULL)
  456 		return;
  457 
  458 	toneport = usb_get_intfdata(interface);
  459 	del_timer_sync(&toneport->timer);
  460 	idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
  461 
  462 	if (toneport_has_led(idProduct)) {
  463 		device_remove_file(&interface->dev, &dev_attr_led_red);
  464 		device_remove_file(&interface->dev, &dev_attr_led_green);
  465 	}
  466 
  467 	if (toneport != NULL) {
  468 		struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm;
  469 
  470 		if (line6pcm != NULL) {
  471 			line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
  472 			line6_pcm_disconnect(line6pcm);
  473 		}
  474 	}
  475 
  476 	toneport_destruct(interface);
  477 }
  478 
  479 
  480 
  481 
  482 
  483 /* LDV_COMMENT_BEGIN_MAIN */
  484 #ifdef LDV_MAIN8_sequence_infinite_withcheck_stateful
  485 
  486 /*###########################################################################*/
  487 
  488 /*############## Driver Environment Generator 0.2 output ####################*/
  489 
  490 /*###########################################################################*/
  491 
  492 
  493 
  494 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */
  495 void ldv_check_final_state(void);
  496 
  497 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */
  498 void ldv_check_return_value(int res);
  499 
  500 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */
  501 void ldv_check_return_value_probe(int res);
  502 
  503 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */
  504 void ldv_initialize(void);
  505 
  506 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */
  507 void ldv_handler_precall(void);
  508 
  509 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */
  510 int nondet_int(void);
  511 
  512 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */
  513 int LDV_IN_INTERRUPT;
  514 
  515 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */
  516 void ldv_main8_sequence_infinite_withcheck_stateful(void) {
  517 
  518 
  519 
  520 	/* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */
  521 	/*============================= VARIABLE DECLARATION PART   =============================*/
  522 	/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_monitor **/
  523 	/* content: static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)*/
  524 	/* LDV_COMMENT_BEGIN_PREP */
  525 	#define TONEPORT_PCM_DELAY 1
  526 	#ifdef CONFIG_PM
  527 	#endif
  528 	#ifdef CONFIG_PM
  529 	#endif
  530 	/* LDV_COMMENT_END_PREP */
  531 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "snd_toneport_monitor_info" */
  532 	struct snd_kcontrol * var_group1;
  533 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "snd_toneport_monitor_info" */
  534 	struct snd_ctl_elem_info * var_group2;
  535 	/* content: static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  536 	/* LDV_COMMENT_BEGIN_PREP */
  537 	#define TONEPORT_PCM_DELAY 1
  538 	#ifdef CONFIG_PM
  539 	#endif
  540 	#ifdef CONFIG_PM
  541 	#endif
  542 	/* LDV_COMMENT_END_PREP */
  543 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "snd_toneport_monitor_get" */
  544 	struct snd_ctl_elem_value * var_group3;
  545 	/* content: static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  546 	/* LDV_COMMENT_BEGIN_PREP */
  547 	#define TONEPORT_PCM_DELAY 1
  548 	#ifdef CONFIG_PM
  549 	#endif
  550 	#ifdef CONFIG_PM
  551 	#endif
  552 	/* LDV_COMMENT_END_PREP */
  553 
  554 	/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_source **/
  555 	/* content: static int snd_toneport_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)*/
  556 	/* LDV_COMMENT_BEGIN_PREP */
  557 	#define TONEPORT_PCM_DELAY 1
  558 	#ifdef CONFIG_PM
  559 	#endif
  560 	#ifdef CONFIG_PM
  561 	#endif
  562 	/* LDV_COMMENT_END_PREP */
  563 	/* content: static int snd_toneport_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  564 	/* LDV_COMMENT_BEGIN_PREP */
  565 	#define TONEPORT_PCM_DELAY 1
  566 	#ifdef CONFIG_PM
  567 	#endif
  568 	#ifdef CONFIG_PM
  569 	#endif
  570 	/* LDV_COMMENT_END_PREP */
  571 	/* content: static int snd_toneport_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  572 	/* LDV_COMMENT_BEGIN_PREP */
  573 	#define TONEPORT_PCM_DELAY 1
  574 	#ifdef CONFIG_PM
  575 	#endif
  576 	#ifdef CONFIG_PM
  577 	#endif
  578 	/* LDV_COMMENT_END_PREP */
  579 
  580 	/** TIMER SECTION timer **/
  581 	/* content: static void toneport_start_pcm(unsigned long arg)*/
  582 	/* LDV_COMMENT_BEGIN_PREP */
  583 	#define TONEPORT_PCM_DELAY 1
  584 	#ifdef CONFIG_PM
  585 	#endif
  586 	#ifdef CONFIG_PM
  587 	#endif
  588 	/* LDV_COMMENT_END_PREP */
  589 	/* LDV_COMMENT_VAR_DECLARE Variable declaration for function "toneport_start_pcm" */
  590 	unsigned long  var_toneport_start_pcm_11_p0;
  591 
  592 
  593 
  594 
  595 	/* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */
  596 	/* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */
  597 	/*============================= VARIABLE INITIALIZING PART  =============================*/
  598 	LDV_IN_INTERRUPT=1;
  599 
  600 
  601 
  602 
  603 	/* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */
  604 	/* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */
  605 	/*============================= FUNCTION CALL SECTION       =============================*/
  606 	/* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */
  607 	ldv_initialize();
  608 	
  609 
  610 	
  611 
  612 	
  613 
  614 
  615 	while(  nondet_int()
  616 	) {
  617 
  618 		switch(nondet_int()) {
  619 
  620 			case 0: {
  621 
  622 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_monitor **/
  623 				
  624 
  625 				/* content: static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)*/
  626 				/* LDV_COMMENT_BEGIN_PREP */
  627 				#define TONEPORT_PCM_DELAY 1
  628 				#ifdef CONFIG_PM
  629 				#endif
  630 				#ifdef CONFIG_PM
  631 				#endif
  632 				/* LDV_COMMENT_END_PREP */
  633 				/* LDV_COMMENT_FUNCTION_CALL Function from field "info" from driver structure with callbacks "toneport_control_monitor" */
  634 				ldv_handler_precall();
  635 				snd_toneport_monitor_info( var_group1, var_group2);
  636 				
  637 
  638 				
  639 
  640 			}
  641 
  642 			break;
  643 			case 1: {
  644 
  645 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_monitor **/
  646 				
  647 
  648 				/* content: static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  649 				/* LDV_COMMENT_BEGIN_PREP */
  650 				#define TONEPORT_PCM_DELAY 1
  651 				#ifdef CONFIG_PM
  652 				#endif
  653 				#ifdef CONFIG_PM
  654 				#endif
  655 				/* LDV_COMMENT_END_PREP */
  656 				/* LDV_COMMENT_FUNCTION_CALL Function from field "get" from driver structure with callbacks "toneport_control_monitor" */
  657 				ldv_handler_precall();
  658 				snd_toneport_monitor_get( var_group1, var_group3);
  659 				
  660 
  661 				
  662 
  663 			}
  664 
  665 			break;
  666 			case 2: {
  667 
  668 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_monitor **/
  669 				
  670 
  671 				/* content: static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  672 				/* LDV_COMMENT_BEGIN_PREP */
  673 				#define TONEPORT_PCM_DELAY 1
  674 				#ifdef CONFIG_PM
  675 				#endif
  676 				#ifdef CONFIG_PM
  677 				#endif
  678 				/* LDV_COMMENT_END_PREP */
  679 				/* LDV_COMMENT_FUNCTION_CALL Function from field "put" from driver structure with callbacks "toneport_control_monitor" */
  680 				ldv_handler_precall();
  681 				snd_toneport_monitor_put( var_group1, var_group3);
  682 				
  683 
  684 				
  685 
  686 			}
  687 
  688 			break;
  689 			case 3: {
  690 
  691 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_source **/
  692 				
  693 
  694 				/* content: static int snd_toneport_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)*/
  695 				/* LDV_COMMENT_BEGIN_PREP */
  696 				#define TONEPORT_PCM_DELAY 1
  697 				#ifdef CONFIG_PM
  698 				#endif
  699 				#ifdef CONFIG_PM
  700 				#endif
  701 				/* LDV_COMMENT_END_PREP */
  702 				/* LDV_COMMENT_FUNCTION_CALL Function from field "info" from driver structure with callbacks "toneport_control_source" */
  703 				ldv_handler_precall();
  704 				snd_toneport_source_info( var_group1, var_group2);
  705 				
  706 
  707 				
  708 
  709 			}
  710 
  711 			break;
  712 			case 4: {
  713 
  714 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_source **/
  715 				
  716 
  717 				/* content: static int snd_toneport_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  718 				/* LDV_COMMENT_BEGIN_PREP */
  719 				#define TONEPORT_PCM_DELAY 1
  720 				#ifdef CONFIG_PM
  721 				#endif
  722 				#ifdef CONFIG_PM
  723 				#endif
  724 				/* LDV_COMMENT_END_PREP */
  725 				/* LDV_COMMENT_FUNCTION_CALL Function from field "get" from driver structure with callbacks "toneport_control_source" */
  726 				ldv_handler_precall();
  727 				snd_toneport_source_get( var_group1, var_group3);
  728 				
  729 
  730 				
  731 
  732 			}
  733 
  734 			break;
  735 			case 5: {
  736 
  737 				/** STRUCT: struct type: snd_kcontrol_new, struct name: toneport_control_source **/
  738 				
  739 
  740 				/* content: static int snd_toneport_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)*/
  741 				/* LDV_COMMENT_BEGIN_PREP */
  742 				#define TONEPORT_PCM_DELAY 1
  743 				#ifdef CONFIG_PM
  744 				#endif
  745 				#ifdef CONFIG_PM
  746 				#endif
  747 				/* LDV_COMMENT_END_PREP */
  748 				/* LDV_COMMENT_FUNCTION_CALL Function from field "put" from driver structure with callbacks "toneport_control_source" */
  749 				ldv_handler_precall();
  750 				snd_toneport_source_put( var_group1, var_group3);
  751 				
  752 
  753 				
  754 
  755 			}
  756 
  757 			break;
  758 			case 6: {
  759 
  760 				/** TIMER SECTION timer **/
  761 				
  762 
  763 				/* content: static void toneport_start_pcm(unsigned long arg)*/
  764 				/* LDV_COMMENT_BEGIN_PREP */
  765 				#define TONEPORT_PCM_DELAY 1
  766 				#ifdef CONFIG_PM
  767 				#endif
  768 				#ifdef CONFIG_PM
  769 				#endif
  770 				/* LDV_COMMENT_END_PREP */
  771 				/* LDV_COMMENT_FUNCTION_CALL */
  772 				ldv_handler_precall();
  773 				toneport_start_pcm( var_toneport_start_pcm_11_p0);
  774 				
  775 
  776 				
  777 
  778 			}
  779 
  780 			break;
  781 			default: break;
  782 
  783 		}
  784 
  785 	}
  786 
  787 	ldv_module_exit: 
  788 
  789 	/* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */
  790 	ldv_final: ldv_check_final_state();
  791 
  792 	/* LDV_COMMENT_END_FUNCTION_CALL_SECTION */
  793 	return;
  794 
  795 }
  796 #endif
  797 
  798 /* LDV_COMMENT_END_MAIN */                 1 
    2 #include <linux/kernel.h>
    3 #include <linux/module.h>
    4 
    5 #include <linux/usb.h>
    6 
    7 #include <verifier/rcv.h> // For LDV auxiliary routines.
    8 #include <kernel-model/ERR.inc>
    9 
   10 // There are 3 possible states of usb device reference counter
   11 enum
   12 {
   13  LDV_USB_DEV_ZERO_STATE = 0, // Usb device reference hasn't been acquired
   14  LDV_USB_DEV_ACQUIRED = 1, // Usb device reference acquired
   15  LDV_USB_DEV_INCREASED = 2 // Usb device reference counter increased
   16 };
   17 
   18 /* LDV_COMMENT_OTHER The model automaton state (one of thee possible ones). */
   19 int ldv_usb_dev_state = LDV_USB_DEV_ZERO_STATE;
   20 
   21 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_interface_to_usbdev') Change state state after acquiring a reference to usb_device. */
   22 void ldv_interface_to_usbdev(void)
   23 {
   24  /* LDV_COMMENT_OTHER Initially we suppose this function is used to acquire a reference to usb_device. */
   25  if (ldv_usb_dev_state == LDV_USB_DEV_ZERO_STATE)
   26   /* LDV_COMMENT_CHANGE_STATE Usb device reference acquired. */
   27   ldv_usb_dev_state = LDV_USB_DEV_ACQUIRED;
   28 }
   29 
   30 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_usb_get_dev') Change state after increasing the reference counter with usb_get_dev. */
   31 void ldv_usb_get_dev(void)
   32 {
   33  /* LDV_COMMENT_OTHER Here the reference has surely been acquired somewhere. */
   34  if (ldv_usb_dev_state < LDV_USB_DEV_ACQUIRED) {
   35   /* LDV_COMMENT_CHANGE_STATE The reference has already been acquired. */
   36   ldv_usb_dev_state = LDV_USB_DEV_ACQUIRED;
   37  }
   38  /* LDV_COMMENT_CHANGE_STATE Increase reference counter. */
   39  ldv_usb_dev_state++;
   40 }
   41 
   42 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_usb_put_dev') Change state after decreasing the reference counter with usb_put_dev. */
   43 void ldv_usb_put_dev(void)
   44 {
   45  /* LDV_COMMENT_ASSERT Check usb device reference counter has been increased. */
   46  ldv_assert(ldv_usb_dev_state >= LDV_USB_DEV_INCREASED);
   47  /* LDV_COMMENT_CHANGE_STATE Decrease reference counter. */
   48  ldv_usb_dev_state--;
   49  /* LDV_COMMENT_OTHER LDV_USB_DEV_ACQUIRED is special (for when the one has forgotten to increase the counter). Not intednded to be used here. */
   50  if (ldv_usb_dev_state == LDV_USB_DEV_ACQUIRED) {
   51   /* LDV_COMMENT_CHANGE_STATE Re-zero the model variable. */
   52   ldv_usb_dev_state = LDV_USB_DEV_ZERO_STATE;
   53  }
   54 }
   55 
   56 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_return_value_probe') Check the probe function leaved the model in the proper state. */
   57 void ldv_check_return_value_probe(int retval)
   58 {
   59  /* LDV_COMMENT_OTHER Probe finished unsuccessfully and returned an error. */
   60  if (retval) {
   61   /* LDV_COMMENT_ASSERT Check usb device reference counter is not increased. */
   62   ldv_assert(ldv_usb_dev_state < LDV_USB_DEV_INCREASED);
   63   /* LDV_COMMENT_OTHER LDV_USB_DEV_ACQUIRED is special (for when the one has forgotten to increase the counter). Not this case. */
   64   if (ldv_usb_dev_state == LDV_USB_DEV_ACQUIRED)
   65    /* LDV_COMMENT_CHANGE_STATE Re-zero the model variable. */
   66    ldv_usb_dev_state = LDV_USB_DEV_ZERO_STATE;
   67  } // else	/* LDV_COMMENT_OTHER Probe finished successfully and returned 0. */
   68 //		/* LDV_COMMENT_ASSERT Check usb device reference counter is not acquired or has been increased. */
   69 //		ldv_assert(ldv_usb_dev_state != LDV_USB_DEV_ACQUIRED);
   70 }
   71 
   72 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_final_state') Check that usb device reference hasn't been acquired or the counter has been decreased. */
   73 void ldv_check_final_state(void)
   74 {
   75  /* LDV_COMMENT_ASSERT Check that usb device reference hasn't been acquired or the counter has been decreased. */
   76  ldv_assert(ldv_usb_dev_state < LDV_USB_DEV_INCREASED);
   77 }                 1 #ifndef _LDV_RCV_H_
    2 #define _LDV_RCV_H_
    3 
    4 /* If expr evaluates to zero, ldv_assert() causes a program to reach the error
    5    label like the standard assert(). */
    6 #define ldv_assert(expr) ((expr) ? 0 : ldv_error())
    7 
    8 /* The error label wrapper. It is used because of some static verifiers (like
    9    BLAST) don't accept multiple error labels through a program. */
   10 static inline void ldv_error(void)
   11 {
   12   LDV_ERROR: goto LDV_ERROR;
   13 }
   14 
   15 /* If expr evaluates to zero, ldv_assume() causes an infinite loop that is
   16    avoided by verifiers. */
   17 #define ldv_assume(expr) ((expr) ? 0 : ldv_stop())
   18 
   19 /* Infinite loop, that causes verifiers to skip such paths. */
   20 static inline void ldv_stop(void) {
   21   LDV_STOP: goto LDV_STOP;
   22 }
   23 
   24 /* Special nondeterministic functions. */
   25 int ldv_undef_int(void);
   26 void *ldv_undef_ptr(void);
   27 unsigned long ldv_undef_ulong(void);
   28 /* Return nondeterministic negative integer number. */
   29 static inline int ldv_undef_int_negative(void)
   30 {
   31   int ret = ldv_undef_int();
   32 
   33   ldv_assume(ret < 0);
   34 
   35   return ret;
   36 }
   37 /* Return nondeterministic nonpositive integer number. */
   38 static inline int ldv_undef_int_nonpositive(void)
   39 {
   40   int ret = ldv_undef_int();
   41 
   42   ldv_assume(ret <= 0);
   43 
   44   return ret;
   45 }
   46 
   47 /* Add explicit model for __builin_expect GCC function. Without the model a
   48    return value will be treated as nondetermined by verifiers. */
   49 long __builtin_expect(long exp, long c)
   50 {
   51   return exp;
   52 }
   53 
   54 /* This function causes the program to exit abnormally. GCC implements this
   55 function by using a target-dependent mechanism (such as intentionally executing
   56 an illegal instruction) or by calling abort. The mechanism used may vary from
   57 release to release so you should not rely on any particular implementation.
   58 http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
   59 void __builtin_trap(void)
   60 {
   61   ldv_assert(0);
   62 }
   63 
   64 /* The constant is for simulating an error of ldv_undef_ptr() function. */
   65 #define LDV_PTR_MAX 2012
   66 
   67 #endif /* _LDV_RCV_H_ */                 1 /*
    2  * device.h - generic, centralized driver model
    3  *
    4  * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
    5  * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
    6  * Copyright (c) 2008-2009 Novell Inc.
    7  *
    8  * This file is released under the GPLv2
    9  *
   10  * See Documentation/driver-model/ for more information.
   11  */
   12 
   13 #ifndef _DEVICE_H_
   14 #define _DEVICE_H_
   15 
   16 #include <linux/ioport.h>
   17 #include <linux/kobject.h>
   18 #include <linux/klist.h>
   19 #include <linux/list.h>
   20 #include <linux/lockdep.h>
   21 #include <linux/compiler.h>
   22 #include <linux/types.h>
   23 #include <linux/mutex.h>
   24 #include <linux/pinctrl/devinfo.h>
   25 #include <linux/pm.h>
   26 #include <linux/atomic.h>
   27 #include <linux/ratelimit.h>
   28 #include <linux/uidgid.h>
   29 #include <linux/gfp.h>
   30 #include <asm/device.h>
   31 
   32 struct device;
   33 struct device_private;
   34 struct device_driver;
   35 struct driver_private;
   36 struct module;
   37 struct class;
   38 struct subsys_private;
   39 struct bus_type;
   40 struct device_node;
   41 struct iommu_ops;
   42 struct iommu_group;
   43 
   44 struct bus_attribute {
   45 	struct attribute	attr;
   46 	ssize_t (*show)(struct bus_type *bus, char *buf);
   47 	ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
   48 };
   49 
   50 #define BUS_ATTR(_name, _mode, _show, _store)	\
   51 	struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
   52 #define BUS_ATTR_RW(_name) \
   53 	struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)
   54 #define BUS_ATTR_RO(_name) \
   55 	struct bus_attribute bus_attr_##_name = __ATTR_RO(_name)
   56 
   57 extern int __must_check bus_create_file(struct bus_type *,
   58 					struct bus_attribute *);
   59 extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
   60 
   61 /**
   62  * struct bus_type - The bus type of the device
   63  *
   64  * @name:	The name of the bus.
   65  * @dev_name:	Used for subsystems to enumerate devices like ("foo%u", dev->id).
   66  * @dev_root:	Default device to use as the parent.
   67  * @dev_attrs:	Default attributes of the devices on the bus.
   68  * @bus_groups:	Default attributes of the bus.
   69  * @dev_groups:	Default attributes of the devices on the bus.
   70  * @drv_groups: Default attributes of the device drivers on the bus.
   71  * @match:	Called, perhaps multiple times, whenever a new device or driver
   72  *		is added for this bus. It should return a nonzero value if the
   73  *		given device can be handled by the given driver.
   74  * @uevent:	Called when a device is added, removed, or a few other things
   75  *		that generate uevents to add the environment variables.
   76  * @probe:	Called when a new device or driver add to this bus, and callback
   77  *		the specific driver's probe to initial the matched device.
   78  * @remove:	Called when a device removed from this bus.
   79  * @shutdown:	Called at shut-down time to quiesce the device.
   80  *
   81  * @online:	Called to put the device back online (after offlining it).
   82  * @offline:	Called to put the device offline for hot-removal. May fail.
   83  *
   84  * @suspend:	Called when a device on this bus wants to go to sleep mode.
   85  * @resume:	Called to bring a device on this bus out of sleep mode.
   86  * @pm:		Power management operations of this bus, callback the specific
   87  *		device driver's pm-ops.
   88  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
   89  *              driver implementations to a bus and allow the driver to do
   90  *              bus-specific setup
   91  * @p:		The private data of the driver core, only the driver core can
   92  *		touch this.
   93  * @lock_key:	Lock class key for use by the lock validator
   94  *
   95  * A bus is a channel between the processor and one or more devices. For the
   96  * purposes of the device model, all devices are connected via a bus, even if
   97  * it is an internal, virtual, "platform" bus. Buses can plug into each other.
   98  * A USB controller is usually a PCI device, for example. The device model
   99  * represents the actual connections between buses and the devices they control.
  100  * A bus is represented by the bus_type structure. It contains the name, the
  101  * default attributes, the bus' methods, PM operations, and the driver core's
  102  * private data.
  103  */
  104 struct bus_type {
  105 	const char		*name;
  106 	const char		*dev_name;
  107 	struct device		*dev_root;
  108 	struct device_attribute	*dev_attrs;	/* use dev_groups instead */
  109 	const struct attribute_group **bus_groups;
  110 	const struct attribute_group **dev_groups;
  111 	const struct attribute_group **drv_groups;
  112 
  113 	int (*match)(struct device *dev, struct device_driver *drv);
  114 	int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
  115 	int (*probe)(struct device *dev);
  116 	int (*remove)(struct device *dev);
  117 	void (*shutdown)(struct device *dev);
  118 
  119 	int (*online)(struct device *dev);
  120 	int (*offline)(struct device *dev);
  121 
  122 	int (*suspend)(struct device *dev, pm_message_t state);
  123 	int (*resume)(struct device *dev);
  124 
  125 	const struct dev_pm_ops *pm;
  126 
  127 	struct iommu_ops *iommu_ops;
  128 
  129 	struct subsys_private *p;
  130 	struct lock_class_key lock_key;
  131 };
  132 
  133 extern int __must_check bus_register(struct bus_type *bus);
  134 
  135 extern void bus_unregister(struct bus_type *bus);
  136 
  137 extern int __must_check bus_rescan_devices(struct bus_type *bus);
  138 
  139 /* iterator helpers for buses */
  140 struct subsys_dev_iter {
  141 	struct klist_iter		ki;
  142 	const struct device_type	*type;
  143 };
  144 void subsys_dev_iter_init(struct subsys_dev_iter *iter,
  145 			 struct bus_type *subsys,
  146 			 struct device *start,
  147 			 const struct device_type *type);
  148 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
  149 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
  150 
  151 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
  152 		     int (*fn)(struct device *dev, void *data));
  153 struct device *bus_find_device(struct bus_type *bus, struct device *start,
  154 			       void *data,
  155 			       int (*match)(struct device *dev, void *data));
  156 struct device *bus_find_device_by_name(struct bus_type *bus,
  157 				       struct device *start,
  158 				       const char *name);
  159 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
  160 					struct device *hint);
  161 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
  162 		     void *data, int (*fn)(struct device_driver *, void *));
  163 void bus_sort_breadthfirst(struct bus_type *bus,
  164 			   int (*compare)(const struct device *a,
  165 					  const struct device *b));
  166 /*
  167  * Bus notifiers: Get notified of addition/removal of devices
  168  * and binding/unbinding of drivers to devices.
  169  * In the long run, it should be a replacement for the platform
  170  * notify hooks.
  171  */
  172 struct notifier_block;
  173 
  174 extern int bus_register_notifier(struct bus_type *bus,
  175 				 struct notifier_block *nb);
  176 extern int bus_unregister_notifier(struct bus_type *bus,
  177 				   struct notifier_block *nb);
  178 
  179 /* All 4 notifers below get called with the target struct device *
  180  * as an argument. Note that those functions are likely to be called
  181  * with the device lock held in the core, so be careful.
  182  */
  183 #define BUS_NOTIFY_ADD_DEVICE		0x00000001 /* device added */
  184 #define BUS_NOTIFY_DEL_DEVICE		0x00000002 /* device removed */
  185 #define BUS_NOTIFY_BIND_DRIVER		0x00000003 /* driver about to be
  186 						      bound */
  187 #define BUS_NOTIFY_BOUND_DRIVER		0x00000004 /* driver bound to device */
  188 #define BUS_NOTIFY_UNBIND_DRIVER	0x00000005 /* driver about to be
  189 						      unbound */
  190 #define BUS_NOTIFY_UNBOUND_DRIVER	0x00000006 /* driver is unbound
  191 						      from the device */
  192 
  193 extern struct kset *bus_get_kset(struct bus_type *bus);
  194 extern struct klist *bus_get_device_klist(struct bus_type *bus);
  195 
  196 /**
  197  * struct device_driver - The basic device driver structure
  198  * @name:	Name of the device driver.
  199  * @bus:	The bus which the device of this driver belongs to.
  200  * @owner:	The module owner.
  201  * @mod_name:	Used for built-in modules.
  202  * @suppress_bind_attrs: Disables bind/unbind via sysfs.
  203  * @of_match_table: The open firmware table.
  204  * @acpi_match_table: The ACPI match table.
  205  * @probe:	Called to query the existence of a specific device,
  206  *		whether this driver can work with it, and bind the driver
  207  *		to a specific device.
  208  * @remove:	Called when the device is removed from the system to
  209  *		unbind a device from this driver.
  210  * @shutdown:	Called at shut-down time to quiesce the device.
  211  * @suspend:	Called to put the device to sleep mode. Usually to a
  212  *		low power state.
  213  * @resume:	Called to bring a device from sleep mode.
  214  * @groups:	Default attributes that get created by the driver core
  215  *		automatically.
  216  * @pm:		Power management operations of the device which matched
  217  *		this driver.
  218  * @p:		Driver core's private data, no one other than the driver
  219  *		core can touch this.
  220  *
  221  * The device driver-model tracks all of the drivers known to the system.
  222  * The main reason for this tracking is to enable the driver core to match
  223  * up drivers with new devices. Once drivers are known objects within the
  224  * system, however, a number of other things become possible. Device drivers
  225  * can export information and configuration variables that are independent
  226  * of any specific device.
  227  */
  228 struct device_driver {
  229 	const char		*name;
  230 	struct bus_type		*bus;
  231 
  232 	struct module		*owner;
  233 	const char		*mod_name;	/* used for built-in modules */
  234 
  235 	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
  236 
  237 	const struct of_device_id	*of_match_table;
  238 	const struct acpi_device_id	*acpi_match_table;
  239 
  240 	int (*probe) (struct device *dev);
  241 	int (*remove) (struct device *dev);
  242 	void (*shutdown) (struct device *dev);
  243 	int (*suspend) (struct device *dev, pm_message_t state);
  244 	int (*resume) (struct device *dev);
  245 	const struct attribute_group **groups;
  246 
  247 	const struct dev_pm_ops *pm;
  248 
  249 	struct driver_private *p;
  250 };
  251 
  252 
  253 extern int __must_check driver_register(struct device_driver *drv);
  254 extern void driver_unregister(struct device_driver *drv);
  255 
  256 extern struct device_driver *driver_find(const char *name,
  257 					 struct bus_type *bus);
  258 extern int driver_probe_done(void);
  259 extern void wait_for_device_probe(void);
  260 
  261 
  262 /* sysfs interface for exporting driver attributes */
  263 
  264 struct driver_attribute {
  265 	struct attribute attr;
  266 	ssize_t (*show)(struct device_driver *driver, char *buf);
  267 	ssize_t (*store)(struct device_driver *driver, const char *buf,
  268 			 size_t count);
  269 };
  270 
  271 #define DRIVER_ATTR(_name, _mode, _show, _store) \
  272 	struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
  273 #define DRIVER_ATTR_RW(_name) \
  274 	struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
  275 #define DRIVER_ATTR_RO(_name) \
  276 	struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
  277 #define DRIVER_ATTR_WO(_name) \
  278 	struct driver_attribute driver_attr_##_name = __ATTR_WO(_name)
  279 
  280 extern int __must_check driver_create_file(struct device_driver *driver,
  281 					const struct driver_attribute *attr);
  282 extern void driver_remove_file(struct device_driver *driver,
  283 			       const struct driver_attribute *attr);
  284 
  285 extern int __must_check driver_for_each_device(struct device_driver *drv,
  286 					       struct device *start,
  287 					       void *data,
  288 					       int (*fn)(struct device *dev,
  289 							 void *));
  290 struct device *driver_find_device(struct device_driver *drv,
  291 				  struct device *start, void *data,
  292 				  int (*match)(struct device *dev, void *data));
  293 
  294 /**
  295  * struct subsys_interface - interfaces to device functions
  296  * @name:       name of the device function
  297  * @subsys:     subsytem of the devices to attach to
  298  * @node:       the list of functions registered at the subsystem
  299  * @add_dev:    device hookup to device function handler
  300  * @remove_dev: device hookup to device function handler
  301  *
  302  * Simple interfaces attached to a subsystem. Multiple interfaces can
  303  * attach to a subsystem and its devices. Unlike drivers, they do not
  304  * exclusively claim or control devices. Interfaces usually represent
  305  * a specific functionality of a subsystem/class of devices.
  306  */
  307 struct subsys_interface {
  308 	const char *name;
  309 	struct bus_type *subsys;
  310 	struct list_head node;
  311 	int (*add_dev)(struct device *dev, struct subsys_interface *sif);
  312 	int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
  313 };
  314 
  315 int subsys_interface_register(struct subsys_interface *sif);
  316 void subsys_interface_unregister(struct subsys_interface *sif);
  317 
  318 int subsys_system_register(struct bus_type *subsys,
  319 			   const struct attribute_group **groups);
  320 int subsys_virtual_register(struct bus_type *subsys,
  321 			    const struct attribute_group **groups);
  322 
  323 /**
  324  * struct class - device classes
  325  * @name:	Name of the class.
  326  * @owner:	The module owner.
  327  * @class_attrs: Default attributes of this class.
  328  * @dev_groups:	Default attributes of the devices that belong to the class.
  329  * @dev_kobj:	The kobject that represents this class and links it into the hierarchy.
  330  * @dev_uevent:	Called when a device is added, removed from this class, or a
  331  *		few other things that generate uevents to add the environment
  332  *		variables.
  333  * @devnode:	Callback to provide the devtmpfs.
  334  * @class_release: Called to release this class.
  335  * @dev_release: Called to release the device.
  336  * @suspend:	Used to put the device to sleep mode, usually to a low power
  337  *		state.
  338  * @resume:	Used to bring the device from the sleep mode.
  339  * @ns_type:	Callbacks so sysfs can detemine namespaces.
  340  * @namespace:	Namespace of the device belongs to this class.
  341  * @pm:		The default device power management operations of this class.
  342  * @p:		The private data of the driver core, no one other than the
  343  *		driver core can touch this.
  344  *
  345  * A class is a higher-level view of a device that abstracts out low-level
  346  * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
  347  * at the class level, they are all simply disks. Classes allow user space
  348  * to work with devices based on what they do, rather than how they are
  349  * connected or how they work.
  350  */
  351 struct class {
  352 	const char		*name;
  353 	struct module		*owner;
  354 
  355 	struct class_attribute		*class_attrs;
  356 	const struct attribute_group	**dev_groups;
  357 	struct kobject			*dev_kobj;
  358 
  359 	int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
  360 	char *(*devnode)(struct device *dev, umode_t *mode);
  361 
  362 	void (*class_release)(struct class *class);
  363 	void (*dev_release)(struct device *dev);
  364 
  365 	int (*suspend)(struct device *dev, pm_message_t state);
  366 	int (*resume)(struct device *dev);
  367 
  368 	const struct kobj_ns_type_operations *ns_type;
  369 	const void *(*namespace)(struct device *dev);
  370 
  371 	const struct dev_pm_ops *pm;
  372 
  373 	struct subsys_private *p;
  374 };
  375 
  376 struct class_dev_iter {
  377 	struct klist_iter		ki;
  378 	const struct device_type	*type;
  379 };
  380 
  381 extern struct kobject *sysfs_dev_block_kobj;
  382 extern struct kobject *sysfs_dev_char_kobj;
  383 extern int __must_check __class_register(struct class *class,
  384 					 struct lock_class_key *key);
  385 extern void class_unregister(struct class *class);
  386 
  387 /* This is a #define to keep the compiler from merging different
  388  * instances of the __key variable */
  389 #define class_register(class)			\
  390 ({						\
  391 	static struct lock_class_key __key;	\
  392 	__class_register(class, &__key);	\
  393 })
  394 
  395 struct class_compat;
  396 struct class_compat *class_compat_register(const char *name);
  397 void class_compat_unregister(struct class_compat *cls);
  398 int class_compat_create_link(struct class_compat *cls, struct device *dev,
  399 			     struct device *device_link);
  400 void class_compat_remove_link(struct class_compat *cls, struct device *dev,
  401 			      struct device *device_link);
  402 
  403 extern void class_dev_iter_init(struct class_dev_iter *iter,
  404 				struct class *class,
  405 				struct device *start,
  406 				const struct device_type *type);
  407 extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
  408 extern void class_dev_iter_exit(struct class_dev_iter *iter);
  409 
  410 extern int class_for_each_device(struct class *class, struct device *start,
  411 				 void *data,
  412 				 int (*fn)(struct device *dev, void *data));
  413 extern struct device *class_find_device(struct class *class,
  414 					struct device *start, const void *data,
  415 					int (*match)(struct device *, const void *));
  416 
  417 struct class_attribute {
  418 	struct attribute attr;
  419 	ssize_t (*show)(struct class *class, struct class_attribute *attr,
  420 			char *buf);
  421 	ssize_t (*store)(struct class *class, struct class_attribute *attr,
  422 			const char *buf, size_t count);
  423 };
  424 
  425 #define CLASS_ATTR(_name, _mode, _show, _store) \
  426 	struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
  427 #define CLASS_ATTR_RW(_name) \
  428 	struct class_attribute class_attr_##_name = __ATTR_RW(_name)
  429 #define CLASS_ATTR_RO(_name) \
  430 	struct class_attribute class_attr_##_name = __ATTR_RO(_name)
  431 
  432 extern int __must_check class_create_file_ns(struct class *class,
  433 					     const struct class_attribute *attr,
  434 					     const void *ns);
  435 extern void class_remove_file_ns(struct class *class,
  436 				 const struct class_attribute *attr,
  437 				 const void *ns);
  438 
  439 static inline int __must_check class_create_file(struct class *class,
  440 					const struct class_attribute *attr)
  441 {
  442 	return class_create_file_ns(class, attr, NULL);
  443 }
  444 
  445 static inline void class_remove_file(struct class *class,
  446 				     const struct class_attribute *attr)
  447 {
  448 	return class_remove_file_ns(class, attr, NULL);
  449 }
  450 
  451 /* Simple class attribute that is just a static string */
  452 struct class_attribute_string {
  453 	struct class_attribute attr;
  454 	char *str;
  455 };
  456 
  457 /* Currently read-only only */
  458 #define _CLASS_ATTR_STRING(_name, _mode, _str) \
  459 	{ __ATTR(_name, _mode, show_class_attr_string, NULL), _str }
  460 #define CLASS_ATTR_STRING(_name, _mode, _str) \
  461 	struct class_attribute_string class_attr_##_name = \
  462 		_CLASS_ATTR_STRING(_name, _mode, _str)
  463 
  464 extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr,
  465                         char *buf);
  466 
  467 struct class_interface {
  468 	struct list_head	node;
  469 	struct class		*class;
  470 
  471 	int (*add_dev)		(struct device *, struct class_interface *);
  472 	void (*remove_dev)	(struct device *, struct class_interface *);
  473 };
  474 
  475 extern int __must_check class_interface_register(struct class_interface *);
  476 extern void class_interface_unregister(struct class_interface *);
  477 
  478 extern struct class * __must_check __class_create(struct module *owner,
  479 						  const char *name,
  480 						  struct lock_class_key *key);
  481 extern void class_destroy(struct class *cls);
  482 
  483 /* This is a #define to keep the compiler from merging different
  484  * instances of the __key variable */
  485 #define class_create(owner, name)		\
  486 ({						\
  487 	static struct lock_class_key __key;	\
  488 	__class_create(owner, name, &__key);	\
  489 })
  490 
  491 /*
  492  * The type of device, "struct device" is embedded in. A class
  493  * or bus can contain devices of different types
  494  * like "partitions" and "disks", "mouse" and "event".
  495  * This identifies the device type and carries type-specific
  496  * information, equivalent to the kobj_type of a kobject.
  497  * If "name" is specified, the uevent will contain it in
  498  * the DEVTYPE variable.
  499  */
  500 struct device_type {
  501 	const char *name;
  502 	const struct attribute_group **groups;
  503 	int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
  504 	char *(*devnode)(struct device *dev, umode_t *mode,
  505 			 kuid_t *uid, kgid_t *gid);
  506 	void (*release)(struct device *dev);
  507 
  508 	const struct dev_pm_ops *pm;
  509 };
  510 
  511 /* interface for exporting device attributes */
  512 struct device_attribute {
  513 	struct attribute	attr;
  514 	ssize_t (*show)(struct device *dev, struct device_attribute *attr,
  515 			char *buf);
  516 	ssize_t (*store)(struct device *dev, struct device_attribute *attr,
  517 			 const char *buf, size_t count);
  518 };
  519 
  520 struct dev_ext_attribute {
  521 	struct device_attribute attr;
  522 	void *var;
  523 };
  524 
  525 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
  526 			  char *buf);
  527 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
  528 			   const char *buf, size_t count);
  529 ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
  530 			char *buf);
  531 ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
  532 			 const char *buf, size_t count);
  533 ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
  534 			char *buf);
  535 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
  536 			 const char *buf, size_t count);
  537 
  538 #define DEVICE_ATTR(_name, _mode, _show, _store) \
  539 	struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
  540 #define DEVICE_ATTR_RW(_name) \
  541 	struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
  542 #define DEVICE_ATTR_RO(_name) \
  543 	struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
  544 #define DEVICE_ATTR_WO(_name) \
  545 	struct device_attribute dev_attr_##_name = __ATTR_WO(_name)
  546 #define DEVICE_ULONG_ATTR(_name, _mode, _var) \
  547 	struct dev_ext_attribute dev_attr_##_name = \
  548 		{ __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }
  549 #define DEVICE_INT_ATTR(_name, _mode, _var) \
  550 	struct dev_ext_attribute dev_attr_##_name = \
  551 		{ __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) }
  552 #define DEVICE_BOOL_ATTR(_name, _mode, _var) \
  553 	struct dev_ext_attribute dev_attr_##_name = \
  554 		{ __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) }
  555 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
  556 	struct device_attribute dev_attr_##_name =		\
  557 		__ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
  558 
  559 extern int device_create_file(struct device *device,
  560 			      const struct device_attribute *entry);
  561 extern void device_remove_file(struct device *dev,
  562 			       const struct device_attribute *attr);
  563 extern bool device_remove_file_self(struct device *dev,
  564 				    const struct device_attribute *attr);
  565 extern int __must_check device_create_bin_file(struct device *dev,
  566 					const struct bin_attribute *attr);
  567 extern void device_remove_bin_file(struct device *dev,
  568 				   const struct bin_attribute *attr);
  569 
  570 /* device resource management */
  571 typedef void (*dr_release_t)(struct device *dev, void *res);
  572 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
  573 
  574 #ifdef CONFIG_DEBUG_DEVRES
  575 extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
  576 			     const char *name);
  577 #define devres_alloc(release, size, gfp) \
  578 	__devres_alloc(release, size, gfp, #release)
  579 #else
  580 extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
  581 #endif
  582 extern void devres_for_each_res(struct device *dev, dr_release_t release,
  583 				dr_match_t match, void *match_data,
  584 				void (*fn)(struct device *, void *, void *),
  585 				void *data);
  586 extern void devres_free(void *res);
  587 extern void devres_add(struct device *dev, void *res);
  588 extern void *devres_find(struct device *dev, dr_release_t release,
  589 			 dr_match_t match, void *match_data);
  590 extern void *devres_get(struct device *dev, void *new_res,
  591 			dr_match_t match, void *match_data);
  592 extern void *devres_remove(struct device *dev, dr_release_t release,
  593 			   dr_match_t match, void *match_data);
  594 extern int devres_destroy(struct device *dev, dr_release_t release,
  595 			  dr_match_t match, void *match_data);
  596 extern int devres_release(struct device *dev, dr_release_t release,
  597 			  dr_match_t match, void *match_data);
  598 
  599 /* devres group */
  600 extern void * __must_check devres_open_group(struct device *dev, void *id,
  601 					     gfp_t gfp);
  602 extern void devres_close_group(struct device *dev, void *id);
  603 extern void devres_remove_group(struct device *dev, void *id);
  604 extern int devres_release_group(struct device *dev, void *id);
  605 
  606 /* managed devm_k.alloc/kfree for device drivers */
  607 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
  608 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
  609 {
  610 	return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
  611 }
  612 static inline void *devm_kmalloc_array(struct device *dev,
  613 				       size_t n, size_t size, gfp_t flags)
  614 {
  615 	if (size != 0 && n > SIZE_MAX / size)
  616 		return NULL;
  617 	return devm_kmalloc(dev, n * size, flags);
  618 }
  619 static inline void *devm_kcalloc(struct device *dev,
  620 				 size_t n, size_t size, gfp_t flags)
  621 {
  622 	return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
  623 }
  624 extern void devm_kfree(struct device *dev, void *p);
  625 extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
  626 extern void *devm_kmemdup(struct device *dev, const void *src, size_t len,
  627 			  gfp_t gfp);
  628 
  629 extern unsigned long devm_get_free_pages(struct device *dev,
  630 					 gfp_t gfp_mask, unsigned int order);
  631 extern void devm_free_pages(struct device *dev, unsigned long addr);
  632 
  633 void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
  634 void __iomem *devm_request_and_ioremap(struct device *dev,
  635 			struct resource *res);
  636 
  637 /* allows to add/remove a custom action to devres stack */
  638 int devm_add_action(struct device *dev, void (*action)(void *), void *data);
  639 void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
  640 
  641 struct device_dma_parameters {
  642 	/*
  643 	 * a low level driver may set these to teach IOMMU code about
  644 	 * sg limitations.
  645 	 */
  646 	unsigned int max_segment_size;
  647 	unsigned long segment_boundary_mask;
  648 };
  649 
  650 struct acpi_device;
  651 
  652 struct acpi_dev_node {
  653 #ifdef CONFIG_ACPI
  654 	struct acpi_device *companion;
  655 #endif
  656 };
  657 
  658 /**
  659  * struct device - The basic device structure
  660  * @parent:	The device's "parent" device, the device to which it is attached.
  661  * 		In most cases, a parent device is some sort of bus or host
  662  * 		controller. If parent is NULL, the device, is a top-level device,
  663  * 		which is not usually what you want.
  664  * @p:		Holds the private data of the driver core portions of the device.
  665  * 		See the comment of the struct device_private for detail.
  666  * @kobj:	A top-level, abstract class from which other classes are derived.
  667  * @init_name:	Initial name of the device.
  668  * @type:	The type of device.
  669  * 		This identifies the device type and carries type-specific
  670  * 		information.
  671  * @mutex:	Mutex to synchronize calls to its driver.
  672  * @bus:	Type of bus device is on.
  673  * @driver:	Which driver has allocated this
  674  * @platform_data: Platform data specific to the device.
  675  * 		Example: For devices on custom boards, as typical of embedded
  676  * 		and SOC based hardware, Linux often uses platform_data to point
  677  * 		to board-specific structures describing devices and how they
  678  * 		are wired.  That can include what ports are available, chip
  679  * 		variants, which GPIO pins act in what additional roles, and so
  680  * 		on.  This shrinks the "Board Support Packages" (BSPs) and
  681  * 		minimizes board-specific #ifdefs in drivers.
  682  * @driver_data: Private pointer for driver specific info.
  683  * @power:	For device power management.
  684  * 		See Documentation/power/devices.txt for details.
  685  * @pm_domain:	Provide callbacks that are executed during system suspend,
  686  * 		hibernation, system resume and during runtime PM transitions
  687  * 		along with subsystem-level and driver-level callbacks.
  688  * @pins:	For device pin management.
  689  *		See Documentation/pinctrl.txt for details.
  690  * @numa_node:	NUMA node this device is close to.
  691  * @dma_mask:	Dma mask (if dma'ble device).
  692  * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
  693  * 		hardware supports 64-bit addresses for consistent allocations
  694  * 		such descriptors.
  695  * @dma_pfn_offset: offset of DMA memory range relatively of RAM
  696  * @dma_parms:	A low level driver may set these to teach IOMMU code about
  697  * 		segment limitations.
  698  * @dma_pools:	Dma pools (if dma'ble device).
  699  * @dma_mem:	Internal for coherent mem override.
  700  * @cma_area:	Contiguous memory area for dma allocations
  701  * @archdata:	For arch-specific additions.
  702  * @of_node:	Associated device tree node.
  703  * @acpi_node:	Associated ACPI device node.
  704  * @devt:	For creating the sysfs "dev".
  705  * @id:		device instance
  706  * @devres_lock: Spinlock to protect the resource of the device.
  707  * @devres_head: The resources list of the device.
  708  * @knode_class: The node used to add the device to the class list.
  709  * @class:	The class of the device.
  710  * @groups:	Optional attribute groups.
  711  * @release:	Callback to free the device after all references have
  712  * 		gone away. This should be set by the allocator of the
  713  * 		device (i.e. the bus driver that discovered the device).
  714  * @iommu_group: IOMMU group the device belongs to.
  715  *
  716  * @offline_disabled: If set, the device is permanently online.
  717  * @offline:	Set after successful invocation of bus type's .offline().
  718  *
  719  * At the lowest level, every device in a Linux system is represented by an
  720  * instance of struct device. The device structure contains the information
  721  * that the device model core needs to model the system. Most subsystems,
  722  * however, track additional information about the devices they host. As a
  723  * result, it is rare for devices to be represented by bare device structures;
  724  * instead, that structure, like kobject structures, is usually embedded within
  725  * a higher-level representation of the device.
  726  */
  727 struct device {
  728 	struct device		*parent;
  729 
  730 	struct device_private	*p;
  731 
  732 	struct kobject kobj;
  733 	const char		*init_name; /* initial name of the device */
  734 	const struct device_type *type;
  735 
  736 	struct mutex		mutex;	/* mutex to synchronize calls to
  737 					 * its driver.
  738 					 */
  739 
  740 	struct bus_type	*bus;		/* type of bus device is on */
  741 	struct device_driver *driver;	/* which driver has allocated this
  742 					   device */
  743 	void		*platform_data;	/* Platform specific data, device
  744 					   core doesn't touch it */
  745 	void		*driver_data;	/* Driver data, set and get with
  746 					   dev_set/get_drvdata */
  747 	struct dev_pm_info	power;
  748 	struct dev_pm_domain	*pm_domain;
  749 
  750 #ifdef CONFIG_PINCTRL
  751 	struct dev_pin_info	*pins;
  752 #endif
  753 
  754 #ifdef CONFIG_NUMA
  755 	int		numa_node;	/* NUMA node this device is close to */
  756 #endif
  757 	u64		*dma_mask;	/* dma mask (if dma'able device) */
  758 	u64		coherent_dma_mask;/* Like dma_mask, but for
  759 					     alloc_coherent mappings as
  760 					     not all hardware supports
  761 					     64 bit addresses for consistent
  762 					     allocations such descriptors. */
  763 	unsigned long	dma_pfn_offset;
  764 
  765 	struct device_dma_parameters *dma_parms;
  766 
  767 	struct list_head	dma_pools;	/* dma pools (if dma'ble) */
  768 
  769 	struct dma_coherent_mem	*dma_mem; /* internal for coherent mem
  770 					     override */
  771 #ifdef CONFIG_DMA_CMA
  772 	struct cma *cma_area;		/* contiguous memory area for dma
  773 					   allocations */
  774 #endif
  775 	/* arch specific additions */
  776 	struct dev_archdata	archdata;
  777 
  778 	struct device_node	*of_node; /* associated device tree node */
  779 	struct acpi_dev_node	acpi_node; /* associated ACPI device node */
  780 
  781 	dev_t			devt;	/* dev_t, creates the sysfs "dev" */
  782 	u32			id;	/* device instance */
  783 
  784 	spinlock_t		devres_lock;
  785 	struct list_head	devres_head;
  786 
  787 	struct klist_node	knode_class;
  788 	struct class		*class;
  789 	const struct attribute_group **groups;	/* optional groups */
  790 
  791 	void	(*release)(struct device *dev);
  792 	struct iommu_group	*iommu_group;
  793 
  794 	bool			offline_disabled:1;
  795 	bool			offline:1;
  796 };
  797 
  798 static inline struct device *kobj_to_dev(struct kobject *kobj)
  799 {
  800 	return container_of(kobj, struct device, kobj);
  801 }
  802 
  803 /* Get the wakeup routines, which depend on struct device */
  804 #include <linux/pm_wakeup.h>
  805 
  806 static inline const char *dev_name(const struct device *dev)
  807 {
  808 	/* Use the init name until the kobject becomes available */
  809 	if (dev->init_name)
  810 		return dev->init_name;
  811 
  812 	return kobject_name(&dev->kobj);
  813 }
  814 
  815 extern __printf(2, 3)
  816 int dev_set_name(struct device *dev, const char *name, ...);
  817 
  818 #ifdef CONFIG_NUMA
  819 static inline int dev_to_node(struct device *dev)
  820 {
  821 	return dev->numa_node;
  822 }
  823 static inline void set_dev_node(struct device *dev, int node)
  824 {
  825 	dev->numa_node = node;
  826 }
  827 #else
  828 static inline int dev_to_node(struct device *dev)
  829 {
  830 	return -1;
  831 }
  832 static inline void set_dev_node(struct device *dev, int node)
  833 {
  834 }
  835 #endif
  836 
  837 static inline void *dev_get_drvdata(const struct device *dev)
  838 {
  839 	return dev->driver_data;
  840 }
  841 
  842 static inline void dev_set_drvdata(struct device *dev, void *data)
  843 {
  844 	dev->driver_data = data;
  845 }
  846 
  847 static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
  848 {
  849 	return dev ? dev->power.subsys_data : NULL;
  850 }
  851 
  852 static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
  853 {
  854 	return dev->kobj.uevent_suppress;
  855 }
  856 
  857 static inline void dev_set_uevent_suppress(struct device *dev, int val)
  858 {
  859 	dev->kobj.uevent_suppress = val;
  860 }
  861 
  862 static inline int device_is_registered(struct device *dev)
  863 {
  864 	return dev->kobj.state_in_sysfs;
  865 }
  866 
  867 static inline void device_enable_async_suspend(struct device *dev)
  868 {
  869 	if (!dev->power.is_prepared)
  870 		dev->power.async_suspend = true;
  871 }
  872 
  873 static inline void device_disable_async_suspend(struct device *dev)
  874 {
  875 	if (!dev->power.is_prepared)
  876 		dev->power.async_suspend = false;
  877 }
  878 
  879 static inline bool device_async_suspend_enabled(struct device *dev)
  880 {
  881 	return !!dev->power.async_suspend;
  882 }
  883 
  884 static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
  885 {
  886 	dev->power.ignore_children = enable;
  887 }
  888 
  889 static inline void dev_pm_syscore_device(struct device *dev, bool val)
  890 {
  891 #ifdef CONFIG_PM_SLEEP
  892 	dev->power.syscore = val;
  893 #endif
  894 }
  895 
  896 static inline void device_lock(struct device *dev)
  897 {
  898 	mutex_lock(&dev->mutex);
  899 }
  900 
  901 static inline int device_trylock(struct device *dev)
  902 {
  903 	return mutex_trylock(&dev->mutex);
  904 }
  905 
  906 static inline void device_unlock(struct device *dev)
  907 {
  908 	mutex_unlock(&dev->mutex);
  909 }
  910 
  911 void driver_init(void);
  912 
  913 /*
  914  * High level routines for use by the bus drivers
  915  */
  916 extern int __must_check device_register(struct device *dev);
  917 extern void device_unregister(struct device *dev);
  918 extern void device_initialize(struct device *dev);
  919 extern int __must_check device_add(struct device *dev);
  920 extern void device_del(struct device *dev);
  921 extern int device_for_each_child(struct device *dev, void *data,
  922 		     int (*fn)(struct device *dev, void *data));
  923 extern struct device *device_find_child(struct device *dev, void *data,
  924 				int (*match)(struct device *dev, void *data));
  925 extern int device_rename(struct device *dev, const char *new_name);
  926 extern int device_move(struct device *dev, struct device *new_parent,
  927 		       enum dpm_order dpm_order);
  928 extern const char *device_get_devnode(struct device *dev,
  929 				      umode_t *mode, kuid_t *uid, kgid_t *gid,
  930 				      const char **tmp);
  931 
  932 static inline bool device_supports_offline(struct device *dev)
  933 {
  934 	return dev->bus && dev->bus->offline && dev->bus->online;
  935 }
  936 
  937 extern void lock_device_hotplug(void);
  938 extern void unlock_device_hotplug(void);
  939 extern int lock_device_hotplug_sysfs(void);
  940 extern int device_offline(struct device *dev);
  941 extern int device_online(struct device *dev);
  942 /*
  943  * Root device objects for grouping under /sys/devices
  944  */
  945 extern struct device *__root_device_register(const char *name,
  946 					     struct module *owner);
  947 
  948 /* This is a macro to avoid include problems with THIS_MODULE */
  949 #define root_device_register(name) \
  950 	__root_device_register(name, THIS_MODULE)
  951 
  952 extern void root_device_unregister(struct device *root);
  953 
  954 static inline void *dev_get_platdata(const struct device *dev)
  955 {
  956 	return dev->platform_data;
  957 }
  958 
  959 /*
  960  * Manual binding of a device to driver. See drivers/base/bus.c
  961  * for information on use.
  962  */
  963 extern int __must_check device_bind_driver(struct device *dev);
  964 extern void device_release_driver(struct device *dev);
  965 extern int  __must_check device_attach(struct device *dev);
  966 extern int __must_check driver_attach(struct device_driver *drv);
  967 extern int __must_check device_reprobe(struct device *dev);
  968 
  969 /*
  970  * Easy functions for dynamically creating devices on the fly
  971  */
  972 extern struct device *device_create_vargs(struct class *cls,
  973 					  struct device *parent,
  974 					  dev_t devt,
  975 					  void *drvdata,
  976 					  const char *fmt,
  977 					  va_list vargs);
  978 extern __printf(5, 6)
  979 struct device *device_create(struct class *cls, struct device *parent,
  980 			     dev_t devt, void *drvdata,
  981 			     const char *fmt, ...);
  982 extern __printf(6, 7)
  983 struct device *device_create_with_groups(struct class *cls,
  984 			     struct device *parent, dev_t devt, void *drvdata,
  985 			     const struct attribute_group **groups,
  986 			     const char *fmt, ...);
  987 extern void device_destroy(struct class *cls, dev_t devt);
  988 
  989 /*
  990  * Platform "fixup" functions - allow the platform to have their say
  991  * about devices and actions that the general device layer doesn't
  992  * know about.
  993  */
  994 /* Notify platform of device discovery */
  995 extern int (*platform_notify)(struct device *dev);
  996 
  997 extern int (*platform_notify_remove)(struct device *dev);
  998 
  999 
 1000 /*
 1001  * get_device - atomically increment the reference count for the device.
 1002  *
 1003  */
 1004 extern struct device *get_device(struct device *dev);
 1005 extern void put_device(struct device *dev);
 1006 
 1007 #ifdef CONFIG_DEVTMPFS
 1008 extern int devtmpfs_create_node(struct device *dev);
 1009 extern int devtmpfs_delete_node(struct device *dev);
 1010 extern int devtmpfs_mount(const char *mntdir);
 1011 #else
 1012 static inline int devtmpfs_create_node(struct device *dev) { return 0; }
 1013 static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
 1014 static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
 1015 #endif
 1016 
 1017 /* drivers/base/power/shutdown.c */
 1018 extern void device_shutdown(void);
 1019 
 1020 /* debugging and troubleshooting/diagnostic helpers. */
 1021 extern const char *dev_driver_string(const struct device *dev);
 1022 
 1023 
 1024 #ifdef CONFIG_PRINTK
 1025 
 1026 extern __printf(3, 0)
 1027 int dev_vprintk_emit(int level, const struct device *dev,
 1028 		     const char *fmt, va_list args);
 1029 extern __printf(3, 4)
 1030 int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
 1031 
 1032 extern __printf(3, 4)
 1033 int dev_printk(const char *level, const struct device *dev,
 1034 	       const char *fmt, ...);
 1035 extern __printf(2, 3)
 1036 int dev_emerg(const struct device *dev, const char *fmt, ...);
 1037 extern __printf(2, 3)
 1038 int dev_alert(const struct device *dev, const char *fmt, ...);
 1039 extern __printf(2, 3)
 1040 int dev_crit(const struct device *dev, const char *fmt, ...);
 1041 extern __printf(2, 3)
 1042 int dev_err(const struct device *dev, const char *fmt, ...);
 1043 extern __printf(2, 3)
 1044 int dev_warn(const struct device *dev, const char *fmt, ...);
 1045 extern __printf(2, 3)
 1046 int dev_notice(const struct device *dev, const char *fmt, ...);
 1047 extern __printf(2, 3)
 1048 int _dev_info(const struct device *dev, const char *fmt, ...);
 1049 
 1050 #else
 1051 
 1052 static inline __printf(3, 0)
 1053 int dev_vprintk_emit(int level, const struct device *dev,
 1054 		     const char *fmt, va_list args)
 1055 { return 0; }
 1056 static inline __printf(3, 4)
 1057 int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
 1058 { return 0; }
 1059 
 1060 static inline int __dev_printk(const char *level, const struct device *dev,
 1061 			       struct va_format *vaf)
 1062 { return 0; }
 1063 static inline __printf(3, 4)
 1064 int dev_printk(const char *level, const struct device *dev,
 1065 	       const char *fmt, ...)
 1066 { return 0; }
 1067 
 1068 static inline __printf(2, 3)
 1069 int dev_emerg(const struct device *dev, const char *fmt, ...)
 1070 { return 0; }
 1071 static inline __printf(2, 3)
 1072 int dev_crit(const struct device *dev, const char *fmt, ...)
 1073 { return 0; }
 1074 static inline __printf(2, 3)
 1075 int dev_alert(const struct device *dev, const char *fmt, ...)
 1076 { return 0; }
 1077 static inline __printf(2, 3)
 1078 int dev_err(const struct device *dev, const char *fmt, ...)
 1079 { return 0; }
 1080 static inline __printf(2, 3)
 1081 int dev_warn(const struct device *dev, const char *fmt, ...)
 1082 { return 0; }
 1083 static inline __printf(2, 3)
 1084 int dev_notice(const struct device *dev, const char *fmt, ...)
 1085 { return 0; }
 1086 static inline __printf(2, 3)
 1087 int _dev_info(const struct device *dev, const char *fmt, ...)
 1088 { return 0; }
 1089 
 1090 #endif
 1091 
 1092 /*
 1093  * Stupid hackaround for existing uses of non-printk uses dev_info
 1094  *
 1095  * Note that the definition of dev_info below is actually _dev_info
 1096  * and a macro is used to avoid redefining dev_info
 1097  */
 1098 
 1099 #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
 1100 
 1101 #if defined(CONFIG_DYNAMIC_DEBUG)
 1102 #define dev_dbg(dev, format, ...)		     \
 1103 do {						     \
 1104 	dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
 1105 } while (0)
 1106 #elif defined(DEBUG)
 1107 #define dev_dbg(dev, format, arg...)		\
 1108 	dev_printk(KERN_DEBUG, dev, format, ##arg)
 1109 #else
 1110 #define dev_dbg(dev, format, arg...)				\
 1111 ({								\
 1112 	if (0)							\
 1113 		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
 1114 	0;							\
 1115 })
 1116 #endif
 1117 
 1118 #define dev_level_ratelimited(dev_level, dev, fmt, ...)			\
 1119 do {									\
 1120 	static DEFINE_RATELIMIT_STATE(_rs,				\
 1121 				      DEFAULT_RATELIMIT_INTERVAL,	\
 1122 				      DEFAULT_RATELIMIT_BURST);		\
 1123 	if (__ratelimit(&_rs))						\
 1124 		dev_level(dev, fmt, ##__VA_ARGS__);			\
 1125 } while (0)
 1126 
 1127 #define dev_emerg_ratelimited(dev, fmt, ...)				\
 1128 	dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
 1129 #define dev_alert_ratelimited(dev, fmt, ...)				\
 1130 	dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
 1131 #define dev_crit_ratelimited(dev, fmt, ...)				\
 1132 	dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__)
 1133 #define dev_err_ratelimited(dev, fmt, ...)				\
 1134 	dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
 1135 #define dev_warn_ratelimited(dev, fmt, ...)				\
 1136 	dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__)
 1137 #define dev_notice_ratelimited(dev, fmt, ...)				\
 1138 	dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
 1139 #define dev_info_ratelimited(dev, fmt, ...)				\
 1140 	dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
 1141 #if defined(CONFIG_DYNAMIC_DEBUG)
 1142 /* descriptor check is first to prevent flooding with "callbacks suppressed" */
 1143 #define dev_dbg_ratelimited(dev, fmt, ...)				\
 1144 do {									\
 1145 	static DEFINE_RATELIMIT_STATE(_rs,				\
 1146 				      DEFAULT_RATELIMIT_INTERVAL,	\
 1147 				      DEFAULT_RATELIMIT_BURST);		\
 1148 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
 1149 	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
 1150 	    __ratelimit(&_rs))						\
 1151 		__dynamic_dev_dbg(&descriptor, dev, fmt,		\
 1152 				  ##__VA_ARGS__);			\
 1153 } while (0)
 1154 #elif defined(DEBUG)
 1155 #define dev_dbg_ratelimited(dev, fmt, ...)				\
 1156 do {									\
 1157 	static DEFINE_RATELIMIT_STATE(_rs,				\
 1158 				      DEFAULT_RATELIMIT_INTERVAL,	\
 1159 				      DEFAULT_RATELIMIT_BURST);		\
 1160 	if (__ratelimit(&_rs))						\
 1161 		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
 1162 } while (0)
 1163 #else
 1164 #define dev_dbg_ratelimited(dev, fmt, ...)			\
 1165 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 1166 #endif
 1167 
 1168 #ifdef VERBOSE_DEBUG
 1169 #define dev_vdbg	dev_dbg
 1170 #else
 1171 #define dev_vdbg(dev, format, arg...)				\
 1172 ({								\
 1173 	if (0)							\
 1174 		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
 1175 	0;							\
 1176 })
 1177 #endif
 1178 
 1179 /*
 1180  * dev_WARN*() acts like dev_printk(), but with the key difference of
 1181  * using WARN/WARN_ONCE to include file/line information and a backtrace.
 1182  */
 1183 #define dev_WARN(dev, format, arg...) \
 1184 	WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg);
 1185 
 1186 #define dev_WARN_ONCE(dev, condition, format, arg...) \
 1187 	WARN_ONCE(condition, "%s %s: " format, \
 1188 			dev_driver_string(dev), dev_name(dev), ## arg)
 1189 
 1190 /* Create alias, so I can be autoloaded. */
 1191 #define MODULE_ALIAS_CHARDEV(major,minor) \
 1192 	MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
 1193 #define MODULE_ALIAS_CHARDEV_MAJOR(major) \
 1194 	MODULE_ALIAS("char-major-" __stringify(major) "-*")
 1195 
 1196 #ifdef CONFIG_SYSFS_DEPRECATED
 1197 extern long sysfs_deprecated;
 1198 #else
 1199 #define sysfs_deprecated 0
 1200 #endif
 1201 
 1202 /**
 1203  * module_driver() - Helper macro for drivers that don't do anything
 1204  * special in module init/exit. This eliminates a lot of boilerplate.
 1205  * Each module may only use this macro once, and calling it replaces
 1206  * module_init() and module_exit().
 1207  *
 1208  * @__driver: driver name
 1209  * @__register: register function for this driver type
 1210  * @__unregister: unregister function for this driver type
 1211  * @...: Additional arguments to be passed to __register and __unregister.
 1212  *
 1213  * Use this macro to construct bus specific macros for registering
 1214  * drivers, and do not use it on its own.
 1215  */
 1216 #define module_driver(__driver, __register, __unregister, ...) \
 1217 static int __init __driver##_init(void) \
 1218 { \
 1219 	return __register(&(__driver) , ##__VA_ARGS__); \
 1220 } \
 1221 module_init(__driver##_init); \
 1222 static void __exit __driver##_exit(void) \
 1223 { \
 1224 	__unregister(&(__driver) , ##__VA_ARGS__); \
 1225 } \
 1226 module_exit(__driver##_exit);
 1227 
 1228 #endif /* _DEVICE_H_ */                 1 #ifndef __LINUX_USB_H
    2 #define __LINUX_USB_H
    3 
    4 #include <linux/mod_devicetable.h>
    5 #include <linux/usb/ch9.h>
    6 
    7 #define USB_MAJOR			180
    8 #define USB_DEVICE_MAJOR		189
    9 
   10 
   11 #ifdef __KERNEL__
   12 
   13 #include <linux/errno.h>        /* for -ENODEV */
   14 #include <linux/delay.h>	/* for mdelay() */
   15 #include <linux/interrupt.h>	/* for in_interrupt() */
   16 #include <linux/list.h>		/* for struct list_head */
   17 #include <linux/kref.h>		/* for struct kref */
   18 #include <linux/device.h>	/* for struct device */
   19 #include <linux/fs.h>		/* for struct file_operations */
   20 #include <linux/completion.h>	/* for struct completion */
   21 #include <linux/sched.h>	/* for current && schedule_timeout */
   22 #include <linux/mutex.h>	/* for struct mutex */
   23 #include <linux/pm_runtime.h>	/* for runtime PM */
   24 
   25 struct usb_device;
   26 struct usb_driver;
   27 struct wusb_dev;
   28 
   29 /*-------------------------------------------------------------------------*/
   30 
   31 /*
   32  * Host-side wrappers for standard USB descriptors ... these are parsed
   33  * from the data provided by devices.  Parsing turns them from a flat
   34  * sequence of descriptors into a hierarchy:
   35  *
   36  *  - devices have one (usually) or more configs;
   37  *  - configs have one (often) or more interfaces;
   38  *  - interfaces have one (usually) or more settings;
   39  *  - each interface setting has zero or (usually) more endpoints.
   40  *  - a SuperSpeed endpoint has a companion descriptor
   41  *
   42  * And there might be other descriptors mixed in with those.
   43  *
   44  * Devices may also have class-specific or vendor-specific descriptors.
   45  */
   46 
   47 struct ep_device;
   48 
   49 /**
   50  * struct usb_host_endpoint - host-side endpoint descriptor and queue
   51  * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
   52  * @ss_ep_comp: SuperSpeed companion descriptor for this endpoint
   53  * @urb_list: urbs queued to this endpoint; maintained by usbcore
   54  * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
   55  *	with one or more transfer descriptors (TDs) per urb
   56  * @ep_dev: ep_device for sysfs info
   57  * @extra: descriptors following this endpoint in the configuration
   58  * @extralen: how many bytes of "extra" are valid
   59  * @enabled: URBs may be submitted to this endpoint
   60  * @streams: number of USB-3 streams allocated on the endpoint
   61  *
   62  * USB requests are always queued to a given endpoint, identified by a
   63  * descriptor within an active interface in a given USB configuration.
   64  */
   65 struct usb_host_endpoint {
   66 	struct usb_endpoint_descriptor		desc;
   67 	struct usb_ss_ep_comp_descriptor	ss_ep_comp;
   68 	struct list_head		urb_list;
   69 	void				*hcpriv;
   70 	struct ep_device		*ep_dev;	/* For sysfs info */
   71 
   72 	unsigned char *extra;   /* Extra descriptors */
   73 	int extralen;
   74 	int enabled;
   75 	int streams;
   76 };
   77 
   78 /* host-side wrapper for one interface setting's parsed descriptors */
   79 struct usb_host_interface {
   80 	struct usb_interface_descriptor	desc;
   81 
   82 	int extralen;
   83 	unsigned char *extra;   /* Extra descriptors */
   84 
   85 	/* array of desc.bNumEndpoint endpoints associated with this
   86 	 * interface setting.  these will be in no particular order.
   87 	 */
   88 	struct usb_host_endpoint *endpoint;
   89 
   90 	char *string;		/* iInterface string, if present */
   91 };
   92 
   93 enum usb_interface_condition {
   94 	USB_INTERFACE_UNBOUND = 0,
   95 	USB_INTERFACE_BINDING,
   96 	USB_INTERFACE_BOUND,
   97 	USB_INTERFACE_UNBINDING,
   98 };
   99 
  100 /**
  101  * struct usb_interface - what usb device drivers talk to
  102  * @altsetting: array of interface structures, one for each alternate
  103  *	setting that may be selected.  Each one includes a set of
  104  *	endpoint configurations.  They will be in no particular order.
  105  * @cur_altsetting: the current altsetting.
  106  * @num_altsetting: number of altsettings defined.
  107  * @intf_assoc: interface association descriptor
  108  * @minor: the minor number assigned to this interface, if this
  109  *	interface is bound to a driver that uses the USB major number.
  110  *	If this interface does not use the USB major, this field should
  111  *	be unused.  The driver should set this value in the probe()
  112  *	function of the driver, after it has been assigned a minor
  113  *	number from the USB core by calling usb_register_dev().
  114  * @condition: binding state of the interface: not bound, binding
  115  *	(in probe()), bound to a driver, or unbinding (in disconnect())
  116  * @sysfs_files_created: sysfs attributes exist
  117  * @ep_devs_created: endpoint child pseudo-devices exist
  118  * @unregistering: flag set when the interface is being unregistered
  119  * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
  120  *	capability during autosuspend.
  121  * @needs_altsetting0: flag set when a set-interface request for altsetting 0
  122  *	has been deferred.
  123  * @needs_binding: flag set when the driver should be re-probed or unbound
  124  *	following a reset or suspend operation it doesn't support.
  125  * @dev: driver model's view of this device
  126  * @usb_dev: if an interface is bound to the USB major, this will point
  127  *	to the sysfs representation for that device.
  128  * @pm_usage_cnt: PM usage counter for this interface
  129  * @reset_ws: Used for scheduling resets from atomic context.
  130  * @reset_running: set to 1 if the interface is currently running a
  131  *      queued reset so that usb_cancel_queued_reset() doesn't try to
  132  *      remove from the workqueue when running inside the worker
  133  *      thread. See __usb_queue_reset_device().
  134  * @resetting_device: USB core reset the device, so use alt setting 0 as
  135  *	current; needs bandwidth alloc after reset.
  136  *
  137  * USB device drivers attach to interfaces on a physical device.  Each
  138  * interface encapsulates a single high level function, such as feeding
  139  * an audio stream to a speaker or reporting a change in a volume control.
  140  * Many USB devices only have one interface.  The protocol used to talk to
  141  * an interface's endpoints can be defined in a usb "class" specification,
  142  * or by a product's vendor.  The (default) control endpoint is part of
  143  * every interface, but is never listed among the interface's descriptors.
  144  *
  145  * The driver that is bound to the interface can use standard driver model
  146  * calls such as dev_get_drvdata() on the dev member of this structure.
  147  *
  148  * Each interface may have alternate settings.  The initial configuration
  149  * of a device sets altsetting 0, but the device driver can change
  150  * that setting using usb_set_interface().  Alternate settings are often
  151  * used to control the use of periodic endpoints, such as by having
  152  * different endpoints use different amounts of reserved USB bandwidth.
  153  * All standards-conformant USB devices that use isochronous endpoints
  154  * will use them in non-default settings.
  155  *
  156  * The USB specification says that alternate setting numbers must run from
  157  * 0 to one less than the total number of alternate settings.  But some
  158  * devices manage to mess this up, and the structures aren't necessarily
  159  * stored in numerical order anyhow.  Use usb_altnum_to_altsetting() to
  160  * look up an alternate setting in the altsetting array based on its number.
  161  */
  162 struct usb_interface {
  163 	/* array of alternate settings for this interface,
  164 	 * stored in no particular order */
  165 	struct usb_host_interface *altsetting;
  166 
  167 	struct usb_host_interface *cur_altsetting;	/* the currently
  168 					 * active alternate setting */
  169 	unsigned num_altsetting;	/* number of alternate settings */
  170 
  171 	/* If there is an interface association descriptor then it will list
  172 	 * the associated interfaces */
  173 	struct usb_interface_assoc_descriptor *intf_assoc;
  174 
  175 	int minor;			/* minor number this interface is
  176 					 * bound to */
  177 	enum usb_interface_condition condition;		/* state of binding */
  178 	unsigned sysfs_files_created:1;	/* the sysfs attributes exist */
  179 	unsigned ep_devs_created:1;	/* endpoint "devices" exist */
  180 	unsigned unregistering:1;	/* unregistration is in progress */
  181 	unsigned needs_remote_wakeup:1;	/* driver requires remote wakeup */
  182 	unsigned needs_altsetting0:1;	/* switch to altsetting 0 is pending */
  183 	unsigned needs_binding:1;	/* needs delayed unbind/rebind */
  184 	unsigned reset_running:1;
  185 	unsigned resetting_device:1;	/* true: bandwidth alloc after reset */
  186 
  187 	struct device dev;		/* interface specific device info */
  188 	struct device *usb_dev;
  189 	atomic_t pm_usage_cnt;		/* usage counter for autosuspend */
  190 	struct work_struct reset_ws;	/* for resets in atomic context */
  191 };
  192 #define	to_usb_interface(d) container_of(d, struct usb_interface, dev)
  193 
  194 static inline void *usb_get_intfdata(struct usb_interface *intf)
  195 {
  196 	return dev_get_drvdata(&intf->dev);
  197 }
  198 
  199 static inline void usb_set_intfdata(struct usb_interface *intf, void *data)
  200 {
  201 	dev_set_drvdata(&intf->dev, data);
  202 }
  203 
  204 struct usb_interface *usb_get_intf(struct usb_interface *intf);
  205 void usb_put_intf(struct usb_interface *intf);
  206 
  207 /* Hard limit */
  208 #define USB_MAXENDPOINTS	30
  209 /* this maximum is arbitrary */
  210 #define USB_MAXINTERFACES	32
  211 #define USB_MAXIADS		(USB_MAXINTERFACES/2)
  212 
  213 /**
  214  * struct usb_interface_cache - long-term representation of a device interface
  215  * @num_altsetting: number of altsettings defined.
  216  * @ref: reference counter.
  217  * @altsetting: variable-length array of interface structures, one for
  218  *	each alternate setting that may be selected.  Each one includes a
  219  *	set of endpoint configurations.  They will be in no particular order.
  220  *
  221  * These structures persist for the lifetime of a usb_device, unlike
  222  * struct usb_interface (which persists only as long as its configuration
  223  * is installed).  The altsetting arrays can be accessed through these
  224  * structures at any time, permitting comparison of configurations and
  225  * providing support for the /proc/bus/usb/devices pseudo-file.
  226  */
  227 struct usb_interface_cache {
  228 	unsigned num_altsetting;	/* number of alternate settings */
  229 	struct kref ref;		/* reference counter */
  230 
  231 	/* variable-length array of alternate settings for this interface,
  232 	 * stored in no particular order */
  233 	struct usb_host_interface altsetting[0];
  234 };
  235 #define	ref_to_usb_interface_cache(r) \
  236 		container_of(r, struct usb_interface_cache, ref)
  237 #define	altsetting_to_usb_interface_cache(a) \
  238 		container_of(a, struct usb_interface_cache, altsetting[0])
  239 
  240 /**
  241  * struct usb_host_config - representation of a device's configuration
  242  * @desc: the device's configuration descriptor.
  243  * @string: pointer to the cached version of the iConfiguration string, if
  244  *	present for this configuration.
  245  * @intf_assoc: list of any interface association descriptors in this config
  246  * @interface: array of pointers to usb_interface structures, one for each
  247  *	interface in the configuration.  The number of interfaces is stored
  248  *	in desc.bNumInterfaces.  These pointers are valid only while the
  249  *	the configuration is active.
  250  * @intf_cache: array of pointers to usb_interface_cache structures, one
  251  *	for each interface in the configuration.  These structures exist
  252  *	for the entire life of the device.
  253  * @extra: pointer to buffer containing all extra descriptors associated
  254  *	with this configuration (those preceding the first interface
  255  *	descriptor).
  256  * @extralen: length of the extra descriptors buffer.
  257  *
  258  * USB devices may have multiple configurations, but only one can be active
  259  * at any time.  Each encapsulates a different operational environment;
  260  * for example, a dual-speed device would have separate configurations for
  261  * full-speed and high-speed operation.  The number of configurations
  262  * available is stored in the device descriptor as bNumConfigurations.
  263  *
  264  * A configuration can contain multiple interfaces.  Each corresponds to
  265  * a different function of the USB device, and all are available whenever
  266  * the configuration is active.  The USB standard says that interfaces
  267  * are supposed to be numbered from 0 to desc.bNumInterfaces-1, but a lot
  268  * of devices get this wrong.  In addition, the interface array is not
  269  * guaranteed to be sorted in numerical order.  Use usb_ifnum_to_if() to
  270  * look up an interface entry based on its number.
  271  *
  272  * Device drivers should not attempt to activate configurations.  The choice
  273  * of which configuration to install is a policy decision based on such
  274  * considerations as available power, functionality provided, and the user's
  275  * desires (expressed through userspace tools).  However, drivers can call
  276  * usb_reset_configuration() to reinitialize the current configuration and
  277  * all its interfaces.
  278  */
  279 struct usb_host_config {
  280 	struct usb_config_descriptor	desc;
  281 
  282 	char *string;		/* iConfiguration string, if present */
  283 
  284 	/* List of any Interface Association Descriptors in this
  285 	 * configuration. */
  286 	struct usb_interface_assoc_descriptor *intf_assoc[USB_MAXIADS];
  287 
  288 	/* the interfaces associated with this configuration,
  289 	 * stored in no particular order */
  290 	struct usb_interface *interface[USB_MAXINTERFACES];
  291 
  292 	/* Interface information available even when this is not the
  293 	 * active configuration */
  294 	struct usb_interface_cache *intf_cache[USB_MAXINTERFACES];
  295 
  296 	unsigned char *extra;   /* Extra descriptors */
  297 	int extralen;
  298 };
  299 
  300 /* USB2.0 and USB3.0 device BOS descriptor set */
  301 struct usb_host_bos {
  302 	struct usb_bos_descriptor	*desc;
  303 
  304 	/* wireless cap descriptor is handled by wusb */
  305 	struct usb_ext_cap_descriptor	*ext_cap;
  306 	struct usb_ss_cap_descriptor	*ss_cap;
  307 	struct usb_ss_container_id_descriptor	*ss_id;
  308 };
  309 
  310 int __usb_get_extra_descriptor(char *buffer, unsigned size,
  311 	unsigned char type, void **ptr);
  312 #define usb_get_extra_descriptor(ifpoint, type, ptr) \
  313 				__usb_get_extra_descriptor((ifpoint)->extra, \
  314 				(ifpoint)->extralen, \
  315 				type, (void **)ptr)
  316 
  317 /* ----------------------------------------------------------------------- */
  318 
  319 /* USB device number allocation bitmap */
  320 struct usb_devmap {
  321 	unsigned long devicemap[128 / (8*sizeof(unsigned long))];
  322 };
  323 
  324 /*
  325  * Allocated per bus (tree of devices) we have:
  326  */
  327 struct usb_bus {
  328 	struct device *controller;	/* host/master side hardware */
  329 	int busnum;			/* Bus number (in order of reg) */
  330 	const char *bus_name;		/* stable id (PCI slot_name etc) */
  331 	u8 uses_dma;			/* Does the host controller use DMA? */
  332 	u8 uses_pio_for_control;	/*
  333 					 * Does the host controller use PIO
  334 					 * for control transfers?
  335 					 */
  336 	u8 otg_port;			/* 0, or number of OTG/HNP port */
  337 	unsigned is_b_host:1;		/* true during some HNP roleswitches */
  338 	unsigned b_hnp_enable:1;	/* OTG: did A-Host enable HNP? */
  339 	unsigned no_stop_on_short:1;    /*
  340 					 * Quirk: some controllers don't stop
  341 					 * the ep queue on a short transfer
  342 					 * with the URB_SHORT_NOT_OK flag set.
  343 					 */
  344 	unsigned no_sg_constraint:1;	/* no sg constraint */
  345 	unsigned sg_tablesize;		/* 0 or largest number of sg list entries */
  346 
  347 	int devnum_next;		/* Next open device number in
  348 					 * round-robin allocation */
  349 
  350 	struct usb_devmap devmap;	/* device address allocation map */
  351 	struct usb_device *root_hub;	/* Root hub */
  352 	struct usb_bus *hs_companion;	/* Companion EHCI bus, if any */
  353 	struct list_head bus_list;	/* list of busses */
  354 
  355 	struct mutex usb_address0_mutex; /* unaddressed device mutex */
  356 
  357 	int bandwidth_allocated;	/* on this bus: how much of the time
  358 					 * reserved for periodic (intr/iso)
  359 					 * requests is used, on average?
  360 					 * Units: microseconds/frame.
  361 					 * Limits: Full/low speed reserve 90%,
  362 					 * while high speed reserves 80%.
  363 					 */
  364 	int bandwidth_int_reqs;		/* number of Interrupt requests */
  365 	int bandwidth_isoc_reqs;	/* number of Isoc. requests */
  366 
  367 	unsigned resuming_ports;	/* bit array: resuming root-hub ports */
  368 
  369 #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
  370 	struct mon_bus *mon_bus;	/* non-null when associated */
  371 	int monitored;			/* non-zero when monitored */
  372 #endif
  373 };
  374 
  375 struct usb_dev_state;
  376 
  377 /* ----------------------------------------------------------------------- */
  378 
  379 struct usb_tt;
  380 
  381 enum usb_device_removable {
  382 	USB_DEVICE_REMOVABLE_UNKNOWN = 0,
  383 	USB_DEVICE_REMOVABLE,
  384 	USB_DEVICE_FIXED,
  385 };
  386 
  387 enum usb_port_connect_type {
  388 	USB_PORT_CONNECT_TYPE_UNKNOWN = 0,
  389 	USB_PORT_CONNECT_TYPE_HOT_PLUG,
  390 	USB_PORT_CONNECT_TYPE_HARD_WIRED,
  391 	USB_PORT_NOT_USED,
  392 };
  393 
  394 /*
  395  * USB 2.0 Link Power Management (LPM) parameters.
  396  */
  397 struct usb2_lpm_parameters {
  398 	/* Best effort service latency indicate how long the host will drive
  399 	 * resume on an exit from L1.
  400 	 */
  401 	unsigned int besl;
  402 
  403 	/* Timeout value in microseconds for the L1 inactivity (LPM) timer.
  404 	 * When the timer counts to zero, the parent hub will initiate a LPM
  405 	 * transition to L1.
  406 	 */
  407 	int timeout;
  408 };
  409 
  410 /*
  411  * USB 3.0 Link Power Management (LPM) parameters.
  412  *
  413  * PEL and SEL are USB 3.0 Link PM latencies for device-initiated LPM exit.
  414  * MEL is the USB 3.0 Link PM latency for host-initiated LPM exit.
  415  * All three are stored in nanoseconds.
  416  */
  417 struct usb3_lpm_parameters {
  418 	/*
  419 	 * Maximum exit latency (MEL) for the host to send a packet to the
  420 	 * device (either a Ping for isoc endpoints, or a data packet for
  421 	 * interrupt endpoints), the hubs to decode the packet, and for all hubs
  422 	 * in the path to transition the links to U0.
  423 	 */
  424 	unsigned int mel;
  425 	/*
  426 	 * Maximum exit latency for a device-initiated LPM transition to bring
  427 	 * all links into U0.  Abbreviated as "PEL" in section 9.4.12 of the USB
  428 	 * 3.0 spec, with no explanation of what "P" stands for.  "Path"?
  429 	 */
  430 	unsigned int pel;
  431 
  432 	/*
  433 	 * The System Exit Latency (SEL) includes PEL, and three other
  434 	 * latencies.  After a device initiates a U0 transition, it will take
  435 	 * some time from when the device sends the ERDY to when it will finally
  436 	 * receive the data packet.  Basically, SEL should be the worse-case
  437 	 * latency from when a device starts initiating a U0 transition to when
  438 	 * it will get data.
  439 	 */
  440 	unsigned int sel;
  441 	/*
  442 	 * The idle timeout value that is currently programmed into the parent
  443 	 * hub for this device.  When the timer counts to zero, the parent hub
  444 	 * will initiate an LPM transition to either U1 or U2.
  445 	 */
  446 	int timeout;
  447 };
  448 
  449 /**
  450  * struct usb_device - kernel's representation of a USB device
  451  * @devnum: device number; address on a USB bus
  452  * @devpath: device ID string for use in messages (e.g., /port/...)
  453  * @route: tree topology hex string for use with xHCI
  454  * @state: device state: configured, not attached, etc.
  455  * @speed: device speed: high/full/low (or error)
  456  * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
  457  * @ttport: device port on that tt hub
  458  * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
  459  * @parent: our hub, unless we're the root
  460  * @bus: bus we're part of
  461  * @ep0: endpoint 0 data (default control pipe)
  462  * @dev: generic device interface
  463  * @descriptor: USB device descriptor
  464  * @bos: USB device BOS descriptor set
  465  * @config: all of the device's configs
  466  * @actconfig: the active configuration
  467  * @ep_in: array of IN endpoints
  468  * @ep_out: array of OUT endpoints
  469  * @rawdescriptors: raw descriptors for each config
  470  * @bus_mA: Current available from the bus
  471  * @portnum: parent port number (origin 1)
  472  * @level: number of USB hub ancestors
  473  * @can_submit: URBs may be submitted
  474  * @persist_enabled:  USB_PERSIST enabled for this device
  475  * @have_langid: whether string_langid is valid
  476  * @authorized: policy has said we can use it;
  477  *	(user space) policy determines if we authorize this device to be
  478  *	used or not. By default, wired USB devices are authorized.
  479  *	WUSB devices are not, until we authorize them from user space.
  480  *	FIXME -- complete doc
  481  * @authenticated: Crypto authentication passed
  482  * @wusb: device is Wireless USB
  483  * @lpm_capable: device supports LPM
  484  * @usb2_hw_lpm_capable: device can perform USB2 hardware LPM
  485  * @usb2_hw_lpm_besl_capable: device can perform USB2 hardware BESL LPM
  486  * @usb2_hw_lpm_enabled: USB2 hardware LPM is enabled
  487  * @usb2_hw_lpm_allowed: Userspace allows USB 2.0 LPM to be enabled
  488  * @usb3_lpm_enabled: USB3 hardware LPM enabled
  489  * @string_langid: language ID for strings
  490  * @product: iProduct string, if present (static)
  491  * @manufacturer: iManufacturer string, if present (static)
  492  * @serial: iSerialNumber string, if present (static)
  493  * @filelist: usbfs files that are open to this device
  494  * @maxchild: number of ports if hub
  495  * @quirks: quirks of the whole device
  496  * @urbnum: number of URBs submitted for the whole device
  497  * @active_duration: total time device is not suspended
  498  * @connect_time: time device was first connected
  499  * @do_remote_wakeup:  remote wakeup should be enabled
  500  * @reset_resume: needs reset instead of resume
  501  * @port_is_suspended: the upstream port is suspended (L2 or U3)
  502  * @wusb_dev: if this is a Wireless USB device, link to the WUSB
  503  *	specific data for the device.
  504  * @slot_id: Slot ID assigned by xHCI
  505  * @removable: Device can be physically removed from this port
  506  * @l1_params: best effor service latency for USB2 L1 LPM state, and L1 timeout.
  507  * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout.
  508  * @u2_params: exit latencies for USB3 U2 LPM state, and hub-initiated timeout.
  509  * @lpm_disable_count: Ref count used by usb_disable_lpm() and usb_enable_lpm()
  510  *	to keep track of the number of functions that require USB 3.0 Link Power
  511  *	Management to be disabled for this usb_device.  This count should only
  512  *	be manipulated by those functions, with the bandwidth_mutex is held.
  513  *
  514  * Notes:
  515  * Usbcore drivers should not set usbdev->state directly.  Instead use
  516  * usb_set_device_state().
  517  */
  518 struct usb_device {
  519 	int		devnum;
  520 	char		devpath[16];
  521 	u32		route;
  522 	enum usb_device_state	state;
  523 	enum usb_device_speed	speed;
  524 
  525 	struct usb_tt	*tt;
  526 	int		ttport;
  527 
  528 	unsigned int toggle[2];
  529 
  530 	struct usb_device *parent;
  531 	struct usb_bus *bus;
  532 	struct usb_host_endpoint ep0;
  533 
  534 	struct device dev;
  535 
  536 	struct usb_device_descriptor descriptor;
  537 	struct usb_host_bos *bos;
  538 	struct usb_host_config *config;
  539 
  540 	struct usb_host_config *actconfig;
  541 	struct usb_host_endpoint *ep_in[16];
  542 	struct usb_host_endpoint *ep_out[16];
  543 
  544 	char **rawdescriptors;
  545 
  546 	unsigned short bus_mA;
  547 	u8 portnum;
  548 	u8 level;
  549 
  550 	unsigned can_submit:1;
  551 	unsigned persist_enabled:1;
  552 	unsigned have_langid:1;
  553 	unsigned authorized:1;
  554 	unsigned authenticated:1;
  555 	unsigned wusb:1;
  556 	unsigned lpm_capable:1;
  557 	unsigned usb2_hw_lpm_capable:1;
  558 	unsigned usb2_hw_lpm_besl_capable:1;
  559 	unsigned usb2_hw_lpm_enabled:1;
  560 	unsigned usb2_hw_lpm_allowed:1;
  561 	unsigned usb3_lpm_enabled:1;
  562 	int string_langid;
  563 
  564 	/* static strings from the device */
  565 	char *product;
  566 	char *manufacturer;
  567 	char *serial;
  568 
  569 	struct list_head filelist;
  570 
  571 	int maxchild;
  572 
  573 	u32 quirks;
  574 	atomic_t urbnum;
  575 
  576 	unsigned long active_duration;
  577 
  578 #ifdef CONFIG_PM
  579 	unsigned long connect_time;
  580 
  581 	unsigned do_remote_wakeup:1;
  582 	unsigned reset_resume:1;
  583 	unsigned port_is_suspended:1;
  584 #endif
  585 	struct wusb_dev *wusb_dev;
  586 	int slot_id;
  587 	enum usb_device_removable removable;
  588 	struct usb2_lpm_parameters l1_params;
  589 	struct usb3_lpm_parameters u1_params;
  590 	struct usb3_lpm_parameters u2_params;
  591 	unsigned lpm_disable_count;
  592 };
  593 #define	to_usb_device(d) container_of(d, struct usb_device, dev)
  594 
  595 static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
  596 {
  597 	return to_usb_device(intf->dev.parent);
  598 }
  599 
  600 extern struct usb_device *usb_get_dev(struct usb_device *dev);
  601 extern void usb_put_dev(struct usb_device *dev);
  602 extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
  603 	int port1);
  604 
  605 /**
  606  * usb_hub_for_each_child - iterate over all child devices on the hub
  607  * @hdev:  USB device belonging to the usb hub
  608  * @port1: portnum associated with child device
  609  * @child: child device pointer
  610  */
  611 #define usb_hub_for_each_child(hdev, port1, child) \
  612 	for (port1 = 1,	child =	usb_hub_find_child(hdev, port1); \
  613 			port1 <= hdev->maxchild; \
  614 			child = usb_hub_find_child(hdev, ++port1)) \
  615 		if (!child) continue; else
  616 
  617 /* USB device locking */
  618 #define usb_lock_device(udev)		device_lock(&(udev)->dev)
  619 #define usb_unlock_device(udev)		device_unlock(&(udev)->dev)
  620 #define usb_trylock_device(udev)	device_trylock(&(udev)->dev)
  621 extern int usb_lock_device_for_reset(struct usb_device *udev,
  622 				     const struct usb_interface *iface);
  623 
  624 /* USB port reset for device reinitialization */
  625 extern int usb_reset_device(struct usb_device *dev);
  626 extern void usb_queue_reset_device(struct usb_interface *dev);
  627 
  628 #ifdef CONFIG_ACPI
  629 extern int usb_acpi_set_power_state(struct usb_device *hdev, int index,
  630 	bool enable);
  631 extern bool usb_acpi_power_manageable(struct usb_device *hdev, int index);
  632 #else
  633 static inline int usb_acpi_set_power_state(struct usb_device *hdev, int index,
  634 	bool enable) { return 0; }
  635 static inline bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
  636 	{ return true; }
  637 #endif
  638 
  639 /* USB autosuspend and autoresume */
  640 #ifdef CONFIG_PM_RUNTIME
  641 extern void usb_enable_autosuspend(struct usb_device *udev);
  642 extern void usb_disable_autosuspend(struct usb_device *udev);
  643 
  644 extern int usb_autopm_get_interface(struct usb_interface *intf);
  645 extern void usb_autopm_put_interface(struct usb_interface *intf);
  646 extern int usb_autopm_get_interface_async(struct usb_interface *intf);
  647 extern void usb_autopm_put_interface_async(struct usb_interface *intf);
  648 extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
  649 extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
  650 
  651 static inline void usb_mark_last_busy(struct usb_device *udev)
  652 {
  653 	pm_runtime_mark_last_busy(&udev->dev);
  654 }
  655 
  656 #else
  657 
  658 static inline int usb_enable_autosuspend(struct usb_device *udev)
  659 { return 0; }
  660 static inline int usb_disable_autosuspend(struct usb_device *udev)
  661 { return 0; }
  662 
  663 static inline int usb_autopm_get_interface(struct usb_interface *intf)
  664 { return 0; }
  665 static inline int usb_autopm_get_interface_async(struct usb_interface *intf)
  666 { return 0; }
  667 
  668 static inline void usb_autopm_put_interface(struct usb_interface *intf)
  669 { }
  670 static inline void usb_autopm_put_interface_async(struct usb_interface *intf)
  671 { }
  672 static inline void usb_autopm_get_interface_no_resume(
  673 		struct usb_interface *intf)
  674 { }
  675 static inline void usb_autopm_put_interface_no_suspend(
  676 		struct usb_interface *intf)
  677 { }
  678 static inline void usb_mark_last_busy(struct usb_device *udev)
  679 { }
  680 #endif
  681 
  682 extern int usb_disable_lpm(struct usb_device *udev);
  683 extern void usb_enable_lpm(struct usb_device *udev);
  684 /* Same as above, but these functions lock/unlock the bandwidth_mutex. */
  685 extern int usb_unlocked_disable_lpm(struct usb_device *udev);
  686 extern void usb_unlocked_enable_lpm(struct usb_device *udev);
  687 
  688 extern int usb_disable_ltm(struct usb_device *udev);
  689 extern void usb_enable_ltm(struct usb_device *udev);
  690 
  691 static inline bool usb_device_supports_ltm(struct usb_device *udev)
  692 {
  693 	if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
  694 		return false;
  695 	return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
  696 }
  697 
  698 static inline bool usb_device_no_sg_constraint(struct usb_device *udev)
  699 {
  700 	return udev && udev->bus && udev->bus->no_sg_constraint;
  701 }
  702 
  703 
  704 /*-------------------------------------------------------------------------*/
  705 
  706 /* for drivers using iso endpoints */
  707 extern int usb_get_current_frame_number(struct usb_device *usb_dev);
  708 
  709 /* Sets up a group of bulk endpoints to support multiple stream IDs. */
  710 extern int usb_alloc_streams(struct usb_interface *interface,
  711 		struct usb_host_endpoint **eps, unsigned int num_eps,
  712 		unsigned int num_streams, gfp_t mem_flags);
  713 
  714 /* Reverts a group of bulk endpoints back to not using stream IDs. */
  715 extern int usb_free_streams(struct usb_interface *interface,
  716 		struct usb_host_endpoint **eps, unsigned int num_eps,
  717 		gfp_t mem_flags);
  718 
  719 /* used these for multi-interface device registration */
  720 extern int usb_driver_claim_interface(struct usb_driver *driver,
  721 			struct usb_interface *iface, void *priv);
  722 
  723 /**
  724  * usb_interface_claimed - returns true iff an interface is claimed
  725  * @iface: the interface being checked
  726  *
  727  * Return: %true (nonzero) iff the interface is claimed, else %false
  728  * (zero).
  729  *
  730  * Note:
  731  * Callers must own the driver model's usb bus readlock.  So driver
  732  * probe() entries don't need extra locking, but other call contexts
  733  * may need to explicitly claim that lock.
  734  *
  735  */
  736 static inline int usb_interface_claimed(struct usb_interface *iface)
  737 {
  738 	return (iface->dev.driver != NULL);
  739 }
  740 
  741 extern void usb_driver_release_interface(struct usb_driver *driver,
  742 			struct usb_interface *iface);
  743 const struct usb_device_id *usb_match_id(struct usb_interface *interface,
  744 					 const struct usb_device_id *id);
  745 extern int usb_match_one_id(struct usb_interface *interface,
  746 			    const struct usb_device_id *id);
  747 
  748 extern int usb_for_each_dev(void *data, int (*fn)(struct usb_device *, void *));
  749 extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
  750 		int minor);
  751 extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
  752 		unsigned ifnum);
  753 extern struct usb_host_interface *usb_altnum_to_altsetting(
  754 		const struct usb_interface *intf, unsigned int altnum);
  755 extern struct usb_host_interface *usb_find_alt_setting(
  756 		struct usb_host_config *config,
  757 		unsigned int iface_num,
  758 		unsigned int alt_num);
  759 
  760 /* port claiming functions */
  761 int usb_hub_claim_port(struct usb_device *hdev, unsigned port1,
  762 		struct usb_dev_state *owner);
  763 int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
  764 		struct usb_dev_state *owner);
  765 
  766 /**
  767  * usb_make_path - returns stable device path in the usb tree
  768  * @dev: the device whose path is being constructed
  769  * @buf: where to put the string
  770  * @size: how big is "buf"?
  771  *
  772  * Return: Length of the string (> 0) or negative if size was too small.
  773  *
  774  * Note:
  775  * This identifier is intended to be "stable", reflecting physical paths in
  776  * hardware such as physical bus addresses for host controllers or ports on
  777  * USB hubs.  That makes it stay the same until systems are physically
  778  * reconfigured, by re-cabling a tree of USB devices or by moving USB host
  779  * controllers.  Adding and removing devices, including virtual root hubs
  780  * in host controller driver modules, does not change these path identifiers;
  781  * neither does rebooting or re-enumerating.  These are more useful identifiers
  782  * than changeable ("unstable") ones like bus numbers or device addresses.
  783  *
  784  * With a partial exception for devices connected to USB 2.0 root hubs, these
  785  * identifiers are also predictable.  So long as the device tree isn't changed,
  786  * plugging any USB device into a given hub port always gives it the same path.
  787  * Because of the use of "companion" controllers, devices connected to ports on
  788  * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
  789  * high speed, and a different one if they are full or low speed.
  790  */
  791 static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
  792 {
  793 	int actual;
  794 	actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name,
  795 			  dev->devpath);
  796 	return (actual >= (int)size) ? -1 : actual;
  797 }
  798 
  799 /*-------------------------------------------------------------------------*/
  800 
  801 #define USB_DEVICE_ID_MATCH_DEVICE \
  802 		(USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
  803 #define USB_DEVICE_ID_MATCH_DEV_RANGE \
  804 		(USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
  805 #define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
  806 		(USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
  807 #define USB_DEVICE_ID_MATCH_DEV_INFO \
  808 		(USB_DEVICE_ID_MATCH_DEV_CLASS | \
  809 		USB_DEVICE_ID_MATCH_DEV_SUBCLASS | \
  810 		USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
  811 #define USB_DEVICE_ID_MATCH_INT_INFO \
  812 		(USB_DEVICE_ID_MATCH_INT_CLASS | \
  813 		USB_DEVICE_ID_MATCH_INT_SUBCLASS | \
  814 		USB_DEVICE_ID_MATCH_INT_PROTOCOL)
  815 
  816 /**
  817  * USB_DEVICE - macro used to describe a specific usb device
  818  * @vend: the 16 bit USB Vendor ID
  819  * @prod: the 16 bit USB Product ID
  820  *
  821  * This macro is used to create a struct usb_device_id that matches a
  822  * specific device.
  823  */
  824 #define USB_DEVICE(vend, prod) \
  825 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
  826 	.idVendor = (vend), \
  827 	.idProduct = (prod)
  828 /**
  829  * USB_DEVICE_VER - describe a specific usb device with a version range
  830  * @vend: the 16 bit USB Vendor ID
  831  * @prod: the 16 bit USB Product ID
  832  * @lo: the bcdDevice_lo value
  833  * @hi: the bcdDevice_hi value
  834  *
  835  * This macro is used to create a struct usb_device_id that matches a
  836  * specific device, with a version range.
  837  */
  838 #define USB_DEVICE_VER(vend, prod, lo, hi) \
  839 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
  840 	.idVendor = (vend), \
  841 	.idProduct = (prod), \
  842 	.bcdDevice_lo = (lo), \
  843 	.bcdDevice_hi = (hi)
  844 
  845 /**
  846  * USB_DEVICE_INTERFACE_CLASS - describe a usb device with a specific interface class
  847  * @vend: the 16 bit USB Vendor ID
  848  * @prod: the 16 bit USB Product ID
  849  * @cl: bInterfaceClass value
  850  *
  851  * This macro is used to create a struct usb_device_id that matches a
  852  * specific interface class of devices.
  853  */
  854 #define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \
  855 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
  856 		       USB_DEVICE_ID_MATCH_INT_CLASS, \
  857 	.idVendor = (vend), \
  858 	.idProduct = (prod), \
  859 	.bInterfaceClass = (cl)
  860 
  861 /**
  862  * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol
  863  * @vend: the 16 bit USB Vendor ID
  864  * @prod: the 16 bit USB Product ID
  865  * @pr: bInterfaceProtocol value
  866  *
  867  * This macro is used to create a struct usb_device_id that matches a
  868  * specific interface protocol of devices.
  869  */
  870 #define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \
  871 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
  872 		       USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
  873 	.idVendor = (vend), \
  874 	.idProduct = (prod), \
  875 	.bInterfaceProtocol = (pr)
  876 
  877 /**
  878  * USB_DEVICE_INTERFACE_NUMBER - describe a usb device with a specific interface number
  879  * @vend: the 16 bit USB Vendor ID
  880  * @prod: the 16 bit USB Product ID
  881  * @num: bInterfaceNumber value
  882  *
  883  * This macro is used to create a struct usb_device_id that matches a
  884  * specific interface number of devices.
  885  */
  886 #define USB_DEVICE_INTERFACE_NUMBER(vend, prod, num) \
  887 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
  888 		       USB_DEVICE_ID_MATCH_INT_NUMBER, \
  889 	.idVendor = (vend), \
  890 	.idProduct = (prod), \
  891 	.bInterfaceNumber = (num)
  892 
  893 /**
  894  * USB_DEVICE_INFO - macro used to describe a class of usb devices
  895  * @cl: bDeviceClass value
  896  * @sc: bDeviceSubClass value
  897  * @pr: bDeviceProtocol value
  898  *
  899  * This macro is used to create a struct usb_device_id that matches a
  900  * specific class of devices.
  901  */
  902 #define USB_DEVICE_INFO(cl, sc, pr) \
  903 	.match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, \
  904 	.bDeviceClass = (cl), \
  905 	.bDeviceSubClass = (sc), \
  906 	.bDeviceProtocol = (pr)
  907 
  908 /**
  909  * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
  910  * @cl: bInterfaceClass value
  911  * @sc: bInterfaceSubClass value
  912  * @pr: bInterfaceProtocol value
  913  *
  914  * This macro is used to create a struct usb_device_id that matches a
  915  * specific class of interfaces.
  916  */
  917 #define USB_INTERFACE_INFO(cl, sc, pr) \
  918 	.match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \
  919 	.bInterfaceClass = (cl), \
  920 	.bInterfaceSubClass = (sc), \
  921 	.bInterfaceProtocol = (pr)
  922 
  923 /**
  924  * USB_DEVICE_AND_INTERFACE_INFO - describe a specific usb device with a class of usb interfaces
  925  * @vend: the 16 bit USB Vendor ID
  926  * @prod: the 16 bit USB Product ID
  927  * @cl: bInterfaceClass value
  928  * @sc: bInterfaceSubClass value
  929  * @pr: bInterfaceProtocol value
  930  *
  931  * This macro is used to create a struct usb_device_id that matches a
  932  * specific device with a specific class of interfaces.
  933  *
  934  * This is especially useful when explicitly matching devices that have
  935  * vendor specific bDeviceClass values, but standards-compliant interfaces.
  936  */
  937 #define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
  938 	.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  939 		| USB_DEVICE_ID_MATCH_DEVICE, \
  940 	.idVendor = (vend), \
  941 	.idProduct = (prod), \
  942 	.bInterfaceClass = (cl), \
  943 	.bInterfaceSubClass = (sc), \
  944 	.bInterfaceProtocol = (pr)
  945 
  946 /**
  947  * USB_VENDOR_AND_INTERFACE_INFO - describe a specific usb vendor with a class of usb interfaces
  948  * @vend: the 16 bit USB Vendor ID
  949  * @cl: bInterfaceClass value
  950  * @sc: bInterfaceSubClass value
  951  * @pr: bInterfaceProtocol value
  952  *
  953  * This macro is used to create a struct usb_device_id that matches a
  954  * specific vendor with a specific class of interfaces.
  955  *
  956  * This is especially useful when explicitly matching devices that have
  957  * vendor specific bDeviceClass values, but standards-compliant interfaces.
  958  */
  959 #define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \
  960 	.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  961 		| USB_DEVICE_ID_MATCH_VENDOR, \
  962 	.idVendor = (vend), \
  963 	.bInterfaceClass = (cl), \
  964 	.bInterfaceSubClass = (sc), \
  965 	.bInterfaceProtocol = (pr)
  966 
  967 /* ----------------------------------------------------------------------- */
  968 
  969 /* Stuff for dynamic usb ids */
  970 struct usb_dynids {
  971 	spinlock_t lock;
  972 	struct list_head list;
  973 };
  974 
  975 struct usb_dynid {
  976 	struct list_head node;
  977 	struct usb_device_id id;
  978 };
  979 
  980 extern ssize_t usb_store_new_id(struct usb_dynids *dynids,
  981 				const struct usb_device_id *id_table,
  982 				struct device_driver *driver,
  983 				const char *buf, size_t count);
  984 
  985 extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf);
  986 
  987 /**
  988  * struct usbdrv_wrap - wrapper for driver-model structure
  989  * @driver: The driver-model core driver structure.
  990  * @for_devices: Non-zero for device drivers, 0 for interface drivers.
  991  */
  992 struct usbdrv_wrap {
  993 	struct device_driver driver;
  994 	int for_devices;
  995 };
  996 
  997 /**
  998  * struct usb_driver - identifies USB interface driver to usbcore
  999  * @name: The driver name should be unique among USB drivers,
 1000  *	and should normally be the same as the module name.
 1001  * @probe: Called to see if the driver is willing to manage a particular
 1002  *	interface on a device.  If it is, probe returns zero and uses
 1003  *	usb_set_intfdata() to associate driver-specific data with the
 1004  *	interface.  It may also use usb_set_interface() to specify the
 1005  *	appropriate altsetting.  If unwilling to manage the interface,
 1006  *	return -ENODEV, if genuine IO errors occurred, an appropriate
 1007  *	negative errno value.
 1008  * @disconnect: Called when the interface is no longer accessible, usually
 1009  *	because its device has been (or is being) disconnected or the
 1010  *	driver module is being unloaded.
 1011  * @unlocked_ioctl: Used for drivers that want to talk to userspace through
 1012  *	the "usbfs" filesystem.  This lets devices provide ways to
 1013  *	expose information to user space regardless of where they
 1014  *	do (or don't) show up otherwise in the filesystem.
 1015  * @suspend: Called when the device is going to be suspended by the
 1016  *	system either from system sleep or runtime suspend context. The
 1017  *	return value will be ignored in system sleep context, so do NOT
 1018  *	try to continue using the device if suspend fails in this case.
 1019  *	Instead, let the resume or reset-resume routine recover from
 1020  *	the failure.
 1021  * @resume: Called when the device is being resumed by the system.
 1022  * @reset_resume: Called when the suspended device has been reset instead
 1023  *	of being resumed.
 1024  * @pre_reset: Called by usb_reset_device() when the device is about to be
 1025  *	reset.  This routine must not return until the driver has no active
 1026  *	URBs for the device, and no more URBs may be submitted until the
 1027  *	post_reset method is called.
 1028  * @post_reset: Called by usb_reset_device() after the device
 1029  *	has been reset
 1030  * @id_table: USB drivers use ID table to support hotplugging.
 1031  *	Export this with MODULE_DEVICE_TABLE(usb,...).  This must be set
 1032  *	or your driver's probe function will never get called.
 1033  * @dynids: used internally to hold the list of dynamically added device
 1034  *	ids for this driver.
 1035  * @drvwrap: Driver-model core structure wrapper.
 1036  * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be
 1037  *	added to this driver by preventing the sysfs file from being created.
 1038  * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
 1039  *	for interfaces bound to this driver.
 1040  * @soft_unbind: if set to 1, the USB core will not kill URBs and disable
 1041  *	endpoints before calling the driver's disconnect method.
 1042  * @disable_hub_initiated_lpm: if set to 0, the USB core will not allow hubs
 1043  *	to initiate lower power link state transitions when an idle timeout
 1044  *	occurs.  Device-initiated USB 3.0 link PM will still be allowed.
 1045  *
 1046  * USB interface drivers must provide a name, probe() and disconnect()
 1047  * methods, and an id_table.  Other driver fields are optional.
 1048  *
 1049  * The id_table is used in hotplugging.  It holds a set of descriptors,
 1050  * and specialized data may be associated with each entry.  That table
 1051  * is used by both user and kernel mode hotplugging support.
 1052  *
 1053  * The probe() and disconnect() methods are called in a context where
 1054  * they can sleep, but they should avoid abusing the privilege.  Most
 1055  * work to connect to a device should be done when the device is opened,
 1056  * and undone at the last close.  The disconnect code needs to address
 1057  * concurrency issues with respect to open() and close() methods, as
 1058  * well as forcing all pending I/O requests to complete (by unlinking
 1059  * them as necessary, and blocking until the unlinks complete).
 1060  */
 1061 struct usb_driver {
 1062 	const char *name;
 1063 
 1064 	int (*probe) (struct usb_interface *intf,
 1065 		      const struct usb_device_id *id);
 1066 
 1067 	void (*disconnect) (struct usb_interface *intf);
 1068 
 1069 	int (*unlocked_ioctl) (struct usb_interface *intf, unsigned int code,
 1070 			void *buf);
 1071 
 1072 	int (*suspend) (struct usb_interface *intf, pm_message_t message);
 1073 	int (*resume) (struct usb_interface *intf);
 1074 	int (*reset_resume)(struct usb_interface *intf);
 1075 
 1076 	int (*pre_reset)(struct usb_interface *intf);
 1077 	int (*post_reset)(struct usb_interface *intf);
 1078 
 1079 	const struct usb_device_id *id_table;
 1080 
 1081 	struct usb_dynids dynids;
 1082 	struct usbdrv_wrap drvwrap;
 1083 	unsigned int no_dynamic_id:1;
 1084 	unsigned int supports_autosuspend:1;
 1085 	unsigned int disable_hub_initiated_lpm:1;
 1086 	unsigned int soft_unbind:1;
 1087 };
 1088 #define	to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver)
 1089 
 1090 /**
 1091  * struct usb_device_driver - identifies USB device driver to usbcore
 1092  * @name: The driver name should be unique among USB drivers,
 1093  *	and should normally be the same as the module name.
 1094  * @probe: Called to see if the driver is willing to manage a particular
 1095  *	device.  If it is, probe returns zero and uses dev_set_drvdata()
 1096  *	to associate driver-specific data with the device.  If unwilling
 1097  *	to manage the device, return a negative errno value.
 1098  * @disconnect: Called when the device is no longer accessible, usually
 1099  *	because it has been (or is being) disconnected or the driver's
 1100  *	module is being unloaded.
 1101  * @suspend: Called when the device is going to be suspended by the system.
 1102  * @resume: Called when the device is being resumed by the system.
 1103  * @drvwrap: Driver-model core structure wrapper.
 1104  * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
 1105  *	for devices bound to this driver.
 1106  *
 1107  * USB drivers must provide all the fields listed above except drvwrap.
 1108  */
 1109 struct usb_device_driver {
 1110 	const char *name;
 1111 
 1112 	int (*probe) (struct usb_device *udev);
 1113 	void (*disconnect) (struct usb_device *udev);
 1114 
 1115 	int (*suspend) (struct usb_device *udev, pm_message_t message);
 1116 	int (*resume) (struct usb_device *udev, pm_message_t message);
 1117 	struct usbdrv_wrap drvwrap;
 1118 	unsigned int supports_autosuspend:1;
 1119 };
 1120 #define	to_usb_device_driver(d) container_of(d, struct usb_device_driver, \
 1121 		drvwrap.driver)
 1122 
 1123 extern struct bus_type usb_bus_type;
 1124 
 1125 /**
 1126  * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
 1127  * @name: the usb class device name for this driver.  Will show up in sysfs.
 1128  * @devnode: Callback to provide a naming hint for a possible
 1129  *	device node to create.
 1130  * @fops: pointer to the struct file_operations of this driver.
 1131  * @minor_base: the start of the minor range for this driver.
 1132  *
 1133  * This structure is used for the usb_register_dev() and
 1134  * usb_unregister_dev() functions, to consolidate a number of the
 1135  * parameters used for them.
 1136  */
 1137 struct usb_class_driver {
 1138 	char *name;
 1139 	char *(*devnode)(struct device *dev, umode_t *mode);
 1140 	const struct file_operations *fops;
 1141 	int minor_base;
 1142 };
 1143 
 1144 /*
 1145  * use these in module_init()/module_exit()
 1146  * and don't forget MODULE_DEVICE_TABLE(usb, ...)
 1147  */
 1148 extern int usb_register_driver(struct usb_driver *, struct module *,
 1149 			       const char *);
 1150 
 1151 /* use a define to avoid include chaining to get THIS_MODULE & friends */
 1152 #define usb_register(driver) \
 1153 	usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
 1154 
 1155 extern void usb_deregister(struct usb_driver *);
 1156 
 1157 /**
 1158  * module_usb_driver() - Helper macro for registering a USB driver
 1159  * @__usb_driver: usb_driver struct
 1160  *
 1161  * Helper macro for USB drivers which do not do anything special in module
 1162  * init/exit. This eliminates a lot of boilerplate. Each module may only
 1163  * use this macro once, and calling it replaces module_init() and module_exit()
 1164  */
 1165 #define module_usb_driver(__usb_driver) \
 1166 	module_driver(__usb_driver, usb_register, \
 1167 		       usb_deregister)
 1168 
 1169 extern int usb_register_device_driver(struct usb_device_driver *,
 1170 			struct module *);
 1171 extern void usb_deregister_device_driver(struct usb_device_driver *);
 1172 
 1173 extern int usb_register_dev(struct usb_interface *intf,
 1174 			    struct usb_class_driver *class_driver);
 1175 extern void usb_deregister_dev(struct usb_interface *intf,
 1176 			       struct usb_class_driver *class_driver);
 1177 
 1178 extern int usb_disabled(void);
 1179 
 1180 /* ----------------------------------------------------------------------- */
 1181 
 1182 /*
 1183  * URB support, for asynchronous request completions
 1184  */
 1185 
 1186 /*
 1187  * urb->transfer_flags:
 1188  *
 1189  * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
 1190  */
 1191 #define URB_SHORT_NOT_OK	0x0001	/* report short reads as errors */
 1192 #define URB_ISO_ASAP		0x0002	/* iso-only; use the first unexpired
 1193 					 * slot in the schedule */
 1194 #define URB_NO_TRANSFER_DMA_MAP	0x0004	/* urb->transfer_dma valid on submit */
 1195 #define URB_NO_FSBR		0x0020	/* UHCI-specific */
 1196 #define URB_ZERO_PACKET		0x0040	/* Finish bulk OUT with short packet */
 1197 #define URB_NO_INTERRUPT	0x0080	/* HINT: no non-error interrupt
 1198 					 * needed */
 1199 #define URB_FREE_BUFFER		0x0100	/* Free transfer buffer with the URB */
 1200 
 1201 /* The following flags are used internally by usbcore and HCDs */
 1202 #define URB_DIR_IN		0x0200	/* Transfer from device to host */
 1203 #define URB_DIR_OUT		0
 1204 #define URB_DIR_MASK		URB_DIR_IN
 1205 
 1206 #define URB_DMA_MAP_SINGLE	0x00010000	/* Non-scatter-gather mapping */
 1207 #define URB_DMA_MAP_PAGE	0x00020000	/* HCD-unsupported S-G */
 1208 #define URB_DMA_MAP_SG		0x00040000	/* HCD-supported S-G */
 1209 #define URB_MAP_LOCAL		0x00080000	/* HCD-local-memory mapping */
 1210 #define URB_SETUP_MAP_SINGLE	0x00100000	/* Setup packet DMA mapped */
 1211 #define URB_SETUP_MAP_LOCAL	0x00200000	/* HCD-local setup packet */
 1212 #define URB_DMA_SG_COMBINED	0x00400000	/* S-G entries were combined */
 1213 #define URB_ALIGNED_TEMP_BUFFER	0x00800000	/* Temp buffer was alloc'd */
 1214 
 1215 struct usb_iso_packet_descriptor {
 1216 	unsigned int offset;
 1217 	unsigned int length;		/* expected length */
 1218 	unsigned int actual_length;
 1219 	int status;
 1220 };
 1221 
 1222 struct urb;
 1223 
 1224 struct usb_anchor {
 1225 	struct list_head urb_list;
 1226 	wait_queue_head_t wait;
 1227 	spinlock_t lock;
 1228 	atomic_t suspend_wakeups;
 1229 	unsigned int poisoned:1;
 1230 };
 1231 
 1232 static inline void init_usb_anchor(struct usb_anchor *anchor)
 1233 {
 1234 	memset(anchor, 0, sizeof(*anchor));
 1235 	INIT_LIST_HEAD(&anchor->urb_list);
 1236 	init_waitqueue_head(&anchor->wait);
 1237 	spin_lock_init(&anchor->lock);
 1238 }
 1239 
 1240 typedef void (*usb_complete_t)(struct urb *);
 1241 
 1242 /**
 1243  * struct urb - USB Request Block
 1244  * @urb_list: For use by current owner of the URB.
 1245  * @anchor_list: membership in the list of an anchor
 1246  * @anchor: to anchor URBs to a common mooring
 1247  * @ep: Points to the endpoint's data structure.  Will eventually
 1248  *	replace @pipe.
 1249  * @pipe: Holds endpoint number, direction, type, and more.
 1250  *	Create these values with the eight macros available;
 1251  *	usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl"
 1252  *	(control), "bulk", "int" (interrupt), or "iso" (isochronous).
 1253  *	For example usb_sndbulkpipe() or usb_rcvintpipe().  Endpoint
 1254  *	numbers range from zero to fifteen.  Note that "in" endpoint two
 1255  *	is a different endpoint (and pipe) from "out" endpoint two.
 1256  *	The current configuration controls the existence, type, and
 1257  *	maximum packet size of any given endpoint.
 1258  * @stream_id: the endpoint's stream ID for bulk streams
 1259  * @dev: Identifies the USB device to perform the request.
 1260  * @status: This is read in non-iso completion functions to get the
 1261  *	status of the particular request.  ISO requests only use it
 1262  *	to tell whether the URB was unlinked; detailed status for
 1263  *	each frame is in the fields of the iso_frame-desc.
 1264  * @transfer_flags: A variety of flags may be used to affect how URB
 1265  *	submission, unlinking, or operation are handled.  Different
 1266  *	kinds of URB can use different flags.
 1267  * @transfer_buffer:  This identifies the buffer to (or from) which the I/O
 1268  *	request will be performed unless URB_NO_TRANSFER_DMA_MAP is set
 1269  *	(however, do not leave garbage in transfer_buffer even then).
 1270  *	This buffer must be suitable for DMA; allocate it with
 1271  *	kmalloc() or equivalent.  For transfers to "in" endpoints, contents
 1272  *	of this buffer will be modified.  This buffer is used for the data
 1273  *	stage of control transfers.
 1274  * @transfer_dma: When transfer_flags includes URB_NO_TRANSFER_DMA_MAP,
 1275  *	the device driver is saying that it provided this DMA address,
 1276  *	which the host controller driver should use in preference to the
 1277  *	transfer_buffer.
 1278  * @sg: scatter gather buffer list, the buffer size of each element in
 1279  * 	the list (except the last) must be divisible by the endpoint's
 1280  * 	max packet size if no_sg_constraint isn't set in 'struct usb_bus'
 1281  * @num_mapped_sgs: (internal) number of mapped sg entries
 1282  * @num_sgs: number of entries in the sg list
 1283  * @transfer_buffer_length: How big is transfer_buffer.  The transfer may
 1284  *	be broken up into chunks according to the current maximum packet
 1285  *	size for the endpoint, which is a function of the configuration
 1286  *	and is encoded in the pipe.  When the length is zero, neither
 1287  *	transfer_buffer nor transfer_dma is used.
 1288  * @actual_length: This is read in non-iso completion functions, and
 1289  *	it tells how many bytes (out of transfer_buffer_length) were
 1290  *	transferred.  It will normally be the same as requested, unless
 1291  *	either an error was reported or a short read was performed.
 1292  *	The URB_SHORT_NOT_OK transfer flag may be used to make such
 1293  *	short reads be reported as errors.
 1294  * @setup_packet: Only used for control transfers, this points to eight bytes
 1295  *	of setup data.  Control transfers always start by sending this data
 1296  *	to the device.  Then transfer_buffer is read or written, if needed.
 1297  * @setup_dma: DMA pointer for the setup packet.  The caller must not use
 1298  *	this field; setup_packet must point to a valid buffer.
 1299  * @start_frame: Returns the initial frame for isochronous transfers.
 1300  * @number_of_packets: Lists the number of ISO transfer buffers.
 1301  * @interval: Specifies the polling interval for interrupt or isochronous
 1302  *	transfers.  The units are frames (milliseconds) for full and low
 1303  *	speed devices, and microframes (1/8 millisecond) for highspeed
 1304  *	and SuperSpeed devices.
 1305  * @error_count: Returns the number of ISO transfers that reported errors.
 1306  * @context: For use in completion functions.  This normally points to
 1307  *	request-specific driver context.
 1308  * @complete: Completion handler. This URB is passed as the parameter to the
 1309  *	completion function.  The completion function may then do what
 1310  *	it likes with the URB, including resubmitting or freeing it.
 1311  * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to
 1312  *	collect the transfer status for each buffer.
 1313  *
 1314  * This structure identifies USB transfer requests.  URBs must be allocated by
 1315  * calling usb_alloc_urb() and freed with a call to usb_free_urb().
 1316  * Initialization may be done using various usb_fill_*_urb() functions.  URBs
 1317  * are submitted using usb_submit_urb(), and pending requests may be canceled
 1318  * using usb_unlink_urb() or usb_kill_urb().
 1319  *
 1320  * Data Transfer Buffers:
 1321  *
 1322  * Normally drivers provide I/O buffers allocated with kmalloc() or otherwise
 1323  * taken from the general page pool.  That is provided by transfer_buffer
 1324  * (control requests also use setup_packet), and host controller drivers
 1325  * perform a dma mapping (and unmapping) for each buffer transferred.  Those
 1326  * mapping operations can be expensive on some platforms (perhaps using a dma
 1327  * bounce buffer or talking to an IOMMU),
 1328  * although they're cheap on commodity x86 and ppc hardware.
 1329  *
 1330  * Alternatively, drivers may pass the URB_NO_TRANSFER_DMA_MAP transfer flag,
 1331  * which tells the host controller driver that no such mapping is needed for
 1332  * the transfer_buffer since
 1333  * the device driver is DMA-aware.  For example, a device driver might
 1334  * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map().
 1335  * When this transfer flag is provided, host controller drivers will
 1336  * attempt to use the dma address found in the transfer_dma
 1337  * field rather than determining a dma address themselves.
 1338  *
 1339  * Note that transfer_buffer must still be set if the controller
 1340  * does not support DMA (as indicated by bus.uses_dma) and when talking
 1341  * to root hub. If you have to trasfer between highmem zone and the device
 1342  * on such controller, create a bounce buffer or bail out with an error.
 1343  * If transfer_buffer cannot be set (is in highmem) and the controller is DMA
 1344  * capable, assign NULL to it, so that usbmon knows not to use the value.
 1345  * The setup_packet must always be set, so it cannot be located in highmem.
 1346  *
 1347  * Initialization:
 1348  *
 1349  * All URBs submitted must initialize the dev, pipe, transfer_flags (may be
 1350  * zero), and complete fields.  All URBs must also initialize
 1351  * transfer_buffer and transfer_buffer_length.  They may provide the
 1352  * URB_SHORT_NOT_OK transfer flag, indicating that short reads are
 1353  * to be treated as errors; that flag is invalid for write requests.
 1354  *
 1355  * Bulk URBs may
 1356  * use the URB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers
 1357  * should always terminate with a short packet, even if it means adding an
 1358  * extra zero length packet.
 1359  *
 1360  * Control URBs must provide a valid pointer in the setup_packet field.
 1361  * Unlike the transfer_buffer, the setup_packet may not be mapped for DMA
 1362  * beforehand.
 1363  *
 1364  * Interrupt URBs must provide an interval, saying how often (in milliseconds
 1365  * or, for highspeed devices, 125 microsecond units)
 1366  * to poll for transfers.  After the URB has been submitted, the interval
 1367  * field reflects how the transfer was actually scheduled.
 1368  * The polling interval may be more frequent than requested.
 1369  * For example, some controllers have a maximum interval of 32 milliseconds,
 1370  * while others support intervals of up to 1024 milliseconds.
 1371  * Isochronous URBs also have transfer intervals.  (Note that for isochronous
 1372  * endpoints, as well as high speed interrupt endpoints, the encoding of
 1373  * the transfer interval in the endpoint descriptor is logarithmic.
 1374  * Device drivers must convert that value to linear units themselves.)
 1375  *
 1376  * If an isochronous endpoint queue isn't already running, the host
 1377  * controller will schedule a new URB to start as soon as bandwidth
 1378  * utilization allows.  If the queue is running then a new URB will be
 1379  * scheduled to start in the first transfer slot following the end of the
 1380  * preceding URB, if that slot has not already expired.  If the slot has
 1381  * expired (which can happen when IRQ delivery is delayed for a long time),
 1382  * the scheduling behavior depends on the URB_ISO_ASAP flag.  If the flag
 1383  * is clear then the URB will be scheduled to start in the expired slot,
 1384  * implying that some of its packets will not be transferred; if the flag
 1385  * is set then the URB will be scheduled in the first unexpired slot,
 1386  * breaking the queue's synchronization.  Upon URB completion, the
 1387  * start_frame field will be set to the (micro)frame number in which the
 1388  * transfer was scheduled.  Ranges for frame counter values are HC-specific
 1389  * and can go from as low as 256 to as high as 65536 frames.
 1390  *
 1391  * Isochronous URBs have a different data transfer model, in part because
 1392  * the quality of service is only "best effort".  Callers provide specially
 1393  * allocated URBs, with number_of_packets worth of iso_frame_desc structures
 1394  * at the end.  Each such packet is an individual ISO transfer.  Isochronous
 1395  * URBs are normally queued, submitted by drivers to arrange that
 1396  * transfers are at least double buffered, and then explicitly resubmitted
 1397  * in completion handlers, so
 1398  * that data (such as audio or video) streams at as constant a rate as the
 1399  * host controller scheduler can support.
 1400  *
 1401  * Completion Callbacks:
 1402  *
 1403  * The completion callback is made in_interrupt(), and one of the first
 1404  * things that a completion handler should do is check the status field.
 1405  * The status field is provided for all URBs.  It is used to report
 1406  * unlinked URBs, and status for all non-ISO transfers.  It should not
 1407  * be examined before the URB is returned to the completion handler.
 1408  *
 1409  * The context field is normally used to link URBs back to the relevant
 1410  * driver or request state.
 1411  *
 1412  * When the completion callback is invoked for non-isochronous URBs, the
 1413  * actual_length field tells how many bytes were transferred.  This field
 1414  * is updated even when the URB terminated with an error or was unlinked.
 1415  *
 1416  * ISO transfer status is reported in the status and actual_length fields
 1417  * of the iso_frame_desc array, and the number of errors is reported in
 1418  * error_count.  Completion callbacks for ISO transfers will normally
 1419  * (re)submit URBs to ensure a constant transfer rate.
 1420  *
 1421  * Note that even fields marked "public" should not be touched by the driver
 1422  * when the urb is owned by the hcd, that is, since the call to
 1423  * usb_submit_urb() till the entry into the completion routine.
 1424  */
 1425 struct urb {
 1426 	/* private: usb core and host controller only fields in the urb */
 1427 	struct kref kref;		/* reference count of the URB */
 1428 	void *hcpriv;			/* private data for host controller */
 1429 	atomic_t use_count;		/* concurrent submissions counter */
 1430 	atomic_t reject;		/* submissions will fail */
 1431 	int unlinked;			/* unlink error code */
 1432 
 1433 	/* public: documented fields in the urb that can be used by drivers */
 1434 	struct list_head urb_list;	/* list head for use by the urb's
 1435 					 * current owner */
 1436 	struct list_head anchor_list;	/* the URB may be anchored */
 1437 	struct usb_anchor *anchor;
 1438 	struct usb_device *dev;		/* (in) pointer to associated device */
 1439 	struct usb_host_endpoint *ep;	/* (internal) pointer to endpoint */
 1440 	unsigned int pipe;		/* (in) pipe information */
 1441 	unsigned int stream_id;		/* (in) stream ID */
 1442 	int status;			/* (return) non-ISO status */
 1443 	unsigned int transfer_flags;	/* (in) URB_SHORT_NOT_OK | ...*/
 1444 	void *transfer_buffer;		/* (in) associated data buffer */
 1445 	dma_addr_t transfer_dma;	/* (in) dma addr for transfer_buffer */
 1446 	struct scatterlist *sg;		/* (in) scatter gather buffer list */
 1447 	int num_mapped_sgs;		/* (internal) mapped sg entries */
 1448 	int num_sgs;			/* (in) number of entries in the sg list */
 1449 	u32 transfer_buffer_length;	/* (in) data buffer length */
 1450 	u32 actual_length;		/* (return) actual transfer length */
 1451 	unsigned char *setup_packet;	/* (in) setup packet (control only) */
 1452 	dma_addr_t setup_dma;		/* (in) dma addr for setup_packet */
 1453 	int start_frame;		/* (modify) start frame (ISO) */
 1454 	int number_of_packets;		/* (in) number of ISO packets */
 1455 	int interval;			/* (modify) transfer interval
 1456 					 * (INT/ISO) */
 1457 	int error_count;		/* (return) number of ISO errors */
 1458 	void *context;			/* (in) context for completion */
 1459 	usb_complete_t complete;	/* (in) completion routine */
 1460 	struct usb_iso_packet_descriptor iso_frame_desc[0];
 1461 					/* (in) ISO ONLY */
 1462 };
 1463 
 1464 /* ----------------------------------------------------------------------- */
 1465 
 1466 /**
 1467  * usb_fill_control_urb - initializes a control urb
 1468  * @urb: pointer to the urb to initialize.
 1469  * @dev: pointer to the struct usb_device for this urb.
 1470  * @pipe: the endpoint pipe
 1471  * @setup_packet: pointer to the setup_packet buffer
 1472  * @transfer_buffer: pointer to the transfer buffer
 1473  * @buffer_length: length of the transfer buffer
 1474  * @complete_fn: pointer to the usb_complete_t function
 1475  * @context: what to set the urb context to.
 1476  *
 1477  * Initializes a control urb with the proper information needed to submit
 1478  * it to a device.
 1479  */
 1480 static inline void usb_fill_control_urb(struct urb *urb,
 1481 					struct usb_device *dev,
 1482 					unsigned int pipe,
 1483 					unsigned char *setup_packet,
 1484 					void *transfer_buffer,
 1485 					int buffer_length,
 1486 					usb_complete_t complete_fn,
 1487 					void *context)
 1488 {
 1489 	urb->dev = dev;
 1490 	urb->pipe = pipe;
 1491 	urb->setup_packet = setup_packet;
 1492 	urb->transfer_buffer = transfer_buffer;
 1493 	urb->transfer_buffer_length = buffer_length;
 1494 	urb->complete = complete_fn;
 1495 	urb->context = context;
 1496 }
 1497 
 1498 /**
 1499  * usb_fill_bulk_urb - macro to help initialize a bulk urb
 1500  * @urb: pointer to the urb to initialize.
 1501  * @dev: pointer to the struct usb_device for this urb.
 1502  * @pipe: the endpoint pipe
 1503  * @transfer_buffer: pointer to the transfer buffer
 1504  * @buffer_length: length of the transfer buffer
 1505  * @complete_fn: pointer to the usb_complete_t function
 1506  * @context: what to set the urb context to.
 1507  *
 1508  * Initializes a bulk urb with the proper information needed to submit it
 1509  * to a device.
 1510  */
 1511 static inline void usb_fill_bulk_urb(struct urb *urb,
 1512 				     struct usb_device *dev,
 1513 				     unsigned int pipe,
 1514 				     void *transfer_buffer,
 1515 				     int buffer_length,
 1516 				     usb_complete_t complete_fn,
 1517 				     void *context)
 1518 {
 1519 	urb->dev = dev;
 1520 	urb->pipe = pipe;
 1521 	urb->transfer_buffer = transfer_buffer;
 1522 	urb->transfer_buffer_length = buffer_length;
 1523 	urb->complete = complete_fn;
 1524 	urb->context = context;
 1525 }
 1526 
 1527 /**
 1528  * usb_fill_int_urb - macro to help initialize a interrupt urb
 1529  * @urb: pointer to the urb to initialize.
 1530  * @dev: pointer to the struct usb_device for this urb.
 1531  * @pipe: the endpoint pipe
 1532  * @transfer_buffer: pointer to the transfer buffer
 1533  * @buffer_length: length of the transfer buffer
 1534  * @complete_fn: pointer to the usb_complete_t function
 1535  * @context: what to set the urb context to.
 1536  * @interval: what to set the urb interval to, encoded like
 1537  *	the endpoint descriptor's bInterval value.
 1538  *
 1539  * Initializes a interrupt urb with the proper information needed to submit
 1540  * it to a device.
 1541  *
 1542  * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic
 1543  * encoding of the endpoint interval, and express polling intervals in
 1544  * microframes (eight per millisecond) rather than in frames (one per
 1545  * millisecond).
 1546  *
 1547  * Wireless USB also uses the logarithmic encoding, but specifies it in units of
 1548  * 128us instead of 125us.  For Wireless USB devices, the interval is passed
 1549  * through to the host controller, rather than being translated into microframe
 1550  * units.
 1551  */
 1552 static inline void usb_fill_int_urb(struct urb *urb,
 1553 				    struct usb_device *dev,
 1554 				    unsigned int pipe,
 1555 				    void *transfer_buffer,
 1556 				    int buffer_length,
 1557 				    usb_complete_t complete_fn,
 1558 				    void *context,
 1559 				    int interval)
 1560 {
 1561 	urb->dev = dev;
 1562 	urb->pipe = pipe;
 1563 	urb->transfer_buffer = transfer_buffer;
 1564 	urb->transfer_buffer_length = buffer_length;
 1565 	urb->complete = complete_fn;
 1566 	urb->context = context;
 1567 
 1568 	if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) {
 1569 		/* make sure interval is within allowed range */
 1570 		interval = clamp(interval, 1, 16);
 1571 
 1572 		urb->interval = 1 << (interval - 1);
 1573 	} else {
 1574 		urb->interval = interval;
 1575 	}
 1576 
 1577 	urb->start_frame = -1;
 1578 }
 1579 
 1580 extern void usb_init_urb(struct urb *urb);
 1581 extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
 1582 extern void usb_free_urb(struct urb *urb);
 1583 #define usb_put_urb usb_free_urb
 1584 extern struct urb *usb_get_urb(struct urb *urb);
 1585 extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
 1586 extern int usb_unlink_urb(struct urb *urb);
 1587 extern void usb_kill_urb(struct urb *urb);
 1588 extern void usb_poison_urb(struct urb *urb);
 1589 extern void usb_unpoison_urb(struct urb *urb);
 1590 extern void usb_block_urb(struct urb *urb);
 1591 extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
 1592 extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
 1593 extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
 1594 extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor);
 1595 extern void usb_anchor_suspend_wakeups(struct usb_anchor *anchor);
 1596 extern void usb_anchor_resume_wakeups(struct usb_anchor *anchor);
 1597 extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor);
 1598 extern void usb_unanchor_urb(struct urb *urb);
 1599 extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
 1600 					 unsigned int timeout);
 1601 extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
 1602 extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
 1603 extern int usb_anchor_empty(struct usb_anchor *anchor);
 1604 
 1605 #define usb_unblock_urb	usb_unpoison_urb
 1606 
 1607 /**
 1608  * usb_urb_dir_in - check if an URB describes an IN transfer
 1609  * @urb: URB to be checked
 1610  *
 1611  * Return: 1 if @urb describes an IN transfer (device-to-host),
 1612  * otherwise 0.
 1613  */
 1614 static inline int usb_urb_dir_in(struct urb *urb)
 1615 {
 1616 	return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN;
 1617 }
 1618 
 1619 /**
 1620  * usb_urb_dir_out - check if an URB describes an OUT transfer
 1621  * @urb: URB to be checked
 1622  *
 1623  * Return: 1 if @urb describes an OUT transfer (host-to-device),
 1624  * otherwise 0.
 1625  */
 1626 static inline int usb_urb_dir_out(struct urb *urb)
 1627 {
 1628 	return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
 1629 }
 1630 
 1631 void *usb_alloc_coherent(struct usb_device *dev, size_t size,
 1632 	gfp_t mem_flags, dma_addr_t *dma);
 1633 void usb_free_coherent(struct usb_device *dev, size_t size,
 1634 	void *addr, dma_addr_t dma);
 1635 
 1636 #if 0
 1637 struct urb *usb_buffer_map(struct urb *urb);
 1638 void usb_buffer_dmasync(struct urb *urb);
 1639 void usb_buffer_unmap(struct urb *urb);
 1640 #endif
 1641 
 1642 struct scatterlist;
 1643 int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
 1644 		      struct scatterlist *sg, int nents);
 1645 #if 0
 1646 void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in,
 1647 			   struct scatterlist *sg, int n_hw_ents);
 1648 #endif
 1649 void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
 1650 			 struct scatterlist *sg, int n_hw_ents);
 1651 
 1652 /*-------------------------------------------------------------------*
 1653  *                         SYNCHRONOUS CALL SUPPORT                  *
 1654  *-------------------------------------------------------------------*/
 1655 
 1656 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
 1657 	__u8 request, __u8 requesttype, __u16 value, __u16 index,
 1658 	void *data, __u16 size, int timeout);
 1659 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
 1660 	void *data, int len, int *actual_length, int timeout);
 1661 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
 1662 	void *data, int len, int *actual_length,
 1663 	int timeout);
 1664 
 1665 /* wrappers around usb_control_msg() for the most common standard requests */
 1666 extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
 1667 	unsigned char descindex, void *buf, int size);
 1668 extern int usb_get_status(struct usb_device *dev,
 1669 	int type, int target, void *data);
 1670 extern int usb_string(struct usb_device *dev, int index,
 1671 	char *buf, size_t size);
 1672 
 1673 /* wrappers that also update important state inside usbcore */
 1674 extern int usb_clear_halt(struct usb_device *dev, int pipe);
 1675 extern int usb_reset_configuration(struct usb_device *dev);
 1676 extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
 1677 extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
 1678 
 1679 /* this request isn't really synchronous, but it belongs with the others */
 1680 extern int usb_driver_set_configuration(struct usb_device *udev, int config);
 1681 
 1682 /* choose and set configuration for device */
 1683 extern int usb_choose_configuration(struct usb_device *udev);
 1684 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 1685 
 1686 /*
 1687  * timeouts, in milliseconds, used for sending/receiving control messages
 1688  * they typically complete within a few frames (msec) after they're issued
 1689  * USB identifies 5 second timeouts, maybe more in a few cases, and a few
 1690  * slow devices (like some MGE Ellipse UPSes) actually push that limit.
 1691  */
 1692 #define USB_CTRL_GET_TIMEOUT	5000
 1693 #define USB_CTRL_SET_TIMEOUT	5000
 1694 
 1695 
 1696 /**
 1697  * struct usb_sg_request - support for scatter/gather I/O
 1698  * @status: zero indicates success, else negative errno
 1699  * @bytes: counts bytes transferred.
 1700  *
 1701  * These requests are initialized using usb_sg_init(), and then are used
 1702  * as request handles passed to usb_sg_wait() or usb_sg_cancel().  Most
 1703  * members of the request object aren't for driver access.
 1704  *
 1705  * The status and bytecount values are valid only after usb_sg_wait()
 1706  * returns.  If the status is zero, then the bytecount matches the total
 1707  * from the request.
 1708  *
 1709  * After an error completion, drivers may need to clear a halt condition
 1710  * on the endpoint.
 1711  */
 1712 struct usb_sg_request {
 1713 	int			status;
 1714 	size_t			bytes;
 1715 
 1716 	/* private:
 1717 	 * members below are private to usbcore,
 1718 	 * and are not provided for driver access!
 1719 	 */
 1720 	spinlock_t		lock;
 1721 
 1722 	struct usb_device	*dev;
 1723 	int			pipe;
 1724 
 1725 	int			entries;
 1726 	struct urb		**urbs;
 1727 
 1728 	int			count;
 1729 	struct completion	complete;
 1730 };
 1731 
 1732 int usb_sg_init(
 1733 	struct usb_sg_request	*io,
 1734 	struct usb_device	*dev,
 1735 	unsigned		pipe,
 1736 	unsigned		period,
 1737 	struct scatterlist	*sg,
 1738 	int			nents,
 1739 	size_t			length,
 1740 	gfp_t			mem_flags
 1741 );
 1742 void usb_sg_cancel(struct usb_sg_request *io);
 1743 void usb_sg_wait(struct usb_sg_request *io);
 1744 
 1745 
 1746 /* ----------------------------------------------------------------------- */
 1747 
 1748 /*
 1749  * For various legacy reasons, Linux has a small cookie that's paired with
 1750  * a struct usb_device to identify an endpoint queue.  Queue characteristics
 1751  * are defined by the endpoint's descriptor.  This cookie is called a "pipe",
 1752  * an unsigned int encoded as:
 1753  *
 1754  *  - direction:	bit 7		(0 = Host-to-Device [Out],
 1755  *					 1 = Device-to-Host [In] ...
 1756  *					like endpoint bEndpointAddress)
 1757  *  - device address:	bits 8-14       ... bit positions known to uhci-hcd
 1758  *  - endpoint:		bits 15-18      ... bit positions known to uhci-hcd
 1759  *  - pipe type:	bits 30-31	(00 = isochronous, 01 = interrupt,
 1760  *					 10 = control, 11 = bulk)
 1761  *
 1762  * Given the device address and endpoint descriptor, pipes are redundant.
 1763  */
 1764 
 1765 /* NOTE:  these are not the standard USB_ENDPOINT_XFER_* values!! */
 1766 /* (yet ... they're the values used by usbfs) */
 1767 #define PIPE_ISOCHRONOUS		0
 1768 #define PIPE_INTERRUPT			1
 1769 #define PIPE_CONTROL			2
 1770 #define PIPE_BULK			3
 1771 
 1772 #define usb_pipein(pipe)	((pipe) & USB_DIR_IN)
 1773 #define usb_pipeout(pipe)	(!usb_pipein(pipe))
 1774 
 1775 #define usb_pipedevice(pipe)	(((pipe) >> 8) & 0x7f)
 1776 #define usb_pipeendpoint(pipe)	(((pipe) >> 15) & 0xf)
 1777 
 1778 #define usb_pipetype(pipe)	(((pipe) >> 30) & 3)
 1779 #define usb_pipeisoc(pipe)	(usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
 1780 #define usb_pipeint(pipe)	(usb_pipetype((pipe)) == PIPE_INTERRUPT)
 1781 #define usb_pipecontrol(pipe)	(usb_pipetype((pipe)) == PIPE_CONTROL)
 1782 #define usb_pipebulk(pipe)	(usb_pipetype((pipe)) == PIPE_BULK)
 1783 
 1784 static inline unsigned int __create_pipe(struct usb_device *dev,
 1785 		unsigned int endpoint)
 1786 {
 1787 	return (dev->devnum << 8) | (endpoint << 15);
 1788 }
 1789 
 1790 /* Create various pipes... */
 1791 #define usb_sndctrlpipe(dev, endpoint)	\
 1792 	((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
 1793 #define usb_rcvctrlpipe(dev, endpoint)	\
 1794 	((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
 1795 #define usb_sndisocpipe(dev, endpoint)	\
 1796 	((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
 1797 #define usb_rcvisocpipe(dev, endpoint)	\
 1798 	((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
 1799 #define usb_sndbulkpipe(dev, endpoint)	\
 1800 	((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
 1801 #define usb_rcvbulkpipe(dev, endpoint)	\
 1802 	((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
 1803 #define usb_sndintpipe(dev, endpoint)	\
 1804 	((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
 1805 #define usb_rcvintpipe(dev, endpoint)	\
 1806 	((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
 1807 
 1808 static inline struct usb_host_endpoint *
 1809 usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)
 1810 {
 1811 	struct usb_host_endpoint **eps;
 1812 	eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out;
 1813 	return eps[usb_pipeendpoint(pipe)];
 1814 }
 1815 
 1816 /*-------------------------------------------------------------------------*/
 1817 
 1818 static inline __u16
 1819 usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
 1820 {
 1821 	struct usb_host_endpoint	*ep;
 1822 	unsigned			epnum = usb_pipeendpoint(pipe);
 1823 
 1824 	if (is_out) {
 1825 		WARN_ON(usb_pipein(pipe));
 1826 		ep = udev->ep_out[epnum];
 1827 	} else {
 1828 		WARN_ON(usb_pipeout(pipe));
 1829 		ep = udev->ep_in[epnum];
 1830 	}
 1831 	if (!ep)
 1832 		return 0;
 1833 
 1834 	/* NOTE:  only 0x07ff bits are for packet size... */
 1835 	return usb_endpoint_maxp(&ep->desc);
 1836 }
 1837 
 1838 /* ----------------------------------------------------------------------- */
 1839 
 1840 /* translate USB error codes to codes user space understands */
 1841 static inline int usb_translate_errors(int error_code)
 1842 {
 1843 	switch (error_code) {
 1844 	case 0:
 1845 	case -ENOMEM:
 1846 	case -ENODEV:
 1847 	case -EOPNOTSUPP:
 1848 		return error_code;
 1849 	default:
 1850 		return -EIO;
 1851 	}
 1852 }
 1853 
 1854 /* Events from the usb core */
 1855 #define USB_DEVICE_ADD		0x0001
 1856 #define USB_DEVICE_REMOVE	0x0002
 1857 #define USB_BUS_ADD		0x0003
 1858 #define USB_BUS_REMOVE		0x0004
 1859 extern void usb_register_notify(struct notifier_block *nb);
 1860 extern void usb_unregister_notify(struct notifier_block *nb);
 1861 
 1862 /* debugfs stuff */
 1863 extern struct dentry *usb_debug_root;
 1864 
 1865 #endif  /* __KERNEL__ */
 1866 
 1867 #endif                 1 #ifndef __SOUND_CORE_H
    2 #define __SOUND_CORE_H
    3 
    4 /*
    5  *  Main header file for the ALSA driver
    6  *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
   10  *   it under the terms of the GNU General Public License as published by
   11  *   the Free Software Foundation; either version 2 of the License, or
   12  *   (at your option) any later version.
   13  *
   14  *   This program is distributed in the hope that it will be useful,
   15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17  *   GNU General Public License for more details.
   18  *
   19  *   You should have received a copy of the GNU General Public License
   20  *   along with this program; if not, write to the Free Software
   21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   22  *
   23  */
   24 
   25 #include <linux/device.h>
   26 #include <linux/sched.h>		/* wake_up() */
   27 #include <linux/mutex.h>		/* struct mutex */
   28 #include <linux/rwsem.h>		/* struct rw_semaphore */
   29 #include <linux/pm.h>			/* pm_message_t */
   30 #include <linux/stringify.h>
   31 #include <linux/printk.h>
   32 
   33 /* number of supported soundcards */
   34 #ifdef CONFIG_SND_DYNAMIC_MINORS
   35 #define SNDRV_CARDS CONFIG_SND_MAX_CARDS
   36 #else
   37 #define SNDRV_CARDS 8		/* don't change - minor numbers */
   38 #endif
   39 
   40 #define CONFIG_SND_MAJOR	116	/* standard configuration */
   41 
   42 /* forward declarations */
   43 struct pci_dev;
   44 struct module;
   45 struct completion;
   46 
   47 /* device allocation stuff */
   48 
   49 /* type of the object used in snd_device_*()
   50  * this also defines the calling order
   51  */
   52 enum snd_device_type {
   53 	SNDRV_DEV_LOWLEVEL,
   54 	SNDRV_DEV_CONTROL,
   55 	SNDRV_DEV_INFO,
   56 	SNDRV_DEV_BUS,
   57 	SNDRV_DEV_CODEC,
   58 	SNDRV_DEV_PCM,
   59 	SNDRV_DEV_COMPRESS,
   60 	SNDRV_DEV_RAWMIDI,
   61 	SNDRV_DEV_TIMER,
   62 	SNDRV_DEV_SEQUENCER,
   63 	SNDRV_DEV_HWDEP,
   64 	SNDRV_DEV_JACK,
   65 };
   66 
   67 enum snd_device_state {
   68 	SNDRV_DEV_BUILD,
   69 	SNDRV_DEV_REGISTERED,
   70 	SNDRV_DEV_DISCONNECTED,
   71 };
   72 
   73 struct snd_device;
   74 
   75 struct snd_device_ops {
   76 	int (*dev_free)(struct snd_device *dev);
   77 	int (*dev_register)(struct snd_device *dev);
   78 	int (*dev_disconnect)(struct snd_device *dev);
   79 };
   80 
   81 struct snd_device {
   82 	struct list_head list;		/* list of registered devices */
   83 	struct snd_card *card;		/* card which holds this device */
   84 	enum snd_device_state state;	/* state of the device */
   85 	enum snd_device_type type;	/* device type */
   86 	void *device_data;		/* device structure */
   87 	struct snd_device_ops *ops;	/* operations */
   88 };
   89 
   90 #define snd_device(n) list_entry(n, struct snd_device, list)
   91 
   92 /* main structure for soundcard */
   93 
   94 struct snd_card {
   95 	int number;			/* number of soundcard (index to
   96 								snd_cards) */
   97 
   98 	char id[16];			/* id string of this card */
   99 	char driver[16];		/* driver name */
  100 	char shortname[32];		/* short name of this soundcard */
  101 	char longname[80];		/* name of this soundcard */
  102 	char mixername[80];		/* mixer name */
  103 	char components[128];		/* card components delimited with
  104 								space */
  105 	struct module *module;		/* top-level module */
  106 
  107 	void *private_data;		/* private data for soundcard */
  108 	void (*private_free) (struct snd_card *card); /* callback for freeing of
  109 								private data */
  110 	struct list_head devices;	/* devices */
  111 
  112 	unsigned int last_numid;	/* last used numeric ID */
  113 	struct rw_semaphore controls_rwsem;	/* controls list lock */
  114 	rwlock_t ctl_files_rwlock;	/* ctl_files list lock */
  115 	int controls_count;		/* count of all controls */
  116 	int user_ctl_count;		/* count of all user controls */
  117 	struct list_head controls;	/* all controls for this card */
  118 	struct list_head ctl_files;	/* active control files */
  119 
  120 	struct snd_info_entry *proc_root;	/* root for soundcard specific files */
  121 	struct snd_info_entry *proc_id;	/* the card id */
  122 	struct proc_dir_entry *proc_root_link;	/* number link to real id */
  123 
  124 	struct list_head files_list;	/* all files associated to this card */
  125 	struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown
  126 								state */
  127 	spinlock_t files_lock;		/* lock the files for this card */
  128 	int shutdown;			/* this card is going down */
  129 	struct completion *release_completion;
  130 	struct device *dev;		/* device assigned to this card */
  131 	struct device card_dev;		/* cardX object for sysfs */
  132 	bool registered;		/* card_dev is registered? */
  133 
  134 #ifdef CONFIG_PM
  135 	unsigned int power_state;	/* power state */
  136 	struct mutex power_lock;	/* power lock */
  137 	wait_queue_head_t power_sleep;
  138 #endif
  139 
  140 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
  141 	struct snd_mixer_oss *mixer_oss;
  142 	int mixer_oss_change_count;
  143 #endif
  144 };
  145 
  146 #define dev_to_snd_card(p)	container_of(p, struct snd_card, card_dev)
  147 
  148 #ifdef CONFIG_PM
  149 static inline void snd_power_lock(struct snd_card *card)
  150 {
  151 	mutex_lock(&card->power_lock);
  152 }
  153 
  154 static inline void snd_power_unlock(struct snd_card *card)
  155 {
  156 	mutex_unlock(&card->power_lock);
  157 }
  158 
  159 static inline unsigned int snd_power_get_state(struct snd_card *card)
  160 {
  161 	return card->power_state;
  162 }
  163 
  164 static inline void snd_power_change_state(struct snd_card *card, unsigned int state)
  165 {
  166 	card->power_state = state;
  167 	wake_up(&card->power_sleep);
  168 }
  169 
  170 /* init.c */
  171 int snd_power_wait(struct snd_card *card, unsigned int power_state);
  172 
  173 #else /* ! CONFIG_PM */
  174 
  175 #define snd_power_lock(card)		do { (void)(card); } while (0)
  176 #define snd_power_unlock(card)		do { (void)(card); } while (0)
  177 static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; }
  178 #define snd_power_get_state(card)	({ (void)(card); SNDRV_CTL_POWER_D0; })
  179 #define snd_power_change_state(card, state)	do { (void)(card); } while (0)
  180 
  181 #endif /* CONFIG_PM */
  182 
  183 struct snd_minor {
  184 	int type;			/* SNDRV_DEVICE_TYPE_XXX */
  185 	int card;			/* card number */
  186 	int device;			/* device number */
  187 	const struct file_operations *f_ops;	/* file operations */
  188 	void *private_data;		/* private data for f_ops->open */
  189 	struct device *dev;		/* device for sysfs */
  190 	struct snd_card *card_ptr;	/* assigned card instance */
  191 };
  192 
  193 /* return a device pointer linked to each sound device as a parent */
  194 static inline struct device *snd_card_get_device_link(struct snd_card *card)
  195 {
  196 	return card ? &card->card_dev : NULL;
  197 }
  198 
  199 /* sound.c */
  200 
  201 extern int snd_major;
  202 extern int snd_ecards_limit;
  203 extern struct class *sound_class;
  204 
  205 void snd_request_card(int card);
  206 
  207 int snd_register_device_for_dev(int type, struct snd_card *card,
  208 				int dev,
  209 				const struct file_operations *f_ops,
  210 				void *private_data,
  211 				const char *name,
  212 				struct device *device);
  213 
  214 /**
  215  * snd_register_device - Register the ALSA device file for the card
  216  * @type: the device type, SNDRV_DEVICE_TYPE_XXX
  217  * @card: the card instance
  218  * @dev: the device index
  219  * @f_ops: the file operations
  220  * @private_data: user pointer for f_ops->open()
  221  * @name: the device file name
  222  *
  223  * Registers an ALSA device file for the given card.
  224  * The operators have to be set in reg parameter.
  225  *
  226  * This function uses the card's device pointer to link to the
  227  * correct &struct device.
  228  *
  229  * Return: Zero if successful, or a negative error code on failure.
  230  */
  231 static inline int snd_register_device(int type, struct snd_card *card, int dev,
  232 				      const struct file_operations *f_ops,
  233 				      void *private_data,
  234 				      const char *name)
  235 {
  236 	return snd_register_device_for_dev(type, card, dev, f_ops,
  237 					   private_data, name,
  238 					   snd_card_get_device_link(card));
  239 }
  240 
  241 int snd_unregister_device(int type, struct snd_card *card, int dev);
  242 void *snd_lookup_minor_data(unsigned int minor, int type);
  243 struct device *snd_get_device(int type, struct snd_card *card, int dev);
  244 
  245 #ifdef CONFIG_SND_OSSEMUL
  246 int snd_register_oss_device(int type, struct snd_card *card, int dev,
  247 			    const struct file_operations *f_ops, void *private_data);
  248 int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
  249 void *snd_lookup_oss_minor_data(unsigned int minor, int type);
  250 #endif
  251 
  252 int snd_minor_info_init(void);
  253 int snd_minor_info_done(void);
  254 
  255 /* sound_oss.c */
  256 
  257 #ifdef CONFIG_SND_OSSEMUL
  258 int snd_minor_info_oss_init(void);
  259 int snd_minor_info_oss_done(void);
  260 #else
  261 static inline int snd_minor_info_oss_init(void) { return 0; }
  262 static inline int snd_minor_info_oss_done(void) { return 0; }
  263 #endif
  264 
  265 /* memory.c */
  266 
  267 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
  268 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
  269 
  270 /* init.c */
  271 
  272 extern struct snd_card *snd_cards[SNDRV_CARDS];
  273 int snd_card_locked(int card);
  274 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
  275 #define SND_MIXER_OSS_NOTIFY_REGISTER	0
  276 #define SND_MIXER_OSS_NOTIFY_DISCONNECT	1
  277 #define SND_MIXER_OSS_NOTIFY_FREE	2
  278 extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd);
  279 #endif
  280 
  281 int snd_card_new(struct device *parent, int idx, const char *xid,
  282 		 struct module *module, int extra_size,
  283 		 struct snd_card **card_ret);
  284 
  285 int snd_card_disconnect(struct snd_card *card);
  286 int snd_card_free(struct snd_card *card);
  287 int snd_card_free_when_closed(struct snd_card *card);
  288 void snd_card_set_id(struct snd_card *card, const char *id);
  289 int snd_card_register(struct snd_card *card);
  290 int snd_card_info_init(void);
  291 int snd_card_info_done(void);
  292 int snd_component_add(struct snd_card *card, const char *component);
  293 int snd_card_file_add(struct snd_card *card, struct file *file);
  294 int snd_card_file_remove(struct snd_card *card, struct file *file);
  295 #define snd_card_unref(card)	put_device(&(card)->card_dev)
  296 
  297 #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
  298 
  299 /* device.c */
  300 
  301 int snd_device_new(struct snd_card *card, enum snd_device_type type,
  302 		   void *device_data, struct snd_device_ops *ops);
  303 int snd_device_register(struct snd_card *card, void *device_data);
  304 int snd_device_register_all(struct snd_card *card);
  305 int snd_device_disconnect_all(struct snd_card *card);
  306 void snd_device_free(struct snd_card *card, void *device_data);
  307 void snd_device_free_all(struct snd_card *card);
  308 
  309 /* isadma.c */
  310 
  311 #ifdef CONFIG_ISA_DMA_API
  312 #define DMA_MODE_NO_ENABLE	0x0100
  313 
  314 void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode);
  315 void snd_dma_disable(unsigned long dma);
  316 unsigned int snd_dma_pointer(unsigned long dma, unsigned int size);
  317 #endif
  318 
  319 /* misc.c */
  320 struct resource;
  321 void release_and_free_resource(struct resource *res);
  322 
  323 /* --- */
  324 
  325 /* sound printk debug levels */
  326 enum {
  327 	SND_PR_ALWAYS,
  328 	SND_PR_DEBUG,
  329 	SND_PR_VERBOSE,
  330 };
  331 
  332 #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK)
  333 __printf(4, 5)
  334 void __snd_printk(unsigned int level, const char *file, int line,
  335 		  const char *format, ...);
  336 #else
  337 #define __snd_printk(level, file, line, format, args...) \
  338 	printk(format, ##args)
  339 #endif
  340 
  341 /**
  342  * snd_printk - printk wrapper
  343  * @fmt: format string
  344  *
  345  * Works like printk() but prints the file and the line of the caller
  346  * when configured with CONFIG_SND_VERBOSE_PRINTK.
  347  */
  348 #define snd_printk(fmt, args...) \
  349 	__snd_printk(0, __FILE__, __LINE__, fmt, ##args)
  350 
  351 #ifdef CONFIG_SND_DEBUG
  352 /**
  353  * snd_printd - debug printk
  354  * @fmt: format string
  355  *
  356  * Works like snd_printk() for debugging purposes.
  357  * Ignored when CONFIG_SND_DEBUG is not set.
  358  */
  359 #define snd_printd(fmt, args...) \
  360 	__snd_printk(1, __FILE__, __LINE__, fmt, ##args)
  361 #define _snd_printd(level, fmt, args...) \
  362 	__snd_printk(level, __FILE__, __LINE__, fmt, ##args)
  363 
  364 /**
  365  * snd_BUG - give a BUG warning message and stack trace
  366  *
  367  * Calls WARN() if CONFIG_SND_DEBUG is set.
  368  * Ignored when CONFIG_SND_DEBUG is not set.
  369  */
  370 #define snd_BUG()		WARN(1, "BUG?\n")
  371 
  372 /**
  373  * Suppress high rates of output when CONFIG_SND_DEBUG is enabled.
  374  */
  375 #define snd_printd_ratelimit() printk_ratelimit()
  376 
  377 /**
  378  * snd_BUG_ON - debugging check macro
  379  * @cond: condition to evaluate
  380  *
  381  * Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set,
  382  * otherwise just evaluates the conditional and returns the value.
  383  */
  384 #define snd_BUG_ON(cond)	WARN_ON((cond))
  385 
  386 #else /* !CONFIG_SND_DEBUG */
  387 
  388 __printf(1, 2)
  389 static inline void snd_printd(const char *format, ...) {}
  390 __printf(2, 3)
  391 static inline void _snd_printd(int level, const char *format, ...) {}
  392 
  393 #define snd_BUG()			do { } while (0)
  394 
  395 #define snd_BUG_ON(condition) ({ \
  396 	int __ret_warn_on = !!(condition); \
  397 	unlikely(__ret_warn_on); \
  398 })
  399 
  400 static inline bool snd_printd_ratelimit(void) { return false; }
  401 
  402 #endif /* CONFIG_SND_DEBUG */
  403 
  404 #ifdef CONFIG_SND_DEBUG_VERBOSE
  405 /**
  406  * snd_printdd - debug printk
  407  * @format: format string
  408  *
  409  * Works like snd_printk() for debugging purposes.
  410  * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
  411  */
  412 #define snd_printdd(format, args...) \
  413 	__snd_printk(2, __FILE__, __LINE__, format, ##args)
  414 #else
  415 __printf(1, 2)
  416 static inline void snd_printdd(const char *format, ...) {}
  417 #endif
  418 
  419 
  420 #define SNDRV_OSS_VERSION         ((3<<16)|(8<<8)|(1<<4)|(0))	/* 3.8.1a */
  421 
  422 /* for easier backward-porting */
  423 #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
  424 #define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev))
  425 #define gameport_set_port_data(gp,r) ((gp)->port_data = (r))
  426 #define gameport_get_port_data(gp) (gp)->port_data
  427 #endif
  428 
  429 /* PCI quirk list helper */
  430 struct snd_pci_quirk {
  431 	unsigned short subvendor;	/* PCI subvendor ID */
  432 	unsigned short subdevice;	/* PCI subdevice ID */
  433 	unsigned short subdevice_mask;	/* bitmask to match */
  434 	int value;			/* value */
  435 #ifdef CONFIG_SND_DEBUG_VERBOSE
  436 	const char *name;		/* name of the device (optional) */
  437 #endif
  438 };
  439 
  440 #define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev)	\
  441 	.subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask)
  442 #define _SND_PCI_QUIRK_ID(vend, dev) \
  443 	_SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev)
  444 #define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)}
  445 #ifdef CONFIG_SND_DEBUG_VERBOSE
  446 #define SND_PCI_QUIRK(vend,dev,xname,val) \
  447 	{_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)}
  448 #define SND_PCI_QUIRK_VENDOR(vend, xname, val)			\
  449 	{_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val), .name = (xname)}
  450 #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val)			\
  451 	{_SND_PCI_QUIRK_ID_MASK(vend, mask, dev),			\
  452 			.value = (val), .name = (xname)}
  453 #define snd_pci_quirk_name(q)	((q)->name)
  454 #else
  455 #define SND_PCI_QUIRK(vend,dev,xname,val) \
  456 	{_SND_PCI_QUIRK_ID(vend, dev), .value = (val)}
  457 #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val)			\
  458 	{_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)}
  459 #define SND_PCI_QUIRK_VENDOR(vend, xname, val)			\
  460 	{_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)}
  461 #define snd_pci_quirk_name(q)	""
  462 #endif
  463 
  464 #ifdef CONFIG_PCI
  465 const struct snd_pci_quirk *
  466 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
  467 
  468 const struct snd_pci_quirk *
  469 snd_pci_quirk_lookup_id(u16 vendor, u16 device,
  470 			const struct snd_pci_quirk *list);
  471 #else
  472 static inline const struct snd_pci_quirk *
  473 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
  474 {
  475 	return NULL;
  476 }
  477 
  478 static inline const struct snd_pci_quirk *
  479 snd_pci_quirk_lookup_id(u16 vendor, u16 device,
  480 			const struct snd_pci_quirk *list)
  481 {
  482 	return NULL;
  483 }
  484 #endif
  485 
  486 #endif /* __SOUND_CORE_H */            | 
Here is an explanation of a rule violation arisen while checking your driver against a corresponding kernel.
Note that it may be false positive, i.e. there isn't a real error indeed. Please analyze a given error trace and related source code to understand whether there is an error in your driver.
Error trace column contains a path on which the given rule is violated. You can expand/collapse some entity classes by clicking on corresponding checkboxes in a main menu or in an advanced Others menu. Also you can expand/collapse each particular entity by clicking on +/-. In hovering on some entities you can see some tips. Also the error trace is bound with related source code. Line numbers may be shown as links on the left. You can click on them to open corresponding lines in source code.
Source code column contains a content of files related with the error trace. There is source code of your driver (note that there are some LDV modifications at the end), kernel headers and rule model. Tabs show a currently opened file and other available files. In hovering on them you can see full file names. On clicking a corresponding file content will be shown.
| Ядро | Модуль | Правило | Верификатор | Вердикт | Статус | Время создания | Описание проблемы | 
| linux-3.16-rc1.tar.xz | drivers/staging/line6/line6usb.ko | 132_1a | CPAchecker | Bug | Fixed | 2015-03-11 15:38:56 | L0158 | 
Комментарий
L0158
[В начало]