aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-02-15 13:36:30 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-02-15 13:36:30 -0500
commit52833e897fd8c6f62b3e5e27291fa9bc803f7460 (patch)
treecfe90047ee6c7402674a29ec7258319142b96ff1 /drivers
parent8d042218b075de3cdbe066198515b3521553746e (diff)
parent4ee29f6a52158cea526b16a44ae38643946103ec (diff)
Merge branch 'linus_origin' into hotfixes
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/blacklist.c64
-rw-r--r--drivers/acpi/event.c2
-rw-r--r--drivers/acpi/hardware/hwsleep.c1
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/processor_idle.c19
-rw-r--r--drivers/block/swim3.c4
-rw-r--r--drivers/char/hvc_rtas.c2
-rw-r--r--drivers/cpuidle/cpuidle.c3
-rw-r--r--drivers/cpuidle/sysfs.c14
-rw-r--r--drivers/hid/hid-input-quirks.c17
-rw-r--r--drivers/hid/hid-input.c8
-rw-r--r--drivers/hid/usbhid/hid-quirks.c38
-rw-r--r--drivers/infiniband/core/cm.c26
-rw-r--r--drivers/infiniband/core/cma.c10
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c17
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c1
-rw-r--r--drivers/macintosh/mediabay.c2
-rw-r--r--drivers/md/bitmap.c8
-rw-r--r--drivers/md/dm-table.c4
-rw-r--r--drivers/md/md.c3
-rw-r--r--drivers/misc/thinkpad_acpi.c4
-rw-r--r--drivers/mtd/mtdsuper.c14
-rw-r--r--drivers/net/mlx4/mr.c21
-rw-r--r--drivers/oprofile/buffer_sync.c21
-rw-r--r--drivers/pnp/pnpacpi/core.c2
-rw-r--r--drivers/pnp/pnpbios/core.c2
-rw-r--r--drivers/ps3/ps3-lpm.c22
-rw-r--r--drivers/ps3/ps3-sys-manager.c44
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/serial/sh-sci.h9
-rw-r--r--drivers/sh/maple/maple.c981
-rw-r--r--drivers/usb/gadget/file_storage.c8
36 files changed, 772 insertions, 613 deletions
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 9ce983ed60f0..ea92bac42c53 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -186,6 +186,12 @@ static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d)
186 acpi_dmi_osi_linux(-1, d); /* unknown */ 186 acpi_dmi_osi_linux(-1, d); /* unknown */
187 return 0; 187 return 0;
188} 188}
189static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
190{
191 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
192 acpi_osi_setup("!Windows 2006");
193 return 0;
194}
189 195
190/* 196/*
191 * Most BIOS that invoke OSI(Linux) do nothing with it. 197 * Most BIOS that invoke OSI(Linux) do nothing with it.
@@ -228,10 +234,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
228 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), 234 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"),
229 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), 235 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"),
230 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), 236 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"),
231 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
232 * 237 *
233 * _OSI(Linux) is a NOP: 238 * _OSI(Linux) is a NOP:
234 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), 239 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"),
240 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
235 */ 241 */
236 { 242 {
237 .callback = dmi_disable_osi_linux, 243 .callback = dmi_disable_osi_linux,
@@ -327,12 +333,20 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
327 }, 333 },
328 { /* OSI(Linux) effect unknown */ 334 { /* OSI(Linux) effect unknown */
329 .callback = dmi_unknown_osi_linux, 335 .callback = dmi_unknown_osi_linux,
330 .ident = "Dell OP GX620", 336 .ident = "Dell OptiPlex GX620",
331 .matches = { 337 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 338 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
333 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), 339 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"),
334 }, 340 },
335 }, 341 },
342 { /* OSI(Linux) causes some USB initialization to not run */
343 .callback = dmi_unknown_osi_linux,
344 .ident = "Dell OptiPlex 755",
345 .matches = {
346 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
347 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"),
348 },
349 },
336 { /* OSI(Linux) effect unknown */ 350 { /* OSI(Linux) effect unknown */
337 .callback = dmi_unknown_osi_linux, 351 .callback = dmi_unknown_osi_linux,
338 .ident = "Dell PE 1900", 352 .ident = "Dell PE 1900",
@@ -342,6 +356,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
342 }, 356 },
343 }, 357 },
344 { /* OSI(Linux) is a NOP */ 358 { /* OSI(Linux) is a NOP */
359 .callback = dmi_unknown_osi_linux,
360 .ident = "Dell PE 1950",
361 .matches = {
362 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
363 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
364 },
365 },
366 { /* OSI(Linux) is a NOP */
345 .callback = dmi_disable_osi_linux, 367 .callback = dmi_disable_osi_linux,
346 .ident = "Dell PE R200", 368 .ident = "Dell PE R200",
347 .matches = { 369 .matches = {
@@ -357,6 +379,22 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
357 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), 379 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"),
358 }, 380 },
359 }, 381 },
382 { /* OSI(Linux) touches USB */
383 .callback = dmi_unknown_osi_linux,
384 .ident = "Dell PR 390",
385 .matches = {
386 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
387 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"),
388 },
389 },
390 { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */
391 .callback = dmi_unknown_osi_linux,
392 .ident = "Dell PR M4300",
393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"),
396 },
397 },
360 { /* OSI(Linux) is a NOP */ 398 { /* OSI(Linux) is a NOP */
361 .callback = dmi_disable_osi_linux, 399 .callback = dmi_disable_osi_linux,
362 .ident = "Dell Vostro 1000", 400 .ident = "Dell Vostro 1000",
@@ -390,10 +428,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
390 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"), 428 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"),
391 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"), 429 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"),
392 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"), 430 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"),
431 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
393 * _OSI(Linux) unknown effect: 432 * _OSI(Linux) unknown effect:
394 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"), 433 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"),
395 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"), 434 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"),
396 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
397 */ 435 */
398 { 436 {
399 .callback = dmi_disable_osi_linux, 437 .callback = dmi_disable_osi_linux,
@@ -402,6 +440,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
402 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 440 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
403 }, 441 },
404 }, 442 },
443 {
444 .callback = dmi_disable_osi_vista,
445 .ident = "Fujitsu Siemens",
446 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
449 },
450 },
405 /* 451 /*
406 * Disable OSI(Linux) warnings on all "Hewlett-Packard" 452 * Disable OSI(Linux) warnings on all "Hewlett-Packard"
407 * 453 *
@@ -443,10 +489,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
443 * _OSI(Linux) helps sound 489 * _OSI(Linux) helps sound
444 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"), 490 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"),
445 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"), 491 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"),
492 * _OSI(Linux) has Linux specific hooks
493 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
446 * _OSI(Linux) is a NOP: 494 * _OSI(Linux) is a NOP:
447 * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), 495 * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
448 * _OSI(Linux) effect unknown 496 * DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"),
449 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
450 */ 497 */
451 { 498 {
452 .callback = dmi_enable_osi_linux, 499 .callback = dmi_enable_osi_linux,
@@ -465,7 +512,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
465 }, 512 },
466 }, 513 },
467 { 514 {
468 .callback = dmi_unknown_osi_linux, 515 .callback = dmi_enable_osi_linux,
469 .ident = "Lenovo ThinkPad X61", 516 .ident = "Lenovo ThinkPad X61",
470 .matches = { 517 .matches = {
471 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 518 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -473,7 +520,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
473 }, 520 },
474 }, 521 },
475 { 522 {
476 .callback = dmi_unknown_osi_linux, 523 .callback = dmi_disable_osi_linux,
477 .ident = "Lenovo 3000 V100", 524 .ident = "Lenovo 3000 V100",
478 .matches = { 525 .matches = {
479 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 526 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -543,8 +590,9 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
543 * Disable OSI(Linux) warnings on all "Sony Corporation" 590 * Disable OSI(Linux) warnings on all "Sony Corporation"
544 * 591 *
545 * _OSI(Linux) is a NOP: 592 * _OSI(Linux) is a NOP:
546 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"), 593 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"),
547 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"), 594 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"),
595 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"),
548 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"), 596 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"),
549 * _OSI(Linux) unknown effect: 597 * _OSI(Linux) unknown effect:
550 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), 598 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"),
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 5479dc0eeeec..abec1ca94cf4 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -110,7 +110,7 @@ static const struct file_operations acpi_system_event_ops = {
110#endif /* CONFIG_ACPI_PROC_EVENT */ 110#endif /* CONFIG_ACPI_PROC_EVENT */
111 111
112/* ACPI notifier chain */ 112/* ACPI notifier chain */
113BLOCKING_NOTIFIER_HEAD(acpi_chain_head); 113static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
114 114
115int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) 115int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data)
116{ 116{
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 058d0be5cbe2..4290e0193097 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -616,6 +616,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
616 return_ACPI_STATUS(status); 616 return_ACPI_STATUS(status);
617 } 617 }
618 618
619 arg.integer.value = sleep_state;
619 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 620 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
620 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 621 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
621 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); 622 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 15e602377655..8edba7b678eb 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -325,7 +325,7 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
325} 325}
326 326
327#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD 327#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
328struct acpi_table_header *acpi_find_dsdt_initrd(void) 328static struct acpi_table_header *acpi_find_dsdt_initrd(void)
329{ 329{
330 struct file *firmware_file; 330 struct file *firmware_file;
331 mm_segment_t oldfs; 331 mm_segment_t oldfs;
@@ -419,7 +419,7 @@ acpi_os_table_override(struct acpi_table_header * existing_table,
419} 419}
420 420
421#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD 421#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
422int __init acpi_no_initrd_override_setup(char *s) 422static int __init acpi_no_initrd_override_setup(char *s)
423{ 423{
424 acpi_no_initrd_override = 1; 424 acpi_no_initrd_override = 1;
425 return 1; 425 return 1;
@@ -1109,7 +1109,7 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1109 * string starting with '!' disables that string 1109 * string starting with '!' disables that string
1110 * otherwise string is added to list, augmenting built-in strings 1110 * otherwise string is added to list, augmenting built-in strings
1111 */ 1111 */
1112static int __init acpi_osi_setup(char *str) 1112int __init acpi_osi_setup(char *str)
1113{ 1113{
1114 if (str == NULL || *str == '\0') { 1114 if (str == NULL || *str == '\0') {
1115 printk(KERN_INFO PREFIX "_OSI method disabled\n"); 1115 printk(KERN_INFO PREFIX "_OSI method disabled\n");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 32003fdc91e8..980e1c33e6c5 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -945,11 +945,16 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
945 * Otherwise, ignore this info and continue. 945 * Otherwise, ignore this info and continue.
946 */ 946 */
947 cx.entry_method = ACPI_CSTATE_HALT; 947 cx.entry_method = ACPI_CSTATE_HALT;
948 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
948 } else { 949 } else {
949 continue; 950 continue;
950 } 951 }
952 } else {
953 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
954 cx.address);
951 } 955 }
952 956
957
953 obj = &(element->package.elements[2]); 958 obj = &(element->package.elements[2]);
954 if (obj->type != ACPI_TYPE_INTEGER) 959 if (obj->type != ACPI_TYPE_INTEGER)
955 continue; 960 continue;
@@ -1420,6 +1425,14 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1420 return 0; 1425 return 0;
1421 1426
1422 local_irq_disable(); 1427 local_irq_disable();
1428
1429 /* Do not access any ACPI IO ports in suspend path */
1430 if (acpi_idle_suspend) {
1431 acpi_safe_halt();
1432 local_irq_enable();
1433 return 0;
1434 }
1435
1423 if (pr->flags.bm_check) 1436 if (pr->flags.bm_check)
1424 acpi_idle_update_bm_rld(pr, cx); 1437 acpi_idle_update_bm_rld(pr, cx);
1425 1438
@@ -1643,6 +1656,11 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1643 return -EINVAL; 1656 return -EINVAL;
1644 } 1657 }
1645 1658
1659 for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
1660 dev->states[i].name[0] = '\0';
1661 dev->states[i].desc[0] = '\0';
1662 }
1663
1646 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 1664 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
1647 cx = &pr->power.states[i]; 1665 cx = &pr->power.states[i];
1648 state = &dev->states[count]; 1666 state = &dev->states[count];
@@ -1659,6 +1677,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1659 cpuidle_set_statedata(state, cx); 1677 cpuidle_set_statedata(state, cx);
1660 1678
1661 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); 1679 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
1680 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1662 state->exit_latency = cx->latency; 1681 state->exit_latency = cx->latency;
1663 state->target_residency = cx->latency * latency_factor; 1682 state->target_residency = cx->latency * latency_factor;
1664 state->power_usage = cx->power; 1683 state->power_usage = cx->power;
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index b4e462f154ea..730ccea78e45 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -251,10 +251,6 @@ static int floppy_release(struct inode *inode, struct file *filp);
251static int floppy_check_change(struct gendisk *disk); 251static int floppy_check_change(struct gendisk *disk);
252static int floppy_revalidate(struct gendisk *disk); 252static int floppy_revalidate(struct gendisk *disk);
253 253
254#ifndef CONFIG_PMAC_MEDIABAY
255#define check_media_bay(which, what) 1
256#endif
257
258static void swim3_select(struct floppy_state *fs, int sel) 254static void swim3_select(struct floppy_state *fs, int sel)
259{ 255{
260 struct swim3 __iomem *sw = fs->swim3; 256 struct swim3 __iomem *sw = fs->swim3;
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index bb09413d5a21..88590d040046 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -76,7 +76,7 @@ static struct hv_ops hvc_rtas_get_put_ops = {
76 .put_chars = hvc_rtas_write_console, 76 .put_chars = hvc_rtas_write_console,
77}; 77};
78 78
79static int hvc_rtas_init(void) 79static int __init hvc_rtas_init(void)
80{ 80{
81 struct hvc_struct *hp; 81 struct hvc_struct *hp;
82 82
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 60f71e6345e3..d73663a52324 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -219,7 +219,8 @@ static void poll_idle_init(struct cpuidle_device *dev)
219 219
220 cpuidle_set_statedata(state, NULL); 220 cpuidle_set_statedata(state, NULL);
221 221
222 snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)"); 222 snprintf(state->name, CPUIDLE_NAME_LEN, "C0");
223 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
223 state->exit_latency = 0; 224 state->exit_latency = 0;
224 state->target_residency = 0; 225 state->target_residency = 0;
225 state->power_usage = -1; 226 state->power_usage = -1;
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 088ea74edd34..69102ca05685 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -218,16 +218,23 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
218 return sprintf(buf, "%u\n", state->_name);\ 218 return sprintf(buf, "%u\n", state->_name);\
219} 219}
220 220
221static ssize_t show_state_name(struct cpuidle_state *state, char *buf) 221#define define_show_state_str_function(_name) \
222{ 222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223 return sprintf(buf, "%s\n", state->name); 223{ \
224 if (state->_name[0] == '\0')\
225 return sprintf(buf, "<null>\n");\
226 return sprintf(buf, "%s\n", state->_name);\
224} 227}
225 228
226define_show_state_function(exit_latency) 229define_show_state_function(exit_latency)
227define_show_state_function(power_usage) 230define_show_state_function(power_usage)
228define_show_state_function(usage) 231define_show_state_function(usage)
229define_show_state_function(time) 232define_show_state_function(time)
233define_show_state_str_function(name)
234define_show_state_str_function(desc)
235
230define_one_state_ro(name, show_state_name); 236define_one_state_ro(name, show_state_name);
237define_one_state_ro(desc, show_state_desc);
231define_one_state_ro(latency, show_state_exit_latency); 238define_one_state_ro(latency, show_state_exit_latency);
232define_one_state_ro(power, show_state_power_usage); 239define_one_state_ro(power, show_state_power_usage);
233define_one_state_ro(usage, show_state_usage); 240define_one_state_ro(usage, show_state_usage);
@@ -235,6 +242,7 @@ define_one_state_ro(time, show_state_time);
235 242
236static struct attribute *cpuidle_state_default_attrs[] = { 243static struct attribute *cpuidle_state_default_attrs[] = {
237 &attr_name.attr, 244 &attr_name.attr,
245 &attr_desc.attr,
238 &attr_latency.attr, 246 &attr_latency.attr,
239 &attr_power.attr, 247 &attr_power.attr,
240 &attr_usage.attr, 248 &attr_usage.attr,
diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c
index a870ba58faa3..dceadd0c1419 100644
--- a/drivers/hid/hid-input-quirks.c
+++ b/drivers/hid/hid-input-quirks.c
@@ -352,7 +352,7 @@ int hidinput_mapping_quirks(struct hid_usage *usage,
352 return 0; 352 return 0;
353} 353}
354 354
355void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) 355int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
356{ 356{
357 struct input_dev *input; 357 struct input_dev *input;
358 358
@@ -362,34 +362,34 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru
362 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { 362 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) {
363 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON; 363 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
364 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON; 364 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
365 return; 365 return 1;
366 } 366 }
367 367
368 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && 368 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
369 (usage->type == EV_REL) && 369 (usage->type == EV_REL) &&
370 (usage->code == REL_WHEEL)) { 370 (usage->code == REL_WHEEL)) {
371 hid->delayed_value = value; 371 hid->delayed_value = value;
372 return; 372 return 1;
373 } 373 }
374 374
375 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && 375 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
376 (usage->hid == 0x000100b8)) { 376 (usage->hid == 0x000100b8)) {
377 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value); 377 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
378 return; 378 return 1;
379 } 379 }
380 380
381 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) { 381 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
382 input_event(input, usage->type, usage->code, -value); 382 input_event(input, usage->type, usage->code, -value);
383 return; 383 return 1;
384 } 384 }
385 385
386 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) { 386 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
387 input_event(input, usage->type, REL_HWHEEL, value); 387 input_event(input, usage->type, REL_HWHEEL, value);
388 return; 388 return 1;
389 } 389 }
390 390
391 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value)) 391 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
392 return; 392 return 1;
393 393
394 /* Handling MS keyboards special buttons */ 394 /* Handling MS keyboards special buttons */
395 if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS && 395 if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS &&
@@ -416,8 +416,9 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru
416 if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && 416 if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT &&
417 usage->type == EV_REL && usage->code == REL_HWHEEL) { 417 usage->type == EV_REL && usage->code == REL_HWHEEL) {
418 input_event(input, usage->type, REL_WHEEL, -value); 418 input_event(input, usage->type, REL_WHEEL, -value);
419 return; 419 return 1;
420 } 420 }
421 return 0;
421} 422}
422 423
423 424
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 5325d98b4328..5a38fb27d69f 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -97,6 +97,7 @@ struct hidinput_key_translation {
97#define APPLE_FLAG_FKEY 0x01 97#define APPLE_FLAG_FKEY 0x01
98 98
99static struct hidinput_key_translation apple_fn_keys[] = { 99static struct hidinput_key_translation apple_fn_keys[] = {
100 { KEY_BACKSPACE, KEY_DELETE },
100 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, 101 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
101 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, 102 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
102 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */ 103 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */
@@ -109,6 +110,10 @@ static struct hidinput_key_translation apple_fn_keys[] = {
109 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, 110 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
110 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, 111 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
111 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, 112 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
113 { KEY_UP, KEY_PAGEUP },
114 { KEY_DOWN, KEY_PAGEDOWN },
115 { KEY_LEFT, KEY_HOME },
116 { KEY_RIGHT, KEY_END },
112 { } 117 { }
113}; 118};
114 119
@@ -854,7 +859,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
854 return; 859 return;
855 860
856 /* handle input events for quirky devices */ 861 /* handle input events for quirky devices */
857 hidinput_event_quirks(hid, field, usage, value); 862 if (hidinput_event_quirks(hid, field, usage, value))
863 return;
858 864
859 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 865 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
860 int hat_dir = usage->hat_dir; 866 int hat_dir = usage->hat_dir;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index b77b61e0cd7b..e6d05f6b1c1c 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -66,6 +66,12 @@
66#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 66#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
67#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 67#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
68#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 68#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
69#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
70#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
71#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
72#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
73#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
74#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
69#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a 75#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
70#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b 76#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
71#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 77#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
@@ -193,6 +199,17 @@
193#define USB_DEVICE_ID_GTCO_502 0x0502 199#define USB_DEVICE_ID_GTCO_502 0x0502
194#define USB_DEVICE_ID_GTCO_503 0x0503 200#define USB_DEVICE_ID_GTCO_503 0x0503
195#define USB_DEVICE_ID_GTCO_504 0x0504 201#define USB_DEVICE_ID_GTCO_504 0x0504
202#define USB_DEVICE_ID_GTCO_600 0x0600
203#define USB_DEVICE_ID_GTCO_601 0x0601
204#define USB_DEVICE_ID_GTCO_602 0x0602
205#define USB_DEVICE_ID_GTCO_603 0x0603
206#define USB_DEVICE_ID_GTCO_604 0x0604
207#define USB_DEVICE_ID_GTCO_605 0x0605
208#define USB_DEVICE_ID_GTCO_606 0x0606
209#define USB_DEVICE_ID_GTCO_607 0x0607
210#define USB_DEVICE_ID_GTCO_608 0x0608
211#define USB_DEVICE_ID_GTCO_609 0x0609
212#define USB_DEVICE_ID_GTCO_609 0x0609
196#define USB_DEVICE_ID_GTCO_1000 0x1000 213#define USB_DEVICE_ID_GTCO_1000 0x1000
197#define USB_DEVICE_ID_GTCO_1001 0x1001 214#define USB_DEVICE_ID_GTCO_1001 0x1001
198#define USB_DEVICE_ID_GTCO_1002 0x1002 215#define USB_DEVICE_ID_GTCO_1002 0x1002
@@ -200,7 +217,7 @@
200#define USB_DEVICE_ID_GTCO_1004 0x1004 217#define USB_DEVICE_ID_GTCO_1004 0x1004
201#define USB_DEVICE_ID_GTCO_1005 0x1005 218#define USB_DEVICE_ID_GTCO_1005 0x1005
202#define USB_DEVICE_ID_GTCO_1006 0x1006 219#define USB_DEVICE_ID_GTCO_1006 0x1006
203 220#define USB_DEVICE_ID_GTCO_1007 0x1007
204#define USB_VENDOR_ID_HAPP 0x078b 221#define USB_VENDOR_ID_HAPP 0x078b
205#define USB_DEVICE_ID_UGCI_DRIVING 0x0010 222#define USB_DEVICE_ID_UGCI_DRIVING 0x0010
206#define USB_DEVICE_ID_UGCI_FLYING 0x0020 223#define USB_DEVICE_ID_UGCI_FLYING 0x0020
@@ -368,6 +385,7 @@
368#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 385#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
369#define USB_DEVICE_ID_VERNIER_SKIP 0x0003 386#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
370#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 387#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
388#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
371 389
372#define USB_VENDOR_ID_WACOM 0x056a 390#define USB_VENDOR_ID_WACOM 0x056a
373 391
@@ -496,6 +514,16 @@ static const struct hid_blacklist {
496 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE }, 514 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE },
497 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE }, 515 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE },
498 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE }, 516 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE },
517 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_600, HID_QUIRK_IGNORE },
518 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_601, HID_QUIRK_IGNORE },
519 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_602, HID_QUIRK_IGNORE },
520 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_603, HID_QUIRK_IGNORE },
521 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_604, HID_QUIRK_IGNORE },
522 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_605, HID_QUIRK_IGNORE },
523 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_606, HID_QUIRK_IGNORE },
524 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_607, HID_QUIRK_IGNORE },
525 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_608, HID_QUIRK_IGNORE },
526 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_609, HID_QUIRK_IGNORE },
499 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE }, 527 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE },
500 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE }, 528 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE },
501 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE }, 529 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE },
@@ -503,6 +531,7 @@ static const struct hid_blacklist {
503 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE }, 531 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE },
504 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE }, 532 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE },
505 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE }, 533 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE },
534 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007, HID_QUIRK_IGNORE },
506 { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE }, 535 { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE },
507 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, 536 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE },
508 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE }, 537 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE },
@@ -541,6 +570,7 @@ static const struct hid_blacklist {
541 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, 570 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE },
542 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, 571 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE },
543 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, 572 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE },
573 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC, HID_QUIRK_IGNORE },
544 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 574 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
545 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 575 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
546 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE }, 576 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE },
@@ -593,6 +623,12 @@ static const struct hid_blacklist {
593 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN }, 623 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN },
594 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, 624 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
595 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN }, 625 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN },
626 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
627 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD },
628 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
629 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_HAS_FN },
630 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
631 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS, HID_QUIRK_APPLE_HAS_FN },
596 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 632 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
597 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 633 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
598 634
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 638b727d42e0..b10ade92efed 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3587,8 +3587,6 @@ static void cm_release_port_obj(struct kobject *obj)
3587{ 3587{
3588 struct cm_port *cm_port; 3588 struct cm_port *cm_port;
3589 3589
3590 printk(KERN_ERR "free cm port\n");
3591
3592 cm_port = container_of(obj, struct cm_port, port_obj); 3590 cm_port = container_of(obj, struct cm_port, port_obj);
3593 kfree(cm_port); 3591 kfree(cm_port);
3594} 3592}
@@ -3601,8 +3599,6 @@ static void cm_release_dev_obj(struct kobject *obj)
3601{ 3599{
3602 struct cm_device *cm_dev; 3600 struct cm_device *cm_dev;
3603 3601
3604 printk(KERN_ERR "free cm dev\n");
3605
3606 cm_dev = container_of(obj, struct cm_device, dev_obj); 3602 cm_dev = container_of(obj, struct cm_device, dev_obj);
3607 kfree(cm_dev); 3603 kfree(cm_dev);
3608} 3604}
@@ -3616,18 +3612,12 @@ struct class cm_class = {
3616}; 3612};
3617EXPORT_SYMBOL(cm_class); 3613EXPORT_SYMBOL(cm_class);
3618 3614
3619static void cm_remove_fs_obj(struct kobject *obj)
3620{
3621 kobject_put(obj->parent);
3622 kobject_put(obj);
3623}
3624
3625static int cm_create_port_fs(struct cm_port *port) 3615static int cm_create_port_fs(struct cm_port *port)
3626{ 3616{
3627 int i, ret; 3617 int i, ret;
3628 3618
3629 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, 3619 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
3630 kobject_get(&port->cm_dev->dev_obj), 3620 &port->cm_dev->dev_obj,
3631 "%d", port->port_num); 3621 "%d", port->port_num);
3632 if (ret) { 3622 if (ret) {
3633 kfree(port); 3623 kfree(port);
@@ -3637,7 +3627,7 @@ static int cm_create_port_fs(struct cm_port *port)
3637 for (i = 0; i < CM_COUNTER_GROUPS; i++) { 3627 for (i = 0; i < CM_COUNTER_GROUPS; i++) {
3638 ret = kobject_init_and_add(&port->counter_group[i].obj, 3628 ret = kobject_init_and_add(&port->counter_group[i].obj,
3639 &cm_counter_obj_type, 3629 &cm_counter_obj_type,
3640 kobject_get(&port->port_obj), 3630 &port->port_obj,
3641 "%s", counter_group_names[i]); 3631 "%s", counter_group_names[i]);
3642 if (ret) 3632 if (ret)
3643 goto error; 3633 goto error;
@@ -3647,8 +3637,8 @@ static int cm_create_port_fs(struct cm_port *port)
3647 3637
3648error: 3638error:
3649 while (i--) 3639 while (i--)
3650 cm_remove_fs_obj(&port->counter_group[i].obj); 3640 kobject_put(&port->counter_group[i].obj);
3651 cm_remove_fs_obj(&port->port_obj); 3641 kobject_put(&port->port_obj);
3652 return ret; 3642 return ret;
3653 3643
3654} 3644}
@@ -3658,9 +3648,9 @@ static void cm_remove_port_fs(struct cm_port *port)
3658 int i; 3648 int i;
3659 3649
3660 for (i = 0; i < CM_COUNTER_GROUPS; i++) 3650 for (i = 0; i < CM_COUNTER_GROUPS; i++)
3661 cm_remove_fs_obj(&port->counter_group[i].obj); 3651 kobject_put(&port->counter_group[i].obj);
3662 3652
3663 cm_remove_fs_obj(&port->port_obj); 3653 kobject_put(&port->port_obj);
3664} 3654}
3665 3655
3666static void cm_add_one(struct ib_device *device) 3656static void cm_add_one(struct ib_device *device)
@@ -3744,7 +3734,7 @@ error1:
3744 ib_unregister_mad_agent(port->mad_agent); 3734 ib_unregister_mad_agent(port->mad_agent);
3745 cm_remove_port_fs(port); 3735 cm_remove_port_fs(port);
3746 } 3736 }
3747 cm_remove_fs_obj(&cm_dev->dev_obj); 3737 kobject_put(&cm_dev->dev_obj);
3748} 3738}
3749 3739
3750static void cm_remove_one(struct ib_device *device) 3740static void cm_remove_one(struct ib_device *device)
@@ -3771,7 +3761,7 @@ static void cm_remove_one(struct ib_device *device)
3771 ib_unregister_mad_agent(port->mad_agent); 3761 ib_unregister_mad_agent(port->mad_agent);
3772 cm_remove_port_fs(port); 3762 cm_remove_port_fs(port);
3773 } 3763 }
3774 cm_remove_fs_obj(&cm_dev->dev_obj); 3764 kobject_put(&cm_dev->dev_obj);
3775} 3765}
3776 3766
3777static int __init ib_cm_init(void) 3767static int __init ib_cm_init(void)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1eff1b2c0e08..34507daaf9b6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1107,7 +1107,6 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1107 event.param.ud.private_data_len = 1107 event.param.ud.private_data_len =
1108 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset; 1108 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset;
1109 } else { 1109 } else {
1110 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1111 conn_id = cma_new_conn_id(&listen_id->id, ib_event); 1110 conn_id = cma_new_conn_id(&listen_id->id, ib_event);
1112 cma_set_req_event_data(&event, &ib_event->param.req_rcvd, 1111 cma_set_req_event_data(&event, &ib_event->param.req_rcvd,
1113 ib_event->private_data, offset); 1112 ib_event->private_data, offset);
@@ -1130,6 +1129,15 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1130 1129
1131 ret = conn_id->id.event_handler(&conn_id->id, &event); 1130 ret = conn_id->id.event_handler(&conn_id->id, &event);
1132 if (!ret) { 1131 if (!ret) {
1132 /*
1133 * Acquire mutex to prevent user executing rdma_destroy_id()
1134 * while we're accessing the cm_id.
1135 */
1136 mutex_lock(&lock);
1137 if (cma_comp(conn_id, CMA_CONNECT) &&
1138 !cma_is_ud_ps(conn_id->id.ps))
1139 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1140 mutex_unlock(&lock);
1133 cma_enable_remove(conn_id); 1141 cma_enable_remove(conn_id);
1134 goto out; 1142 goto out;
1135 } 1143 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index e9a08fa3dffe..320f2b6ddee6 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -35,6 +35,7 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/timer.h> 36#include <linux/timer.h>
37#include <linux/notifier.h> 37#include <linux/notifier.h>
38#include <linux/inetdevice.h>
38 39
39#include <net/neighbour.h> 40#include <net/neighbour.h>
40#include <net/netevent.h> 41#include <net/netevent.h>
@@ -1784,6 +1785,17 @@ err:
1784 return err; 1785 return err;
1785} 1786}
1786 1787
1788static int is_loopback_dst(struct iw_cm_id *cm_id)
1789{
1790 struct net_device *dev;
1791
1792 dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
1793 if (!dev)
1794 return 0;
1795 dev_put(dev);
1796 return 1;
1797}
1798
1787int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 1799int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1788{ 1800{
1789 int err = 0; 1801 int err = 0;
@@ -1791,6 +1803,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1791 struct iwch_ep *ep; 1803 struct iwch_ep *ep;
1792 struct rtable *rt; 1804 struct rtable *rt;
1793 1805
1806 if (is_loopback_dst(cm_id)) {
1807 err = -ENOSYS;
1808 goto out;
1809 }
1810
1794 ep = alloc_ep(sizeof(*ep), GFP_KERNEL); 1811 ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
1795 if (!ep) { 1812 if (!ep) {
1796 printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); 1813 printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__);
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 7dc91a3e712d..fe2c2e94a5f8 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -199,7 +199,7 @@ struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc,
199 if (err) 199 if (err)
200 goto err_free; 200 goto err_free;
201 201
202 err = mlx4_mr_enable(to_mdev(pd->device)->dev, &fmr->mfmr.mr); 202 err = mlx4_fmr_enable(to_mdev(pd->device)->dev, &fmr->mfmr);
203 if (err) 203 if (err)
204 goto err_mr; 204 goto err_mr;
205 205
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 6bd9f1393349..1e1e336d3ef9 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -473,7 +473,7 @@ static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq,
473 if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd)) 473 if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd))
474 return; 474 return;
475 475
476 cqe->db_cnt = cpu_to_be16(be16_to_cpu(cqe->db_cnt) - dbd); 476 be16_add_cpu(&cqe->db_cnt, -dbd);
477 cqe->wqe = new_wqe; 477 cqe->wqe = new_wqe;
478 cqe->syndrome = SYNDROME_WR_FLUSH_ERR; 478 cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
479 479
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 1f4d27d7c16d..252db0822f6c 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -542,6 +542,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
542 for (i = 0; i < npages; ++i) { 542 for (i = 0; i < npages; ++i) {
543 db_tab->page[i].refcount = 0; 543 db_tab->page[i].refcount = 0;
544 db_tab->page[i].uvirt = 0; 544 db_tab->page[i].uvirt = 0;
545 sg_init_table(&db_tab->page[i].mem, 1);
545 } 546 }
546 547
547 return db_tab; 548 return db_tab;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index f9b7caa54143..054fab8e27a0 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -209,7 +209,6 @@ struct ipoib_cm_tx {
209 unsigned tx_tail; 209 unsigned tx_tail;
210 unsigned long flags; 210 unsigned long flags;
211 u32 mtu; 211 u32 mtu;
212 struct ib_wc ibwc[IPOIB_NUM_WC];
213}; 212};
214 213
215struct ipoib_cm_rx_buf { 214struct ipoib_cm_rx_buf {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 9d3e778dc56d..08c4396cf418 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -780,6 +780,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
780 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { 780 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
781 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 781 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
782 ipoib_ib_dev_down(dev, 0); 782 ipoib_ib_dev_down(dev, 0);
783 ipoib_ib_dev_stop(dev, 0);
783 ipoib_pkey_dev_delay_open(dev); 784 ipoib_pkey_dev_delay_open(dev);
784 return; 785 return;
785 } 786 }
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index 936788272a5f..51a112815f46 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -416,7 +416,6 @@ static void poll_media_bay(struct media_bay_info* bay)
416 } 416 }
417} 417}
418 418
419#ifdef CONFIG_MAC_FLOPPY
420int check_media_bay(struct device_node *which_bay, int what) 419int check_media_bay(struct device_node *which_bay, int what)
421{ 420{
422 int i; 421 int i;
@@ -431,7 +430,6 @@ int check_media_bay(struct device_node *which_bay, int what)
431 return -ENODEV; 430 return -ENODEV;
432} 431}
433EXPORT_SYMBOL(check_media_bay); 432EXPORT_SYMBOL(check_media_bay);
434#endif /* CONFIG_MAC_FLOPPY */
435 433
436#ifdef CONFIG_BLK_DEV_IDE_PMAC 434#ifdef CONFIG_BLK_DEV_IDE_PMAC
437int check_media_bay_by_base(unsigned long base, int what) 435int check_media_bay_by_base(unsigned long base, int what)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index a0585fb6da94..7aeceedcf7d4 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
206/* copy the pathname of a file to a buffer */ 206/* copy the pathname of a file to a buffer */
207char *file_path(struct file *file, char *buf, int count) 207char *file_path(struct file *file, char *buf, int count)
208{ 208{
209 struct dentry *d;
210 struct vfsmount *v;
211
212 if (!buf) 209 if (!buf)
213 return NULL; 210 return NULL;
214 211
215 d = file->f_path.dentry; 212 buf = d_path(&file->f_path, buf, count);
216 v = file->f_path.mnt;
217
218 buf = d_path(d, v, buf, count);
219 213
220 return IS_ERR(buf) ? NULL : buf; 214 return IS_ERR(buf) ? NULL : buf;
221} 215}
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index f16062982383..e75b1437b58b 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -361,7 +361,7 @@ static int lookup_device(const char *path, dev_t *dev)
361 if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) 361 if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd)))
362 return r; 362 return r;
363 363
364 inode = nd.dentry->d_inode; 364 inode = nd.path.dentry->d_inode;
365 if (!inode) { 365 if (!inode) {
366 r = -ENOENT; 366 r = -ENOENT;
367 goto out; 367 goto out;
@@ -375,7 +375,7 @@ static int lookup_device(const char *path, dev_t *dev)
375 *dev = inode->i_rdev; 375 *dev = inode->i_rdev;
376 376
377 out: 377 out:
378 path_release(&nd); 378 path_put(&nd.path);
379 return r; 379 return r;
380} 380}
381 381
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5fc326d3970e..7da6ec244e15 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5197,8 +5197,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
5197 chunk_kb ? "KB" : "B"); 5197 chunk_kb ? "KB" : "B");
5198 if (bitmap->file) { 5198 if (bitmap->file) {
5199 seq_printf(seq, ", file: "); 5199 seq_printf(seq, ", file: ");
5200 seq_path(seq, bitmap->file->f_path.mnt, 5200 seq_path(seq, &bitmap->file->f_path, " \t\n");
5201 bitmap->file->f_path.dentry," \t\n");
5202 } 5201 }
5203 5202
5204 seq_printf(seq, "\n"); 5203 seq_printf(seq, "\n");
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 7ba1acad5402..e2c7edd206a6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1689,7 +1689,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev,
1689static struct device_attribute dev_attr_hotkey_wakeup_reason = 1689static struct device_attribute dev_attr_hotkey_wakeup_reason =
1690 __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL); 1690 __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL);
1691 1691
1692void hotkey_wakeup_reason_notify_change(void) 1692static void hotkey_wakeup_reason_notify_change(void)
1693{ 1693{
1694 if (tp_features.hotkey_mask) 1694 if (tp_features.hotkey_mask)
1695 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 1695 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
@@ -1708,7 +1708,7 @@ static struct device_attribute dev_attr_hotkey_wakeup_hotunplug_complete =
1708 __ATTR(wakeup_hotunplug_complete, S_IRUGO, 1708 __ATTR(wakeup_hotunplug_complete, S_IRUGO,
1709 hotkey_wakeup_hotunplug_complete_show, NULL); 1709 hotkey_wakeup_hotunplug_complete_show, NULL);
1710 1710
1711void hotkey_wakeup_hotunplug_complete_notify_change(void) 1711static void hotkey_wakeup_hotunplug_complete_notify_change(void)
1712{ 1712{
1713 if (tp_features.hotkey_mask) 1713 if (tp_features.hotkey_mask)
1714 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 1714 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 9b430f20b640..28cc6787a800 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -184,26 +184,26 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
184 ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); 184 ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
185 185
186 DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", 186 DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n",
187 ret, nd.dentry ? nd.dentry->d_inode : NULL); 187 ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL);
188 188
189 if (ret) 189 if (ret)
190 return ret; 190 return ret;
191 191
192 ret = -EINVAL; 192 ret = -EINVAL;
193 193
194 if (!S_ISBLK(nd.dentry->d_inode->i_mode)) 194 if (!S_ISBLK(nd.path.dentry->d_inode->i_mode))
195 goto out; 195 goto out;
196 196
197 if (nd.mnt->mnt_flags & MNT_NODEV) { 197 if (nd.path.mnt->mnt_flags & MNT_NODEV) {
198 ret = -EACCES; 198 ret = -EACCES;
199 goto out; 199 goto out;
200 } 200 }
201 201
202 if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) 202 if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR)
203 goto not_an_MTD_device; 203 goto not_an_MTD_device;
204 204
205 mtdnr = iminor(nd.dentry->d_inode); 205 mtdnr = iminor(nd.path.dentry->d_inode);
206 path_release(&nd); 206 path_put(&nd.path);
207 207
208 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, 208 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
209 mnt); 209 mnt);
@@ -214,7 +214,7 @@ not_an_MTD_device:
214 "MTD: Attempt to mount non-MTD device \"%s\"\n", 214 "MTD: Attempt to mount non-MTD device \"%s\"\n",
215 dev_name); 215 dev_name);
216out: 216out:
217 path_release(&nd); 217 path_put(&nd.path);
218 return ret; 218 return ret;
219 219
220} 220}
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index 679dfdb6807f..79b317b88c86 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -578,13 +578,6 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
578 goto err_free; 578 goto err_free;
579 } 579 }
580 580
581 fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table,
582 key_to_hw_index(fmr->mr.key), NULL);
583 if (!fmr->mpt) {
584 err = -ENOMEM;
585 goto err_free;
586 }
587
588 return 0; 581 return 0;
589 582
590err_free: 583err_free:
@@ -595,7 +588,19 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_alloc);
595 588
596int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr) 589int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
597{ 590{
598 return mlx4_mr_enable(dev, &fmr->mr); 591 struct mlx4_priv *priv = mlx4_priv(dev);
592 int err;
593
594 err = mlx4_mr_enable(dev, &fmr->mr);
595 if (err)
596 return err;
597
598 fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table,
599 key_to_hw_index(fmr->mr.key), NULL);
600 if (!fmr->mpt)
601 return -ENOMEM;
602
603 return 0;
599} 604}
600EXPORT_SYMBOL_GPL(mlx4_fmr_enable); 605EXPORT_SYMBOL_GPL(mlx4_fmr_enable);
601 606
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 8134c7e198a5..b07ba2a14119 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -187,23 +187,22 @@ void sync_stop(void)
187 end_sync(); 187 end_sync();
188} 188}
189 189
190 190
191/* Optimisation. We can manage without taking the dcookie sem 191/* Optimisation. We can manage without taking the dcookie sem
192 * because we cannot reach this code without at least one 192 * because we cannot reach this code without at least one
193 * dcookie user still being registered (namely, the reader 193 * dcookie user still being registered (namely, the reader
194 * of the event buffer). */ 194 * of the event buffer). */
195static inline unsigned long fast_get_dcookie(struct dentry * dentry, 195static inline unsigned long fast_get_dcookie(struct path *path)
196 struct vfsmount * vfsmnt)
197{ 196{
198 unsigned long cookie; 197 unsigned long cookie;
199 198
200 if (dentry->d_cookie) 199 if (path->dentry->d_cookie)
201 return (unsigned long)dentry; 200 return (unsigned long)path->dentry;
202 get_dcookie(dentry, vfsmnt, &cookie); 201 get_dcookie(path, &cookie);
203 return cookie; 202 return cookie;
204} 203}
205 204
206 205
207/* Look up the dcookie for the task's first VM_EXECUTABLE mapping, 206/* Look up the dcookie for the task's first VM_EXECUTABLE mapping,
208 * which corresponds loosely to "application name". This is 207 * which corresponds loosely to "application name". This is
209 * not strictly necessary but allows oprofile to associate 208 * not strictly necessary but allows oprofile to associate
@@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm)
222 continue; 221 continue;
223 if (!(vma->vm_flags & VM_EXECUTABLE)) 222 if (!(vma->vm_flags & VM_EXECUTABLE))
224 continue; 223 continue;
225 cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 224 cookie = fast_get_dcookie(&vma->vm_file->f_path);
226 vma->vm_file->f_path.mnt);
227 break; 225 break;
228 } 226 }
229 227
@@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o
248 continue; 246 continue;
249 247
250 if (vma->vm_file) { 248 if (vma->vm_file) {
251 cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 249 cookie = fast_get_dcookie(&vma->vm_file->f_path);
252 vma->vm_file->f_path.mnt);
253 *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - 250 *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
254 vma->vm_start; 251 vma->vm_start;
255 } else { 252 } else {
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 662b4c279cfc..c283a9a70d83 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -36,7 +36,7 @@ static int num = 0;
36 * have irqs (PIC, Timer) because we call acpi_register_gsi. 36 * have irqs (PIC, Timer) because we call acpi_register_gsi.
37 * Finally, only devices that have a CRS method need to be in this list. 37 * Finally, only devices that have a CRS method need to be in this list.
38 */ 38 */
39static struct __initdata acpi_device_id excluded_id_list[] = { 39static struct acpi_device_id excluded_id_list[] __initdata = {
40 {"PNP0C09", 0}, /* EC */ 40 {"PNP0C09", 0}, /* EC */
41 {"PNP0C0F", 0}, /* Link device */ 41 {"PNP0C0F", 0}, /* Link device */
42 {"PNP0000", 0}, /* PIC */ 42 {"PNP0000", 0}, /* PIC */
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index f7e67197a568..a8a51500e1e9 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -105,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
105 char *argv[3], **envp, *buf, *scratch; 105 char *argv[3], **envp, *buf, *scratch;
106 int i = 0, value; 106 int i = 0, value;
107 107
108 if (!current->fs->root)
109 return -EAGAIN;
110 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) 108 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL)))
111 return -ENOMEM; 109 return -ENOMEM;
112 if (!(buf = kzalloc(256, GFP_KERNEL))) { 110 if (!(buf = kzalloc(256, GFP_KERNEL))) {
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 4c066545d176..6c9592ce4996 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -76,7 +76,6 @@
76 * 76 *
77 * @pm_control: Shadow of the processor's pm_control register. 77 * @pm_control: Shadow of the processor's pm_control register.
78 * @pm_start_stop: Shadow of the processor's pm_start_stop register. 78 * @pm_start_stop: Shadow of the processor's pm_start_stop register.
79 * @pm_interval: Shadow of the processor's pm_interval register.
80 * @group_control: Shadow of the processor's group_control register. 79 * @group_control: Shadow of the processor's group_control register.
81 * @debug_bus_control: Shadow of the processor's debug_bus_control register. 80 * @debug_bus_control: Shadow of the processor's debug_bus_control register.
82 * 81 *
@@ -91,7 +90,6 @@
91struct ps3_lpm_shadow_regs { 90struct ps3_lpm_shadow_regs {
92 u64 pm_control; 91 u64 pm_control;
93 u64 pm_start_stop; 92 u64 pm_start_stop;
94 u64 pm_interval;
95 u64 group_control; 93 u64 group_control;
96 u64 debug_bus_control; 94 u64 debug_bus_control;
97}; 95};
@@ -181,9 +179,9 @@ void ps3_set_bookmark(u64 bookmark)
181 * includes cycles before the call. 179 * includes cycles before the call.
182 */ 180 */
183 181
184 asm volatile("or 29, 29, 29;"); /* db10cyc */ 182 asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;");
185 mtspr(SPRN_BKMK, bookmark); 183 mtspr(SPRN_BKMK, bookmark);
186 asm volatile("or 29, 29, 29;"); /* db10cyc */ 184 asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;");
187} 185}
188EXPORT_SYMBOL_GPL(ps3_set_bookmark); 186EXPORT_SYMBOL_GPL(ps3_set_bookmark);
189 187
@@ -408,7 +406,14 @@ u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg)
408 case pm_start_stop: 406 case pm_start_stop:
409 return lpm_priv->shadow.pm_start_stop; 407 return lpm_priv->shadow.pm_start_stop;
410 case pm_interval: 408 case pm_interval:
411 return lpm_priv->shadow.pm_interval; 409 result = lv1_set_lpm_interval(lpm_priv->lpm_id, 0, 0, &val);
410 if (result) {
411 val = 0;
412 dev_dbg(sbd_core(), "%s:%u: lv1 set_inteval failed: "
413 "reg %u, %s\n", __func__, __LINE__, reg,
414 ps3_result(result));
415 }
416 return (u32)val;
412 case group_control: 417 case group_control:
413 return lpm_priv->shadow.group_control; 418 return lpm_priv->shadow.group_control;
414 case debug_bus_control: 419 case debug_bus_control:
@@ -475,10 +480,8 @@ void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val)
475 lpm_priv->shadow.pm_control = val; 480 lpm_priv->shadow.pm_control = val;
476 break; 481 break;
477 case pm_interval: 482 case pm_interval:
478 if (val != lpm_priv->shadow.pm_interval) 483 result = lv1_set_lpm_interval(lpm_priv->lpm_id, val,
479 result = lv1_set_lpm_interval(lpm_priv->lpm_id, val, 484 PS3_WRITE_PM_MASK, &dummy);
480 PS3_WRITE_PM_MASK, &dummy);
481 lpm_priv->shadow.pm_interval = val;
482 break; 485 break;
483 case pm_start_stop: 486 case pm_start_stop:
484 if (val != lpm_priv->shadow.pm_start_stop) 487 if (val != lpm_priv->shadow.pm_start_stop)
@@ -1140,7 +1143,6 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
1140 1143
1141 lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT; 1144 lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT;
1142 lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT; 1145 lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT;
1143 lpm_priv->shadow.pm_interval = PS3_LPM_SHADOW_REG_INIT;
1144 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; 1146 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT;
1145 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; 1147 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT;
1146 1148
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c
index c3c3aba3ffce..d4f6f960dd18 100644
--- a/drivers/ps3/ps3-sys-manager.c
+++ b/drivers/ps3/ps3-sys-manager.c
@@ -28,10 +28,6 @@
28 28
29#include "vuart.h" 29#include "vuart.h"
30 30
31MODULE_AUTHOR("Sony Corporation");
32MODULE_LICENSE("GPL v2");
33MODULE_DESCRIPTION("PS3 System Manager");
34
35/** 31/**
36 * ps3_sys_manager - PS3 system manager driver. 32 * ps3_sys_manager - PS3 system manager driver.
37 * 33 *
@@ -142,9 +138,11 @@ enum ps3_sys_manager_attr {
142 138
143/** 139/**
144 * enum ps3_sys_manager_event - External event type, reported by system manager. 140 * enum ps3_sys_manager_event - External event type, reported by system manager.
145 * @PS3_SM_EVENT_POWER_PRESSED: payload.value not used. 141 * @PS3_SM_EVENT_POWER_PRESSED: payload.value =
142 * enum ps3_sys_manager_button_event.
146 * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. 143 * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec.
147 * @PS3_SM_EVENT_RESET_PRESSED: payload.value not used. 144 * @PS3_SM_EVENT_RESET_PRESSED: payload.value =
145 * enum ps3_sys_manager_button_event.
148 * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. 146 * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec.
149 * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. 147 * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id.
150 * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. 148 * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id.
@@ -162,6 +160,17 @@ enum ps3_sys_manager_event {
162}; 160};
163 161
164/** 162/**
163 * enum ps3_sys_manager_button_event - Button event payload values.
164 * @PS3_SM_BUTTON_EVENT_HARD: Hardware generated event.
165 * @PS3_SM_BUTTON_EVENT_SOFT: Software generated event.
166 */
167
168enum ps3_sys_manager_button_event {
169 PS3_SM_BUTTON_EVENT_HARD = 0,
170 PS3_SM_BUTTON_EVENT_SOFT = 1,
171};
172
173/**
165 * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. 174 * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed.
166 */ 175 */
167 176
@@ -181,7 +190,9 @@ enum ps3_sys_manager_next_op {
181 * @PS3_SM_WAKE_P_O_R: Power on reset. 190 * @PS3_SM_WAKE_P_O_R: Power on reset.
182 * 191 *
183 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. 192 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN.
184 * System will always wake from the PS3_SM_WAKE_DEFAULT sources. 193 * The system will always wake from the PS3_SM_WAKE_DEFAULT sources.
194 * Sources listed here are the only ones available to guests in the
195 * other-os lpar.
185 */ 196 */
186 197
187enum ps3_sys_manager_wake_source { 198enum ps3_sys_manager_wake_source {
@@ -189,7 +200,7 @@ enum ps3_sys_manager_wake_source {
189 PS3_SM_WAKE_DEFAULT = 0, 200 PS3_SM_WAKE_DEFAULT = 0,
190 PS3_SM_WAKE_RTC = 0x00000040, 201 PS3_SM_WAKE_RTC = 0x00000040,
191 PS3_SM_WAKE_RTC_ERROR = 0x00000080, 202 PS3_SM_WAKE_RTC_ERROR = 0x00000080,
192 PS3_SM_WAKE_P_O_R = 0x10000000, 203 PS3_SM_WAKE_P_O_R = 0x80000000,
193}; 204};
194 205
195/** 206/**
@@ -418,8 +429,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev)
418 429
419 switch (event.type) { 430 switch (event.type) {
420 case PS3_SM_EVENT_POWER_PRESSED: 431 case PS3_SM_EVENT_POWER_PRESSED:
421 dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", 432 dev_dbg(&dev->core, "%s:%d: POWER_PRESSED (%s)\n",
422 __func__, __LINE__); 433 __func__, __LINE__,
434 (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft"
435 : "hard"));
423 ps3_sm_force_power_off = 1; 436 ps3_sm_force_power_off = 1;
424 /* 437 /*
425 * A memory barrier is use here to sync memory since 438 * A memory barrier is use here to sync memory since
@@ -434,8 +447,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev)
434 __func__, __LINE__, event.value); 447 __func__, __LINE__, event.value);
435 break; 448 break;
436 case PS3_SM_EVENT_RESET_PRESSED: 449 case PS3_SM_EVENT_RESET_PRESSED:
437 dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", 450 dev_dbg(&dev->core, "%s:%d: RESET_PRESSED (%s)\n",
438 __func__, __LINE__); 451 __func__, __LINE__,
452 (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft"
453 : "hard"));
439 ps3_sm_force_power_off = 0; 454 ps3_sm_force_power_off = 0;
440 /* 455 /*
441 * A memory barrier is use here to sync memory since 456 * A memory barrier is use here to sync memory since
@@ -622,7 +637,7 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev)
622 ps3_vuart_cancel_async(dev); 637 ps3_vuart_cancel_async(dev);
623 638
624 ps3_sys_manager_send_attr(dev, 0); 639 ps3_sys_manager_send_attr(dev, 0);
625 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_LPAR_REBOOT, 640 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT,
626 PS3_SM_WAKE_DEFAULT); 641 PS3_SM_WAKE_DEFAULT);
627 ps3_sys_manager_send_request_shutdown(dev); 642 ps3_sys_manager_send_request_shutdown(dev);
628 643
@@ -699,4 +714,7 @@ static int __init ps3_sys_manager_init(void)
699module_init(ps3_sys_manager_init); 714module_init(ps3_sys_manager_init);
700/* Module remove not supported. */ 715/* Module remove not supported. */
701 716
717MODULE_AUTHOR("Sony Corporation");
718MODULE_LICENSE("GPL v2");
719MODULE_DESCRIPTION("PS3 System Manager");
702MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); 720MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER);
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index ddf639144538..9ce12cb2cebc 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -393,7 +393,7 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
393 if (cflag & CRTSCTS) { 393 if (cflag & CRTSCTS) {
394 fcr_val |= SCFCR_MCE; 394 fcr_val |= SCFCR_MCE;
395 } else { 395 } else {
396#ifdef CONFIG_CPU_SUBTYPE_SH7343 396#if defined(CONFIG_CPU_SUBTYPE_SH7343) || defined(CONFIG_CPU_SUBTYPE_SH7366)
397 /* Nothing */ 397 /* Nothing */
398#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 398#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
399 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 399 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index f5764ebcfe07..01a9dd715f5d 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -97,13 +97,18 @@
97# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 97# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
98# define SCIF_ONLY 98# define SCIF_ONLY
99# define PORT_PSCR 0xA405011E 99# define PORT_PSCR 0xA405011E
100#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
101# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
102# define SCSPTR0 SCPDR0
103# define SCIF_ORER 0x0001 /* overrun error bit */
104# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
105# define SCIF_ONLY
100#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 106#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
101# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 107# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
102# define SCIF_ORER 0x0001 /* overrun error bit */ 108# define SCIF_ORER 0x0001 /* overrun error bit */
103# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 109# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
104# define SCIF_ONLY 110# define SCIF_ONLY
105#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 111#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
106# include <asm/hardware.h>
107# define SCIF_BASE_ADDR 0x01030000 112# define SCIF_BASE_ADDR 0x01030000
108# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR 113# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
109# define SCIF_PTR2_OFFS 0x0000020 114# define SCIF_PTR2_OFFS 0x0000020
@@ -577,7 +582,7 @@ static inline int sci_rxd_in(struct uart_port *port)
577 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ 582 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
578 return 1; 583 return 1;
579} 584}
580#elif defined(CONFIG_CPU_SUBTYPE_SH7722) 585#elif defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366)
581static inline int sci_rxd_in(struct uart_port *port) 586static inline int sci_rxd_in(struct uart_port *port)
582{ 587{
583 if (port->mapbase == 0xffe00000) 588 if (port->mapbase == 0xffe00000)
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index e52a6296ca46..9cfcfd8dad5e 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -31,6 +31,7 @@
31#include <asm/mach/dma.h> 31#include <asm/mach/dma.h>
32#include <asm/mach/sysasic.h> 32#include <asm/mach/sysasic.h>
33#include <asm/mach/maple.h> 33#include <asm/mach/maple.h>
34#include <linux/delay.h>
34 35
35MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); 36MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
36MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); 37MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
@@ -53,12 +54,12 @@ static struct device maple_bus;
53static int subdevice_map[MAPLE_PORTS]; 54static int subdevice_map[MAPLE_PORTS];
54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 55static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
55static unsigned long maple_pnp_time; 56static unsigned long maple_pnp_time;
56static int started, scanning, liststatus; 57static int started, scanning, liststatus, realscan;
57static struct kmem_cache *maple_queue_cache; 58static struct kmem_cache *maple_queue_cache;
58 59
59struct maple_device_specify { 60struct maple_device_specify {
60 int port; 61 int port;
61 int unit; 62 int unit;
62}; 63};
63 64
64/** 65/**
@@ -68,22 +69,22 @@ struct maple_device_specify {
68 */ 69 */
69int maple_driver_register(struct device_driver *drv) 70int maple_driver_register(struct device_driver *drv)
70{ 71{
71 if (!drv) 72 if (!drv)
72 return -EINVAL; 73 return -EINVAL;
73 drv->bus = &maple_bus_type; 74 drv->bus = &maple_bus_type;
74 return driver_register(drv); 75 return driver_register(drv);
75} 76}
76EXPORT_SYMBOL_GPL(maple_driver_register); 77EXPORT_SYMBOL_GPL(maple_driver_register);
77 78
78/* set hardware registers to enable next round of dma */ 79/* set hardware registers to enable next round of dma */
79static void maplebus_dma_reset(void) 80static void maplebus_dma_reset(void)
80{ 81{
81 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET); 82 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
82 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */ 83 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
83 ctrl_outl(1, MAPLE_TRIGTYPE); 84 ctrl_outl(1, MAPLE_TRIGTYPE);
84 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED); 85 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED);
85 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); 86 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
86 ctrl_outl(1, MAPLE_ENABLE); 87 ctrl_outl(1, MAPLE_ENABLE);
87} 88}
88 89
89/** 90/**
@@ -94,27 +95,36 @@ static void maplebus_dma_reset(void)
94 * @function: the function code for the device 95 * @function: the function code for the device
95 */ 96 */
96void maple_getcond_callback(struct maple_device *dev, 97void maple_getcond_callback(struct maple_device *dev,
97 void (*callback) (struct mapleq * mq), 98 void (*callback) (struct mapleq *mq),
98 unsigned long interval, unsigned long function) 99 unsigned long interval, unsigned long function)
99{ 100{
100 dev->callback = callback; 101 dev->callback = callback;
101 dev->interval = interval; 102 dev->interval = interval;
102 dev->function = cpu_to_be32(function); 103 dev->function = cpu_to_be32(function);
103 dev->when = jiffies; 104 dev->when = jiffies;
104} 105}
105EXPORT_SYMBOL_GPL(maple_getcond_callback); 106EXPORT_SYMBOL_GPL(maple_getcond_callback);
106 107
107static int maple_dma_done(void) 108static int maple_dma_done(void)
108{ 109{
109 return (ctrl_inl(MAPLE_STATE) & 1) == 0; 110 return (ctrl_inl(MAPLE_STATE) & 1) == 0;
110} 111}
111 112
112static void maple_release_device(struct device *dev) 113static void maple_release_device(struct device *dev)
113{ 114{
114 if (dev->type) { 115 struct maple_device *mdev;
115 kfree(dev->type->name); 116 struct mapleq *mq;
116 kfree(dev->type); 117 if (!dev)
117 } 118 return;
119 mdev = to_maple_dev(dev);
120 mq = mdev->mq;
121 if (mq) {
122 if (mq->recvbufdcsp)
123 kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
124 kfree(mq);
125 mq = NULL;
126 }
127 kfree(mdev);
118} 128}
119 129
120/** 130/**
@@ -123,60 +133,64 @@ static void maple_release_device(struct device *dev)
123 */ 133 */
124void maple_add_packet(struct mapleq *mq) 134void maple_add_packet(struct mapleq *mq)
125{ 135{
126 mutex_lock(&maple_list_lock); 136 mutex_lock(&maple_list_lock);
127 list_add(&mq->list, &maple_waitq); 137 list_add(&mq->list, &maple_waitq);
128 mutex_unlock(&maple_list_lock); 138 mutex_unlock(&maple_list_lock);
129} 139}
130EXPORT_SYMBOL_GPL(maple_add_packet); 140EXPORT_SYMBOL_GPL(maple_add_packet);
131 141
132static struct mapleq *maple_allocq(struct maple_device *dev) 142static struct mapleq *maple_allocq(struct maple_device *mdev)
133{ 143{
134 struct mapleq *mq; 144 struct mapleq *mq;
135 145
136 mq = kmalloc(sizeof(*mq), GFP_KERNEL); 146 mq = kmalloc(sizeof(*mq), GFP_KERNEL);
137 if (!mq) 147 if (!mq)
138 return NULL; 148 return NULL;
139 149
140 mq->dev = dev; 150 mq->dev = mdev;
141 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); 151 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
142 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp); 152 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
143 if (!mq->recvbuf) { 153 if (!mq->recvbuf) {
144 kfree(mq); 154 kfree(mq);
145 return NULL; 155 return NULL;
146 } 156 }
147 157
148 return mq; 158 return mq;
149} 159}
150 160
151static struct maple_device *maple_alloc_dev(int port, int unit) 161static struct maple_device *maple_alloc_dev(int port, int unit)
152{ 162{
153 struct maple_device *dev; 163 struct maple_device *mdev;
154 164
155 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 165 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
156 if (!dev) 166 if (!mdev)
157 return NULL; 167 return NULL;
158 168
159 dev->port = port; 169 mdev->port = port;
160 dev->unit = unit; 170 mdev->unit = unit;
161 dev->mq = maple_allocq(dev); 171 mdev->mq = maple_allocq(mdev);
162 172
163 if (!dev->mq) { 173 if (!mdev->mq) {
164 kfree(dev); 174 kfree(mdev);
165 return NULL; 175 return NULL;
166 } 176 }
167 177 mdev->dev.bus = &maple_bus_type;
168 return dev; 178 mdev->dev.parent = &maple_bus;
179 mdev->function = 0;
180 return mdev;
169} 181}
170 182
171static void maple_free_dev(struct maple_device *mdev) 183static void maple_free_dev(struct maple_device *mdev)
172{ 184{
173 if (!mdev) 185 if (!mdev)
174 return; 186 return;
175 if (mdev->mq) { 187 if (mdev->mq) {
176 kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp); 188 if (mdev->mq->recvbufdcsp)
177 kfree(mdev->mq); 189 kmem_cache_free(maple_queue_cache,
178 } 190 mdev->mq->recvbufdcsp);
179 kfree(mdev); 191 kfree(mdev->mq);
192 }
193 kfree(mdev);
180} 194}
181 195
182/* process the command queue into a maple command block 196/* process the command queue into a maple command block
@@ -184,153 +198,162 @@ static void maple_free_dev(struct maple_device *mdev)
184 */ 198 */
185static void maple_build_block(struct mapleq *mq) 199static void maple_build_block(struct mapleq *mq)
186{ 200{
187 int port, unit, from, to, len; 201 int port, unit, from, to, len;
188 unsigned long *lsendbuf = mq->sendbuf; 202 unsigned long *lsendbuf = mq->sendbuf;
189 203
190 port = mq->dev->port & 3; 204 port = mq->dev->port & 3;
191 unit = mq->dev->unit; 205 unit = mq->dev->unit;
192 len = mq->length; 206 len = mq->length;
193 from = port << 6; 207 from = port << 6;
194 to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20); 208 to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20);
195 209
196 *maple_lastptr &= 0x7fffffff; 210 *maple_lastptr &= 0x7fffffff;
197 maple_lastptr = maple_sendptr; 211 maple_lastptr = maple_sendptr;
198 212
199 *maple_sendptr++ = (port << 16) | len | 0x80000000; 213 *maple_sendptr++ = (port << 16) | len | 0x80000000;
200 *maple_sendptr++ = PHYSADDR(mq->recvbuf); 214 *maple_sendptr++ = PHYSADDR(mq->recvbuf);
201 *maple_sendptr++ = 215 *maple_sendptr++ =
202 mq->command | (to << 8) | (from << 16) | (len << 24); 216 mq->command | (to << 8) | (from << 16) | (len << 24);
203 217
204 while (len-- > 0) 218 while (len-- > 0)
205 *maple_sendptr++ = *lsendbuf++; 219 *maple_sendptr++ = *lsendbuf++;
206} 220}
207 221
208/* build up command queue */ 222/* build up command queue */
209static void maple_send(void) 223static void maple_send(void)
210{ 224{
211 int i; 225 int i;
212 int maple_packets; 226 int maple_packets;
213 struct mapleq *mq, *nmq; 227 struct mapleq *mq, *nmq;
214 228
215 if (!list_empty(&maple_sentq)) 229 if (!list_empty(&maple_sentq))
216 return; 230 return;
217 if (list_empty(&maple_waitq) || !maple_dma_done()) 231 if (list_empty(&maple_waitq) || !maple_dma_done())
218 return; 232 return;
219 maple_packets = 0; 233 maple_packets = 0;
220 maple_sendptr = maple_lastptr = maple_sendbuf; 234 maple_sendptr = maple_lastptr = maple_sendbuf;
221 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { 235 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
222 maple_build_block(mq); 236 maple_build_block(mq);
223 list_move(&mq->list, &maple_sentq); 237 list_move(&mq->list, &maple_sentq);
224 if (maple_packets++ > MAPLE_MAXPACKETS) 238 if (maple_packets++ > MAPLE_MAXPACKETS)
225 break; 239 break;
226 } 240 }
227 if (maple_packets > 0) { 241 if (maple_packets > 0) {
228 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) 242 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)
229 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, 243 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,
230 PAGE_SIZE, DMA_BIDIRECTIONAL); 244 PAGE_SIZE, DMA_BIDIRECTIONAL);
231 } 245 }
232} 246}
233 247
234static int attach_matching_maple_driver(struct device_driver *driver, 248static int attach_matching_maple_driver(struct device_driver *driver,
235 void *devptr) 249 void *devptr)
236{ 250{
237 struct maple_driver *maple_drv; 251 struct maple_driver *maple_drv;
238 struct maple_device *mdev; 252 struct maple_device *mdev;
239 253
240 mdev = devptr; 254 mdev = devptr;
241 maple_drv = to_maple_driver(driver); 255 maple_drv = to_maple_driver(driver);
242 if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) { 256 if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) {
243 if (maple_drv->connect(mdev) == 0) { 257 if (maple_drv->connect(mdev) == 0) {
244 mdev->driver = maple_drv; 258 mdev->driver = maple_drv;
245 return 1; 259 return 1;
246 } 260 }
247 } 261 }
248 return 0; 262 return 0;
249} 263}
250 264
251static void maple_detach_driver(struct maple_device *mdev) 265static void maple_detach_driver(struct maple_device *mdev)
252{ 266{
253 if (!mdev) 267 if (!mdev)
254 return; 268 return;
255 if (mdev->driver) { 269 if (mdev->driver) {
256 if (mdev->driver->disconnect) 270 if (mdev->driver->disconnect)
257 mdev->driver->disconnect(mdev); 271 mdev->driver->disconnect(mdev);
258 } 272 }
259 mdev->driver = NULL; 273 mdev->driver = NULL;
260 if (mdev->registered) { 274 device_unregister(&mdev->dev);
261 maple_release_device(&mdev->dev); 275 mdev = NULL;
262 device_unregister(&mdev->dev);
263 }
264 mdev->registered = 0;
265 maple_free_dev(mdev);
266} 276}
267 277
268/* process initial MAPLE_COMMAND_DEVINFO for each device or port */ 278/* process initial MAPLE_COMMAND_DEVINFO for each device or port */
269static void maple_attach_driver(struct maple_device *dev) 279static void maple_attach_driver(struct maple_device *mdev)
270{ 280{
271 char *p; 281 char *p, *recvbuf;
272 282 unsigned long function;
273 char *recvbuf; 283 int matched, retval;
274 unsigned long function; 284
275 int matched, retval; 285 recvbuf = mdev->mq->recvbuf;
276 286 /* copy the data as individual elements in
277 recvbuf = dev->mq->recvbuf; 287 * case of memory optimisation */
278 memcpy(&dev->devinfo, recvbuf + 4, sizeof(dev->devinfo)); 288 memcpy(&mdev->devinfo.function, recvbuf + 4, 4);
279 memcpy(dev->product_name, dev->devinfo.product_name, 30); 289 memcpy(&mdev->devinfo.function_data[0], recvbuf + 8, 12);
280 memcpy(dev->product_licence, dev->devinfo.product_licence, 60); 290 memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1);
281 dev->product_name[30] = '\0'; 291 memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1);
282 dev->product_licence[60] = '\0'; 292 memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30);
283 293 memcpy(&mdev->devinfo.product_licence[0], recvbuf + 52, 60);
284 for (p = dev->product_name + 29; dev->product_name <= p; p--) 294 memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2);
285 if (*p == ' ') 295 memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2);
286 *p = '\0'; 296 memcpy(mdev->product_name, mdev->devinfo.product_name, 30);
287 else 297 mdev->product_name[30] = '\0';
288 break; 298 memcpy(mdev->product_licence, mdev->devinfo.product_licence, 60);
289 299 mdev->product_licence[60] = '\0';
290 for (p = dev->product_licence + 59; dev->product_licence <= p; p--) 300
291 if (*p == ' ') 301 for (p = mdev->product_name + 29; mdev->product_name <= p; p--)
292 *p = '\0'; 302 if (*p == ' ')
293 else 303 *p = '\0';
294 break; 304 else
295 305 break;
296 function = be32_to_cpu(dev->devinfo.function); 306 for (p = mdev->product_licence + 59; mdev->product_licence <= p; p--)
297 307 if (*p == ' ')
298 if (function > 0x200) { 308 *p = '\0';
299 /* Do this silently - as not a real device */ 309 else
300 function = 0; 310 break;
301 dev->driver = &maple_dummy_driver; 311
302 sprintf(dev->dev.bus_id, "%d:0.port", dev->port); 312 if (realscan) {
303 } else { 313 printk(KERN_INFO "Maple device detected: %s\n",
304 printk(KERN_INFO 314 mdev->product_name);
305 "Maple bus at (%d, %d): Connected function 0x%lX\n", 315 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
306 dev->port, dev->unit, function); 316 }
307 317
308 matched = 318 function = be32_to_cpu(mdev->devinfo.function);
309 bus_for_each_drv(&maple_bus_type, NULL, dev, 319
310 attach_matching_maple_driver); 320 if (function > 0x200) {
311 321 /* Do this silently - as not a real device */
312 if (matched == 0) { 322 function = 0;
313 /* Driver does not exist yet */ 323 mdev->driver = &maple_dummy_driver;
314 printk(KERN_INFO 324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port);
315 "No maple driver found for this device\n"); 325 } else {
316 dev->driver = &maple_dummy_driver; 326 if (realscan)
317 } 327 printk(KERN_INFO
318 328 "Maple bus at (%d, %d): Function 0x%lX\n",
319 sprintf(dev->dev.bus_id, "%d:0%d.%lX", dev->port, 329 mdev->port, mdev->unit, function);
320 dev->unit, function); 330
321 } 331 matched =
322 dev->function = function; 332 bus_for_each_drv(&maple_bus_type, NULL, mdev,
323 dev->dev.bus = &maple_bus_type; 333 attach_matching_maple_driver);
324 dev->dev.parent = &maple_bus; 334
325 dev->dev.release = &maple_release_device; 335 if (matched == 0) {
326 retval = device_register(&dev->dev); 336 /* Driver does not exist yet */
327 if (retval) { 337 if (realscan)
328 printk(KERN_INFO 338 printk(KERN_INFO
329 "Maple bus: Attempt to register device (%x, %x) failed.\n", 339 "No maple driver found.\n");
330 dev->port, dev->unit); 340 mdev->driver = &maple_dummy_driver;
331 maple_free_dev(dev); 341 }
332 } 342 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port,
333 dev->registered = 1; 343 mdev->unit, function);
344 }
345 mdev->function = function;
346 mdev->dev.release = &maple_release_device;
347 retval = device_register(&mdev->dev);
348 if (retval) {
349 printk(KERN_INFO
350 "Maple bus: Attempt to register device"
351 " (%x, %x) failed.\n",
352 mdev->port, mdev->unit);
353 maple_free_dev(mdev);
354 mdev = NULL;
355 return;
356 }
334} 357}
335 358
336/* 359/*
@@ -340,270 +363,262 @@ static void maple_attach_driver(struct maple_device *dev)
340 */ 363 */
341static int detach_maple_device(struct device *device, void *portptr) 364static int detach_maple_device(struct device *device, void *portptr)
342{ 365{
343 struct maple_device_specify *ds; 366 struct maple_device_specify *ds;
344 struct maple_device *mdev; 367 struct maple_device *mdev;
345 368
346 ds = portptr; 369 ds = portptr;
347 mdev = to_maple_dev(device); 370 mdev = to_maple_dev(device);
348 if (mdev->port == ds->port && mdev->unit == ds->unit) 371 if (mdev->port == ds->port && mdev->unit == ds->unit)
349 return 1; 372 return 1;
350 return 0; 373 return 0;
351} 374}
352 375
353static int setup_maple_commands(struct device *device, void *ignored) 376static int setup_maple_commands(struct device *device, void *ignored)
354{ 377{
355 struct maple_device *maple_dev = to_maple_dev(device); 378 struct maple_device *maple_dev = to_maple_dev(device);
356 379
357 if ((maple_dev->interval > 0) 380 if ((maple_dev->interval > 0)
358 && time_after(jiffies, maple_dev->when)) { 381 && time_after(jiffies, maple_dev->when)) {
359 maple_dev->when = jiffies + maple_dev->interval; 382 maple_dev->when = jiffies + maple_dev->interval;
360 maple_dev->mq->command = MAPLE_COMMAND_GETCOND; 383 maple_dev->mq->command = MAPLE_COMMAND_GETCOND;
361 maple_dev->mq->sendbuf = &maple_dev->function; 384 maple_dev->mq->sendbuf = &maple_dev->function;
362 maple_dev->mq->length = 1; 385 maple_dev->mq->length = 1;
363 maple_add_packet(maple_dev->mq); 386 maple_add_packet(maple_dev->mq);
364 liststatus++; 387 liststatus++;
365 } else { 388 } else {
366 if (time_after(jiffies, maple_pnp_time)) { 389 if (time_after(jiffies, maple_pnp_time)) {
367 maple_dev->mq->command = MAPLE_COMMAND_DEVINFO; 390 maple_dev->mq->command = MAPLE_COMMAND_DEVINFO;
368 maple_dev->mq->length = 0; 391 maple_dev->mq->length = 0;
369 maple_add_packet(maple_dev->mq); 392 maple_add_packet(maple_dev->mq);
370 liststatus++; 393 liststatus++;
371 } 394 }
372 } 395 }
373 396
374 return 0; 397 return 0;
375} 398}
376 399
377/* VBLANK bottom half - implemented via workqueue */ 400/* VBLANK bottom half - implemented via workqueue */
378static void maple_vblank_handler(struct work_struct *work) 401static void maple_vblank_handler(struct work_struct *work)
379{ 402{
380 if (!maple_dma_done()) 403 if (!maple_dma_done())
381 return; 404 return;
382 if (!list_empty(&maple_sentq)) 405 if (!list_empty(&maple_sentq))
383 return; 406 return;
384 ctrl_outl(0, MAPLE_ENABLE); 407 ctrl_outl(0, MAPLE_ENABLE);
385 liststatus = 0; 408 liststatus = 0;
386 bus_for_each_dev(&maple_bus_type, NULL, NULL, 409 bus_for_each_dev(&maple_bus_type, NULL, NULL,
387 setup_maple_commands); 410 setup_maple_commands);
388 if (time_after(jiffies, maple_pnp_time)) 411 if (time_after(jiffies, maple_pnp_time))
389 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; 412 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL;
390 if (liststatus && list_empty(&maple_sentq)) { 413 if (liststatus && list_empty(&maple_sentq)) {
391 INIT_LIST_HEAD(&maple_sentq); 414 INIT_LIST_HEAD(&maple_sentq);
392 maple_send(); 415 maple_send();
393 } 416 }
394 maplebus_dma_reset(); 417 maplebus_dma_reset();
395} 418}
396 419
397/* handle devices added via hotplugs - placing them on queue for DEVINFO*/ 420/* handle devices added via hotplugs - placing them on queue for DEVINFO*/
398static void maple_map_subunits(struct maple_device *mdev, int submask) 421static void maple_map_subunits(struct maple_device *mdev, int submask)
399{ 422{
400 int retval, k, devcheck; 423 int retval, k, devcheck;
401 struct maple_device *mdev_add; 424 struct maple_device *mdev_add;
402 struct maple_device_specify ds; 425 struct maple_device_specify ds;
403 426
404 for (k = 0; k < 5; k++) { 427 for (k = 0; k < 5; k++) {
405 ds.port = mdev->port; 428 ds.port = mdev->port;
406 ds.unit = k + 1; 429 ds.unit = k + 1;
407 retval = 430 retval =
408 bus_for_each_dev(&maple_bus_type, NULL, &ds, 431 bus_for_each_dev(&maple_bus_type, NULL, &ds,
409 detach_maple_device); 432 detach_maple_device);
410 if (retval) { 433 if (retval) {
411 submask = submask >> 1; 434 submask = submask >> 1;
412 continue; 435 continue;
413 } 436 }
414 devcheck = submask & 0x01; 437 devcheck = submask & 0x01;
415 if (devcheck) { 438 if (devcheck) {
416 mdev_add = maple_alloc_dev(mdev->port, k + 1); 439 mdev_add = maple_alloc_dev(mdev->port, k + 1);
417 if (!mdev_add) 440 if (!mdev_add)
418 return; 441 return;
419 mdev_add->mq->command = MAPLE_COMMAND_DEVINFO; 442 mdev_add->mq->command = MAPLE_COMMAND_DEVINFO;
420 mdev_add->mq->length = 0; 443 mdev_add->mq->length = 0;
421 maple_add_packet(mdev_add->mq); 444 maple_add_packet(mdev_add->mq);
422 scanning = 1; 445 scanning = 1;
423 } 446 }
424 submask = submask >> 1; 447 submask = submask >> 1;
425 } 448 }
426} 449}
427 450
428/* mark a device as removed */ 451/* mark a device as removed */
429static void maple_clean_submap(struct maple_device *mdev) 452static void maple_clean_submap(struct maple_device *mdev)
430{ 453{
431 int killbit; 454 int killbit;
432 455
433 killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20); 456 killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20);
434 killbit = ~killbit; 457 killbit = ~killbit;
435 killbit &= 0xFF; 458 killbit &= 0xFF;
436 subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit; 459 subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit;
437} 460}
438 461
439/* handle empty port or hotplug removal */ 462/* handle empty port or hotplug removal */
440static void maple_response_none(struct maple_device *mdev, 463static void maple_response_none(struct maple_device *mdev,
441 struct mapleq *mq) 464 struct mapleq *mq)
442{ 465{
443 if (mdev->unit != 0) { 466 if (mdev->unit != 0) {
444 list_del(&mq->list); 467 list_del(&mq->list);
445 maple_clean_submap(mdev); 468 maple_clean_submap(mdev);
446 printk(KERN_INFO 469 printk(KERN_INFO
447 "Maple bus device detaching at (%d, %d)\n", 470 "Maple bus device detaching at (%d, %d)\n",
448 mdev->port, mdev->unit); 471 mdev->port, mdev->unit);
449 maple_detach_driver(mdev); 472 maple_detach_driver(mdev);
450 return; 473 return;
451 } 474 }
452 if (!started) { 475 if (!started) {
453 printk(KERN_INFO "No maple devices attached to port %d\n", 476 printk(KERN_INFO "No maple devices attached to port %d\n",
454 mdev->port); 477 mdev->port);
455 return; 478 return;
456 } 479 }
457 maple_clean_submap(mdev); 480 maple_clean_submap(mdev);
458} 481}
459 482
460/* preprocess hotplugs or scans */ 483/* preprocess hotplugs or scans */
461static void maple_response_devinfo(struct maple_device *mdev, 484static void maple_response_devinfo(struct maple_device *mdev,
462 char *recvbuf) 485 char *recvbuf)
463{ 486{
464 char submask; 487 char submask;
465 if ((!started) || (scanning == 2)) { 488 if ((!started) || (scanning == 2)) {
466 maple_attach_driver(mdev); 489 maple_attach_driver(mdev);
467 return; 490 return;
468 } 491 }
469 if (mdev->unit == 0) { 492 if (mdev->unit == 0) {
470 submask = recvbuf[2] & 0x1F; 493 submask = recvbuf[2] & 0x1F;
471 if (submask ^ subdevice_map[mdev->port]) { 494 if (submask ^ subdevice_map[mdev->port]) {
472 maple_map_subunits(mdev, submask); 495 maple_map_subunits(mdev, submask);
473 subdevice_map[mdev->port] = submask; 496 subdevice_map[mdev->port] = submask;
474 } 497 }
475 } 498 }
476} 499}
477 500
478/* maple dma end bottom half - implemented via workqueue */ 501/* maple dma end bottom half - implemented via workqueue */
479static void maple_dma_handler(struct work_struct *work) 502static void maple_dma_handler(struct work_struct *work)
480{ 503{
481 struct mapleq *mq, *nmq; 504 struct mapleq *mq, *nmq;
482 struct maple_device *dev; 505 struct maple_device *dev;
483 char *recvbuf; 506 char *recvbuf;
484 enum maple_code code; 507 enum maple_code code;
485 508
486 if (!maple_dma_done()) 509 if (!maple_dma_done())
487 return; 510 return;
488 ctrl_outl(0, MAPLE_ENABLE); 511 ctrl_outl(0, MAPLE_ENABLE);
489 if (!list_empty(&maple_sentq)) { 512 if (!list_empty(&maple_sentq)) {
490 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { 513 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) {
491 recvbuf = mq->recvbuf; 514 recvbuf = mq->recvbuf;
492 code = recvbuf[0]; 515 code = recvbuf[0];
493 dev = mq->dev; 516 dev = mq->dev;
494 switch (code) { 517 switch (code) {
495 case MAPLE_RESPONSE_NONE: 518 case MAPLE_RESPONSE_NONE:
496 maple_response_none(dev, mq); 519 maple_response_none(dev, mq);
497 break; 520 break;
498 521
499 case MAPLE_RESPONSE_DEVINFO: 522 case MAPLE_RESPONSE_DEVINFO:
500 maple_response_devinfo(dev, recvbuf); 523 maple_response_devinfo(dev, recvbuf);
501 break; 524 break;
502 525
503 case MAPLE_RESPONSE_DATATRF: 526 case MAPLE_RESPONSE_DATATRF:
504 if (dev->callback) 527 if (dev->callback)
505 dev->callback(mq); 528 dev->callback(mq);
506 break; 529 break;
507 530
508 case MAPLE_RESPONSE_FILEERR: 531 case MAPLE_RESPONSE_FILEERR:
509 case MAPLE_RESPONSE_AGAIN: 532 case MAPLE_RESPONSE_AGAIN:
510 case MAPLE_RESPONSE_BADCMD: 533 case MAPLE_RESPONSE_BADCMD:
511 case MAPLE_RESPONSE_BADFUNC: 534 case MAPLE_RESPONSE_BADFUNC:
512 printk(KERN_DEBUG 535 printk(KERN_DEBUG
513 "Maple non-fatal error 0x%X\n", 536 "Maple non-fatal error 0x%X\n",
514 code); 537 code);
515 break; 538 break;
516 539
517 case MAPLE_RESPONSE_ALLINFO: 540 case MAPLE_RESPONSE_ALLINFO:
518 printk(KERN_DEBUG 541 printk(KERN_DEBUG
519 "Maple - extended device information not supported\n"); 542 "Maple - extended device information"
520 break; 543 " not supported\n");
521 544 break;
522 case MAPLE_RESPONSE_OK: 545
523 break; 546 case MAPLE_RESPONSE_OK:
524 547 break;
525 default: 548
526 break; 549 default:
527 } 550 break;
528 } 551 }
529 INIT_LIST_HEAD(&maple_sentq); 552 }
530 if (scanning == 1) { 553 INIT_LIST_HEAD(&maple_sentq);
531 maple_send(); 554 if (scanning == 1) {
532 scanning = 2; 555 maple_send();
533 } else 556 scanning = 2;
534 scanning = 0; 557 } else
535 558 scanning = 0;
536 if (started == 0) 559
537 started = 1; 560 if (started == 0)
538 } 561 started = 1;
539 maplebus_dma_reset(); 562 }
563 maplebus_dma_reset();
540} 564}
541 565
542static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id) 566static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id)
543{ 567{
544 /* Load everything into the bottom half */ 568 /* Load everything into the bottom half */
545 schedule_work(&maple_dma_process); 569 schedule_work(&maple_dma_process);
546 return IRQ_HANDLED; 570 return IRQ_HANDLED;
547} 571}
548 572
549static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id) 573static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id)
550{ 574{
551 schedule_work(&maple_vblank_process); 575 schedule_work(&maple_vblank_process);
552 return IRQ_HANDLED; 576 return IRQ_HANDLED;
553} 577}
554 578
555static struct irqaction maple_dma_irq = {
556 .name = "maple bus DMA handler",
557 .handler = maplebus_dma_interrupt,
558 .flags = IRQF_SHARED,
559};
560
561static struct irqaction maple_vblank_irq = {
562 .name = "maple bus VBLANK handler",
563 .handler = maplebus_vblank_interrupt,
564 .flags = IRQF_SHARED,
565};
566
567static int maple_set_dma_interrupt_handler(void) 579static int maple_set_dma_interrupt_handler(void)
568{ 580{
569 return setup_irq(HW_EVENT_MAPLE_DMA, &maple_dma_irq); 581 return request_irq(HW_EVENT_MAPLE_DMA, maplebus_dma_interrupt,
582 IRQF_SHARED, "maple bus DMA", &maple_dummy_driver);
570} 583}
571 584
572static int maple_set_vblank_interrupt_handler(void) 585static int maple_set_vblank_interrupt_handler(void)
573{ 586{
574 return setup_irq(HW_EVENT_VSYNC, &maple_vblank_irq); 587 return request_irq(HW_EVENT_VSYNC, maplebus_vblank_interrupt,
588 IRQF_SHARED, "maple bus VBLANK", &maple_dummy_driver);
575} 589}
576 590
577static int maple_get_dma_buffer(void) 591static int maple_get_dma_buffer(void)
578{ 592{
579 maple_sendbuf = 593 maple_sendbuf =
580 (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, 594 (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
581 MAPLE_DMA_PAGES); 595 MAPLE_DMA_PAGES);
582 if (!maple_sendbuf) 596 if (!maple_sendbuf)
583 return -ENOMEM; 597 return -ENOMEM;
584 return 0; 598 return 0;
585} 599}
586 600
587static int match_maple_bus_driver(struct device *devptr, 601static int match_maple_bus_driver(struct device *devptr,
588 struct device_driver *drvptr) 602 struct device_driver *drvptr)
589{ 603{
590 struct maple_driver *maple_drv; 604 struct maple_driver *maple_drv;
591 struct maple_device *maple_dev; 605 struct maple_device *maple_dev;
592 606
593 maple_drv = container_of(drvptr, struct maple_driver, drv); 607 maple_drv = container_of(drvptr, struct maple_driver, drv);
594 maple_dev = container_of(devptr, struct maple_device, dev); 608 maple_dev = container_of(devptr, struct maple_device, dev);
595 /* Trap empty port case */ 609 /* Trap empty port case */
596 if (maple_dev->devinfo.function == 0xFFFFFFFF) 610 if (maple_dev->devinfo.function == 0xFFFFFFFF)
597 return 0; 611 return 0;
598 else if (maple_dev->devinfo.function & 612 else if (maple_dev->devinfo.function &
599 be32_to_cpu(maple_drv->function)) 613 be32_to_cpu(maple_drv->function))
600 return 1; 614 return 1;
601 return 0; 615 return 0;
602} 616}
603 617
604static int maple_bus_uevent(struct device *dev, struct kobj_uevent_env *env) 618static int maple_bus_uevent(struct device *dev,
619 struct kobj_uevent_env *env)
605{ 620{
606 return 0; 621 return 0;
607} 622}
608 623
609static void maple_bus_release(struct device *dev) 624static void maple_bus_release(struct device *dev)
@@ -611,124 +626,122 @@ static void maple_bus_release(struct device *dev)
611} 626}
612 627
613static struct maple_driver maple_dummy_driver = { 628static struct maple_driver maple_dummy_driver = {
614 .drv = { 629 .drv = {
615 .name = "maple_dummy_driver", 630 .name = "maple_dummy_driver",
616 .bus = &maple_bus_type, 631 .bus = &maple_bus_type,
617 }, 632 },
618}; 633};
619 634
620struct bus_type maple_bus_type = { 635struct bus_type maple_bus_type = {
621 .name = "maple", 636 .name = "maple",
622 .match = match_maple_bus_driver, 637 .match = match_maple_bus_driver,
623 .uevent = maple_bus_uevent, 638 .uevent = maple_bus_uevent,
624}; 639};
625EXPORT_SYMBOL_GPL(maple_bus_type); 640EXPORT_SYMBOL_GPL(maple_bus_type);
626 641
627static struct device maple_bus = { 642static struct device maple_bus = {
628 .bus_id = "maple", 643 .bus_id = "maple",
629 .release = maple_bus_release, 644 .release = maple_bus_release,
630}; 645};
631 646
632static int __init maple_bus_init(void) 647static int __init maple_bus_init(void)
633{ 648{
634 int retval, i; 649 int retval, i;
635 struct maple_device *mdev[MAPLE_PORTS]; 650 struct maple_device *mdev[MAPLE_PORTS];
636 ctrl_outl(0, MAPLE_STATE); 651 ctrl_outl(0, MAPLE_STATE);
637 652
638 retval = device_register(&maple_bus); 653 retval = device_register(&maple_bus);
639 if (retval) 654 if (retval)
640 goto cleanup; 655 goto cleanup;
641 656
642 retval = bus_register(&maple_bus_type); 657 retval = bus_register(&maple_bus_type);
643 if (retval) 658 if (retval)
644 goto cleanup_device; 659 goto cleanup_device;
645 660
646 retval = driver_register(&maple_dummy_driver.drv); 661 retval = driver_register(&maple_dummy_driver.drv);
647 662 if (retval)
648 if (retval) 663 goto cleanup_bus;
649 goto cleanup_bus; 664
650 665 /* allocate memory for maple bus dma */
651 /* allocate memory for maple bus dma */ 666 retval = maple_get_dma_buffer();
652 retval = maple_get_dma_buffer(); 667 if (retval) {
653 if (retval) { 668 printk(KERN_INFO
654 printk(KERN_INFO 669 "Maple bus: Failed to allocate Maple DMA buffers\n");
655 "Maple bus: Failed to allocate Maple DMA buffers\n"); 670 goto cleanup_basic;
656 goto cleanup_basic; 671 }
657 } 672
658 673 /* set up DMA interrupt handler */
659 /* set up DMA interrupt handler */ 674 retval = maple_set_dma_interrupt_handler();
660 retval = maple_set_dma_interrupt_handler(); 675 if (retval) {
661 if (retval) { 676 printk(KERN_INFO
662 printk(KERN_INFO 677 "Maple bus: Failed to grab maple DMA IRQ\n");
663 "Maple bus: Failed to grab maple DMA IRQ\n"); 678 goto cleanup_dma;
664 goto cleanup_dma; 679 }
665 } 680
666 681 /* set up VBLANK interrupt handler */
667 /* set up VBLANK interrupt handler */ 682 retval = maple_set_vblank_interrupt_handler();
668 retval = maple_set_vblank_interrupt_handler(); 683 if (retval) {
669 if (retval) { 684 printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n");
670 printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n"); 685 goto cleanup_irq;
671 goto cleanup_irq; 686 }
672 } 687
673 688 maple_queue_cache =
674 maple_queue_cache = 689 kmem_cache_create("maple_queue_cache", 0x400, 0,
675 kmem_cache_create("maple_queue_cache", 0x400, 0, 690 SLAB_POISON|SLAB_HWCACHE_ALIGN, NULL);
676 SLAB_HWCACHE_ALIGN, NULL); 691
677 692 if (!maple_queue_cache)
678 if (!maple_queue_cache) 693 goto cleanup_bothirqs;
679 goto cleanup_bothirqs; 694
680 695 /* setup maple ports */
681 /* setup maple ports */ 696 for (i = 0; i < MAPLE_PORTS; i++) {
682 for (i = 0; i < MAPLE_PORTS; i++) { 697 mdev[i] = maple_alloc_dev(i, 0);
683 mdev[i] = maple_alloc_dev(i, 0); 698 if (!mdev[i]) {
684 if (!mdev[i]) { 699 while (i-- > 0)
685 while (i-- > 0) 700 maple_free_dev(mdev[i]);
686 maple_free_dev(mdev[i]); 701 goto cleanup_cache;
687 goto cleanup_cache; 702 }
688 } 703 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO;
689 mdev[i]->registered = 0; 704 mdev[i]->mq->length = 0;
690 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; 705 maple_add_packet(mdev[i]->mq);
691 mdev[i]->mq->length = 0; 706 /* delay aids hardware detection */
692 maple_attach_driver(mdev[i]); 707 mdelay(5);
693 maple_add_packet(mdev[i]->mq); 708 subdevice_map[i] = 0;
694 subdevice_map[i] = 0; 709 }
695 } 710
696 711 realscan = 1;
697 /* setup maplebus hardware */ 712 /* setup maplebus hardware */
698 maplebus_dma_reset(); 713 maplebus_dma_reset();
699 714 /* initial detection */
700 /* initial detection */ 715 maple_send();
701 maple_send(); 716 maple_pnp_time = jiffies;
702 717 printk(KERN_INFO "Maple bus core now registered.\n");
703 maple_pnp_time = jiffies; 718
704 719 return 0;
705 printk(KERN_INFO "Maple bus core now registered.\n");
706
707 return 0;
708 720
709cleanup_cache: 721cleanup_cache:
710 kmem_cache_destroy(maple_queue_cache); 722 kmem_cache_destroy(maple_queue_cache);
711 723
712cleanup_bothirqs: 724cleanup_bothirqs:
713 free_irq(HW_EVENT_VSYNC, 0); 725 free_irq(HW_EVENT_VSYNC, 0);
714 726
715cleanup_irq: 727cleanup_irq:
716 free_irq(HW_EVENT_MAPLE_DMA, 0); 728 free_irq(HW_EVENT_MAPLE_DMA, 0);
717 729
718cleanup_dma: 730cleanup_dma:
719 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); 731 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES);
720 732
721cleanup_basic: 733cleanup_basic:
722 driver_unregister(&maple_dummy_driver.drv); 734 driver_unregister(&maple_dummy_driver.drv);
723 735
724cleanup_bus: 736cleanup_bus:
725 bus_unregister(&maple_bus_type); 737 bus_unregister(&maple_bus_type);
726 738
727cleanup_device: 739cleanup_device:
728 device_unregister(&maple_bus); 740 device_unregister(&maple_bus);
729 741
730cleanup: 742cleanup:
731 printk(KERN_INFO "Maple bus registration failed\n"); 743 printk(KERN_INFO "Maple bus registration failed\n");
732 return retval; 744 return retval;
733} 745}
734subsys_initcall(maple_bus_init); 746/* Push init to later to ensure hardware gets detected */
747fs_initcall(maple_bus_init);
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 3301167d4f2a..017a196d041f 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3563,8 +3563,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr,
3563 3563
3564 down_read(&fsg->filesem); 3564 down_read(&fsg->filesem);
3565 if (backing_file_is_open(curlun)) { // Get the complete pathname 3565 if (backing_file_is_open(curlun)) { // Get the complete pathname
3566 p = d_path(curlun->filp->f_path.dentry, 3566 p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
3567 curlun->filp->f_path.mnt, buf, PAGE_SIZE - 1);
3568 if (IS_ERR(p)) 3567 if (IS_ERR(p))
3569 rc = PTR_ERR(p); 3568 rc = PTR_ERR(p);
3570 else { 3569 else {
@@ -3981,9 +3980,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3981 if (backing_file_is_open(curlun)) { 3980 if (backing_file_is_open(curlun)) {
3982 p = NULL; 3981 p = NULL;
3983 if (pathbuf) { 3982 if (pathbuf) {
3984 p = d_path(curlun->filp->f_path.dentry, 3983 p = d_path(&curlun->filp->f_path,
3985 curlun->filp->f_path.mnt, 3984 pathbuf, PATH_MAX);
3986 pathbuf, PATH_MAX);
3987 if (IS_ERR(p)) 3985 if (IS_ERR(p))
3988 p = NULL; 3986 p = NULL;
3989 } 3987 }