Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86:
eeepc-laptop: Use ACPI handle to identify rfkill port
[PATCH] sony-laptop: limit brightness range to DSDT provided ones
sony-laptop: report failures on setting LCD brightness
thinkpad-acpi: module autoloading for newer Lenovo ThinkPads.

+150 -43
+41 -16
drivers/platform/x86/eeepc-laptop.c
··· 585 585 return true; 586 586 } 587 587 588 - static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) 588 + static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle) 589 589 { 590 + struct pci_dev *port; 590 591 struct pci_dev *dev; 591 592 struct pci_bus *bus; 592 593 bool blocked = eeepc_wlan_rfkill_blocked(eeepc); ··· 600 599 mutex_lock(&eeepc->hotplug_lock); 601 600 602 601 if (eeepc->hotplug_slot) { 603 - bus = pci_find_bus(0, 1); 602 + port = acpi_get_pci_dev(handle); 603 + if (!port) { 604 + pr_warning("Unable to find port\n"); 605 + goto out_unlock; 606 + } 607 + 608 + bus = port->subordinate; 609 + 604 610 if (!bus) { 605 - pr_warning("Unable to find PCI bus 1?\n"); 611 + pr_warning("Unable to find PCI bus?\n"); 606 612 goto out_unlock; 607 613 } 608 614 ··· 617 609 pr_err("Unable to read PCI config space?\n"); 618 610 goto out_unlock; 619 611 } 612 + 620 613 absent = (l == 0xffffffff); 621 614 622 615 if (blocked != absent) { ··· 656 647 mutex_unlock(&eeepc->hotplug_lock); 657 648 } 658 649 650 + static void eeepc_rfkill_hotplug_update(struct eeepc_laptop *eeepc, char *node) 651 + { 652 + acpi_status status = AE_OK; 653 + acpi_handle handle; 654 + 655 + status = acpi_get_handle(NULL, node, &handle); 656 + 657 + if (ACPI_SUCCESS(status)) 658 + eeepc_rfkill_hotplug(eeepc, handle); 659 + } 660 + 659 661 static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) 660 662 { 661 663 struct eeepc_laptop *eeepc = data; ··· 674 654 if (event != ACPI_NOTIFY_BUS_CHECK) 675 655 return; 676 656 677 - eeepc_rfkill_hotplug(eeepc); 657 + eeepc_rfkill_hotplug(eeepc, handle); 678 658 } 679 659 680 660 static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, ··· 692 672 eeepc); 693 673 if (ACPI_FAILURE(status)) 694 674 pr_warning("Failed to register notify on %s\n", node); 675 + /* 676 + * Refresh pci hotplug in case the rfkill state was 677 + * changed during setup. 678 + */ 679 + eeepc_rfkill_hotplug(eeepc, handle); 695 680 } else 696 681 return -ENODEV; 697 682 ··· 718 693 if (ACPI_FAILURE(status)) 719 694 pr_err("Error removing rfkill notify handler %s\n", 720 695 node); 696 + /* 697 + * Refresh pci hotplug in case the rfkill 698 + * state was changed after 699 + * eeepc_unregister_rfkill_notifier() 700 + */ 701 + eeepc_rfkill_hotplug(eeepc, handle); 721 702 } 722 703 } 723 704 ··· 847 816 rfkill_destroy(eeepc->wlan_rfkill); 848 817 eeepc->wlan_rfkill = NULL; 849 818 } 850 - /* 851 - * Refresh pci hotplug in case the rfkill state was changed after 852 - * eeepc_unregister_rfkill_notifier() 853 - */ 854 - eeepc_rfkill_hotplug(eeepc); 819 + 855 820 if (eeepc->hotplug_slot) 856 821 pci_hp_deregister(eeepc->hotplug_slot); 857 822 ··· 916 889 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); 917 890 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); 918 891 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); 919 - /* 920 - * Refresh pci hotplug in case the rfkill state was changed during 921 - * setup. 922 - */ 923 - eeepc_rfkill_hotplug(eeepc); 924 892 925 893 exit: 926 894 if (result && result != -ENODEV) ··· 950 928 struct eeepc_laptop *eeepc = dev_get_drvdata(device); 951 929 952 930 /* Refresh both wlan rfkill state and pci hotplug */ 953 - if (eeepc->wlan_rfkill) 954 - eeepc_rfkill_hotplug(eeepc); 931 + if (eeepc->wlan_rfkill) { 932 + eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P5"); 933 + eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P6"); 934 + eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P7"); 935 + } 955 936 956 937 if (eeepc->bluetooth_rfkill) 957 938 rfkill_set_sw_state(eeepc->bluetooth_rfkill,
+105 -25
drivers/platform/x86/sony-laptop.c
··· 934 934 /* 935 935 * Backlight device 936 936 */ 937 + struct sony_backlight_props { 938 + struct backlight_device *dev; 939 + int handle; 940 + u8 offset; 941 + u8 maxlvl; 942 + }; 943 + struct sony_backlight_props sony_bl_props; 944 + 937 945 static int sony_backlight_update_status(struct backlight_device *bd) 938 946 { 939 947 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT", ··· 962 954 { 963 955 int result; 964 956 int *handle = (int *)bl_get_data(bd); 957 + struct sony_backlight_props *sdev = 958 + (struct sony_backlight_props *)bl_get_data(bd); 965 959 966 - sony_call_snc_handle(*handle, 0x0200, &result); 960 + sony_call_snc_handle(sdev->handle, 0x0200, &result); 967 961 968 - return result & 0xff; 962 + return (result & 0xff) - sdev->offset; 969 963 } 970 964 971 965 static int sony_nc_update_status_ng(struct backlight_device *bd) 972 966 { 973 967 int value, result; 974 968 int *handle = (int *)bl_get_data(bd); 969 + struct sony_backlight_props *sdev = 970 + (struct sony_backlight_props *)bl_get_data(bd); 975 971 976 - value = bd->props.brightness; 977 - sony_call_snc_handle(*handle, 0x0100 | (value << 16), &result); 972 + value = bd->props.brightness + sdev->offset; 973 + if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result)) 974 + return -EIO; 978 975 979 - return sony_nc_get_brightness_ng(bd); 976 + return value; 980 977 } 981 978 982 979 static const struct backlight_ops sony_backlight_ops = { ··· 994 981 .update_status = sony_nc_update_status_ng, 995 982 .get_brightness = sony_nc_get_brightness_ng, 996 983 }; 997 - static int backlight_ng_handle; 998 - static struct backlight_device *sony_backlight_device; 999 984 1000 985 /* 1001 986 * New SNC-only Vaios event mapping to driver known keys ··· 1560 1549 &ignore); 1561 1550 } 1562 1551 1552 + static void sony_nc_backlight_ng_read_limits(int handle, 1553 + struct sony_backlight_props *props) 1554 + { 1555 + int offset; 1556 + acpi_status status; 1557 + u8 brlvl, i; 1558 + u8 min = 0xff, max = 0x00; 1559 + struct acpi_object_list params; 1560 + union acpi_object in_obj; 1561 + union acpi_object *lvl_enum; 1562 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1563 + 1564 + props->handle = handle; 1565 + props->offset = 0; 1566 + props->maxlvl = 0xff; 1567 + 1568 + offset = sony_find_snc_handle(handle); 1569 + if (offset < 0) 1570 + return; 1571 + 1572 + /* try to read the boundaries from ACPI tables, if we fail the above 1573 + * defaults should be reasonable 1574 + */ 1575 + params.count = 1; 1576 + params.pointer = &in_obj; 1577 + in_obj.type = ACPI_TYPE_INTEGER; 1578 + in_obj.integer.value = offset; 1579 + status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", &params, 1580 + &buffer); 1581 + if (ACPI_FAILURE(status)) 1582 + return; 1583 + 1584 + lvl_enum = (union acpi_object *) buffer.pointer; 1585 + if (!lvl_enum) { 1586 + pr_err("No SN06 return object."); 1587 + return; 1588 + } 1589 + if (lvl_enum->type != ACPI_TYPE_BUFFER) { 1590 + pr_err("Invalid SN06 return object 0x%.2x\n", 1591 + lvl_enum->type); 1592 + goto out_invalid; 1593 + } 1594 + 1595 + /* the buffer lists brightness levels available, brightness levels are 1596 + * from 0 to 8 in the array, other values are used by ALS control. 1597 + */ 1598 + for (i = 0; i < 9 && i < lvl_enum->buffer.length; i++) { 1599 + 1600 + brlvl = *(lvl_enum->buffer.pointer + i); 1601 + dprintk("Brightness level: %d\n", brlvl); 1602 + 1603 + if (!brlvl) 1604 + break; 1605 + 1606 + if (brlvl > max) 1607 + max = brlvl; 1608 + if (brlvl < min) 1609 + min = brlvl; 1610 + } 1611 + props->offset = min; 1612 + props->maxlvl = max; 1613 + dprintk("Brightness levels: min=%d max=%d\n", props->offset, 1614 + props->maxlvl); 1615 + 1616 + out_invalid: 1617 + kfree(buffer.pointer); 1618 + return; 1619 + } 1620 + 1563 1621 static void sony_nc_backlight_setup(void) 1564 1622 { 1565 1623 acpi_handle unused; ··· 1637 1557 struct backlight_properties props; 1638 1558 1639 1559 if (sony_find_snc_handle(0x12f) != -1) { 1640 - backlight_ng_handle = 0x12f; 1641 1560 ops = &sony_backlight_ng_ops; 1642 - max_brightness = 0xff; 1561 + sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props); 1562 + max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 1643 1563 1644 1564 } else if (sony_find_snc_handle(0x137) != -1) { 1645 - backlight_ng_handle = 0x137; 1646 1565 ops = &sony_backlight_ng_ops; 1647 - max_brightness = 0xff; 1566 + sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props); 1567 + max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 1648 1568 1649 1569 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 1650 1570 &unused))) { ··· 1657 1577 memset(&props, 0, sizeof(struct backlight_properties)); 1658 1578 props.type = BACKLIGHT_PLATFORM; 1659 1579 props.max_brightness = max_brightness; 1660 - sony_backlight_device = backlight_device_register("sony", NULL, 1661 - &backlight_ng_handle, 1662 - ops, &props); 1580 + sony_bl_props.dev = backlight_device_register("sony", NULL, 1581 + &sony_bl_props, 1582 + ops, &props); 1663 1583 1664 - if (IS_ERR(sony_backlight_device)) { 1665 - pr_warning(DRV_PFX "unable to register backlight device\n"); 1666 - sony_backlight_device = NULL; 1584 + if (IS_ERR(sony_bl_props.dev)) { 1585 + pr_warn(DRV_PFX "unable to register backlight device\n"); 1586 + sony_bl_props.dev = NULL; 1667 1587 } else 1668 - sony_backlight_device->props.brightness = 1669 - ops->get_brightness(sony_backlight_device); 1588 + sony_bl_props.dev->props.brightness = 1589 + ops->get_brightness(sony_bl_props.dev); 1670 1590 } 1671 1591 1672 1592 static void sony_nc_backlight_cleanup(void) 1673 1593 { 1674 - if (sony_backlight_device) 1675 - backlight_device_unregister(sony_backlight_device); 1594 + if (sony_bl_props.dev) 1595 + backlight_device_unregister(sony_bl_props.dev); 1676 1596 } 1677 1597 1678 1598 static int sony_nc_add(struct acpi_device *device) ··· 2670 2590 mutex_lock(&spic_dev.lock); 2671 2591 switch (cmd) { 2672 2592 case SONYPI_IOCGBRT: 2673 - if (sony_backlight_device == NULL) { 2593 + if (sony_bl_props.dev == NULL) { 2674 2594 ret = -EIO; 2675 2595 break; 2676 2596 } ··· 2683 2603 ret = -EFAULT; 2684 2604 break; 2685 2605 case SONYPI_IOCSBRT: 2686 - if (sony_backlight_device == NULL) { 2606 + if (sony_bl_props.dev == NULL) { 2687 2607 ret = -EIO; 2688 2608 break; 2689 2609 } ··· 2697 2617 break; 2698 2618 } 2699 2619 /* sync the backlight device status */ 2700 - sony_backlight_device->props.brightness = 2701 - sony_backlight_get_brightness(sony_backlight_device); 2620 + sony_bl_props.dev->props.brightness = 2621 + sony_backlight_get_brightness(sony_bl_props.dev); 2702 2622 break; 2703 2623 case SONYPI_IOCGBAT1CAP: 2704 2624 if (ec_read16(SONYPI_BAT1_FULL, &val16)) {
+4 -2
drivers/platform/x86/thinkpad_acpi.c
··· 128 128 }; 129 129 130 130 /* ACPI HIDs */ 131 - #define TPACPI_ACPI_HKEY_HID "IBM0068" 131 + #define TPACPI_ACPI_IBM_HKEY_HID "IBM0068" 132 + #define TPACPI_ACPI_LENOVO_HKEY_HID "LEN0068" 132 133 #define TPACPI_ACPI_EC_HID "PNP0C09" 133 134 134 135 /* Input IDs */ ··· 3880 3879 } 3881 3880 3882 3881 static const struct acpi_device_id ibm_htk_device_ids[] = { 3883 - {TPACPI_ACPI_HKEY_HID, 0}, 3882 + {TPACPI_ACPI_IBM_HKEY_HID, 0}, 3883 + {TPACPI_ACPI_LENOVO_HKEY_HID, 0}, 3884 3884 {"", 0}, 3885 3885 }; 3886 3886