aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt9
-rw-r--r--arch/frv/mm/fault.c8
-rw-r--r--arch/m32r/mm/fault.c14
-rw-r--r--arch/mn10300/mm/fault.c9
-rw-r--r--arch/um/kernel/skas/uaccess.c2
-rw-r--r--arch/xtensa/mm/fault.c14
-rw-r--r--drivers/acpi/ec.c22
-rw-r--r--drivers/acpi/internal.h5
-rw-r--r--drivers/acpi/processor_idle.c17
-rw-r--r--drivers/acpi/sleep.c57
-rw-r--r--drivers/char/Kconfig1
-rw-r--r--drivers/char/n_gsm.c9
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/char/vt_ioctl.c4
-rw-r--r--drivers/misc/vmware_balloon.c18
-rw-r--r--drivers/mmc/host/omap.c1
-rw-r--r--drivers/rtc/rtc-s3c.c9
-rw-r--r--drivers/serial/8250_pci.c71
-rw-r--r--drivers/serial/altera_uart.c44
-rw-r--r--drivers/serial/bfin_5xx.c9
-rw-r--r--drivers/serial/msm_serial.c21
-rw-r--r--drivers/serial/msm_serial.h56
-rw-r--r--drivers/serial/serial_cs.c18
-rw-r--r--drivers/sfi/sfi_core.c4
-rw-r--r--drivers/usb/class/cdc-acm.c6
-rw-r--r--drivers/usb/core/driver.c2
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/f_audio.c4
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c57
-rw-r--r--drivers/usb/host/ehci-hcd.c20
-rw-r--r--drivers/usb/host/isp1362.h2
-rw-r--r--drivers/usb/host/xhci-pci.c2
-rw-r--r--drivers/usb/host/xhci-ring.c31
-rw-r--r--drivers/usb/host/xhci.c57
-rw-r--r--drivers/usb/host/xhci.h12
-rw-r--r--drivers/usb/serial/digi_acceleport.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c4
-rw-r--r--drivers/usb/serial/mos7840.c1
-rw-r--r--drivers/video/Kconfig6
-rw-r--r--drivers/video/fb_defio.c52
-rw-r--r--fs/binfmt_flat.c25
-rw-r--r--fs/compat.c2
-rw-r--r--include/linux/personality.h2
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/usb/audio-v2.h31
-rw-r--r--include/linux/usb/audio.h90
-rw-r--r--kernel/cgroup.c2
-rw-r--r--kernel/exec_domain.c18
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/timer.c2
-rw-r--r--lib/atomic64_test.c3
-rw-r--r--mm/vmscan.c29
-rw-r--r--sound/pci/asihpi/asihpi.c3
-rw-r--r--sound/pci/hda/hda_intel.c7
-rw-r--r--sound/pci/hda/patch_realtek.c1
-rw-r--r--sound/soc/imx/Kconfig11
-rw-r--r--sound/usb/Makefile3
-rw-r--r--sound/usb/card.c18
-rw-r--r--sound/usb/card.h1
-rw-r--r--sound/usb/clock.c311
-rw-r--r--sound/usb/clock.h12
-rw-r--r--sound/usb/endpoint.c57
-rw-r--r--sound/usb/format.c16
-rw-r--r--sound/usb/mixer.c213
-rw-r--r--sound/usb/mixer.h2
-rw-r--r--sound/usb/mixer_maps.c4
-rw-r--r--sound/usb/pcm.c98
-rw-r--r--sound/usb/usbaudio.h5
68 files changed, 1153 insertions, 501 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 672be0109d02..c268783bc4e7 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -578,15 +578,6 @@ Who: Avi Kivity <avi@redhat.com>
578 578
579---------------------------- 579----------------------------
580 580
581What: "acpi=ht" boot option
582When: 2.6.35
583Why: Useful in 2003, implementation is a hack.
584 Generally invoked by accident today.
585 Seen as doing more harm than good.
586Who: Len Brown <len.brown@intel.com>
587
588----------------------------
589
590What: iwlwifi 50XX module parameters 581What: iwlwifi 50XX module parameters
591When: 2.6.40 582When: 2.6.40
592Why: The "..50" modules parameters were used to configure 5000 series and 583Why: The "..50" modules parameters were used to configure 5000 series and
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c
index 30f5d100a81c..a325d57a83d5 100644
--- a/arch/frv/mm/fault.c
+++ b/arch/frv/mm/fault.c
@@ -257,10 +257,10 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
257 */ 257 */
258 out_of_memory: 258 out_of_memory:
259 up_read(&mm->mmap_sem); 259 up_read(&mm->mmap_sem);
260 printk("VM: killing process %s\n", current->comm); 260 if (!user_mode(__frame))
261 if (user_mode(__frame)) 261 goto no_context;
262 do_group_exit(SIGKILL); 262 pagefault_out_of_memory();
263 goto no_context; 263 return;
264 264
265 do_sigbus: 265 do_sigbus:
266 up_read(&mm->mmap_sem); 266 up_read(&mm->mmap_sem);
diff --git a/arch/m32r/mm/fault.c b/arch/m32r/mm/fault.c
index 28ee389e5f5a..b8ec002aef8e 100644
--- a/arch/m32r/mm/fault.c
+++ b/arch/m32r/mm/fault.c
@@ -188,7 +188,6 @@ good_area:
188 if ((error_code & ACE_INSTRUCTION) && !(vma->vm_flags & VM_EXEC)) 188 if ((error_code & ACE_INSTRUCTION) && !(vma->vm_flags & VM_EXEC))
189 goto bad_area; 189 goto bad_area;
190 190
191survive:
192 /* 191 /*
193 * If for any reason at all we couldn't handle the fault, 192 * If for any reason at all we couldn't handle the fault,
194 * make sure we exit gracefully rather than endlessly redo 193 * make sure we exit gracefully rather than endlessly redo
@@ -271,15 +270,10 @@ no_context:
271 */ 270 */
272out_of_memory: 271out_of_memory:
273 up_read(&mm->mmap_sem); 272 up_read(&mm->mmap_sem);
274 if (is_global_init(tsk)) { 273 if (!(error_code & ACE_USERMODE))
275 yield(); 274 goto no_context;
276 down_read(&mm->mmap_sem); 275 pagefault_out_of_memory();
277 goto survive; 276 return;
278 }
279 printk("VM: killing process %s\n", tsk->comm);
280 if (error_code & ACE_USERMODE)
281 do_group_exit(SIGKILL);
282 goto no_context;
283 277
284do_sigbus: 278do_sigbus:
285 up_read(&mm->mmap_sem); 279 up_read(&mm->mmap_sem);
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index 53bb17d0f068..81f153fa51b4 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -338,11 +338,10 @@ no_context:
338 */ 338 */
339out_of_memory: 339out_of_memory:
340 up_read(&mm->mmap_sem); 340 up_read(&mm->mmap_sem);
341 monitor_signal(regs); 341 if ((fault_code & MMUFCR_xFC_ACCESS) != MMUFCR_xFC_ACCESS_USR)
342 printk(KERN_ALERT "VM: killing process %s\n", tsk->comm); 342 goto no_context;
343 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) 343 pagefault_out_of_memory();
344 do_exit(SIGKILL); 344 return;
345 goto no_context;
346 345
347do_sigbus: 346do_sigbus:
348 up_read(&mm->mmap_sem); 347 up_read(&mm->mmap_sem);
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index e22c96993db3..696634214dc6 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -81,7 +81,7 @@ static int do_op_one_page(unsigned long addr, int len, int is_write,
81 81
82 current->thread.fault_catcher = NULL; 82 current->thread.fault_catcher = NULL;
83 83
84 kunmap_atomic(page, KM_UML_USERCOPY); 84 kunmap_atomic((void *)addr, KM_UML_USERCOPY);
85 85
86 return n; 86 return n;
87} 87}
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c
index bc0733359a88..e367e3026436 100644
--- a/arch/xtensa/mm/fault.c
+++ b/arch/xtensa/mm/fault.c
@@ -105,7 +105,6 @@ good_area:
105 * make sure we exit gracefully rather than endlessly redo 105 * make sure we exit gracefully rather than endlessly redo
106 * the fault. 106 * the fault.
107 */ 107 */
108survive:
109 fault = handle_mm_fault(mm, vma, address, is_write ? FAULT_FLAG_WRITE : 0); 108 fault = handle_mm_fault(mm, vma, address, is_write ? FAULT_FLAG_WRITE : 0);
110 if (unlikely(fault & VM_FAULT_ERROR)) { 109 if (unlikely(fault & VM_FAULT_ERROR)) {
111 if (fault & VM_FAULT_OOM) 110 if (fault & VM_FAULT_OOM)
@@ -146,15 +145,10 @@ bad_area:
146 */ 145 */
147out_of_memory: 146out_of_memory:
148 up_read(&mm->mmap_sem); 147 up_read(&mm->mmap_sem);
149 if (is_global_init(current)) { 148 if (!user_mode(regs))
150 yield(); 149 bad_page_fault(regs, address, SIGKILL);
151 down_read(&mm->mmap_sem); 150 else
152 goto survive; 151 pagefault_out_of_memory();
153 }
154 printk("VM: killing process %s\n", current->comm);
155 if (user_mode(regs))
156 do_group_exit(SIGKILL);
157 bad_page_fault(regs, address, SIGKILL);
158 return; 152 return;
159 153
160do_sigbus: 154do_sigbus:
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e61d4f8e62a5..5f2027d782e8 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -79,7 +79,7 @@ enum {
79 EC_FLAGS_GPE_STORM, /* GPE storm detected */ 79 EC_FLAGS_GPE_STORM, /* GPE storm detected */
80 EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and 80 EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and
81 * OpReg are installed */ 81 * OpReg are installed */
82 EC_FLAGS_FROZEN, /* Transactions are suspended */ 82 EC_FLAGS_BLOCKED, /* Transactions are blocked */
83}; 83};
84 84
85/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 85/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -293,7 +293,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
293 if (t->rdata) 293 if (t->rdata)
294 memset(t->rdata, 0, t->rlen); 294 memset(t->rdata, 0, t->rlen);
295 mutex_lock(&ec->lock); 295 mutex_lock(&ec->lock);
296 if (test_bit(EC_FLAGS_FROZEN, &ec->flags)) { 296 if (test_bit(EC_FLAGS_BLOCKED, &ec->flags)) {
297 status = -EINVAL; 297 status = -EINVAL;
298 goto unlock; 298 goto unlock;
299 } 299 }
@@ -459,7 +459,7 @@ int ec_transaction(u8 command,
459 459
460EXPORT_SYMBOL(ec_transaction); 460EXPORT_SYMBOL(ec_transaction);
461 461
462void acpi_ec_suspend_transactions(void) 462void acpi_ec_block_transactions(void)
463{ 463{
464 struct acpi_ec *ec = first_ec; 464 struct acpi_ec *ec = first_ec;
465 465
@@ -468,11 +468,11 @@ void acpi_ec_suspend_transactions(void)
468 468
469 mutex_lock(&ec->lock); 469 mutex_lock(&ec->lock);
470 /* Prevent transactions from being carried out */ 470 /* Prevent transactions from being carried out */
471 set_bit(EC_FLAGS_FROZEN, &ec->flags); 471 set_bit(EC_FLAGS_BLOCKED, &ec->flags);
472 mutex_unlock(&ec->lock); 472 mutex_unlock(&ec->lock);
473} 473}
474 474
475void acpi_ec_resume_transactions(void) 475void acpi_ec_unblock_transactions(void)
476{ 476{
477 struct acpi_ec *ec = first_ec; 477 struct acpi_ec *ec = first_ec;
478 478
@@ -481,10 +481,20 @@ void acpi_ec_resume_transactions(void)
481 481
482 mutex_lock(&ec->lock); 482 mutex_lock(&ec->lock);
483 /* Allow transactions to be carried out again */ 483 /* Allow transactions to be carried out again */
484 clear_bit(EC_FLAGS_FROZEN, &ec->flags); 484 clear_bit(EC_FLAGS_BLOCKED, &ec->flags);
485 mutex_unlock(&ec->lock); 485 mutex_unlock(&ec->lock);
486} 486}
487 487
488void acpi_ec_unblock_transactions_early(void)
489{
490 /*
491 * Allow transactions to happen again (this function is called from
492 * atomic context during wakeup, so we don't need to acquire the mutex).
493 */
494 if (first_ec)
495 clear_bit(EC_FLAGS_BLOCKED, &first_ec->flags);
496}
497
488static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) 498static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data)
489{ 499{
490 int result; 500 int result;
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index e28411367239..f8f190ec066e 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -49,8 +49,9 @@ void acpi_early_processor_set_pdc(void);
49int acpi_ec_init(void); 49int acpi_ec_init(void);
50int acpi_ec_ecdt_probe(void); 50int acpi_ec_ecdt_probe(void);
51int acpi_boot_ec_enable(void); 51int acpi_boot_ec_enable(void);
52void acpi_ec_suspend_transactions(void); 52void acpi_ec_block_transactions(void);
53void acpi_ec_resume_transactions(void); 53void acpi_ec_unblock_transactions(void);
54void acpi_ec_unblock_transactions_early(void);
54 55
55/*-------------------------------------------------------------------------- 56/*--------------------------------------------------------------------------
56 Suspend/Resume 57 Suspend/Resume
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 2e8c27d48f2b..b1b385692f46 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -80,7 +80,7 @@ module_param(nocst, uint, 0000);
80static unsigned int latency_factor __read_mostly = 2; 80static unsigned int latency_factor __read_mostly = 2;
81module_param(latency_factor, uint, 0644); 81module_param(latency_factor, uint, 0644);
82 82
83static s64 us_to_pm_timer_ticks(s64 t) 83static u64 us_to_pm_timer_ticks(s64 t)
84{ 84{
85 return div64_u64(t * PM_TIMER_FREQUENCY, 1000000); 85 return div64_u64(t * PM_TIMER_FREQUENCY, 1000000);
86} 86}
@@ -731,10 +731,10 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
731 731
732 seq_puts(seq, "demotion[--] "); 732 seq_puts(seq, "demotion[--] ");
733 733
734 seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n", 734 seq_printf(seq, "latency[%03d] usage[%08d] duration[%020Lu]\n",
735 pr->power.states[i].latency, 735 pr->power.states[i].latency,
736 pr->power.states[i].usage, 736 pr->power.states[i].usage,
737 (unsigned long long)pr->power.states[i].time); 737 us_to_pm_timer_ticks(pr->power.states[i].time));
738 } 738 }
739 739
740 end: 740 end:
@@ -861,7 +861,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
861 ktime_t kt1, kt2; 861 ktime_t kt1, kt2;
862 s64 idle_time_ns; 862 s64 idle_time_ns;
863 s64 idle_time; 863 s64 idle_time;
864 s64 sleep_ticks = 0;
865 864
866 pr = __get_cpu_var(processors); 865 pr = __get_cpu_var(processors);
867 866
@@ -906,8 +905,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
906 idle_time = idle_time_ns; 905 idle_time = idle_time_ns;
907 do_div(idle_time, NSEC_PER_USEC); 906 do_div(idle_time, NSEC_PER_USEC);
908 907
909 sleep_ticks = us_to_pm_timer_ticks(idle_time);
910
911 /* Tell the scheduler how much we idled: */ 908 /* Tell the scheduler how much we idled: */
912 sched_clock_idle_wakeup_event(idle_time_ns); 909 sched_clock_idle_wakeup_event(idle_time_ns);
913 910
@@ -918,7 +915,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
918 cx->usage++; 915 cx->usage++;
919 916
920 lapic_timer_state_broadcast(pr, cx, 0); 917 lapic_timer_state_broadcast(pr, cx, 0);
921 cx->time += sleep_ticks; 918 cx->time += idle_time;
922 return idle_time; 919 return idle_time;
923} 920}
924 921
@@ -940,7 +937,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
940 ktime_t kt1, kt2; 937 ktime_t kt1, kt2;
941 s64 idle_time_ns; 938 s64 idle_time_ns;
942 s64 idle_time; 939 s64 idle_time;
943 s64 sleep_ticks = 0;
944 940
945 941
946 pr = __get_cpu_var(processors); 942 pr = __get_cpu_var(processors);
@@ -1022,11 +1018,10 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1022 spin_unlock(&c3_lock); 1018 spin_unlock(&c3_lock);
1023 } 1019 }
1024 kt2 = ktime_get_real(); 1020 kt2 = ktime_get_real();
1025 idle_time_ns = ktime_to_us(ktime_sub(kt2, kt1)); 1021 idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1));
1026 idle_time = idle_time_ns; 1022 idle_time = idle_time_ns;
1027 do_div(idle_time, NSEC_PER_USEC); 1023 do_div(idle_time, NSEC_PER_USEC);
1028 1024
1029 sleep_ticks = us_to_pm_timer_ticks(idle_time);
1030 /* Tell the scheduler how much we idled: */ 1025 /* Tell the scheduler how much we idled: */
1031 sched_clock_idle_wakeup_event(idle_time_ns); 1026 sched_clock_idle_wakeup_event(idle_time_ns);
1032 1027
@@ -1037,7 +1032,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1037 cx->usage++; 1032 cx->usage++;
1038 1033
1039 lapic_timer_state_broadcast(pr, cx, 0); 1034 lapic_timer_state_broadcast(pr, cx, 0);
1040 cx->time += sleep_ticks; 1035 cx->time += idle_time;
1041 return idle_time; 1036 return idle_time;
1042} 1037}
1043 1038
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 4ab2275b4461..3fb4bdea7e06 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -94,11 +94,13 @@ void __init acpi_old_suspend_ordering(void)
94} 94}
95 95
96/** 96/**
97 * acpi_pm_disable_gpes - Disable the GPEs. 97 * acpi_pm_freeze - Disable the GPEs and suspend EC transactions.
98 */ 98 */
99static int acpi_pm_disable_gpes(void) 99static int acpi_pm_freeze(void)
100{ 100{
101 acpi_disable_all_gpes(); 101 acpi_disable_all_gpes();
102 acpi_os_wait_events_complete(NULL);
103 acpi_ec_block_transactions();
102 return 0; 104 return 0;
103} 105}
104 106
@@ -126,7 +128,8 @@ static int acpi_pm_prepare(void)
126 int error = __acpi_pm_prepare(); 128 int error = __acpi_pm_prepare();
127 129
128 if (!error) 130 if (!error)
129 acpi_disable_all_gpes(); 131 acpi_pm_freeze();
132
130 return error; 133 return error;
131} 134}
132 135
@@ -256,6 +259,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
256 * acpi_leave_sleep_state will reenable specific GPEs later 259 * acpi_leave_sleep_state will reenable specific GPEs later
257 */ 260 */
258 acpi_disable_all_gpes(); 261 acpi_disable_all_gpes();
262 /* Allow EC transactions to happen. */
263 acpi_ec_unblock_transactions_early();
259 264
260 local_irq_restore(flags); 265 local_irq_restore(flags);
261 printk(KERN_DEBUG "Back to C!\n"); 266 printk(KERN_DEBUG "Back to C!\n");
@@ -267,6 +272,12 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
267 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 272 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
268} 273}
269 274
275static void acpi_suspend_finish(void)
276{
277 acpi_ec_unblock_transactions();
278 acpi_pm_finish();
279}
280
270static int acpi_suspend_state_valid(suspend_state_t pm_state) 281static int acpi_suspend_state_valid(suspend_state_t pm_state)
271{ 282{
272 u32 acpi_state; 283 u32 acpi_state;
@@ -288,7 +299,7 @@ static struct platform_suspend_ops acpi_suspend_ops = {
288 .begin = acpi_suspend_begin, 299 .begin = acpi_suspend_begin,
289 .prepare_late = acpi_pm_prepare, 300 .prepare_late = acpi_pm_prepare,
290 .enter = acpi_suspend_enter, 301 .enter = acpi_suspend_enter,
291 .wake = acpi_pm_finish, 302 .wake = acpi_suspend_finish,
292 .end = acpi_pm_end, 303 .end = acpi_pm_end,
293}; 304};
294 305
@@ -314,9 +325,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
314static struct platform_suspend_ops acpi_suspend_ops_old = { 325static struct platform_suspend_ops acpi_suspend_ops_old = {
315 .valid = acpi_suspend_state_valid, 326 .valid = acpi_suspend_state_valid,
316 .begin = acpi_suspend_begin_old, 327 .begin = acpi_suspend_begin_old,
317 .prepare_late = acpi_pm_disable_gpes, 328 .prepare_late = acpi_pm_freeze,
318 .enter = acpi_suspend_enter, 329 .enter = acpi_suspend_enter,
319 .wake = acpi_pm_finish, 330 .wake = acpi_suspend_finish,
320 .end = acpi_pm_end, 331 .end = acpi_pm_end,
321 .recover = acpi_pm_finish, 332 .recover = acpi_pm_finish,
322}; 333};
@@ -433,6 +444,7 @@ static int acpi_hibernation_enter(void)
433static void acpi_hibernation_finish(void) 444static void acpi_hibernation_finish(void)
434{ 445{
435 hibernate_nvs_free(); 446 hibernate_nvs_free();
447 acpi_ec_unblock_transactions();
436 acpi_pm_finish(); 448 acpi_pm_finish();
437} 449}
438 450
@@ -453,19 +465,13 @@ static void acpi_hibernation_leave(void)
453 } 465 }
454 /* Restore the NVS memory area */ 466 /* Restore the NVS memory area */
455 hibernate_nvs_restore(); 467 hibernate_nvs_restore();
468 /* Allow EC transactions to happen. */
469 acpi_ec_unblock_transactions_early();
456} 470}
457 471
458static int acpi_pm_pre_restore(void) 472static void acpi_pm_thaw(void)
459{
460 acpi_disable_all_gpes();
461 acpi_os_wait_events_complete(NULL);
462 acpi_ec_suspend_transactions();
463 return 0;
464}
465
466static void acpi_pm_restore_cleanup(void)
467{ 473{
468 acpi_ec_resume_transactions(); 474 acpi_ec_unblock_transactions();
469 acpi_enable_all_runtime_gpes(); 475 acpi_enable_all_runtime_gpes();
470} 476}
471 477
@@ -477,8 +483,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
477 .prepare = acpi_pm_prepare, 483 .prepare = acpi_pm_prepare,
478 .enter = acpi_hibernation_enter, 484 .enter = acpi_hibernation_enter,
479 .leave = acpi_hibernation_leave, 485 .leave = acpi_hibernation_leave,
480 .pre_restore = acpi_pm_pre_restore, 486 .pre_restore = acpi_pm_freeze,
481 .restore_cleanup = acpi_pm_restore_cleanup, 487 .restore_cleanup = acpi_pm_thaw,
482}; 488};
483 489
484/** 490/**
@@ -510,12 +516,9 @@ static int acpi_hibernation_begin_old(void)
510 516
511static int acpi_hibernation_pre_snapshot_old(void) 517static int acpi_hibernation_pre_snapshot_old(void)
512{ 518{
513 int error = acpi_pm_disable_gpes(); 519 acpi_pm_freeze();
514 520 hibernate_nvs_save();
515 if (!error) 521 return 0;
516 hibernate_nvs_save();
517
518 return error;
519} 522}
520 523
521/* 524/*
@@ -527,11 +530,11 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
527 .end = acpi_pm_end, 530 .end = acpi_pm_end,
528 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 531 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
529 .finish = acpi_hibernation_finish, 532 .finish = acpi_hibernation_finish,
530 .prepare = acpi_pm_disable_gpes, 533 .prepare = acpi_pm_freeze,
531 .enter = acpi_hibernation_enter, 534 .enter = acpi_hibernation_enter,
532 .leave = acpi_hibernation_leave, 535 .leave = acpi_hibernation_leave,
533 .pre_restore = acpi_pm_pre_restore, 536 .pre_restore = acpi_pm_freeze,
534 .restore_cleanup = acpi_pm_restore_cleanup, 537 .restore_cleanup = acpi_pm_thaw,
535 .recover = acpi_pm_finish, 538 .recover = acpi_pm_finish,
536}; 539};
537#endif /* CONFIG_HIBERNATION */ 540#endif /* CONFIG_HIBERNATION */
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index f09fc0e2062d..7cfcc629a7fd 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1123,6 +1123,7 @@ source "drivers/s390/char/Kconfig"
1123 1123
1124config RAMOOPS 1124config RAMOOPS
1125 tristate "Log panic/oops to a RAM buffer" 1125 tristate "Log panic/oops to a RAM buffer"
1126 depends on HAS_IOMEM
1126 default n 1127 default n
1127 help 1128 help
1128 This enables panic and oops messages to be logged to a circular 1129 This enables panic and oops messages to be logged to a circular
diff --git a/drivers/char/n_gsm.c b/drivers/char/n_gsm.c
index c4161d5e053d..e4089c432f15 100644
--- a/drivers/char/n_gsm.c
+++ b/drivers/char/n_gsm.c
@@ -904,9 +904,7 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
904 int len; 904 int len;
905 /* Priority ordering: We should do priority with RR of the groups */ 905 /* Priority ordering: We should do priority with RR of the groups */
906 int i = 1; 906 int i = 1;
907 unsigned long flags;
908 907
909 spin_lock_irqsave(&gsm->tx_lock, flags);
910 while (i < NUM_DLCI) { 908 while (i < NUM_DLCI) {
911 struct gsm_dlci *dlci; 909 struct gsm_dlci *dlci;
912 910
@@ -927,7 +925,6 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
927 if (len == 0) 925 if (len == 0)
928 i++; 926 i++;
929 } 927 }
930 spin_unlock_irqrestore(&gsm->tx_lock, flags);
931} 928}
932 929
933/** 930/**
@@ -2230,12 +2227,16 @@ static int gsmld_open(struct tty_struct *tty)
2230static void gsmld_write_wakeup(struct tty_struct *tty) 2227static void gsmld_write_wakeup(struct tty_struct *tty)
2231{ 2228{
2232 struct gsm_mux *gsm = tty->disc_data; 2229 struct gsm_mux *gsm = tty->disc_data;
2230 unsigned long flags;
2233 2231
2234 /* Queue poll */ 2232 /* Queue poll */
2235 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 2233 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
2236 gsm_data_kick(gsm); 2234 gsm_data_kick(gsm);
2237 if (gsm->tx_bytes < TX_THRESH_LO) 2235 if (gsm->tx_bytes < TX_THRESH_LO) {
2236 spin_lock_irqsave(&gsm->tx_lock, flags);
2238 gsm_dlci_data_sweep(gsm); 2237 gsm_dlci_data_sweep(gsm);
2238 spin_unlock_irqrestore(&gsm->tx_lock, flags);
2239 }
2239} 2240}
2240 2241
2241/** 2242/**
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 7cdb6ee569cd..1296c42ed5c6 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -304,7 +304,7 @@ static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr)
304 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); 304 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t);
305 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); 305 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr));
306 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); 306 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row);
307 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char, 307 scr_memsetw(d + (b - t - nr) * vc->vc_size_row, vc->vc_video_erase_char,
308 vc->vc_size_row * nr); 308 vc->vc_size_row * nr);
309} 309}
310 310
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 6aa10284104a..cb19dbc52136 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -1303,7 +1303,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1303 if (!perm) 1303 if (!perm)
1304 goto eperm; 1304 goto eperm;
1305 ret = copy_from_user(&ui, up, sizeof(struct unimapinit)); 1305 ret = copy_from_user(&ui, up, sizeof(struct unimapinit));
1306 if (!ret) 1306 if (ret)
1307 ret = -EFAULT;
1308 else
1307 con_clear_unimap(vc, &ui); 1309 con_clear_unimap(vc, &ui);
1308 break; 1310 break;
1309 } 1311 }
diff --git a/drivers/misc/vmware_balloon.c b/drivers/misc/vmware_balloon.c
index db9cd0240c6f..2a1e804a71aa 100644
--- a/drivers/misc/vmware_balloon.c
+++ b/drivers/misc/vmware_balloon.c
@@ -45,7 +45,7 @@
45 45
46MODULE_AUTHOR("VMware, Inc."); 46MODULE_AUTHOR("VMware, Inc.");
47MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); 47MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
48MODULE_VERSION("1.2.1.0-K"); 48MODULE_VERSION("1.2.1.1-k");
49MODULE_ALIAS("dmi:*:svnVMware*:*"); 49MODULE_ALIAS("dmi:*:svnVMware*:*");
50MODULE_ALIAS("vmware_vmmemctl"); 50MODULE_ALIAS("vmware_vmmemctl");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
@@ -101,6 +101,8 @@ MODULE_LICENSE("GPL");
101/* Maximum number of page allocations without yielding processor */ 101/* Maximum number of page allocations without yielding processor */
102#define VMW_BALLOON_YIELD_THRESHOLD 1024 102#define VMW_BALLOON_YIELD_THRESHOLD 1024
103 103
104/* Maximum number of refused pages we accumulate during inflation cycle */
105#define VMW_BALLOON_MAX_REFUSED 16
104 106
105/* 107/*
106 * Hypervisor communication port definitions. 108 * Hypervisor communication port definitions.
@@ -183,6 +185,7 @@ struct vmballoon {
183 185
184 /* transient list of non-balloonable pages */ 186 /* transient list of non-balloonable pages */
185 struct list_head refused_pages; 187 struct list_head refused_pages;
188 unsigned int n_refused_pages;
186 189
187 /* balloon size in pages */ 190 /* balloon size in pages */
188 unsigned int size; 191 unsigned int size;
@@ -428,14 +431,21 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
428 /* inform monitor */ 431 /* inform monitor */
429 locked = vmballoon_send_lock_page(b, page_to_pfn(page)); 432 locked = vmballoon_send_lock_page(b, page_to_pfn(page));
430 if (!locked) { 433 if (!locked) {
434 STATS_INC(b->stats.refused_alloc);
435
431 if (b->reset_required) { 436 if (b->reset_required) {
432 __free_page(page); 437 __free_page(page);
433 return -EIO; 438 return -EIO;
434 } 439 }
435 440
436 /* place on list of non-balloonable pages, retry allocation */ 441 /*
442 * Place page on the list of non-balloonable pages
443 * and retry allocation, unless we already accumulated
444 * too many of them, in which case take a breather.
445 */
437 list_add(&page->lru, &b->refused_pages); 446 list_add(&page->lru, &b->refused_pages);
438 STATS_INC(b->stats.refused_alloc); 447 if (++b->n_refused_pages >= VMW_BALLOON_MAX_REFUSED)
448 return -EIO;
439 } 449 }
440 } while (!locked); 450 } while (!locked);
441 451
@@ -483,6 +493,8 @@ static void vmballoon_release_refused_pages(struct vmballoon *b)
483 __free_page(page); 493 __free_page(page);
484 STATS_INC(b->stats.refused_free); 494 STATS_INC(b->stats.refused_free);
485 } 495 }
496
497 b->n_refused_pages = 0;
486} 498}
487 499
488/* 500/*
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 2b281680e320..d98ddcfac5e5 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1157,7 +1157,6 @@ static void mmc_omap_start_request(struct mmc_omap_host *host,
1157 mmc_omap_start_command(host, req->cmd); 1157 mmc_omap_start_command(host, req->cmd);
1158 if (host->dma_in_use) 1158 if (host->dma_in_use)
1159 omap_start_dma(host->dma_ch); 1159 omap_start_dma(host->dma_ch);
1160 BUG_ON(irqs_disabled());
1161} 1160}
1162 1161
1163static void mmc_omap_request(struct mmc_host *mmc, struct mmc_request *req) 1162static void mmc_omap_request(struct mmc_host *mmc, struct mmc_request *req)
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index e5972b2c17b7..70b68d35f969 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -495,8 +495,6 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
495 pr_debug("s3c2410_rtc: RTCCON=%02x\n", 495 pr_debug("s3c2410_rtc: RTCCON=%02x\n",
496 readb(s3c_rtc_base + S3C2410_RTCCON)); 496 readb(s3c_rtc_base + S3C2410_RTCCON));
497 497
498 s3c_rtc_setfreq(&pdev->dev, 1);
499
500 device_init_wakeup(&pdev->dev, 1); 498 device_init_wakeup(&pdev->dev, 1);
501 499
502 /* register RTC and exit */ 500 /* register RTC and exit */
@@ -510,14 +508,17 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
510 goto err_nortc; 508 goto err_nortc;
511 } 509 }
512 510
511 s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
512
513 if (s3c_rtc_cpu_type == TYPE_S3C64XX) 513 if (s3c_rtc_cpu_type == TYPE_S3C64XX)
514 rtc->max_user_freq = 32768; 514 rtc->max_user_freq = 32768;
515 else 515 else
516 rtc->max_user_freq = 128; 516 rtc->max_user_freq = 128;
517 517
518 s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
519
520 platform_set_drvdata(pdev, rtc); 518 platform_set_drvdata(pdev, rtc);
519
520 s3c_rtc_setfreq(&pdev->dev, 1);
521
521 return 0; 522 return 0;
522 523
523 err_nortc: 524 err_nortc:
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 01c012da4e26..746a44621d91 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -982,6 +982,18 @@ static int skip_tx_en_setup(struct serial_private *priv,
982#define PCI_SUBDEVICE_ID_POCTAL422 0x0408 982#define PCI_SUBDEVICE_ID_POCTAL422 0x0408
983#define PCI_VENDOR_ID_ADVANTECH 0x13fe 983#define PCI_VENDOR_ID_ADVANTECH 0x13fe
984#define PCI_DEVICE_ID_ADVANTECH_PCI3620 0x3620 984#define PCI_DEVICE_ID_ADVANTECH_PCI3620 0x3620
985#define PCI_DEVICE_ID_TITAN_200I 0x8028
986#define PCI_DEVICE_ID_TITAN_400I 0x8048
987#define PCI_DEVICE_ID_TITAN_800I 0x8088
988#define PCI_DEVICE_ID_TITAN_800EH 0xA007
989#define PCI_DEVICE_ID_TITAN_800EHB 0xA008
990#define PCI_DEVICE_ID_TITAN_400EH 0xA009
991#define PCI_DEVICE_ID_TITAN_100E 0xA010
992#define PCI_DEVICE_ID_TITAN_200E 0xA012
993#define PCI_DEVICE_ID_TITAN_400E 0xA013
994#define PCI_DEVICE_ID_TITAN_800E 0xA014
995#define PCI_DEVICE_ID_TITAN_200EI 0xA016
996#define PCI_DEVICE_ID_TITAN_200EISI 0xA017
985 997
986/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ 998/* Unknown vendors/cards - this should not be in linux/pci_ids.h */
987#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 999#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
@@ -1541,6 +1553,10 @@ enum pci_board_num_t {
1541 pbn_b3_4_115200, 1553 pbn_b3_4_115200,
1542 pbn_b3_8_115200, 1554 pbn_b3_8_115200,
1543 1555
1556 pbn_b4_bt_2_921600,
1557 pbn_b4_bt_4_921600,
1558 pbn_b4_bt_8_921600,
1559
1544 /* 1560 /*
1545 * Board-specific versions. 1561 * Board-specific versions.
1546 */ 1562 */
@@ -1995,6 +2011,25 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1995 .uart_offset = 8, 2011 .uart_offset = 8,
1996 }, 2012 },
1997 2013
2014 [pbn_b4_bt_2_921600] = {
2015 .flags = FL_BASE4,
2016 .num_ports = 2,
2017 .base_baud = 921600,
2018 .uart_offset = 8,
2019 },
2020 [pbn_b4_bt_4_921600] = {
2021 .flags = FL_BASE4,
2022 .num_ports = 4,
2023 .base_baud = 921600,
2024 .uart_offset = 8,
2025 },
2026 [pbn_b4_bt_8_921600] = {
2027 .flags = FL_BASE4,
2028 .num_ports = 8,
2029 .base_baud = 921600,
2030 .uart_offset = 8,
2031 },
2032
1998 /* 2033 /*
1999 * Entries following this are board-specific. 2034 * Entries following this are board-specific.
2000 */ 2035 */
@@ -3043,6 +3078,42 @@ static struct pci_device_id serial_pci_tbl[] = {
3043 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800L, 3078 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800L,
3044 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3079 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3045 pbn_b0_bt_8_921600 }, 3080 pbn_b0_bt_8_921600 },
3081 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200I,
3082 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3083 pbn_b4_bt_2_921600 },
3084 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400I,
3085 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3086 pbn_b4_bt_4_921600 },
3087 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800I,
3088 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3089 pbn_b4_bt_8_921600 },
3090 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400EH,
3091 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3092 pbn_b0_4_921600 },
3093 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800EH,
3094 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3095 pbn_b0_4_921600 },
3096 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800EHB,
3097 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3098 pbn_b0_4_921600 },
3099 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_100E,
3100 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3101 pbn_oxsemi_1_4000000 },
3102 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200E,
3103 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3104 pbn_oxsemi_2_4000000 },
3105 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400E,
3106 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3107 pbn_oxsemi_4_4000000 },
3108 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800E,
3109 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3110 pbn_oxsemi_8_4000000 },
3111 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EI,
3112 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3113 pbn_oxsemi_2_4000000 },
3114 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EISI,
3115 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3116 pbn_oxsemi_2_4000000 },
3046 3117
3047 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_10x_550, 3118 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_10x_550,
3048 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3119 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index bcee156d2f2e..0f1189605d21 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -89,15 +89,12 @@ static unsigned int altera_uart_tx_empty(struct uart_port *port)
89static unsigned int altera_uart_get_mctrl(struct uart_port *port) 89static unsigned int altera_uart_get_mctrl(struct uart_port *port)
90{ 90{
91 struct altera_uart *pp = container_of(port, struct altera_uart, port); 91 struct altera_uart *pp = container_of(port, struct altera_uart, port);
92 unsigned long flags;
93 unsigned int sigs; 92 unsigned int sigs;
94 93
95 spin_lock_irqsave(&port->lock, flags);
96 sigs = 94 sigs =
97 (readl(port->membase + ALTERA_UART_STATUS_REG) & 95 (readl(port->membase + ALTERA_UART_STATUS_REG) &
98 ALTERA_UART_STATUS_CTS_MSK) ? TIOCM_CTS : 0; 96 ALTERA_UART_STATUS_CTS_MSK) ? TIOCM_CTS : 0;
99 sigs |= (pp->sigs & TIOCM_RTS); 97 sigs |= (pp->sigs & TIOCM_RTS);
100 spin_unlock_irqrestore(&port->lock, flags);
101 98
102 return sigs; 99 return sigs;
103} 100}
@@ -105,49 +102,37 @@ static unsigned int altera_uart_get_mctrl(struct uart_port *port)
105static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs) 102static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs)
106{ 103{
107 struct altera_uart *pp = container_of(port, struct altera_uart, port); 104 struct altera_uart *pp = container_of(port, struct altera_uart, port);
108 unsigned long flags;
109 105
110 spin_lock_irqsave(&port->lock, flags);
111 pp->sigs = sigs; 106 pp->sigs = sigs;
112 if (sigs & TIOCM_RTS) 107 if (sigs & TIOCM_RTS)
113 pp->imr |= ALTERA_UART_CONTROL_RTS_MSK; 108 pp->imr |= ALTERA_UART_CONTROL_RTS_MSK;
114 else 109 else
115 pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK; 110 pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK;
116 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 111 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
117 spin_unlock_irqrestore(&port->lock, flags);
118} 112}
119 113
120static void altera_uart_start_tx(struct uart_port *port) 114static void altera_uart_start_tx(struct uart_port *port)
121{ 115{
122 struct altera_uart *pp = container_of(port, struct altera_uart, port); 116 struct altera_uart *pp = container_of(port, struct altera_uart, port);
123 unsigned long flags;
124 117
125 spin_lock_irqsave(&port->lock, flags);
126 pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK; 118 pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK;
127 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 119 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
128 spin_unlock_irqrestore(&port->lock, flags);
129} 120}
130 121
131static void altera_uart_stop_tx(struct uart_port *port) 122static void altera_uart_stop_tx(struct uart_port *port)
132{ 123{
133 struct altera_uart *pp = container_of(port, struct altera_uart, port); 124 struct altera_uart *pp = container_of(port, struct altera_uart, port);
134 unsigned long flags;
135 125
136 spin_lock_irqsave(&port->lock, flags);
137 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; 126 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
138 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 127 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
139 spin_unlock_irqrestore(&port->lock, flags);
140} 128}
141 129
142static void altera_uart_stop_rx(struct uart_port *port) 130static void altera_uart_stop_rx(struct uart_port *port)
143{ 131{
144 struct altera_uart *pp = container_of(port, struct altera_uart, port); 132 struct altera_uart *pp = container_of(port, struct altera_uart, port);
145 unsigned long flags;
146 133
147 spin_lock_irqsave(&port->lock, flags);
148 pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK; 134 pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK;
149 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 135 writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
150 spin_unlock_irqrestore(&port->lock, flags);
151} 136}
152 137
153static void altera_uart_break_ctl(struct uart_port *port, int break_state) 138static void altera_uart_break_ctl(struct uart_port *port, int break_state)
@@ -272,10 +257,14 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data)
272 unsigned int isr; 257 unsigned int isr;
273 258
274 isr = readl(port->membase + ALTERA_UART_STATUS_REG) & pp->imr; 259 isr = readl(port->membase + ALTERA_UART_STATUS_REG) & pp->imr;
260
261 spin_lock(&port->lock);
275 if (isr & ALTERA_UART_STATUS_RRDY_MSK) 262 if (isr & ALTERA_UART_STATUS_RRDY_MSK)
276 altera_uart_rx_chars(pp); 263 altera_uart_rx_chars(pp);
277 if (isr & ALTERA_UART_STATUS_TRDY_MSK) 264 if (isr & ALTERA_UART_STATUS_TRDY_MSK)
278 altera_uart_tx_chars(pp); 265 altera_uart_tx_chars(pp);
266 spin_unlock(&port->lock);
267
279 return IRQ_RETVAL(isr); 268 return IRQ_RETVAL(isr);
280} 269}
281 270
@@ -402,31 +391,24 @@ int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp)
402 return 0; 391 return 0;
403} 392}
404 393
405static void altera_uart_console_putc(struct console *co, const char c) 394static void altera_uart_console_putc(struct uart_port *port, const char c)
406{ 395{
407 struct uart_port *port = &(altera_uart_ports + co->index)->port; 396 while (!(readl(port->membase + ALTERA_UART_STATUS_REG) &
408 int i; 397 ALTERA_UART_STATUS_TRDY_MSK))
398 cpu_relax();
409 399
410 for (i = 0; i < 0x10000; i++) {
411 if (readl(port->membase + ALTERA_UART_STATUS_REG) &
412 ALTERA_UART_STATUS_TRDY_MSK)
413 break;
414 }
415 writel(c, port->membase + ALTERA_UART_TXDATA_REG); 400 writel(c, port->membase + ALTERA_UART_TXDATA_REG);
416 for (i = 0; i < 0x10000; i++) {
417 if (readl(port->membase + ALTERA_UART_STATUS_REG) &
418 ALTERA_UART_STATUS_TRDY_MSK)
419 break;
420 }
421} 401}
422 402
423static void altera_uart_console_write(struct console *co, const char *s, 403static void altera_uart_console_write(struct console *co, const char *s,
424 unsigned int count) 404 unsigned int count)
425{ 405{
406 struct uart_port *port = &(altera_uart_ports + co->index)->port;
407
426 for (; count; count--, s++) { 408 for (; count; count--, s++) {
427 altera_uart_console_putc(co, *s); 409 altera_uart_console_putc(port, *s);
428 if (*s == '\n') 410 if (*s == '\n')
429 altera_uart_console_putc(co, '\r'); 411 altera_uart_console_putc(port, '\r');
430 } 412 }
431} 413}
432 414
@@ -516,7 +498,7 @@ static int __devinit altera_uart_probe(struct platform_device *pdev)
516 return 0; 498 return 0;
517} 499}
518 500
519static int altera_uart_remove(struct platform_device *pdev) 501static int __devexit altera_uart_remove(struct platform_device *pdev)
520{ 502{
521 struct uart_port *port; 503 struct uart_port *port;
522 int i; 504 int i;
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 96f7e7484fee..511cbf687877 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -797,7 +797,7 @@ static void bfin_serial_shutdown(struct uart_port *port)
797 gpio_free(uart->rts_pin); 797 gpio_free(uart->rts_pin);
798#endif 798#endif
799#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS 799#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
800 if (UART_GET_IER(uart) && EDSSI) 800 if (UART_GET_IER(uart) & EDSSI)
801 free_irq(uart->status_irq, uart); 801 free_irq(uart->status_irq, uart);
802#endif 802#endif
803} 803}
@@ -869,7 +869,12 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
869 } 869 }
870 870
871 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 871 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
872 quot = uart_get_divisor(port, baud) - ANOMALY_05000230; 872 quot = uart_get_divisor(port, baud);
873
874 /* If discipline is not IRDA, apply ANOMALY_05000230 */
875 if (termios->c_line != N_IRDA)
876 quot -= ANOMALY_05000230;
877
873 spin_lock_irqsave(&uart->port.lock, flags); 878 spin_lock_irqsave(&uart->port.lock, flags);
874 879
875 UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15); 880 UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
diff --git a/drivers/serial/msm_serial.c b/drivers/serial/msm_serial.c
index ecdc0facf7ee..f8c816e7725d 100644
--- a/drivers/serial/msm_serial.c
+++ b/drivers/serial/msm_serial.c
@@ -41,19 +41,6 @@ struct msm_port {
41 unsigned int imr; 41 unsigned int imr;
42}; 42};
43 43
44#define UART_TO_MSM(uart_port) ((struct msm_port *) uart_port)
45
46static inline void msm_write(struct uart_port *port, unsigned int val,
47 unsigned int off)
48{
49 __raw_writel(val, port->membase + off);
50}
51
52static inline unsigned int msm_read(struct uart_port *port, unsigned int off)
53{
54 return __raw_readl(port->membase + off);
55}
56
57static void msm_stop_tx(struct uart_port *port) 44static void msm_stop_tx(struct uart_port *port)
58{ 45{
59 struct msm_port *msm_port = UART_TO_MSM(port); 46 struct msm_port *msm_port = UART_TO_MSM(port);
@@ -320,11 +307,7 @@ static void msm_init_clock(struct uart_port *port)
320 struct msm_port *msm_port = UART_TO_MSM(port); 307 struct msm_port *msm_port = UART_TO_MSM(port);
321 308
322 clk_enable(msm_port->clk); 309 clk_enable(msm_port->clk);
323 310 msm_serial_set_mnd_regs(port);
324 msm_write(port, 0xC0, UART_MREG);
325 msm_write(port, 0xB2, UART_NREG);
326 msm_write(port, 0x7D, UART_DREG);
327 msm_write(port, 0x1C, UART_MNDREG);
328} 311}
329 312
330static int msm_startup(struct uart_port *port) 313static int msm_startup(struct uart_port *port)
@@ -706,6 +689,8 @@ static int __init msm_serial_probe(struct platform_device *pdev)
706 if (unlikely(IS_ERR(msm_port->clk))) 689 if (unlikely(IS_ERR(msm_port->clk)))
707 return PTR_ERR(msm_port->clk); 690 return PTR_ERR(msm_port->clk);
708 port->uartclk = clk_get_rate(msm_port->clk); 691 port->uartclk = clk_get_rate(msm_port->clk);
692 printk(KERN_INFO "uartclk = %d\n", port->uartclk);
693
709 694
710 resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); 695 resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
711 if (unlikely(!resource)) 696 if (unlikely(!resource))
diff --git a/drivers/serial/msm_serial.h b/drivers/serial/msm_serial.h
index 689f1fa0e84e..f6ca9ca79e98 100644
--- a/drivers/serial/msm_serial.h
+++ b/drivers/serial/msm_serial.h
@@ -114,4 +114,60 @@
114#define UART_MISR 0x0010 114#define UART_MISR 0x0010
115#define UART_ISR 0x0014 115#define UART_ISR 0x0014
116 116
117#define UART_TO_MSM(uart_port) ((struct msm_port *) uart_port)
118
119static inline
120void msm_write(struct uart_port *port, unsigned int val, unsigned int off)
121{
122 __raw_writel(val, port->membase + off);
123}
124
125static inline
126unsigned int msm_read(struct uart_port *port, unsigned int off)
127{
128 return __raw_readl(port->membase + off);
129}
130
131/*
132 * Setup the MND registers to use the TCXO clock.
133 */
134static inline void msm_serial_set_mnd_regs_tcxo(struct uart_port *port)
135{
136 msm_write(port, 0x06, UART_MREG);
137 msm_write(port, 0xF1, UART_NREG);
138 msm_write(port, 0x0F, UART_DREG);
139 msm_write(port, 0x1A, UART_MNDREG);
140}
141
142/*
143 * Setup the MND registers to use the TCXO clock divided by 4.
144 */
145static inline void msm_serial_set_mnd_regs_tcxoby4(struct uart_port *port)
146{
147 msm_write(port, 0x18, UART_MREG);
148 msm_write(port, 0xF6, UART_NREG);
149 msm_write(port, 0x0F, UART_DREG);
150 msm_write(port, 0x0A, UART_MNDREG);
151}
152
153static inline
154void msm_serial_set_mnd_regs_from_uartclk(struct uart_port *port)
155{
156 if (port->uartclk == 19200000)
157 msm_serial_set_mnd_regs_tcxo(port);
158 else
159 msm_serial_set_mnd_regs_tcxoby4(port);
160}
161
162/*
163 * TROUT has a specific defect that makes it report it's uartclk
164 * as 19.2Mhz (TCXO) when it's actually 4.8Mhz (TCXO/4). This special
165 * cases TROUT to use the right clock.
166 */
167#ifdef CONFIG_MACH_TROUT
168#define msm_serial_set_mnd_regs msm_serial_set_mnd_regs_tcxoby4
169#else
170#define msm_serial_set_mnd_regs msm_serial_set_mnd_regs_from_uartclk
171#endif
172
117#endif /* __DRIVERS_SERIAL_MSM_SERIAL_H */ 173#endif /* __DRIVERS_SERIAL_MSM_SERIAL_H */
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index dadd686c9801..526307368f8b 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -715,6 +715,8 @@ static struct pcmcia_device_id serial_ids[] = {
715 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), 715 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021),
716 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), 716 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a),
717 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0104, 0x000a), 717 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0104, 0x000a),
718 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a),
719 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a),
718 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0xea15), 720 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0xea15),
719 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0109, 0x0501), 721 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0109, 0x0501),
720 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0138, 0x110a), 722 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0138, 0x110a),
@@ -724,8 +726,6 @@ static struct pcmcia_device_id serial_ids[] = {
724 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081), 726 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081),
725 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101), 727 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101),
726 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab), 728 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab),
727 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a),
728 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a),
729 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63), 729 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63),
730 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63), 730 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63),
731 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef), 731 PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef),
@@ -768,17 +768,26 @@ static struct pcmcia_device_id serial_ids[] = {
768 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x0276), 768 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x0276),
769 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039), 769 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039),
770 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006), 770 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006),
771 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0101), /* TDK DF2814 */
772 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x100a), /* Xircom CM-56G */
773 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x3e0a), /* TDK DF5660 */
771 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a), 774 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a),
775 PCMCIA_DEVICE_MANF_CARD(0x0107, 0x0002), /* USRobotics 14,400 */
772 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d50), 776 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d50),
773 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d51), 777 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d51),
774 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d52), 778 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d52),
775 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d53), 779 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d53),
776 PCMCIA_DEVICE_MANF_CARD(0x010b, 0xd180), 780 PCMCIA_DEVICE_MANF_CARD(0x010b, 0xd180),
781 PCMCIA_DEVICE_MANF_CARD(0x0115, 0x3330), /* USRobotics/SUN 14,400 */
782 PCMCIA_DEVICE_MANF_CARD(0x0124, 0x0100), /* Nokia DTP-2 ver II */
783 PCMCIA_DEVICE_MANF_CARD(0x0134, 0x5600), /* LASAT COMMUNICATIONS A/S */
777 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x000e), 784 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x000e),
778 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x001b), 785 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x001b),
779 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0025), 786 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0025),
780 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0045), 787 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0045),
781 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0052), 788 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0052),
789 PCMCIA_DEVICE_MANF_CARD(0x016c, 0x0006), /* Psion 56K+Fax */
790 PCMCIA_DEVICE_MANF_CARD(0x0200, 0x0001), /* MultiMobile */
782 PCMCIA_DEVICE_PROD_ID134("ADV", "TECH", "COMpad-32/85", 0x67459937, 0x916d02ba, 0x8fbe92ae), 791 PCMCIA_DEVICE_PROD_ID134("ADV", "TECH", "COMpad-32/85", 0x67459937, 0x916d02ba, 0x8fbe92ae),
783 PCMCIA_DEVICE_PROD_ID124("GATEWAY2000", "CC3144", "PCMCIA MODEM", 0x506bccae, 0xcb3685f1, 0xbd6c43ef), 792 PCMCIA_DEVICE_PROD_ID124("GATEWAY2000", "CC3144", "PCMCIA MODEM", 0x506bccae, 0xcb3685f1, 0xbd6c43ef),
784 PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef), 793 PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef),
@@ -792,16 +801,21 @@ static struct pcmcia_device_id serial_ids[] = {
792 PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 33600 FAX/DATA MODEM", 0xa3a3062c, 0x5a00ce95), 801 PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 33600 FAX/DATA MODEM", 0xa3a3062c, 0x5a00ce95),
793 PCMCIA_DEVICE_PROD_ID12("Computerboards, Inc.", "PCM-COM422", 0xd0b78f51, 0x7e2d49ed), 802 PCMCIA_DEVICE_PROD_ID12("Computerboards, Inc.", "PCM-COM422", 0xd0b78f51, 0x7e2d49ed),
794 PCMCIA_DEVICE_PROD_ID12("Dr. Neuhaus", "FURY CARD 14K4", 0x76942813, 0x8b96ce65), 803 PCMCIA_DEVICE_PROD_ID12("Dr. Neuhaus", "FURY CARD 14K4", 0x76942813, 0x8b96ce65),
804 PCMCIA_DEVICE_PROD_ID12("IBM", "ISDN/56K/GSM", 0xb569a6e5, 0xfee5297b),
795 PCMCIA_DEVICE_PROD_ID12("Intelligent", "ANGIA FAX/MODEM", 0xb496e65e, 0xf31602a6), 805 PCMCIA_DEVICE_PROD_ID12("Intelligent", "ANGIA FAX/MODEM", 0xb496e65e, 0xf31602a6),
796 PCMCIA_DEVICE_PROD_ID12("Intel", "MODEM 2400+", 0x816cc815, 0x412729fb), 806 PCMCIA_DEVICE_PROD_ID12("Intel", "MODEM 2400+", 0x816cc815, 0x412729fb),
807 PCMCIA_DEVICE_PROD_ID12("Intertex", "IX34-PCMCIA", 0xf8a097e3, 0x97880447),
797 PCMCIA_DEVICE_PROD_ID12("IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card", 0x3bd2d898, 0x92abc92f), 808 PCMCIA_DEVICE_PROD_ID12("IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card", 0x3bd2d898, 0x92abc92f),
798 PCMCIA_DEVICE_PROD_ID12("MACRONIX", "FAX/MODEM", 0x668388b3, 0x3f9bdf2f), 809 PCMCIA_DEVICE_PROD_ID12("MACRONIX", "FAX/MODEM", 0x668388b3, 0x3f9bdf2f),
799 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT1432LT", 0x5f73be51, 0x0b3e2383), 810 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT1432LT", 0x5f73be51, 0x0b3e2383),
800 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e), 811 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e),
801 PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a), 812 PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a),
813 PCMCIA_DEVICE_PROD_ID12("Option International", "V34bis GSM/PSTN Data/Fax Modem", 0x9d7cd6f5, 0x5cb8bf41),
802 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), 814 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab),
803 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), 815 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
804 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), 816 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d),
817 PCMCIA_DEVICE_PROD_ID12("Telia", "SurfinBird 560P/A+", 0xe2cdd5e, 0xc9314b38),
818 PCMCIA_DEVICE_PROD_ID1("Smart Serial Port", 0x2d8ce292),
805 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"), 819 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"),
806 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"), 820 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"),
807 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), 821 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c
index 005195958647..ceba593dc84f 100644
--- a/drivers/sfi/sfi_core.c
+++ b/drivers/sfi/sfi_core.c
@@ -441,8 +441,10 @@ struct sfi_table_attr __init *sfi_sysfs_install_table(u64 pa)
441 441
442 ret = sysfs_create_bin_file(tables_kobj, 442 ret = sysfs_create_bin_file(tables_kobj,
443 &tbl_attr->attr); 443 &tbl_attr->attr);
444 if (ret) 444 if (ret) {
445 kfree(tbl_attr); 445 kfree(tbl_attr);
446 tbl_attr = NULL;
447 }
446 448
447 sfi_unmap_table(th); 449 sfi_unmap_table(th);
448 return tbl_attr; 450 return tbl_attr;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0c2f14ff9696..61d75507d5d0 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1201,7 +1201,7 @@ made_compressed_probe:
1201 if (rcv->urb == NULL) { 1201 if (rcv->urb == NULL) {
1202 dev_dbg(&intf->dev, 1202 dev_dbg(&intf->dev,
1203 "out of memory (read urbs usb_alloc_urb)\n"); 1203 "out of memory (read urbs usb_alloc_urb)\n");
1204 goto alloc_fail7; 1204 goto alloc_fail6;
1205 } 1205 }
1206 1206
1207 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1207 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
@@ -1225,7 +1225,7 @@ made_compressed_probe:
1225 if (snd->urb == NULL) { 1225 if (snd->urb == NULL) {
1226 dev_dbg(&intf->dev, 1226 dev_dbg(&intf->dev,
1227 "out of memory (write urbs usb_alloc_urb)"); 1227 "out of memory (write urbs usb_alloc_urb)");
1228 goto alloc_fail7; 1228 goto alloc_fail8;
1229 } 1229 }
1230 1230
1231 if (usb_endpoint_xfer_int(epwrite)) 1231 if (usb_endpoint_xfer_int(epwrite))
@@ -1264,6 +1264,7 @@ made_compressed_probe:
1264 i = device_create_file(&intf->dev, 1264 i = device_create_file(&intf->dev,
1265 &dev_attr_iCountryCodeRelDate); 1265 &dev_attr_iCountryCodeRelDate);
1266 if (i < 0) { 1266 if (i < 0) {
1267 device_remove_file(&intf->dev, &dev_attr_wCountryCodes);
1267 kfree(acm->country_codes); 1268 kfree(acm->country_codes);
1268 goto skip_countries; 1269 goto skip_countries;
1269 } 1270 }
@@ -1300,6 +1301,7 @@ alloc_fail8:
1300 usb_free_urb(acm->wb[i].urb); 1301 usb_free_urb(acm->wb[i].urb);
1301alloc_fail7: 1302alloc_fail7:
1302 acm_read_buffers_free(acm); 1303 acm_read_buffers_free(acm);
1304alloc_fail6:
1303 for (i = 0; i < num_rx_buf; i++) 1305 for (i = 0; i < num_rx_buf; i++)
1304 usb_free_urb(acm->ru[i].urb); 1306 usb_free_urb(acm->ru[i].urb);
1305 usb_free_urb(acm->ctrlurb); 1307 usb_free_urb(acm->ctrlurb);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index ded550eda5d9..de98a94d1853 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1328,6 +1328,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
1328 1328
1329 /* For all other calls, take the device back to full power and 1329 /* For all other calls, take the device back to full power and
1330 * tell the PM core in case it was autosuspended previously. 1330 * tell the PM core in case it was autosuspended previously.
1331 * Unbind the interfaces that will need rebinding later.
1331 */ 1332 */
1332 } else { 1333 } else {
1333 status = usb_resume_both(udev, msg); 1334 status = usb_resume_both(udev, msg);
@@ -1336,6 +1337,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
1336 pm_runtime_set_active(dev); 1337 pm_runtime_set_active(dev);
1337 pm_runtime_enable(dev); 1338 pm_runtime_enable(dev);
1338 udev->last_busy = jiffies; 1339 udev->last_busy = jiffies;
1340 do_unbind_rebind(udev, DO_REBIND);
1339 } 1341 }
1340 } 1342 }
1341 1343
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 649c0c5f7158..591ae9fde199 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -295,6 +295,7 @@ config USB_GADGET_S3C_HSOTG
295 boolean "S3C HS/OtG USB Device controller" 295 boolean "S3C HS/OtG USB Device controller"
296 depends on S3C_DEV_USB_HSOTG 296 depends on S3C_DEV_USB_HSOTG
297 select USB_GADGET_S3C_HSOTG_PIO 297 select USB_GADGET_S3C_HSOTG_PIO
298 select USB_GADGET_DUALSPEED
298 help 299 help
299 The Samsung S3C64XX USB2.0 high-speed gadget controller 300 The Samsung S3C64XX USB2.0 high-speed gadget controller
300 integrated into the S3C64XX series SoC. 301 integrated into the S3C64XX series SoC.
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c
index 43bf44514c41..b91115f84b13 100644
--- a/drivers/usb/gadget/f_audio.c
+++ b/drivers/usb/gadget/f_audio.c
@@ -101,7 +101,7 @@ static struct uac_feature_unit_descriptor_0 feature_unit_desc = {
101static struct usb_audio_control mute_control = { 101static struct usb_audio_control mute_control = {
102 .list = LIST_HEAD_INIT(mute_control.list), 102 .list = LIST_HEAD_INIT(mute_control.list),
103 .name = "Mute Control", 103 .name = "Mute Control",
104 .type = UAC_MUTE_CONTROL, 104 .type = UAC_FU_MUTE,
105 /* Todo: add real Mute control code */ 105 /* Todo: add real Mute control code */
106 .set = generic_set_cmd, 106 .set = generic_set_cmd,
107 .get = generic_get_cmd, 107 .get = generic_get_cmd,
@@ -110,7 +110,7 @@ static struct usb_audio_control mute_control = {
110static struct usb_audio_control volume_control = { 110static struct usb_audio_control volume_control = {
111 .list = LIST_HEAD_INIT(volume_control.list), 111 .list = LIST_HEAD_INIT(volume_control.list),
112 .name = "Volume Control", 112 .name = "Volume Control",
113 .type = UAC_VOLUME_CONTROL, 113 .type = UAC_FU_VOLUME,
114 /* Todo: add real Volume control code */ 114 /* Todo: add real Volume control code */
115 .set = generic_set_cmd, 115 .set = generic_set_cmd,
116 .get = generic_get_cmd, 116 .get = generic_get_cmd,
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 1f73b485732d..26193eceb323 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -297,6 +297,12 @@ static void s3c_hsotg_ctrl_epint(struct s3c_hsotg *hsotg,
297 */ 297 */
298static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg) 298static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
299{ 299{
300 unsigned int ep;
301 unsigned int addr;
302 unsigned int size;
303 int timeout;
304 u32 val;
305
300 /* the ryu 2.6.24 release ahs 306 /* the ryu 2.6.24 release ahs
301 writel(0x1C0, hsotg->regs + S3C_GRXFSIZ); 307 writel(0x1C0, hsotg->regs + S3C_GRXFSIZ);
302 writel(S3C_GNPTXFSIZ_NPTxFStAddr(0x200) | 308 writel(S3C_GNPTXFSIZ_NPTxFStAddr(0x200) |
@@ -310,6 +316,51 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
310 writel(S3C_GNPTXFSIZ_NPTxFStAddr(2048) | 316 writel(S3C_GNPTXFSIZ_NPTxFStAddr(2048) |
311 S3C_GNPTXFSIZ_NPTxFDep(0x1C0), 317 S3C_GNPTXFSIZ_NPTxFDep(0x1C0),
312 hsotg->regs + S3C_GNPTXFSIZ); 318 hsotg->regs + S3C_GNPTXFSIZ);
319
320 /* arange all the rest of the TX FIFOs, as some versions of this
321 * block have overlapping default addresses. This also ensures
322 * that if the settings have been changed, then they are set to
323 * known values. */
324
325 /* start at the end of the GNPTXFSIZ, rounded up */
326 addr = 2048 + 1024;
327 size = 768;
328
329 /* currently we allocate TX FIFOs for all possible endpoints,
330 * and assume that they are all the same size. */
331
332 for (ep = 0; ep <= 15; ep++) {
333 val = addr;
334 val |= size << S3C_DPTXFSIZn_DPTxFSize_SHIFT;
335 addr += size;
336
337 writel(val, hsotg->regs + S3C_DPTXFSIZn(ep));
338 }
339
340 /* according to p428 of the design guide, we need to ensure that
341 * all fifos are flushed before continuing */
342
343 writel(S3C_GRSTCTL_TxFNum(0x10) | S3C_GRSTCTL_TxFFlsh |
344 S3C_GRSTCTL_RxFFlsh, hsotg->regs + S3C_GRSTCTL);
345
346 /* wait until the fifos are both flushed */
347 timeout = 100;
348 while (1) {
349 val = readl(hsotg->regs + S3C_GRSTCTL);
350
351 if ((val & (S3C_GRSTCTL_TxFFlsh | S3C_GRSTCTL_RxFFlsh)) == 0)
352 break;
353
354 if (--timeout == 0) {
355 dev_err(hsotg->dev,
356 "%s: timeout flushing fifos (GRSTCTL=%08x)\n",
357 __func__, val);
358 }
359
360 udelay(1);
361 }
362
363 dev_dbg(hsotg->dev, "FIFOs reset, timeout at %d\n", timeout);
313} 364}
314 365
315/** 366/**
@@ -2574,6 +2625,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2574 writel(S3C_DCTL_CGOUTNak | S3C_DCTL_CGNPInNAK, 2625 writel(S3C_DCTL_CGOUTNak | S3C_DCTL_CGNPInNAK,
2575 hsotg->regs + S3C_DCTL); 2626 hsotg->regs + S3C_DCTL);
2576 2627
2628 /* must be at-least 3ms to allow bus to see disconnect */
2629 msleep(3);
2630
2577 /* remove the soft-disconnect and let's go */ 2631 /* remove the soft-disconnect and let's go */
2578 __bic32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon); 2632 __bic32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon);
2579 2633
@@ -2730,6 +2784,9 @@ static void s3c_hsotg_init(struct s3c_hsotg *hsotg)
2730 2784
2731 writel(0, hsotg->regs + S3C_DAINTMSK); 2785 writel(0, hsotg->regs + S3C_DAINTMSK);
2732 2786
2787 /* Be in disconnected state until gadget is registered */
2788 __orr32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon);
2789
2733 if (0) { 2790 if (0) {
2734 /* post global nak until we're ready */ 2791 /* post global nak until we're ready */
2735 writel(S3C_DCTL_SGNPInNAK | S3C_DCTL_SGOUTNak, 2792 writel(S3C_DCTL_SGNPInNAK | S3C_DCTL_SGOUTNak,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index ef3e88f0b3c3..a3ef2a9d9dc2 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1135,7 +1135,7 @@ MODULE_LICENSE ("GPL");
1135 1135
1136#ifdef CONFIG_XPS_USB_HCD_XILINX 1136#ifdef CONFIG_XPS_USB_HCD_XILINX
1137#include "ehci-xilinx-of.c" 1137#include "ehci-xilinx-of.c"
1138#define OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver 1138#define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver
1139#endif 1139#endif
1140 1140
1141#ifdef CONFIG_PLAT_ORION 1141#ifdef CONFIG_PLAT_ORION
@@ -1159,7 +1159,8 @@ MODULE_LICENSE ("GPL");
1159#endif 1159#endif
1160 1160
1161#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1161#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
1162 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) 1162 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
1163 !defined(XILINX_OF_PLATFORM_DRIVER)
1163#error "missing bus glue for ehci-hcd" 1164#error "missing bus glue for ehci-hcd"
1164#endif 1165#endif
1165 1166
@@ -1213,10 +1214,20 @@ static int __init ehci_hcd_init(void)
1213 if (retval < 0) 1214 if (retval < 0)
1214 goto clean3; 1215 goto clean3;
1215#endif 1216#endif
1217
1218#ifdef XILINX_OF_PLATFORM_DRIVER
1219 retval = of_register_platform_driver(&XILINX_OF_PLATFORM_DRIVER);
1220 if (retval < 0)
1221 goto clean4;
1222#endif
1216 return retval; 1223 return retval;
1217 1224
1225#ifdef XILINX_OF_PLATFORM_DRIVER
1226 /* of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER); */
1227clean4:
1228#endif
1218#ifdef OF_PLATFORM_DRIVER 1229#ifdef OF_PLATFORM_DRIVER
1219 /* of_unregister_platform_driver(&OF_PLATFORM_DRIVER); */ 1230 of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
1220clean3: 1231clean3:
1221#endif 1232#endif
1222#ifdef PS3_SYSTEM_BUS_DRIVER 1233#ifdef PS3_SYSTEM_BUS_DRIVER
@@ -1243,6 +1254,9 @@ module_init(ehci_hcd_init);
1243 1254
1244static void __exit ehci_hcd_cleanup(void) 1255static void __exit ehci_hcd_cleanup(void)
1245{ 1256{
1257#ifdef XILINX_OF_PLATFORM_DRIVER
1258 of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER);
1259#endif
1246#ifdef OF_PLATFORM_DRIVER 1260#ifdef OF_PLATFORM_DRIVER
1247 of_unregister_platform_driver(&OF_PLATFORM_DRIVER); 1261 of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
1248#endif 1262#endif
diff --git a/drivers/usb/host/isp1362.h b/drivers/usb/host/isp1362.h
index 5151516ea1de..d995351f9bed 100644
--- a/drivers/usb/host/isp1362.h
+++ b/drivers/usb/host/isp1362.h
@@ -65,7 +65,7 @@ static inline void delayed_insw(unsigned int addr, void *buf, int len)
65 unsigned short *bp = (unsigned short *)buf; 65 unsigned short *bp = (unsigned short *)buf;
66 while (len--) { 66 while (len--) {
67 DUMMY_DELAY_ACCESS; 67 DUMMY_DELAY_ACCESS;
68 *bp++ = inw((void *)addr); 68 *bp++ = inw(addr);
69 } 69 }
70} 70}
71 71
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index edffd81fc253..11482b6b9381 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -78,6 +78,8 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
78 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" 78 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure"
79 " endpoint cmd after reset endpoint\n"); 79 " endpoint cmd after reset endpoint\n");
80 } 80 }
81 if (pdev->vendor == PCI_VENDOR_ID_NEC)
82 xhci->quirks |= XHCI_NEC_HOST;
81 83
82 /* Make sure the HC is halted. */ 84 /* Make sure the HC is halted. */
83 retval = xhci_halt(xhci); 85 retval = xhci_halt(xhci);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 36c858e5b529..9012098add6b 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1071,6 +1071,15 @@ bandwidth_change:
1071 xhci_warn(xhci, "Reset device command completion " 1071 xhci_warn(xhci, "Reset device command completion "
1072 "for disabled slot %u\n", slot_id); 1072 "for disabled slot %u\n", slot_id);
1073 break; 1073 break;
1074 case TRB_TYPE(TRB_NEC_GET_FW):
1075 if (!(xhci->quirks & XHCI_NEC_HOST)) {
1076 xhci->error_bitmask |= 1 << 6;
1077 break;
1078 }
1079 xhci_dbg(xhci, "NEC firmware version %2x.%02x\n",
1080 NEC_FW_MAJOR(event->status),
1081 NEC_FW_MINOR(event->status));
1082 break;
1074 default: 1083 default:
1075 /* Skip over unknown commands on the event ring */ 1084 /* Skip over unknown commands on the event ring */
1076 xhci->error_bitmask |= 1 << 6; 1085 xhci->error_bitmask |= 1 << 6;
@@ -1079,6 +1088,17 @@ bandwidth_change:
1079 inc_deq(xhci, xhci->cmd_ring, false); 1088 inc_deq(xhci, xhci->cmd_ring, false);
1080} 1089}
1081 1090
1091static void handle_vendor_event(struct xhci_hcd *xhci,
1092 union xhci_trb *event)
1093{
1094 u32 trb_type;
1095
1096 trb_type = TRB_FIELD_TO_TYPE(event->generic.field[3]);
1097 xhci_dbg(xhci, "Vendor specific event TRB type = %u\n", trb_type);
1098 if (trb_type == TRB_NEC_CMD_COMP && (xhci->quirks & XHCI_NEC_HOST))
1099 handle_cmd_completion(xhci, &event->event_cmd);
1100}
1101
1082static void handle_port_status(struct xhci_hcd *xhci, 1102static void handle_port_status(struct xhci_hcd *xhci,
1083 union xhci_trb *event) 1103 union xhci_trb *event)
1084{ 1104{
@@ -1659,7 +1679,10 @@ void xhci_handle_event(struct xhci_hcd *xhci)
1659 update_ptrs = 0; 1679 update_ptrs = 0;
1660 break; 1680 break;
1661 default: 1681 default:
1662 xhci->error_bitmask |= 1 << 3; 1682 if ((event->event_cmd.flags & TRB_TYPE_BITMASK) >= TRB_TYPE(48))
1683 handle_vendor_event(xhci, event);
1684 else
1685 xhci->error_bitmask |= 1 << 3;
1663 } 1686 }
1664 /* Any of the above functions may drop and re-acquire the lock, so check 1687 /* Any of the above functions may drop and re-acquire the lock, so check
1665 * to make sure a watchdog timer didn't mark the host as non-responsive. 1688 * to make sure a watchdog timer didn't mark the host as non-responsive.
@@ -2378,6 +2401,12 @@ int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
2378 false); 2401 false);
2379} 2402}
2380 2403
2404int xhci_queue_vendor_command(struct xhci_hcd *xhci,
2405 u32 field1, u32 field2, u32 field3, u32 field4)
2406{
2407 return queue_command(xhci, field1, field2, field3, field4, false);
2408}
2409
2381/* Queue a reset device command TRB */ 2410/* Queue a reset device command TRB */
2382int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id) 2411int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id)
2383{ 2412{
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 40e0a0c221b8..27345cd04da0 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -106,6 +106,33 @@ int xhci_halt(struct xhci_hcd *xhci)
106} 106}
107 107
108/* 108/*
109 * Set the run bit and wait for the host to be running.
110 */
111int xhci_start(struct xhci_hcd *xhci)
112{
113 u32 temp;
114 int ret;
115
116 temp = xhci_readl(xhci, &xhci->op_regs->command);
117 temp |= (CMD_RUN);
118 xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
119 temp);
120 xhci_writel(xhci, temp, &xhci->op_regs->command);
121
122 /*
123 * Wait for the HCHalted Status bit to be 0 to indicate the host is
124 * running.
125 */
126 ret = handshake(xhci, &xhci->op_regs->status,
127 STS_HALT, 0, XHCI_MAX_HALT_USEC);
128 if (ret == -ETIMEDOUT)
129 xhci_err(xhci, "Host took too long to start, "
130 "waited %u microseconds.\n",
131 XHCI_MAX_HALT_USEC);
132 return ret;
133}
134
135/*
109 * Reset a halted HC, and set the internal HC state to HC_STATE_HALT. 136 * Reset a halted HC, and set the internal HC state to HC_STATE_HALT.
110 * 137 *
111 * This resets pipelines, timers, counters, state machines, etc. 138 * This resets pipelines, timers, counters, state machines, etc.
@@ -116,6 +143,7 @@ int xhci_reset(struct xhci_hcd *xhci)
116{ 143{
117 u32 command; 144 u32 command;
118 u32 state; 145 u32 state;
146 int ret;
119 147
120 state = xhci_readl(xhci, &xhci->op_regs->status); 148 state = xhci_readl(xhci, &xhci->op_regs->status);
121 if ((state & STS_HALT) == 0) { 149 if ((state & STS_HALT) == 0) {
@@ -130,7 +158,17 @@ int xhci_reset(struct xhci_hcd *xhci)
130 /* XXX: Why does EHCI set this here? Shouldn't other code do this? */ 158 /* XXX: Why does EHCI set this here? Shouldn't other code do this? */
131 xhci_to_hcd(xhci)->state = HC_STATE_HALT; 159 xhci_to_hcd(xhci)->state = HC_STATE_HALT;
132 160
133 return handshake(xhci, &xhci->op_regs->command, CMD_RESET, 0, 250 * 1000); 161 ret = handshake(xhci, &xhci->op_regs->command,
162 CMD_RESET, 0, 250 * 1000);
163 if (ret)
164 return ret;
165
166 xhci_dbg(xhci, "Wait for controller to be ready for doorbell rings\n");
167 /*
168 * xHCI cannot write to any doorbells or operational registers other
169 * than status until the "Controller Not Ready" flag is cleared.
170 */
171 return handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000);
134} 172}
135 173
136 174
@@ -448,17 +486,20 @@ int xhci_run(struct usb_hcd *hcd)
448 486
449 if (NUM_TEST_NOOPS > 0) 487 if (NUM_TEST_NOOPS > 0)
450 doorbell = xhci_setup_one_noop(xhci); 488 doorbell = xhci_setup_one_noop(xhci);
489 if (xhci->quirks & XHCI_NEC_HOST)
490 xhci_queue_vendor_command(xhci, 0, 0, 0,
491 TRB_TYPE(TRB_NEC_GET_FW));
492
493 if (xhci_start(xhci)) {
494 xhci_halt(xhci);
495 return -ENODEV;
496 }
451 497
452 temp = xhci_readl(xhci, &xhci->op_regs->command);
453 temp |= (CMD_RUN);
454 xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
455 temp);
456 xhci_writel(xhci, temp, &xhci->op_regs->command);
457 /* Flush PCI posted writes */
458 temp = xhci_readl(xhci, &xhci->op_regs->command);
459 xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp); 498 xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp);
460 if (doorbell) 499 if (doorbell)
461 (*doorbell)(xhci); 500 (*doorbell)(xhci);
501 if (xhci->quirks & XHCI_NEC_HOST)
502 xhci_ring_cmd_db(xhci);
462 503
463 xhci_dbg(xhci, "Finished xhci_run\n"); 504 xhci_dbg(xhci, "Finished xhci_run\n");
464 return 0; 505 return 0;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index dada2fb59261..8b4b7d39f79c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -925,6 +925,7 @@ union xhci_trb {
925/* TRB bit mask */ 925/* TRB bit mask */
926#define TRB_TYPE_BITMASK (0xfc00) 926#define TRB_TYPE_BITMASK (0xfc00)
927#define TRB_TYPE(p) ((p) << 10) 927#define TRB_TYPE(p) ((p) << 10)
928#define TRB_FIELD_TO_TYPE(p) (((p) & TRB_TYPE_BITMASK) >> 10)
928/* TRB type IDs */ 929/* TRB type IDs */
929/* bulk, interrupt, isoc scatter/gather, and control data stage */ 930/* bulk, interrupt, isoc scatter/gather, and control data stage */
930#define TRB_NORMAL 1 931#define TRB_NORMAL 1
@@ -992,6 +993,14 @@ union xhci_trb {
992#define TRB_MFINDEX_WRAP 39 993#define TRB_MFINDEX_WRAP 39
993/* TRB IDs 40-47 reserved, 48-63 is vendor-defined */ 994/* TRB IDs 40-47 reserved, 48-63 is vendor-defined */
994 995
996/* Nec vendor-specific command completion event. */
997#define TRB_NEC_CMD_COMP 48
998/* Get NEC firmware revision. */
999#define TRB_NEC_GET_FW 49
1000
1001#define NEC_FW_MINOR(p) (((p) >> 0) & 0xff)
1002#define NEC_FW_MAJOR(p) (((p) >> 8) & 0xff)
1003
995/* 1004/*
996 * TRBS_PER_SEGMENT must be a multiple of 4, 1005 * TRBS_PER_SEGMENT must be a multiple of 4,
997 * since the command ring is 64-byte aligned. 1006 * since the command ring is 64-byte aligned.
@@ -1172,6 +1181,7 @@ struct xhci_hcd {
1172 unsigned int quirks; 1181 unsigned int quirks;
1173#define XHCI_LINK_TRB_QUIRK (1 << 0) 1182#define XHCI_LINK_TRB_QUIRK (1 << 0)
1174#define XHCI_RESET_EP_QUIRK (1 << 1) 1183#define XHCI_RESET_EP_QUIRK (1 << 1)
1184#define XHCI_NEC_HOST (1 << 2)
1175}; 1185};
1176 1186
1177/* For testing purposes */ 1187/* For testing purposes */
@@ -1379,6 +1389,8 @@ void xhci_set_hc_event_deq(struct xhci_hcd *xhci);
1379int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); 1389int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id);
1380int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, 1390int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
1381 u32 slot_id); 1391 u32 slot_id);
1392int xhci_queue_vendor_command(struct xhci_hcd *xhci,
1393 u32 field1, u32 field2, u32 field3, u32 field4);
1382int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, 1394int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
1383 unsigned int ep_index); 1395 unsigned int ep_index);
1384int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, 1396int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 3edda3ed822a..fd35f73b5721 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1239,8 +1239,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1239 1239
1240 /* port and serial sanity check */ 1240 /* port and serial sanity check */
1241 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1241 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
1242 dev_err(&port->dev, 1242 pr_err("%s: port or port->private is NULL, status=%d\n",
1243 "%s: port or port->private is NULL, status=%d\n",
1244 __func__, status); 1243 __func__, status);
1245 return; 1244 return;
1246 } 1245 }
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 050211afc07e..79dd1ae195e5 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2005,6 +2005,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2005 "urb failed to set to rts/cts flow control\n"); 2005 "urb failed to set to rts/cts flow control\n");
2006 } 2006 }
2007 2007
2008 /* raise DTR/RTS */
2009 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2008 } else { 2010 } else {
2009 /* 2011 /*
2010 * Xon/Xoff code 2012 * Xon/Xoff code
@@ -2052,6 +2054,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2052 } 2054 }
2053 } 2055 }
2054 2056
2057 /* lower DTR/RTS */
2058 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2055 } 2059 }
2056 return; 2060 return;
2057} 2061}
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index f8424d1bfc1b..585b7e663740 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -730,7 +730,6 @@ static void mos7840_bulk_in_callback(struct urb *urb)
730 mos7840_port = urb->context; 730 mos7840_port = urb->context;
731 if (!mos7840_port) { 731 if (!mos7840_port) {
732 dbg("%s", "NULL mos7840_port pointer"); 732 dbg("%s", "NULL mos7840_port pointer");
733 mos7840_port->read_urb_busy = false;
734 return; 733 return;
735 } 734 }
736 735
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 1e6fec487973..3d94a1471724 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -8,6 +8,9 @@ menu "Graphics support"
8config HAVE_FB_ATMEL 8config HAVE_FB_ATMEL
9 bool 9 bool
10 10
11config HAVE_FB_IMX
12 bool
13
11source "drivers/char/agp/Kconfig" 14source "drivers/char/agp/Kconfig"
12 15
13source "drivers/gpu/vga/Kconfig" 16source "drivers/gpu/vga/Kconfig"
@@ -400,9 +403,6 @@ config FB_SA1100
400 If you plan to use the LCD display with your SA-1100 system, say 403 If you plan to use the LCD display with your SA-1100 system, say
401 Y here. 404 Y here.
402 405
403config HAVE_FB_IMX
404 bool
405
406config FB_IMX 406config FB_IMX
407 tristate "Motorola i.MX LCD support" 407 tristate "Motorola i.MX LCD support"
408 depends on FB && (HAVE_FB_IMX || ARCH_MX1 || ARCH_MX2) 408 depends on FB && (HAVE_FB_IMX || ARCH_MX1 || ARCH_MX2)
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index 073c9b408cf7..6b93ef93cb12 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -100,6 +100,16 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
100 /* protect against the workqueue changing the page list */ 100 /* protect against the workqueue changing the page list */
101 mutex_lock(&fbdefio->lock); 101 mutex_lock(&fbdefio->lock);
102 102
103 /*
104 * We want the page to remain locked from ->page_mkwrite until
105 * the PTE is marked dirty to avoid page_mkclean() being called
106 * before the PTE is updated, which would leave the page ignored
107 * by defio.
108 * Do this by locking the page here and informing the caller
109 * about it with VM_FAULT_LOCKED.
110 */
111 lock_page(page);
112
103 /* we loop through the pagelist before adding in order 113 /* we loop through the pagelist before adding in order
104 to keep the pagelist sorted */ 114 to keep the pagelist sorted */
105 list_for_each_entry(cur, &fbdefio->pagelist, lru) { 115 list_for_each_entry(cur, &fbdefio->pagelist, lru) {
@@ -121,7 +131,7 @@ page_already_added:
121 131
122 /* come back after delay to process the deferred IO */ 132 /* come back after delay to process the deferred IO */
123 schedule_delayed_work(&info->deferred_work, fbdefio->delay); 133 schedule_delayed_work(&info->deferred_work, fbdefio->delay);
124 return 0; 134 return VM_FAULT_LOCKED;
125} 135}
126 136
127static const struct vm_operations_struct fb_deferred_io_vm_ops = { 137static const struct vm_operations_struct fb_deferred_io_vm_ops = {
@@ -155,41 +165,25 @@ static void fb_deferred_io_work(struct work_struct *work)
155{ 165{
156 struct fb_info *info = container_of(work, struct fb_info, 166 struct fb_info *info = container_of(work, struct fb_info,
157 deferred_work.work); 167 deferred_work.work);
168 struct list_head *node, *next;
169 struct page *cur;
158 struct fb_deferred_io *fbdefio = info->fbdefio; 170 struct fb_deferred_io *fbdefio = info->fbdefio;
159 struct page *page, *tmp_page;
160 struct list_head *node, *tmp_node;
161 struct list_head non_dirty;
162
163 INIT_LIST_HEAD(&non_dirty);
164 171
165 /* here we mkclean the pages, then do all deferred IO */ 172 /* here we mkclean the pages, then do all deferred IO */
166 mutex_lock(&fbdefio->lock); 173 mutex_lock(&fbdefio->lock);
167 list_for_each_entry_safe(page, tmp_page, &fbdefio->pagelist, lru) { 174 list_for_each_entry(cur, &fbdefio->pagelist, lru) {
168 lock_page(page); 175 lock_page(cur);
169 /* 176 page_mkclean(cur);
170 * The workqueue callback can be triggered after a 177 unlock_page(cur);
171 * ->page_mkwrite() call but before the PTE has been marked
172 * dirty. In this case page_mkclean() won't "rearm" the page.
173 *
174 * To avoid this, remove those "non-dirty" pages from the
175 * pagelist before calling the driver's callback, then add
176 * them back to get processed on the next work iteration.
177 * At that time, their PTEs will hopefully be dirty for real.
178 */
179 if (!page_mkclean(page))
180 list_move_tail(&page->lru, &non_dirty);
181 unlock_page(page);
182 } 178 }
183 179
184 /* driver's callback with pagelist */ 180 /* driver's callback with pagelist */
185 fbdefio->deferred_io(info, &fbdefio->pagelist); 181 fbdefio->deferred_io(info, &fbdefio->pagelist);
186 182
187 /* clear the list... */ 183 /* clear the list */
188 list_for_each_safe(node, tmp_node, &fbdefio->pagelist) { 184 list_for_each_safe(node, next, &fbdefio->pagelist) {
189 list_del(node); 185 list_del(node);
190 } 186 }
191 /* ... and add back the "non-dirty" pages to the list */
192 list_splice_tail(&non_dirty, &fbdefio->pagelist);
193 mutex_unlock(&fbdefio->lock); 187 mutex_unlock(&fbdefio->lock);
194} 188}
195 189
@@ -218,7 +212,6 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_open);
218void fb_deferred_io_cleanup(struct fb_info *info) 212void fb_deferred_io_cleanup(struct fb_info *info)
219{ 213{
220 struct fb_deferred_io *fbdefio = info->fbdefio; 214 struct fb_deferred_io *fbdefio = info->fbdefio;
221 struct list_head *node, *tmp_node;
222 struct page *page; 215 struct page *page;
223 int i; 216 int i;
224 217
@@ -226,13 +219,6 @@ void fb_deferred_io_cleanup(struct fb_info *info)
226 cancel_delayed_work(&info->deferred_work); 219 cancel_delayed_work(&info->deferred_work);
227 flush_scheduled_work(); 220 flush_scheduled_work();
228 221
229 /* the list may have still some non-dirty pages at this point */
230 mutex_lock(&fbdefio->lock);
231 list_for_each_safe(node, tmp_node, &fbdefio->pagelist) {
232 list_del(node);
233 }
234 mutex_unlock(&fbdefio->lock);
235
236 /* clear out the mapping that we setup */ 222 /* clear out the mapping that we setup */
237 for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) { 223 for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {
238 page = fb_deferred_io_page(info, i); 224 page = fb_deferred_io_page(info, i);
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 49566c1687d8..b6ab27ccf214 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -56,15 +56,22 @@
56#endif 56#endif
57 57
58/* 58/*
59 * User data (stack, data section and bss) needs to be aligned 59 * User data (data section and bss) needs to be aligned.
60 * for the same reasons as SLAB memory is, and to the same amount. 60 * We pick 0x20 here because it is the max value elf2flt has always
61 * Avoid duplicating architecture specific code by using the same 61 * used in producing FLAT files, and because it seems to be large
62 * macro as with SLAB allocation: 62 * enough to make all the gcc alignment related tests happy.
63 */
64#define FLAT_DATA_ALIGN (0x20)
65
66/*
67 * User data (stack) also needs to be aligned.
68 * Here we can be a bit looser than the data sections since this
69 * needs to only meet arch ABI requirements.
63 */ 70 */
64#ifdef ARCH_SLAB_MINALIGN 71#ifdef ARCH_SLAB_MINALIGN
65#define FLAT_DATA_ALIGN (ARCH_SLAB_MINALIGN) 72#define FLAT_STACK_ALIGN (ARCH_SLAB_MINALIGN)
66#else 73#else
67#define FLAT_DATA_ALIGN (sizeof(void *)) 74#define FLAT_STACK_ALIGN (sizeof(void *))
68#endif 75#endif
69 76
70#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */ 77#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */
@@ -129,7 +136,7 @@ static unsigned long create_flat_tables(
129 136
130 sp = (unsigned long *)p; 137 sp = (unsigned long *)p;
131 sp -= (envc + argc + 2) + 1 + (flat_argvp_envp_on_stack() ? 2 : 0); 138 sp -= (envc + argc + 2) + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
132 sp = (unsigned long *) ((unsigned long)sp & -FLAT_DATA_ALIGN); 139 sp = (unsigned long *) ((unsigned long)sp & -FLAT_STACK_ALIGN);
133 argv = sp + 1 + (flat_argvp_envp_on_stack() ? 2 : 0); 140 argv = sp + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
134 envp = argv + (argc + 1); 141 envp = argv + (argc + 1);
135 142
@@ -589,7 +596,7 @@ static int load_flat_file(struct linux_binprm * bprm,
589 if (IS_ERR_VALUE(result)) { 596 if (IS_ERR_VALUE(result)) {
590 printk("Unable to read data+bss, errno %d\n", (int)-result); 597 printk("Unable to read data+bss, errno %d\n", (int)-result);
591 do_munmap(current->mm, textpos, text_len); 598 do_munmap(current->mm, textpos, text_len);
592 do_munmap(current->mm, realdatastart, data_len + extra); 599 do_munmap(current->mm, realdatastart, len);
593 ret = result; 600 ret = result;
594 goto err; 601 goto err;
595 } 602 }
@@ -876,7 +883,7 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)
876 stack_len = TOP_OF_ARGS - bprm->p; /* the strings */ 883 stack_len = TOP_OF_ARGS - bprm->p; /* the strings */
877 stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */ 884 stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */
878 stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ 885 stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */
879 stack_len += FLAT_DATA_ALIGN - 1; /* reserve for upcoming alignment */ 886 stack_len += FLAT_STACK_ALIGN - 1; /* reserve for upcoming alignment */
880 887
881 res = load_flat_file(bprm, &libinfo, 0, &stack_len); 888 res = load_flat_file(bprm, &libinfo, 0, &stack_len);
882 if (IS_ERR_VALUE(res)) 889 if (IS_ERR_VALUE(res))
diff --git a/fs/compat.c b/fs/compat.c
index f0b391c50552..6490d2134ff3 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -626,7 +626,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
626 tot_len += len; 626 tot_len += len;
627 if (tot_len < tmp) /* maths overflow on the compat_ssize_t */ 627 if (tot_len < tmp) /* maths overflow on the compat_ssize_t */
628 goto out; 628 goto out;
629 if (!access_ok(vrfy_dir(type), buf, len)) { 629 if (!access_ok(vrfy_dir(type), compat_ptr(buf), len)) {
630 ret = -EFAULT; 630 ret = -EFAULT;
631 goto out; 631 goto out;
632 } 632 }
diff --git a/include/linux/personality.h b/include/linux/personality.h
index 126120819a0d..eec3bae164d4 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -12,7 +12,7 @@ struct pt_regs;
12 12
13extern int register_exec_domain(struct exec_domain *); 13extern int register_exec_domain(struct exec_domain *);
14extern int unregister_exec_domain(struct exec_domain *); 14extern int unregister_exec_domain(struct exec_domain *);
15extern int __set_personality(unsigned long); 15extern int __set_personality(unsigned int);
16 16
17#endif /* __KERNEL__ */ 17#endif /* __KERNEL__ */
18 18
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a1a86a53bc73..7f614ce274a9 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -289,7 +289,7 @@ asmlinkage long sys_capget(cap_user_header_t header,
289 cap_user_data_t dataptr); 289 cap_user_data_t dataptr);
290asmlinkage long sys_capset(cap_user_header_t header, 290asmlinkage long sys_capset(cap_user_header_t header,
291 const cap_user_data_t data); 291 const cap_user_data_t data);
292asmlinkage long sys_personality(u_long personality); 292asmlinkage long sys_personality(unsigned int personality);
293 293
294asmlinkage long sys_sigpending(old_sigset_t __user *set); 294asmlinkage long sys_sigpending(old_sigset_t __user *set);
295asmlinkage long sys_sigprocmask(int how, old_sigset_t __user *set, 295asmlinkage long sys_sigprocmask(int how, old_sigset_t __user *set,
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index 92f1d99f0f17..383b94ba8c20 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -18,6 +18,16 @@
18/* v1.0 and v2.0 of this standard have many things in common. For the rest 18/* v1.0 and v2.0 of this standard have many things in common. For the rest
19 * of the definitions, please refer to audio.h */ 19 * of the definitions, please refer to audio.h */
20 20
21static inline bool uac2_control_is_readable(u32 bmControls, u8 control)
22{
23 return (bmControls >> (control * 2)) & 0x1;
24}
25
26static inline bool uac2_control_is_writeable(u32 bmControls, u8 control)
27{
28 return (bmControls >> (control * 2)) & 0x2;
29}
30
21/* 4.7.2.1 Clock Source Descriptor */ 31/* 4.7.2.1 Clock Source Descriptor */
22 32
23struct uac_clock_source_descriptor { 33struct uac_clock_source_descriptor {
@@ -31,6 +41,13 @@ struct uac_clock_source_descriptor {
31 __u8 iClockSource; 41 __u8 iClockSource;
32} __attribute__((packed)); 42} __attribute__((packed));
33 43
44/* bmAttribute fields */
45#define UAC_CLOCK_SOURCE_TYPE_EXT 0x0
46#define UAC_CLOCK_SOURCE_TYPE_INT_FIXED 0x1
47#define UAC_CLOCK_SOURCE_TYPE_INT_VAR 0x2
48#define UAC_CLOCK_SOURCE_TYPE_INT_PROG 0x3
49#define UAC_CLOCK_SOURCE_SYNCED_TO_SOF (1 << 2)
50
34/* 4.7.2.2 Clock Source Descriptor */ 51/* 4.7.2.2 Clock Source Descriptor */
35 52
36struct uac_clock_selector_descriptor { 53struct uac_clock_selector_descriptor {
@@ -39,8 +56,20 @@ struct uac_clock_selector_descriptor {
39 __u8 bDescriptorSubtype; 56 __u8 bDescriptorSubtype;
40 __u8 bClockID; 57 __u8 bClockID;
41 __u8 bNrInPins; 58 __u8 bNrInPins;
42 __u8 bmControls;
43 __u8 baCSourceID[]; 59 __u8 baCSourceID[];
60 /* bmControls, bAssocTerminal and iClockSource omitted */
61} __attribute__((packed));
62
63/* 4.7.2.3 Clock Multiplier Descriptor */
64
65struct uac_clock_multiplier_descriptor {
66 __u8 bLength;
67 __u8 bDescriptorType;
68 __u8 bDescriptorSubtype;
69 __u8 bClockID;
70 __u8 bCSourceID;
71 __u8 bmControls;
72 __u8 iClockMultiplier;
44} __attribute__((packed)); 73} __attribute__((packed));
45 74
46/* 4.7.2.4 Input terminal descriptor */ 75/* 4.7.2.4 Input terminal descriptor */
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 5d646c388752..c51200c715e5 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -47,6 +47,15 @@
47#define UAC_FORMAT_TYPE 0x02 47#define UAC_FORMAT_TYPE 0x02
48#define UAC_FORMAT_SPECIFIC 0x03 48#define UAC_FORMAT_SPECIFIC 0x03
49 49
50/* A.7 Processing Unit Process Types */
51#define UAC_PROCESS_UNDEFINED 0x00
52#define UAC_PROCESS_UP_DOWNMIX 0x01
53#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
54#define UAC_PROCESS_STEREO_EXTENDER 0x03
55#define UAC_PROCESS_REVERB 0x04
56#define UAC_PROCESS_CHORUS 0x05
57#define UAC_PROCESS_DYN_RANGE_COMP 0x06
58
50/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ 59/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
51#define UAC_EP_GENERAL 0x01 60#define UAC_EP_GENERAL 0x01
52 61
@@ -73,6 +82,60 @@
73 82
74#define UAC_GET_STAT 0xff 83#define UAC_GET_STAT 0xff
75 84
85/* A.10 Control Selector Codes */
86
87/* A.10.1 Terminal Control Selectors */
88#define UAC_TERM_COPY_PROTECT 0x01
89
90/* A.10.2 Feature Unit Control Selectors */
91#define UAC_FU_MUTE 0x01
92#define UAC_FU_VOLUME 0x02
93#define UAC_FU_BASS 0x03
94#define UAC_FU_MID 0x04
95#define UAC_FU_TREBLE 0x05
96#define UAC_FU_GRAPHIC_EQUALIZER 0x06
97#define UAC_FU_AUTOMATIC_GAIN 0x07
98#define UAC_FU_DELAY 0x08
99#define UAC_FU_BASS_BOOST 0x09
100#define UAC_FU_LOUDNESS 0x0a
101
102#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
103
104/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
105#define UAC_UD_ENABLE 0x01
106#define UAC_UD_MODE_SELECT 0x02
107
108/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
109#define UAC_DP_ENABLE 0x01
110#define UAC_DP_MODE_SELECT 0x02
111
112/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
113#define UAC_3D_ENABLE 0x01
114#define UAC_3D_SPACE 0x02
115
116/* A.10.3.4 Reverberation Processing Unit Control Selectors */
117#define UAC_REVERB_ENABLE 0x01
118#define UAC_REVERB_LEVEL 0x02
119#define UAC_REVERB_TIME 0x03
120#define UAC_REVERB_FEEDBACK 0x04
121
122/* A.10.3.5 Chorus Processing Unit Control Selectors */
123#define UAC_CHORUS_ENABLE 0x01
124#define UAC_CHORUS_LEVEL 0x02
125#define UAC_CHORUS_RATE 0x03
126#define UAC_CHORUS_DEPTH 0x04
127
128/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
129#define UAC_DCR_ENABLE 0x01
130#define UAC_DCR_RATE 0x02
131#define UAC_DCR_MAXAMPL 0x03
132#define UAC_DCR_THRESHOLD 0x04
133#define UAC_DCR_ATTACK_TIME 0x05
134#define UAC_DCR_RELEASE_TIME 0x06
135
136/* A.10.4 Extension Unit Control Selectors */
137#define UAC_XU_ENABLE 0x01
138
76/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ 139/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
77#define UAC_MS_HEADER 0x01 140#define UAC_MS_HEADER 0x01
78#define UAC_MIDI_IN_JACK 0x02 141#define UAC_MIDI_IN_JACK 0x02
@@ -244,7 +307,7 @@ struct uac_selector_unit_descriptor {
244static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) 307static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
245{ 308{
246 __u8 *raw = (__u8 *) desc; 309 __u8 *raw = (__u8 *) desc;
247 return raw[9 + desc->bLength - 1]; 310 return raw[desc->bLength - 1];
248} 311}
249 312
250/* 4.3.2.5 Feature Unit Descriptor */ 313/* 4.3.2.5 Feature Unit Descriptor */
@@ -463,31 +526,6 @@ struct uac_iso_endpoint_descriptor {
463#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 526#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
464#define UAC_EP_CS_ATTR_FILL_MAX 0x80 527#define UAC_EP_CS_ATTR_FILL_MAX 0x80
465 528
466/* A.10.2 Feature Unit Control Selectors */
467
468#define UAC_FU_CONTROL_UNDEFINED 0x00
469#define UAC_MUTE_CONTROL 0x01
470#define UAC_VOLUME_CONTROL 0x02
471#define UAC_BASS_CONTROL 0x03
472#define UAC_MID_CONTROL 0x04
473#define UAC_TREBLE_CONTROL 0x05
474#define UAC_GRAPHIC_EQUALIZER_CONTROL 0x06
475#define UAC_AUTOMATIC_GAIN_CONTROL 0x07
476#define UAC_DELAY_CONTROL 0x08
477#define UAC_BASS_BOOST_CONTROL 0x09
478#define UAC_LOUDNESS_CONTROL 0x0a
479
480#define UAC_FU_MUTE (1 << (UAC_MUTE_CONTROL - 1))
481#define UAC_FU_VOLUME (1 << (UAC_VOLUME_CONTROL - 1))
482#define UAC_FU_BASS (1 << (UAC_BASS_CONTROL - 1))
483#define UAC_FU_MID (1 << (UAC_MID_CONTROL - 1))
484#define UAC_FU_TREBLE (1 << (UAC_TREBLE_CONTROL - 1))
485#define UAC_FU_GRAPHIC_EQ (1 << (UAC_GRAPHIC_EQUALIZER_CONTROL - 1))
486#define UAC_FU_AUTO_GAIN (1 << (UAC_AUTOMATIC_GAIN_CONTROL - 1))
487#define UAC_FU_DELAY (1 << (UAC_DELAY_CONTROL - 1))
488#define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1))
489#define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1))
490
491/* status word format (3.7.1.1) */ 529/* status word format (3.7.1.1) */
492 530
493#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f 531#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 422cb19f156e..3ac6f5b0a64b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
4598 parent_css = parent->subsys[subsys_id]; 4598 parent_css = parent->subsys[subsys_id];
4599 child_css = child->subsys[subsys_id]; 4599 child_css = child->subsys[subsys_id];
4600 parent_id = parent_css->id; 4600 parent_id = parent_css->id;
4601 depth = parent_id->depth; 4601 depth = parent_id->depth + 1;
4602 4602
4603 child_id = get_new_cssid(ss, depth); 4603 child_id = get_new_cssid(ss, depth);
4604 if (IS_ERR(child_id)) 4604 if (IS_ERR(child_id))
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index c35452cadded..dd62f8e714ca 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -27,7 +27,7 @@ static struct exec_domain *exec_domains = &default_exec_domain;
27static DEFINE_RWLOCK(exec_domains_lock); 27static DEFINE_RWLOCK(exec_domains_lock);
28 28
29 29
30static u_long ident_map[32] = { 30static unsigned long ident_map[32] = {
31 0, 1, 2, 3, 4, 5, 6, 7, 31 0, 1, 2, 3, 4, 5, 6, 7,
32 8, 9, 10, 11, 12, 13, 14, 15, 32 8, 9, 10, 11, 12, 13, 14, 15,
33 16, 17, 18, 19, 20, 21, 22, 23, 33 16, 17, 18, 19, 20, 21, 22, 23,
@@ -56,10 +56,10 @@ default_handler(int segment, struct pt_regs *regp)
56} 56}
57 57
58static struct exec_domain * 58static struct exec_domain *
59lookup_exec_domain(u_long personality) 59lookup_exec_domain(unsigned int personality)
60{ 60{
61 struct exec_domain * ep; 61 unsigned int pers = personality(personality);
62 u_long pers = personality(personality); 62 struct exec_domain *ep;
63 63
64 read_lock(&exec_domains_lock); 64 read_lock(&exec_domains_lock);
65 for (ep = exec_domains; ep; ep = ep->next) { 65 for (ep = exec_domains; ep; ep = ep->next) {
@@ -70,7 +70,7 @@ lookup_exec_domain(u_long personality)
70 70
71#ifdef CONFIG_MODULES 71#ifdef CONFIG_MODULES
72 read_unlock(&exec_domains_lock); 72 read_unlock(&exec_domains_lock);
73 request_module("personality-%ld", pers); 73 request_module("personality-%d", pers);
74 read_lock(&exec_domains_lock); 74 read_lock(&exec_domains_lock);
75 75
76 for (ep = exec_domains; ep; ep = ep->next) { 76 for (ep = exec_domains; ep; ep = ep->next) {
@@ -135,7 +135,7 @@ unregister:
135} 135}
136 136
137int 137int
138__set_personality(u_long personality) 138__set_personality(unsigned int personality)
139{ 139{
140 struct exec_domain *ep, *oep; 140 struct exec_domain *ep, *oep;
141 141
@@ -188,9 +188,9 @@ static int __init proc_execdomains_init(void)
188module_init(proc_execdomains_init); 188module_init(proc_execdomains_init);
189#endif 189#endif
190 190
191SYSCALL_DEFINE1(personality, u_long, personality) 191SYSCALL_DEFINE1(personality, unsigned int, personality)
192{ 192{
193 u_long old = current->personality; 193 unsigned int old = current->personality;
194 194
195 if (personality != 0xffffffff) { 195 if (personality != 0xffffffff) {
196 set_personality(personality); 196 set_personality(personality);
@@ -198,7 +198,7 @@ SYSCALL_DEFINE1(personality, u_long, personality)
198 return -EINVAL; 198 return -EINVAL;
199 } 199 }
200 200
201 return (long)old; 201 return old;
202} 202}
203 203
204 204
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 825e1126008f..07b4f1b1a73a 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -850,7 +850,7 @@ static __init int spawn_ksoftirqd(void)
850 void *cpu = (void *)(long)smp_processor_id(); 850 void *cpu = (void *)(long)smp_processor_id();
851 int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); 851 int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
852 852
853 BUG_ON(err == NOTIFY_BAD); 853 BUG_ON(err != NOTIFY_OK);
854 cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); 854 cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
855 register_cpu_notifier(&cpu_nfb); 855 register_cpu_notifier(&cpu_nfb);
856 return 0; 856 return 0;
diff --git a/kernel/timer.c b/kernel/timer.c
index 2454172a80d3..ee305c8d4e18 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1717,7 +1717,7 @@ void __init init_timers(void)
1717 1717
1718 init_timer_stats(); 1718 init_timer_stats();
1719 1719
1720 BUG_ON(err == NOTIFY_BAD); 1720 BUG_ON(err != NOTIFY_OK);
1721 register_cpu_notifier(&timers_nb); 1721 register_cpu_notifier(&timers_nb);
1722 open_softirq(TIMER_SOFTIRQ, run_timer_softirq); 1722 open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
1723} 1723}
diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c
index 9087d71537dd..250ed11d3ed2 100644
--- a/lib/atomic64_test.c
+++ b/lib/atomic64_test.c
@@ -113,7 +113,8 @@ static __init int test_atomic64(void)
113 r += one; 113 r += one;
114 BUG_ON(v.counter != r); 114 BUG_ON(v.counter != r);
115 115
116#if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(_ASM_GENERIC_ATOMIC64_H) 116#if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
117 defined(CONFIG_S390) || defined(_ASM_GENERIC_ATOMIC64_H)
117 INIT(onestwos); 118 INIT(onestwos);
118 BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); 119 BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1));
119 r -= one; 120 r -= one;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 915dceb487c1..9c7e57cc63a3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1724,13 +1724,13 @@ static void shrink_zone(int priority, struct zone *zone,
1724 * If a zone is deemed to be full of pinned pages then just give it a light 1724 * If a zone is deemed to be full of pinned pages then just give it a light
1725 * scan then give up on it. 1725 * scan then give up on it.
1726 */ 1726 */
1727static int shrink_zones(int priority, struct zonelist *zonelist, 1727static bool shrink_zones(int priority, struct zonelist *zonelist,
1728 struct scan_control *sc) 1728 struct scan_control *sc)
1729{ 1729{
1730 enum zone_type high_zoneidx = gfp_zone(sc->gfp_mask); 1730 enum zone_type high_zoneidx = gfp_zone(sc->gfp_mask);
1731 struct zoneref *z; 1731 struct zoneref *z;
1732 struct zone *zone; 1732 struct zone *zone;
1733 int progress = 0; 1733 bool all_unreclaimable = true;
1734 1734
1735 for_each_zone_zonelist_nodemask(zone, z, zonelist, high_zoneidx, 1735 for_each_zone_zonelist_nodemask(zone, z, zonelist, high_zoneidx,
1736 sc->nodemask) { 1736 sc->nodemask) {
@@ -1757,9 +1757,9 @@ static int shrink_zones(int priority, struct zonelist *zonelist,
1757 } 1757 }
1758 1758
1759 shrink_zone(priority, zone, sc); 1759 shrink_zone(priority, zone, sc);
1760 progress = 1; 1760 all_unreclaimable = false;
1761 } 1761 }
1762 return progress; 1762 return all_unreclaimable;
1763} 1763}
1764 1764
1765/* 1765/*
@@ -1782,7 +1782,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
1782 struct scan_control *sc) 1782 struct scan_control *sc)
1783{ 1783{
1784 int priority; 1784 int priority;
1785 unsigned long ret = 0; 1785 bool all_unreclaimable;
1786 unsigned long total_scanned = 0; 1786 unsigned long total_scanned = 0;
1787 struct reclaim_state *reclaim_state = current->reclaim_state; 1787 struct reclaim_state *reclaim_state = current->reclaim_state;
1788 unsigned long lru_pages = 0; 1788 unsigned long lru_pages = 0;
@@ -1813,7 +1813,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
1813 sc->nr_scanned = 0; 1813 sc->nr_scanned = 0;
1814 if (!priority) 1814 if (!priority)
1815 disable_swap_token(); 1815 disable_swap_token();
1816 ret = shrink_zones(priority, zonelist, sc); 1816 all_unreclaimable = shrink_zones(priority, zonelist, sc);
1817 /* 1817 /*
1818 * Don't shrink slabs when reclaiming memory from 1818 * Don't shrink slabs when reclaiming memory from
1819 * over limit cgroups 1819 * over limit cgroups
@@ -1826,10 +1826,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
1826 } 1826 }
1827 } 1827 }
1828 total_scanned += sc->nr_scanned; 1828 total_scanned += sc->nr_scanned;
1829 if (sc->nr_reclaimed >= sc->nr_to_reclaim) { 1829 if (sc->nr_reclaimed >= sc->nr_to_reclaim)
1830 ret = sc->nr_reclaimed;
1831 goto out; 1830 goto out;
1832 }
1833 1831
1834 /* 1832 /*
1835 * Try to write back as many pages as we just scanned. This 1833 * Try to write back as many pages as we just scanned. This
@@ -1849,9 +1847,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
1849 priority < DEF_PRIORITY - 2) 1847 priority < DEF_PRIORITY - 2)
1850 congestion_wait(BLK_RW_ASYNC, HZ/10); 1848 congestion_wait(BLK_RW_ASYNC, HZ/10);
1851 } 1849 }
1852 /* top priority shrink_zones still had more to do? don't OOM, then */ 1850
1853 if (ret && scanning_global_lru(sc))
1854 ret = sc->nr_reclaimed;
1855out: 1851out:
1856 /* 1852 /*
1857 * Now that we've scanned all the zones at this priority level, note 1853 * Now that we've scanned all the zones at this priority level, note
@@ -1877,7 +1873,14 @@ out:
1877 delayacct_freepages_end(); 1873 delayacct_freepages_end();
1878 put_mems_allowed(); 1874 put_mems_allowed();
1879 1875
1880 return ret; 1876 if (sc->nr_reclaimed)
1877 return sc->nr_reclaimed;
1878
1879 /* top priority shrink_zones still had more to do? don't OOM, then */
1880 if (scanning_global_lru(sc) && !all_unreclaimable)
1881 return 1;
1882
1883 return 0;
1881} 1884}
1882 1885
1883unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 1886unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index f74c7372b3d1..1db586af4f9c 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -2578,6 +2578,9 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2578 if (err) 2578 if (err)
2579 return -err; 2579 return -err;
2580 2580
2581 memset(&prev_ctl, 0, sizeof(prev_ctl));
2582 prev_ctl.control_type = -1;
2583
2581 for (idx = 0; idx < 2000; idx++) { 2584 for (idx = 0; idx < 2000; idx++) {
2582 err = hpi_mixer_get_control_by_index( 2585 err = hpi_mixer_get_control_by_index(
2583 ss, asihpi->h_mixer, 2586 ss, asihpi->h_mixer,
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index dc79564fea30..1df25cf5ce38 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1913,11 +1913,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
1913 if (WARN_ONCE(!azx_dev->period_bytes, 1913 if (WARN_ONCE(!azx_dev->period_bytes,
1914 "hda-intel: zero azx_dev->period_bytes")) 1914 "hda-intel: zero azx_dev->period_bytes"))
1915 return -1; /* this shouldn't happen! */ 1915 return -1; /* this shouldn't happen! */
1916 if (wallclk <= azx_dev->period_wallclk && 1916 if (wallclk < (azx_dev->period_wallclk * 5) / 4 &&
1917 pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) 1917 pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
1918 /* NG - it's below the first next period boundary */ 1918 /* NG - it's below the first next period boundary */
1919 return bdl_pos_adj[chip->dev_index] ? 0 : -1; 1919 return bdl_pos_adj[chip->dev_index] ? 0 : -1;
1920 azx_dev->start_wallclk = wallclk; 1920 azx_dev->start_wallclk += wallclk;
1921 return 1; /* OK, it's fine */ 1921 return 1; /* OK, it's fine */
1922} 1922}
1923 1923
@@ -2288,6 +2288,8 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2288 SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), 2288 SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB),
2289 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), 2289 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
2290 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2290 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
2291 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
2292 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB),
2291 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2293 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB),
2292 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), 2294 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
2293 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba A100-259", POS_FIX_LPIB), 2295 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba A100-259", POS_FIX_LPIB),
@@ -2296,6 +2298,7 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2296 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2298 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
2297 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), 2299 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB),
2298 SND_PCI_QUIRK(0x1565, 0x8218, "Biostar Microtech", POS_FIX_LPIB), 2300 SND_PCI_QUIRK(0x1565, 0x8218, "Biostar Microtech", POS_FIX_LPIB),
2301 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
2299 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB), 2302 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
2300 SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB), 2303 SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB),
2301 {} 2304 {}
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 17d4548cc353..d792cddbf4c2 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -9476,6 +9476,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9476 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24), 9476 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9477 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), 9477 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9478 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), 9478 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9479 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
9479 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), 9480 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9480 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), 9481 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9481 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), 9482 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig
index eba9b9d257a1..252defea93b5 100644
--- a/sound/soc/imx/Kconfig
+++ b/sound/soc/imx/Kconfig
@@ -13,9 +13,18 @@ config SND_MXC_SOC_SSI
13 13
14config SND_MXC_SOC_WM1133_EV1 14config SND_MXC_SOC_WM1133_EV1
15 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" 15 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted"
16 depends on SND_IMX_SOC && EXPERIMENTAL 16 depends on SND_IMX_SOC && MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL
17 select SND_SOC_WM8350 17 select SND_SOC_WM8350
18 select SND_MXC_SOC_SSI 18 select SND_MXC_SOC_SSI
19 help 19 help
20 Enable support for audio on the i.MX31ADS with the WM1133-EV1 20 Enable support for audio on the i.MX31ADS with the WM1133-EV1
21 PMIC board with WM8835x fitted. 21 PMIC board with WM8835x fitted.
22
23config SND_SOC_PHYCORE_AC97
24 tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards"
25 depends on MACH_PCM043 || MACH_PCA100
26 select SND_MXC_SOC_SSI
27 select SND_SOC_WM9712
28 help
29 Say Y if you want to add support for SoC audio on Phytec phyCORE
30 and phyCARD boards in AC97 mode
diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index e7ac7f493a8f..1e362bf8834f 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -11,7 +11,8 @@ snd-usb-audio-objs := card.o \
11 endpoint.o \ 11 endpoint.o \
12 urb.o \ 12 urb.o \
13 pcm.o \ 13 pcm.o \
14 helper.o 14 helper.o \
15 clock.o
15 16
16snd-usbmidi-lib-objs := midi.o 17snd-usbmidi-lib-objs := midi.o
17 18
diff --git a/sound/usb/card.c b/sound/usb/card.c
index da1346bd4856..7a8ac1d81be7 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -236,7 +236,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
236 } 236 }
237 237
238 case UAC_VERSION_2: { 238 case UAC_VERSION_2: {
239 struct uac_clock_source_descriptor *cs;
240 struct usb_interface_assoc_descriptor *assoc = 239 struct usb_interface_assoc_descriptor *assoc =
241 usb_ifnum_to_if(dev, ctrlif)->intf_assoc; 240 usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
242 241
@@ -245,21 +244,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
245 return -EINVAL; 244 return -EINVAL;
246 } 245 }
247 246
248 /* FIXME: for now, we expect there is at least one clock source
249 * descriptor and we always take the first one.
250 * We should properly support devices with multiple clock sources,
251 * clock selectors and sample rate conversion units. */
252
253 cs = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen,
254 NULL, UAC2_CLOCK_SOURCE);
255
256 if (!cs) {
257 snd_printk(KERN_ERR "CLOCK_SOURCE descriptor not found\n");
258 return -EINVAL;
259 }
260
261 chip->clock_id = cs->bClockID;
262
263 for (i = 0; i < assoc->bInterfaceCount; i++) { 247 for (i = 0; i < assoc->bInterfaceCount; i++) {
264 int intf = assoc->bFirstInterface + i; 248 int intf = assoc->bFirstInterface + i;
265 249
@@ -481,6 +465,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
481 goto __error; 465 goto __error;
482 } 466 }
483 467
468 chip->ctrl_intf = alts;
469
484 if (err > 0) { 470 if (err > 0) {
485 /* create normal USB audio interfaces */ 471 /* create normal USB audio interfaces */
486 if (snd_usb_create_streams(chip, ifnum) < 0 || 472 if (snd_usb_create_streams(chip, ifnum) < 0 ||
diff --git a/sound/usb/card.h b/sound/usb/card.h
index ed92420c1095..1febf2f23754 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -25,6 +25,7 @@ struct audioformat {
25 unsigned int rate_min, rate_max; /* min/max rates */ 25 unsigned int rate_min, rate_max; /* min/max rates */
26 unsigned int nr_rates; /* number of rate table entries */ 26 unsigned int nr_rates; /* number of rate table entries */
27 unsigned int *rate_table; /* rate table */ 27 unsigned int *rate_table; /* rate table */
28 unsigned char clock; /* associated clock */
28}; 29};
29 30
30struct snd_usb_substream; 31struct snd_usb_substream;
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
new file mode 100644
index 000000000000..b7aadd614c70
--- /dev/null
+++ b/sound/usb/clock.c
@@ -0,0 +1,311 @@
1/*
2 * Clock domain and sample rate management functions
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20#include <linux/bitops.h>
21#include <linux/init.h>
22#include <linux/list.h>
23#include <linux/slab.h>
24#include <linux/string.h>
25#include <linux/usb.h>
26#include <linux/moduleparam.h>
27#include <linux/mutex.h>
28#include <linux/usb/audio.h>
29#include <linux/usb/audio-v2.h>
30
31#include <sound/core.h>
32#include <sound/info.h>
33#include <sound/pcm.h>
34#include <sound/pcm_params.h>
35#include <sound/initval.h>
36
37#include "usbaudio.h"
38#include "card.h"
39#include "midi.h"
40#include "mixer.h"
41#include "proc.h"
42#include "quirks.h"
43#include "endpoint.h"
44#include "helper.h"
45#include "debug.h"
46#include "pcm.h"
47#include "urb.h"
48#include "format.h"
49
50static struct uac_clock_source_descriptor *
51 snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface,
52 int clock_id)
53{
54 struct uac_clock_source_descriptor *cs = NULL;
55
56 while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
57 ctrl_iface->extralen,
58 cs, UAC2_CLOCK_SOURCE))) {
59 if (cs->bClockID == clock_id)
60 return cs;
61 }
62
63 return NULL;
64}
65
66static struct uac_clock_selector_descriptor *
67 snd_usb_find_clock_selector(struct usb_host_interface *ctrl_iface,
68 int clock_id)
69{
70 struct uac_clock_selector_descriptor *cs = NULL;
71
72 while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
73 ctrl_iface->extralen,
74 cs, UAC2_CLOCK_SELECTOR))) {
75 if (cs->bClockID == clock_id)
76 return cs;
77 }
78
79 return NULL;
80}
81
82static struct uac_clock_multiplier_descriptor *
83 snd_usb_find_clock_multiplier(struct usb_host_interface *ctrl_iface,
84 int clock_id)
85{
86 struct uac_clock_multiplier_descriptor *cs = NULL;
87
88 while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
89 ctrl_iface->extralen,
90 cs, UAC2_CLOCK_MULTIPLIER))) {
91 if (cs->bClockID == clock_id)
92 return cs;
93 }
94
95 return NULL;
96}
97
98static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_id)
99{
100 unsigned char buf;
101 int ret;
102
103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
104 UAC2_CS_CUR,
105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
106 UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8,
107 &buf, sizeof(buf), 1000);
108
109 if (ret < 0)
110 return ret;
111
112 return buf;
113}
114
115static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
116{
117 int err;
118 unsigned char data;
119 struct usb_device *dev = chip->dev;
120
121 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
122 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
123 UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8,
124 &data, sizeof(data), 1000);
125
126 if (err < 0) {
127 snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n",
128 __func__, source_id);
129 return err;
130 }
131
132 return !!data;
133}
134
135/* Try to find the clock source ID of a given clock entity */
136
137static int __uac_clock_find_source(struct snd_usb_audio *chip,
138 struct usb_host_interface *host_iface,
139 int entity_id, unsigned long *visited)
140{
141 struct uac_clock_source_descriptor *source;
142 struct uac_clock_selector_descriptor *selector;
143 struct uac_clock_multiplier_descriptor *multiplier;
144
145 entity_id &= 0xff;
146
147 if (test_and_set_bit(entity_id, visited)) {
148 snd_printk(KERN_WARNING
149 "%s(): recursive clock topology detected, id %d.\n",
150 __func__, entity_id);
151 return -EINVAL;
152 }
153
154 /* first, see if the ID we're looking for is a clock source already */
155 source = snd_usb_find_clock_source(host_iface, entity_id);
156 if (source)
157 return source->bClockID;
158
159 selector = snd_usb_find_clock_selector(host_iface, entity_id);
160 if (selector) {
161 int ret;
162
163 /* the entity ID we are looking for is a selector.
164 * find out what it currently selects */
165 ret = uac_clock_selector_get_val(chip, selector->bClockID);
166 if (ret < 0)
167 return ret;
168
169 if (ret > selector->bNrInPins || ret < 1) {
170 printk(KERN_ERR
171 "%s(): selector reported illegal value, id %d, ret %d\n",
172 __func__, selector->bClockID, ret);
173
174 return -EINVAL;
175 }
176
177 return __uac_clock_find_source(chip, host_iface,
178 selector->baCSourceID[ret-1],
179 visited);
180 }
181
182 /* FIXME: multipliers only act as pass-thru element for now */
183 multiplier = snd_usb_find_clock_multiplier(host_iface, entity_id);
184 if (multiplier)
185 return __uac_clock_find_source(chip, host_iface,
186 multiplier->bCSourceID, visited);
187
188 return -EINVAL;
189}
190
191int snd_usb_clock_find_source(struct snd_usb_audio *chip,
192 struct usb_host_interface *host_iface,
193 int entity_id)
194{
195 DECLARE_BITMAP(visited, 256);
196 memset(visited, 0, sizeof(visited));
197 return __uac_clock_find_source(chip, host_iface, entity_id, visited);
198}
199
200static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
201 struct usb_host_interface *alts,
202 struct audioformat *fmt, int rate)
203{
204 struct usb_device *dev = chip->dev;
205 unsigned int ep;
206 unsigned char data[3];
207 int err, crate;
208
209 ep = get_endpoint(alts, 0)->bEndpointAddress;
210
211 /* if endpoint doesn't have sampling rate control, bail out */
212 if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) {
213 snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n",
214 dev->devnum, iface, fmt->altsetting);
215 return 0;
216 }
217
218 data[0] = rate;
219 data[1] = rate >> 8;
220 data[2] = rate >> 16;
221 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
222 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
223 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
224 data, sizeof(data), 1000)) < 0) {
225 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
226 dev->devnum, iface, fmt->altsetting, rate, ep);
227 return err;
228 }
229
230 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
231 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
232 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
233 data, sizeof(data), 1000)) < 0) {
234 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
235 dev->devnum, iface, fmt->altsetting, ep);
236 return 0; /* some devices don't support reading */
237 }
238
239 crate = data[0] | (data[1] << 8) | (data[2] << 16);
240 if (crate != rate) {
241 snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
242 // runtime->rate = crate;
243 }
244
245 return 0;
246}
247
248static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
249 struct usb_host_interface *alts,
250 struct audioformat *fmt, int rate)
251{
252 struct usb_device *dev = chip->dev;
253 unsigned char data[4];
254 int err, crate;
255 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fmt->clock);
256
257 if (clock < 0)
258 return clock;
259
260 if (!uac_clock_source_is_valid(chip, clock)) {
261 snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n",
262 dev->devnum, iface, fmt->altsetting, clock);
263 return -ENXIO;
264 }
265
266 data[0] = rate;
267 data[1] = rate >> 8;
268 data[2] = rate >> 16;
269 data[3] = rate >> 24;
270 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
271 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
272 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
273 data, sizeof(data), 1000)) < 0) {
274 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
275 dev->devnum, iface, fmt->altsetting, rate);
276 return err;
277 }
278
279 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
280 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
281 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
282 data, sizeof(data), 1000)) < 0) {
283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
284 dev->devnum, iface, fmt->altsetting);
285 return err;
286 }
287
288 crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
289 if (crate != rate)
290 snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
291
292 return 0;
293}
294
295int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
296 struct usb_host_interface *alts,
297 struct audioformat *fmt, int rate)
298{
299 struct usb_interface_descriptor *altsd = get_iface_desc(alts);
300
301 switch (altsd->bInterfaceProtocol) {
302 case UAC_VERSION_1:
303 return set_sample_rate_v1(chip, iface, alts, fmt, rate);
304
305 case UAC_VERSION_2:
306 return set_sample_rate_v2(chip, iface, alts, fmt, rate);
307 }
308
309 return -EINVAL;
310}
311
diff --git a/sound/usb/clock.h b/sound/usb/clock.h
new file mode 100644
index 000000000000..beb253684e2d
--- /dev/null
+++ b/sound/usb/clock.h
@@ -0,0 +1,12 @@
1#ifndef __USBAUDIO_CLOCK_H
2#define __USBAUDIO_CLOCK_H
3
4int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
5 struct usb_host_interface *alts,
6 struct audioformat *fmt, int rate);
7
8int snd_usb_clock_find_source(struct snd_usb_audio *chip,
9 struct usb_host_interface *host_iface,
10 int entity_id);
11
12#endif /* __USBAUDIO_CLOCK_H */
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 28ee1ce3971a..9593b91452b9 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -190,6 +190,38 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
190 return attributes; 190 return attributes;
191} 191}
192 192
193static struct uac2_input_terminal_descriptor *
194 snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface,
195 int terminal_id)
196{
197 struct uac2_input_terminal_descriptor *term = NULL;
198
199 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
200 ctrl_iface->extralen,
201 term, UAC_INPUT_TERMINAL))) {
202 if (term->bTerminalID == terminal_id)
203 return term;
204 }
205
206 return NULL;
207}
208
209static struct uac2_output_terminal_descriptor *
210 snd_usb_find_output_terminal_descriptor(struct usb_host_interface *ctrl_iface,
211 int terminal_id)
212{
213 struct uac2_output_terminal_descriptor *term = NULL;
214
215 while ((term = snd_usb_find_csint_desc(ctrl_iface->extra,
216 ctrl_iface->extralen,
217 term, UAC_OUTPUT_TERMINAL))) {
218 if (term->bTerminalID == terminal_id)
219 return term;
220 }
221
222 return NULL;
223}
224
193int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) 225int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
194{ 226{
195 struct usb_device *dev; 227 struct usb_device *dev;
@@ -199,7 +231,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
199 int i, altno, err, stream; 231 int i, altno, err, stream;
200 int format = 0, num_channels = 0; 232 int format = 0, num_channels = 0;
201 struct audioformat *fp = NULL; 233 struct audioformat *fp = NULL;
202 int num, protocol; 234 int num, protocol, clock = 0;
203 struct uac_format_type_i_continuous_descriptor *fmt; 235 struct uac_format_type_i_continuous_descriptor *fmt;
204 236
205 dev = chip->dev; 237 dev = chip->dev;
@@ -263,6 +295,8 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
263 } 295 }
264 296
265 case UAC_VERSION_2: { 297 case UAC_VERSION_2: {
298 struct uac2_input_terminal_descriptor *input_term;
299 struct uac2_output_terminal_descriptor *output_term;
266 struct uac_as_header_descriptor_v2 *as = 300 struct uac_as_header_descriptor_v2 *as =
267 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); 301 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
268 302
@@ -281,7 +315,25 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
281 num_channels = as->bNrChannels; 315 num_channels = as->bNrChannels;
282 format = le32_to_cpu(as->bmFormats); 316 format = le32_to_cpu(as->bmFormats);
283 317
284 break; 318 /* lookup the terminal associated to this interface
319 * to extract the clock */
320 input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf,
321 as->bTerminalLink);
322 if (input_term) {
323 clock = input_term->bCSourceID;
324 break;
325 }
326
327 output_term = snd_usb_find_output_terminal_descriptor(chip->ctrl_intf,
328 as->bTerminalLink);
329 if (output_term) {
330 clock = output_term->bCSourceID;
331 break;
332 }
333
334 snd_printk(KERN_ERR "%d:%u:%d : bogus bTerminalLink %d\n",
335 dev->devnum, iface_no, altno, as->bTerminalLink);
336 continue;
285 } 337 }
286 338
287 default: 339 default:
@@ -338,6 +390,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
338 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 390 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
339 * (fp->maxpacksize & 0x7ff); 391 * (fp->maxpacksize & 0x7ff);
340 fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); 392 fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no);
393 fp->clock = clock;
341 394
342 /* some quirks for attributes here */ 395 /* some quirks for attributes here */
343 396
diff --git a/sound/usb/format.c b/sound/usb/format.c
index fe29d61de19b..5367cd1e52d9 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -29,6 +29,7 @@
29#include "quirks.h" 29#include "quirks.h"
30#include "helper.h" 30#include "helper.h"
31#include "debug.h" 31#include "debug.h"
32#include "clock.h"
32 33
33/* 34/*
34 * parse the audio format type I descriptor 35 * parse the audio format type I descriptor
@@ -215,15 +216,17 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
215 struct usb_device *dev = chip->dev; 216 struct usb_device *dev = chip->dev;
216 unsigned char tmp[2], *data; 217 unsigned char tmp[2], *data;
217 int i, nr_rates, data_size, ret = 0; 218 int i, nr_rates, data_size, ret = 0;
219 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock);
218 220
219 /* get the number of sample rates first by only fetching 2 bytes */ 221 /* get the number of sample rates first by only fetching 2 bytes */
220 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 222 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
221 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 223 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
222 UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, 224 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
223 tmp, sizeof(tmp), 1000); 225 tmp, sizeof(tmp), 1000);
224 226
225 if (ret < 0) { 227 if (ret < 0) {
226 snd_printk(KERN_ERR "unable to retrieve number of sample rates\n"); 228 snd_printk(KERN_ERR "%s(): unable to retrieve number of sample rates (clock %d)\n",
229 __func__, clock);
227 goto err; 230 goto err;
228 } 231 }
229 232
@@ -237,12 +240,13 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
237 240
238 /* now get the full information */ 241 /* now get the full information */
239 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 242 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
240 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 243 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
241 UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, 244 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
242 data, data_size, 1000); 245 data, data_size, 1000);
243 246
244 if (ret < 0) { 247 if (ret < 0) {
245 snd_printk(KERN_ERR "unable to retrieve sample rate range\n"); 248 snd_printk(KERN_ERR "%s(): unable to retrieve sample rate range (clock %d)\n",
249 __func__, clock);
246 ret = -EINVAL; 250 ret = -EINVAL;
247 goto err_free; 251 goto err_free;
248 } 252 }
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 03ce971e0027..a060d005e209 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -78,39 +78,6 @@ enum {
78 USB_MIXER_U16, 78 USB_MIXER_U16,
79}; 79};
80 80
81enum {
82 USB_PROC_UPDOWN = 1,
83 USB_PROC_UPDOWN_SWITCH = 1,
84 USB_PROC_UPDOWN_MODE_SEL = 2,
85
86 USB_PROC_PROLOGIC = 2,
87 USB_PROC_PROLOGIC_SWITCH = 1,
88 USB_PROC_PROLOGIC_MODE_SEL = 2,
89
90 USB_PROC_3DENH = 3,
91 USB_PROC_3DENH_SWITCH = 1,
92 USB_PROC_3DENH_SPACE = 2,
93
94 USB_PROC_REVERB = 4,
95 USB_PROC_REVERB_SWITCH = 1,
96 USB_PROC_REVERB_LEVEL = 2,
97 USB_PROC_REVERB_TIME = 3,
98 USB_PROC_REVERB_DELAY = 4,
99
100 USB_PROC_CHORUS = 5,
101 USB_PROC_CHORUS_SWITCH = 1,
102 USB_PROC_CHORUS_LEVEL = 2,
103 USB_PROC_CHORUS_RATE = 3,
104 USB_PROC_CHORUS_DEPTH = 4,
105
106 USB_PROC_DCR = 6,
107 USB_PROC_DCR_SWITCH = 1,
108 USB_PROC_DCR_RATIO = 2,
109 USB_PROC_DCR_MAX_AMP = 3,
110 USB_PROC_DCR_THRESHOLD = 4,
111 USB_PROC_DCR_ATTACK = 5,
112 USB_PROC_DCR_RELEASE = 6,
113};
114 81
115/*E-mu 0202(0404) eXtension Unit(XU) control*/ 82/*E-mu 0202(0404) eXtension Unit(XU) control*/
116enum { 83enum {
@@ -198,22 +165,24 @@ static int check_mapped_selector_name(struct mixer_build *state, int unitid,
198 165
199/* 166/*
200 * find an audio control unit with the given unit id 167 * find an audio control unit with the given unit id
201 * this doesn't return any clock related units, so they need to be handled elsewhere
202 */ 168 */
203static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit) 169static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit)
204{ 170{
205 unsigned char *p; 171 /* we just parse the header */
172 struct uac_feature_unit_descriptor *hdr = NULL;
206 173
207 p = NULL; 174 while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr,
208 while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, 175 USB_DT_CS_INTERFACE)) != NULL) {
209 USB_DT_CS_INTERFACE)) != NULL) { 176 if (hdr->bLength >= 4 &&
210 if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC2_EXTENSION_UNIT_V2 && p[3] == unit) 177 hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL &&
211 return p; 178 hdr->bDescriptorSubtype <= UAC2_SAMPLE_RATE_CONVERTER &&
179 hdr->bUnitID == unit)
180 return hdr;
212 } 181 }
182
213 return NULL; 183 return NULL;
214} 184}
215 185
216
217/* 186/*
218 * copy a string with the given id 187 * copy a string with the given id
219 */ 188 */
@@ -344,8 +313,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
344 buf, sizeof(buf), 1000); 313 buf, sizeof(buf), 1000);
345 314
346 if (ret < 0) { 315 if (ret < 0) {
347 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 316 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
348 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); 317 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type);
349 return ret; 318 return ret;
350 } 319 }
351 320
@@ -462,6 +431,16 @@ static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
462 int index, int value) 431 int index, int value)
463{ 432{
464 int err; 433 int err;
434 unsigned int read_only = (channel == 0) ?
435 cval->master_readonly :
436 cval->ch_readonly & (1 << (channel - 1));
437
438 if (read_only) {
439 snd_printdd(KERN_INFO "%s(): channel %d of control %d is read_only\n",
440 __func__, channel, cval->control);
441 return 0;
442 }
443
465 err = snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel, 444 err = snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel,
466 value); 445 value);
467 if (err < 0) 446 if (err < 0)
@@ -631,6 +610,7 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm
631 */ 610 */
632static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term) 611static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term)
633{ 612{
613 int err;
634 void *p1; 614 void *p1;
635 615
636 memset(term, 0, sizeof(*term)); 616 memset(term, 0, sizeof(*term));
@@ -651,6 +631,11 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
651 term->channels = d->bNrChannels; 631 term->channels = d->bNrChannels;
652 term->chconfig = le32_to_cpu(d->bmChannelConfig); 632 term->chconfig = le32_to_cpu(d->bmChannelConfig);
653 term->name = d->iTerminal; 633 term->name = d->iTerminal;
634
635 /* call recursively to get the clock selectors */
636 err = check_input_term(state, d->bCSourceID, term);
637 if (err < 0)
638 return err;
654 } 639 }
655 return 0; 640 return 0;
656 case UAC_FEATURE_UNIT: { 641 case UAC_FEATURE_UNIT: {
@@ -667,7 +652,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
667 term->name = uac_mixer_unit_iMixer(d); 652 term->name = uac_mixer_unit_iMixer(d);
668 return 0; 653 return 0;
669 } 654 }
670 case UAC_SELECTOR_UNIT: { 655 case UAC_SELECTOR_UNIT:
656 case UAC2_CLOCK_SELECTOR: {
671 struct uac_selector_unit_descriptor *d = p1; 657 struct uac_selector_unit_descriptor *d = p1;
672 /* call recursively to retrieve the channel info */ 658 /* call recursively to retrieve the channel info */
673 if (check_input_term(state, d->baSourceID[0], term) < 0) 659 if (check_input_term(state, d->baSourceID[0], term) < 0)
@@ -690,6 +676,13 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
690 term->name = uac_processing_unit_iProcessing(d, state->mixer->protocol); 676 term->name = uac_processing_unit_iProcessing(d, state->mixer->protocol);
691 return 0; 677 return 0;
692 } 678 }
679 case UAC2_CLOCK_SOURCE: {
680 struct uac_clock_source_descriptor *d = p1;
681 term->type = d->bDescriptorSubtype << 16; /* virtual type */
682 term->id = id;
683 term->name = d->iClockSource;
684 return 0;
685 }
693 default: 686 default:
694 return -ENODEV; 687 return -ENODEV;
695 } 688 }
@@ -709,16 +702,20 @@ struct usb_feature_control_info {
709}; 702};
710 703
711static struct usb_feature_control_info audio_feature_info[] = { 704static struct usb_feature_control_info audio_feature_info[] = {
712 { "Mute", USB_MIXER_INV_BOOLEAN }, 705 { "Mute", USB_MIXER_INV_BOOLEAN },
713 { "Volume", USB_MIXER_S16 }, 706 { "Volume", USB_MIXER_S16 },
714 { "Tone Control - Bass", USB_MIXER_S8 }, 707 { "Tone Control - Bass", USB_MIXER_S8 },
715 { "Tone Control - Mid", USB_MIXER_S8 }, 708 { "Tone Control - Mid", USB_MIXER_S8 },
716 { "Tone Control - Treble", USB_MIXER_S8 }, 709 { "Tone Control - Treble", USB_MIXER_S8 },
717 { "Graphic Equalizer", USB_MIXER_S8 }, /* FIXME: not implemeted yet */ 710 { "Graphic Equalizer", USB_MIXER_S8 }, /* FIXME: not implemeted yet */
718 { "Auto Gain Control", USB_MIXER_BOOLEAN }, 711 { "Auto Gain Control", USB_MIXER_BOOLEAN },
719 { "Delay Control", USB_MIXER_U16 }, 712 { "Delay Control", USB_MIXER_U16 },
720 { "Bass Boost", USB_MIXER_BOOLEAN }, 713 { "Bass Boost", USB_MIXER_BOOLEAN },
721 { "Loudness", USB_MIXER_BOOLEAN }, 714 { "Loudness", USB_MIXER_BOOLEAN },
715 /* UAC2 specific */
716 { "Input Gain Control", USB_MIXER_U16 },
717 { "Input Gain Pad Control", USB_MIXER_BOOLEAN },
718 { "Phase Inverter Control", USB_MIXER_BOOLEAN },
722}; 719};
723 720
724 721
@@ -958,7 +955,7 @@ static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str)
958static void build_feature_ctl(struct mixer_build *state, void *raw_desc, 955static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
959 unsigned int ctl_mask, int control, 956 unsigned int ctl_mask, int control,
960 struct usb_audio_term *iterm, int unitid, 957 struct usb_audio_term *iterm, int unitid,
961 int read_only) 958 int readonly_mask)
962{ 959{
963 struct uac_feature_unit_descriptor *desc = raw_desc; 960 struct uac_feature_unit_descriptor *desc = raw_desc;
964 unsigned int len = 0; 961 unsigned int len = 0;
@@ -970,7 +967,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
970 967
971 control++; /* change from zero-based to 1-based value */ 968 control++; /* change from zero-based to 1-based value */
972 969
973 if (control == UAC_GRAPHIC_EQUALIZER_CONTROL) { 970 if (control == UAC_FU_GRAPHIC_EQUALIZER) {
974 /* FIXME: not supported yet */ 971 /* FIXME: not supported yet */
975 return; 972 return;
976 } 973 }
@@ -989,20 +986,25 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
989 cval->control = control; 986 cval->control = control;
990 cval->cmask = ctl_mask; 987 cval->cmask = ctl_mask;
991 cval->val_type = audio_feature_info[control-1].type; 988 cval->val_type = audio_feature_info[control-1].type;
992 if (ctl_mask == 0) 989 if (ctl_mask == 0) {
993 cval->channels = 1; /* master channel */ 990 cval->channels = 1; /* master channel */
994 else { 991 cval->master_readonly = readonly_mask;
992 } else {
995 int i, c = 0; 993 int i, c = 0;
996 for (i = 0; i < 16; i++) 994 for (i = 0; i < 16; i++)
997 if (ctl_mask & (1 << i)) 995 if (ctl_mask & (1 << i))
998 c++; 996 c++;
999 cval->channels = c; 997 cval->channels = c;
998 cval->ch_readonly = readonly_mask;
1000 } 999 }
1001 1000
1002 /* get min/max values */ 1001 /* get min/max values */
1003 get_min_max(cval, 0); 1002 get_min_max(cval, 0);
1004 1003
1005 if (read_only) 1004 /* if all channels in the mask are marked read-only, make the control
1005 * read-only. set_cur_mix_value() will check the mask again and won't
1006 * issue write commands to read-only channels. */
1007 if (cval->channels == readonly_mask)
1006 kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval); 1008 kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval);
1007 else 1009 else
1008 kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); 1010 kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);
@@ -1021,8 +1023,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1021 kctl->id.name, sizeof(kctl->id.name)); 1023 kctl->id.name, sizeof(kctl->id.name));
1022 1024
1023 switch (control) { 1025 switch (control) {
1024 case UAC_MUTE_CONTROL: 1026 case UAC_FU_MUTE:
1025 case UAC_VOLUME_CONTROL: 1027 case UAC_FU_VOLUME:
1026 /* determine the control name. the rule is: 1028 /* determine the control name. the rule is:
1027 * - if a name id is given in descriptor, use it. 1029 * - if a name id is given in descriptor, use it.
1028 * - if the connected input can be determined, then use the name 1030 * - if the connected input can be determined, then use the name
@@ -1049,9 +1051,9 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1049 len = append_ctl_name(kctl, " Playback"); 1051 len = append_ctl_name(kctl, " Playback");
1050 } 1052 }
1051 } 1053 }
1052 append_ctl_name(kctl, control == UAC_MUTE_CONTROL ? 1054 append_ctl_name(kctl, control == UAC_FU_MUTE ?
1053 " Switch" : " Volume"); 1055 " Switch" : " Volume");
1054 if (control == UAC_VOLUME_CONTROL) { 1056 if (control == UAC_FU_VOLUME) {
1055 kctl->tlv.c = mixer_vol_tlv; 1057 kctl->tlv.c = mixer_vol_tlv;
1056 kctl->vd[0].access |= 1058 kctl->vd[0].access |=
1057 SNDRV_CTL_ELEM_ACCESS_TLV_READ | 1059 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
@@ -1150,7 +1152,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
1150 snd_printk(KERN_INFO 1152 snd_printk(KERN_INFO
1151 "usbmixer: master volume quirk for PCM2702 chip\n"); 1153 "usbmixer: master volume quirk for PCM2702 chip\n");
1152 /* disable non-functional volume control */ 1154 /* disable non-functional volume control */
1153 master_bits &= ~UAC_FU_VOLUME; 1155 master_bits &= ~UAC_CONTROL_BIT(UAC_FU_VOLUME);
1154 break; 1156 break;
1155 } 1157 }
1156 if (channels > 0) 1158 if (channels > 0)
@@ -1188,19 +1190,22 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
1188 1190
1189 for (j = 0; j < channels; j++) { 1191 for (j = 0; j < channels; j++) {
1190 unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize); 1192 unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize);
1191 if (mask & (1 << (i * 2))) { 1193 if (uac2_control_is_readable(mask, i)) {
1192 ch_bits |= (1 << j); 1194 ch_bits |= (1 << j);
1193 if (~mask & (1 << ((i * 2) + 1))) 1195 if (!uac2_control_is_writeable(mask, i))
1194 ch_read_only |= (1 << j); 1196 ch_read_only |= (1 << j);
1195 } 1197 }
1196 } 1198 }
1197 1199
1198 /* FIXME: the whole unit is read-only if any of the channels is marked read-only */ 1200 /* NOTE: build_feature_ctl() will mark the control read-only if all channels
1201 * are marked read-only in the descriptors. Otherwise, the control will be
1202 * reported as writeable, but the driver will not actually issue a write
1203 * command for read-only channels */
1199 if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ 1204 if (ch_bits & 1) /* the first channel must be set (for ease of programming) */
1200 build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, !!ch_read_only); 1205 build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, ch_read_only);
1201 if (master_bits & (1 << i * 2)) 1206 if (uac2_control_is_readable(master_bits, i))
1202 build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, 1207 build_feature_ctl(state, _ftr, 0, i, &iterm, unitid,
1203 ~master_bits & (1 << ((i * 2) + 1))); 1208 !uac2_control_is_writeable(master_bits, i));
1204 } 1209 }
1205 } 1210 }
1206 1211
@@ -1392,51 +1397,51 @@ struct procunit_info {
1392}; 1397};
1393 1398
1394static struct procunit_value_info updown_proc_info[] = { 1399static struct procunit_value_info updown_proc_info[] = {
1395 { USB_PROC_UPDOWN_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1400 { UAC_UD_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1396 { USB_PROC_UPDOWN_MODE_SEL, "Mode Select", USB_MIXER_U8, 1 }, 1401 { UAC_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 },
1397 { 0 } 1402 { 0 }
1398}; 1403};
1399static struct procunit_value_info prologic_proc_info[] = { 1404static struct procunit_value_info prologic_proc_info[] = {
1400 { USB_PROC_PROLOGIC_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1405 { UAC_DP_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1401 { USB_PROC_PROLOGIC_MODE_SEL, "Mode Select", USB_MIXER_U8, 1 }, 1406 { UAC_DP_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 },
1402 { 0 } 1407 { 0 }
1403}; 1408};
1404static struct procunit_value_info threed_enh_proc_info[] = { 1409static struct procunit_value_info threed_enh_proc_info[] = {
1405 { USB_PROC_3DENH_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1410 { UAC_3D_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1406 { USB_PROC_3DENH_SPACE, "Spaciousness", USB_MIXER_U8 }, 1411 { UAC_3D_SPACE, "Spaciousness", USB_MIXER_U8 },
1407 { 0 } 1412 { 0 }
1408}; 1413};
1409static struct procunit_value_info reverb_proc_info[] = { 1414static struct procunit_value_info reverb_proc_info[] = {
1410 { USB_PROC_REVERB_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1415 { UAC_REVERB_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1411 { USB_PROC_REVERB_LEVEL, "Level", USB_MIXER_U8 }, 1416 { UAC_REVERB_LEVEL, "Level", USB_MIXER_U8 },
1412 { USB_PROC_REVERB_TIME, "Time", USB_MIXER_U16 }, 1417 { UAC_REVERB_TIME, "Time", USB_MIXER_U16 },
1413 { USB_PROC_REVERB_DELAY, "Delay", USB_MIXER_U8 }, 1418 { UAC_REVERB_FEEDBACK, "Feedback", USB_MIXER_U8 },
1414 { 0 } 1419 { 0 }
1415}; 1420};
1416static struct procunit_value_info chorus_proc_info[] = { 1421static struct procunit_value_info chorus_proc_info[] = {
1417 { USB_PROC_CHORUS_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1422 { UAC_CHORUS_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1418 { USB_PROC_CHORUS_LEVEL, "Level", USB_MIXER_U8 }, 1423 { UAC_CHORUS_LEVEL, "Level", USB_MIXER_U8 },
1419 { USB_PROC_CHORUS_RATE, "Rate", USB_MIXER_U16 }, 1424 { UAC_CHORUS_RATE, "Rate", USB_MIXER_U16 },
1420 { USB_PROC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 }, 1425 { UAC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 },
1421 { 0 } 1426 { 0 }
1422}; 1427};
1423static struct procunit_value_info dcr_proc_info[] = { 1428static struct procunit_value_info dcr_proc_info[] = {
1424 { USB_PROC_DCR_SWITCH, "Switch", USB_MIXER_BOOLEAN }, 1429 { UAC_DCR_ENABLE, "Switch", USB_MIXER_BOOLEAN },
1425 { USB_PROC_DCR_RATIO, "Ratio", USB_MIXER_U16 }, 1430 { UAC_DCR_RATE, "Ratio", USB_MIXER_U16 },
1426 { USB_PROC_DCR_MAX_AMP, "Max Amp", USB_MIXER_S16 }, 1431 { UAC_DCR_MAXAMPL, "Max Amp", USB_MIXER_S16 },
1427 { USB_PROC_DCR_THRESHOLD, "Threshold", USB_MIXER_S16 }, 1432 { UAC_DCR_THRESHOLD, "Threshold", USB_MIXER_S16 },
1428 { USB_PROC_DCR_ATTACK, "Attack Time", USB_MIXER_U16 }, 1433 { UAC_DCR_ATTACK_TIME, "Attack Time", USB_MIXER_U16 },
1429 { USB_PROC_DCR_RELEASE, "Release Time", USB_MIXER_U16 }, 1434 { UAC_DCR_RELEASE_TIME, "Release Time", USB_MIXER_U16 },
1430 { 0 } 1435 { 0 }
1431}; 1436};
1432 1437
1433static struct procunit_info procunits[] = { 1438static struct procunit_info procunits[] = {
1434 { USB_PROC_UPDOWN, "Up Down", updown_proc_info }, 1439 { UAC_PROCESS_UP_DOWNMIX, "Up Down", updown_proc_info },
1435 { USB_PROC_PROLOGIC, "Dolby Prologic", prologic_proc_info }, 1440 { UAC_PROCESS_DOLBY_PROLOGIC, "Dolby Prologic", prologic_proc_info },
1436 { USB_PROC_3DENH, "3D Stereo Extender", threed_enh_proc_info }, 1441 { UAC_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", threed_enh_proc_info },
1437 { USB_PROC_REVERB, "Reverb", reverb_proc_info }, 1442 { UAC_PROCESS_REVERB, "Reverb", reverb_proc_info },
1438 { USB_PROC_CHORUS, "Chorus", chorus_proc_info }, 1443 { UAC_PROCESS_CHORUS, "Chorus", chorus_proc_info },
1439 { USB_PROC_DCR, "DCR", dcr_proc_info }, 1444 { UAC_PROCESS_DYN_RANGE_COMP, "DCR", dcr_proc_info },
1440 { 0 }, 1445 { 0 },
1441}; 1446};
1442/* 1447/*
@@ -1524,7 +1529,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
1524 cval->channels = 1; 1529 cval->channels = 1;
1525 1530
1526 /* get min/max values */ 1531 /* get min/max values */
1527 if (type == USB_PROC_UPDOWN && cval->control == USB_PROC_UPDOWN_MODE_SEL) { 1532 if (type == UAC_PROCESS_UP_DOWNMIX && cval->control == UAC_UD_MODE_SELECT) {
1528 __u8 *control_spec = uac_processing_unit_specific(desc, state->mixer->protocol); 1533 __u8 *control_spec = uac_processing_unit_specific(desc, state->mixer->protocol);
1529 /* FIXME: hard-coded */ 1534 /* FIXME: hard-coded */
1530 cval->min = 1; 1535 cval->min = 1;
@@ -1619,7 +1624,7 @@ static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
1619 struct usb_mixer_elem_info *cval = kcontrol->private_data; 1624 struct usb_mixer_elem_info *cval = kcontrol->private_data;
1620 int val, err; 1625 int val, err;
1621 1626
1622 err = get_cur_ctl_value(cval, 0, &val); 1627 err = get_cur_ctl_value(cval, cval->control << 8, &val);
1623 if (err < 0) { 1628 if (err < 0) {
1624 if (cval->mixer->ignore_ctl_error) { 1629 if (cval->mixer->ignore_ctl_error) {
1625 ucontrol->value.enumerated.item[0] = 0; 1630 ucontrol->value.enumerated.item[0] = 0;
@@ -1638,7 +1643,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
1638 struct usb_mixer_elem_info *cval = kcontrol->private_data; 1643 struct usb_mixer_elem_info *cval = kcontrol->private_data;
1639 int val, oval, err; 1644 int val, oval, err;
1640 1645
1641 err = get_cur_ctl_value(cval, 0, &oval); 1646 err = get_cur_ctl_value(cval, cval->control << 8, &oval);
1642 if (err < 0) { 1647 if (err < 0) {
1643 if (cval->mixer->ignore_ctl_error) 1648 if (cval->mixer->ignore_ctl_error)
1644 return 0; 1649 return 0;
@@ -1647,7 +1652,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
1647 val = ucontrol->value.enumerated.item[0]; 1652 val = ucontrol->value.enumerated.item[0];
1648 val = get_abs_value(cval, val); 1653 val = get_abs_value(cval, val);
1649 if (val != oval) { 1654 if (val != oval) {
1650 set_cur_ctl_value(cval, 0, val); 1655 set_cur_ctl_value(cval, cval->control << 8, val);
1651 return 1; 1656 return 1;
1652 } 1657 }
1653 return 0; 1658 return 0;
@@ -1729,6 +1734,11 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
1729 cval->res = 1; 1734 cval->res = 1;
1730 cval->initialized = 1; 1735 cval->initialized = 1;
1731 1736
1737 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR)
1738 cval->control = UAC2_CX_CLOCK_SELECTOR;
1739 else
1740 cval->control = 0;
1741
1732 namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); 1742 namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
1733 if (! namelist) { 1743 if (! namelist) {
1734 snd_printk(KERN_ERR "cannot malloc\n"); 1744 snd_printk(KERN_ERR "cannot malloc\n");
@@ -1778,7 +1788,9 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
1778 if (! len) 1788 if (! len)
1779 strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); 1789 strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
1780 1790
1781 if ((state->oterm.type & 0xff00) == 0x0100) 1791 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR)
1792 append_ctl_name(kctl, " Clock Source");
1793 else if ((state->oterm.type & 0xff00) == 0x0100)
1782 append_ctl_name(kctl, " Capture Source"); 1794 append_ctl_name(kctl, " Capture Source");
1783 else 1795 else
1784 append_ctl_name(kctl, " Playback Source"); 1796 append_ctl_name(kctl, " Playback Source");
@@ -1812,10 +1824,12 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
1812 1824
1813 switch (p1[2]) { 1825 switch (p1[2]) {
1814 case UAC_INPUT_TERMINAL: 1826 case UAC_INPUT_TERMINAL:
1827 case UAC2_CLOCK_SOURCE:
1815 return 0; /* NOP */ 1828 return 0; /* NOP */
1816 case UAC_MIXER_UNIT: 1829 case UAC_MIXER_UNIT:
1817 return parse_audio_mixer_unit(state, unitid, p1); 1830 return parse_audio_mixer_unit(state, unitid, p1);
1818 case UAC_SELECTOR_UNIT: 1831 case UAC_SELECTOR_UNIT:
1832 case UAC2_CLOCK_SELECTOR:
1819 return parse_audio_selector_unit(state, unitid, p1); 1833 return parse_audio_selector_unit(state, unitid, p1);
1820 case UAC_FEATURE_UNIT: 1834 case UAC_FEATURE_UNIT:
1821 return parse_audio_feature_unit(state, unitid, p1); 1835 return parse_audio_feature_unit(state, unitid, p1);
@@ -1912,6 +1926,11 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1912 err = parse_audio_unit(&state, desc->bSourceID); 1926 err = parse_audio_unit(&state, desc->bSourceID);
1913 if (err < 0) 1927 if (err < 0)
1914 return err; 1928 return err;
1929
1930 /* for UAC2, use the same approach to also add the clock selectors */
1931 err = parse_audio_unit(&state, desc->bCSourceID);
1932 if (err < 0)
1933 return err;
1915 } 1934 }
1916 } 1935 }
1917 1936
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 130123854a6c..a7cf1007fbb0 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -34,6 +34,8 @@ struct usb_mixer_elem_info {
34 unsigned int id; 34 unsigned int id;
35 unsigned int control; /* CS or ICN (high byte) */ 35 unsigned int control; /* CS or ICN (high byte) */
36 unsigned int cmask; /* channel mask bitmap: 0 = master */ 36 unsigned int cmask; /* channel mask bitmap: 0 = master */
37 unsigned int ch_readonly;
38 unsigned int master_readonly;
37 int channels; 39 int channels;
38 int val_type; 40 int val_type;
39 int min, max, res; 41 int min, max, res;
diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
index d93fc89beba8..f1324c423835 100644
--- a/sound/usb/mixer_maps.c
+++ b/sound/usb/mixer_maps.c
@@ -85,8 +85,8 @@ static struct usbmix_name_map extigy_map[] = {
85 /* 16: MU (w/o controls) */ 85 /* 16: MU (w/o controls) */
86 { 17, NULL, 1 }, /* DISABLED: PU-switch (any effect?) */ 86 { 17, NULL, 1 }, /* DISABLED: PU-switch (any effect?) */
87 { 17, "Channel Routing", 2 }, /* PU: mode select */ 87 { 17, "Channel Routing", 2 }, /* PU: mode select */
88 { 18, "Tone Control - Bass", UAC_BASS_CONTROL }, /* FU */ 88 { 18, "Tone Control - Bass", UAC_FU_BASS }, /* FU */
89 { 18, "Tone Control - Treble", UAC_TREBLE_CONTROL }, /* FU */ 89 { 18, "Tone Control - Treble", UAC_FU_TREBLE }, /* FU */
90 { 18, "Master Playback" }, /* FU; others */ 90 { 18, "Master Playback" }, /* FU; others */
91 /* 19: OT speaker */ 91 /* 19: OT speaker */
92 /* 20: OT headphone */ 92 /* 20: OT headphone */
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 056587de7be4..456829882f40 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -31,6 +31,7 @@
31#include "urb.h" 31#include "urb.h"
32#include "helper.h" 32#include "helper.h"
33#include "pcm.h" 33#include "pcm.h"
34#include "clock.h"
34 35
35/* 36/*
36 * return the current pcm pointer. just based on the hwptr_done value. 37 * return the current pcm pointer. just based on the hwptr_done value.
@@ -181,103 +182,6 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
181 return -EINVAL; 182 return -EINVAL;
182} 183}
183 184
184static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
185 struct usb_host_interface *alts,
186 struct audioformat *fmt, int rate)
187{
188 struct usb_device *dev = chip->dev;
189 unsigned int ep;
190 unsigned char data[3];
191 int err, crate;
192
193 ep = get_endpoint(alts, 0)->bEndpointAddress;
194 /* if endpoint doesn't have sampling rate control, bail out */
195 if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) {
196 snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n",
197 dev->devnum, iface, fmt->altsetting);
198 return 0;
199 }
200
201 data[0] = rate;
202 data[1] = rate >> 8;
203 data[2] = rate >> 16;
204 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
205 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
206 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
207 data, sizeof(data), 1000)) < 0) {
208 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
209 dev->devnum, iface, fmt->altsetting, rate, ep);
210 return err;
211 }
212 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
213 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
214 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
215 data, sizeof(data), 1000)) < 0) {
216 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
217 dev->devnum, iface, fmt->altsetting, ep);
218 return 0; /* some devices don't support reading */
219 }
220 crate = data[0] | (data[1] << 8) | (data[2] << 16);
221 if (crate != rate) {
222 snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
223 // runtime->rate = crate;
224 }
225
226 return 0;
227}
228
229static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
230 struct usb_host_interface *alts,
231 struct audioformat *fmt, int rate)
232{
233 struct usb_device *dev = chip->dev;
234 unsigned char data[4];
235 int err, crate;
236
237 data[0] = rate;
238 data[1] = rate >> 8;
239 data[2] = rate >> 16;
240 data[3] = rate >> 24;
241 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
242 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
243 UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8,
244 data, sizeof(data), 1000)) < 0) {
245 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
246 dev->devnum, iface, fmt->altsetting, rate);
247 return err;
248 }
249 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
250 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
251 UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8,
252 data, sizeof(data), 1000)) < 0) {
253 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
254 dev->devnum, iface, fmt->altsetting);
255 return err;
256 }
257 crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
258 if (crate != rate)
259 snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
260
261 return 0;
262}
263
264int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
265 struct usb_host_interface *alts,
266 struct audioformat *fmt, int rate)
267{
268 struct usb_interface_descriptor *altsd = get_iface_desc(alts);
269
270 switch (altsd->bInterfaceProtocol) {
271 case UAC_VERSION_1:
272 return set_sample_rate_v1(chip, iface, alts, fmt, rate);
273
274 case UAC_VERSION_2:
275 return set_sample_rate_v2(chip, iface, alts, fmt, rate);
276 }
277
278 return -EINVAL;
279}
280
281/* 185/*
282 * find a matching format and set up the interface 186 * find a matching format and set up the interface
283 */ 187 */
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 06ebf24d3a4d..24d3319cc34d 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -40,9 +40,6 @@ struct snd_usb_audio {
40 int num_interfaces; 40 int num_interfaces;
41 int num_suspended_intf; 41 int num_suspended_intf;
42 42
43 /* for audio class v2 */
44 int clock_id;
45
46 struct list_head pcm_list; /* list of pcm streams */ 43 struct list_head pcm_list; /* list of pcm streams */
47 int pcm_devs; 44 int pcm_devs;
48 45
@@ -53,6 +50,8 @@ struct snd_usb_audio {
53 int setup; /* from the 'device_setup' module param */ 50 int setup; /* from the 'device_setup' module param */
54 int nrpacks; /* from the 'nrpacks' module param */ 51 int nrpacks; /* from the 'nrpacks' module param */
55 int async_unlink; /* from the 'async_unlink' module param */ 52 int async_unlink; /* from the 'async_unlink' module param */
53
54 struct usb_host_interface *ctrl_intf; /* the audio control interface */
56}; 55};
57 56
58/* 57/*