Lines Matching +full:battery +full:- +full:profile

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * thinkpad_acpi.c - ThinkPad ACPI Extras
5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * Copyright (C) 2006-2009 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
16 * 2007-10-20 changelog trimmed down
18 * 2007-03-27 0.14 renamed to thinkpad_acpi and moved to
21 * 2006-11-22 0.13 new maintainer
23 * not be updated further in-file.
25 * 2005-03-17 0.11 support for 600e, 770x
28 * 2005-01-16 0.9 use MODULE_VERSION
33 * 2004-11-08 0.8 fix init error case, don't return from a macro
45 #include <linux/hwmon-sysfs.h>
73 #include <acpi/battery.h>
119 /* Misc NVRAM-related */
158 /* Hotkey-related */
174 TP_HKEY_EV_WKUP_S3_BATLOW = 0x2313, /* battery empty, S3 */
175 TP_HKEY_EV_WKUP_S4_BATLOW = 0x2413, /* battery empty, S4 */
177 /* Auto-sleep after eject request */
194 /* User-interface events */
206 /* Key-related user-interface events */
212 TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */
213 TP_HKEY_EV_ALARM_BAT_XHOT = 0x6012, /* battery critically hot */
223 /* AC-related events */
226 /* Further user-interface events */
241 #define TPACPI_URL "http://ibm-acpi.sf.net/"
242 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
272 * Driver-wide structs and misc. variables
374 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
382 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
463 * two or three characters from the set [0-9A-Z], i.e. base 36.
515 * tpacpi_check_quirks() - search BIOS/EC version on a list
532 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
533 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
534 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
535 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
536 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
537 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
538 return qlist->quirks; in tpacpi_check_quirks()
540 qlist_size--; in tpacpi_check_quirks()
582 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
708 return -ENXIO; in issue_thinkpad_cmos_command()
711 return -EIO; in issue_thinkpad_cmos_command()
800 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
803 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
810 BUG_ON(!ibm->acpi); in setup_acpi_notify()
812 if (!*ibm->acpi->handle) in setup_acpi_notify()
816 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
818 ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); in setup_acpi_notify()
819 if (!ibm->acpi->device) { in setup_acpi_notify()
820 pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); in setup_acpi_notify()
821 return -ENODEV; in setup_acpi_notify()
824 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
825 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
827 ibm->name); in setup_acpi_notify()
829 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
830 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
834 ibm->name); in setup_acpi_notify()
837 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
839 return -ENODEV; in setup_acpi_notify()
841 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
855 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
857 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
859 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
860 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
861 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
862 return -ENOMEM; in register_tpacpi_subdriver()
865 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
866 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
868 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
870 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
873 ibm->name, rc); in register_tpacpi_subdriver()
874 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
875 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
877 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
893 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
895 if (!ibm || !ibm->read) in dispatch_proc_show()
896 return -EINVAL; in dispatch_proc_show()
897 return ibm->read(m); in dispatch_proc_show()
913 if (!ibm || !ibm->write) in dispatch_proc_write()
914 return -EINVAL; in dispatch_proc_write()
915 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
916 return -EINVAL; in dispatch_proc_write()
920 return -ENOMEM; in dispatch_proc_write()
924 return -EFAULT; in dispatch_proc_write()
928 ret = ibm->write(kernbuf); in dispatch_proc_write()
968 if (ibm->suspend) in tpacpi_suspend_handler()
969 (ibm->suspend)(); in tpacpi_suspend_handler()
982 if (ibm->resume) in tpacpi_resume_handler()
983 (ibm->resume)(); in tpacpi_resume_handler()
1000 if (ibm->shutdown) in tpacpi_shutdown_handler()
1001 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1017 return -EINVAL; in parse_strtoul()
1041 * ThinkPad-ACPI firmware handling model:
1043 * WLSW (master wireless switch) is event-driven, and is common to all
1044 * firmware-controlled radios. It cannot be controlled, just monitored,
1047 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1051 * masked-off hotkeys are used.
1080 /* ThinkPad-ACPI rfkill subdriver */
1101 return -ENODEV; in tpacpi_rfk_update_swstate()
1103 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1107 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1114 * Sync the HW-blocking state of all rfkill switches,
1125 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1127 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1162 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1191 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1192 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1196 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1199 return -ENOMEM; in tpacpi_new_rfkill()
1202 atp_rfk->id = id; in tpacpi_new_rfkill()
1203 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1205 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1214 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1218 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1220 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1223 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1243 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1244 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1256 /* sysfs <radio> enable ------------------------------------------------ */
1263 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1285 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1288 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1290 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1294 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1296 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1303 /* procfs -------------------------------------------------------------- */
1331 int status = -1; in tpacpi_rfk_procfs_write()
1335 return -ENODEV; in tpacpi_rfk_procfs_write()
1343 return -EINVAL; in tpacpi_rfk_procfs_write()
1346 if (status != -1) { in tpacpi_rfk_procfs_write()
1350 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1358 * thinkpad-acpi driver attributes
1361 /* interface_version --------------------------------------------------- */
1368 /* debug_level --------------------------------------------------------- */
1380 return -EINVAL; in debug_level_store()
1388 /* version ------------------------------------------------------------- */
1396 /* --------------------------------------------------------------------- */
1400 /* wlsw_emulstate ------------------------------------------------------ */
1412 return -EINVAL; in wlsw_emulstate_store()
1423 /* bluetooth_emulstate ------------------------------------------------- */
1435 return -EINVAL; in bluetooth_emulstate_store()
1443 /* wwan_emulstate ------------------------------------------------- */
1455 return -EINVAL; in wwan_emulstate_store()
1463 /* uwb_emulstate ------------------------------------------------- */
1475 return -EINVAL; in uwb_emulstate_store()
1561 /* Numeric models ------------------ */
1573 /* A-series ------------------------- */
1587 /* G-series ------------------------- */
1592 /* R-series, T-series --------------- */
1622 /* X-series ------------------------- */
1635 /* (0) - older versions lack DMI EC fw string and functionality */
1636 /* (1) - older versions known to lack functionality */
1692 * thinkpad-acpi metadata subdriver
1727 * Unlike other classes, hotkey-class events have mask/unmask control on
1728 * non-ancient firmware. However, how it behaves changes a lot with the
1952 return -ENODEV; in hotkey_get_wlsw()
1961 return -EIO; in hotkey_get_wlsw()
2055 return -EIO; in hotkey_get_tablet_mode()
2061 return -EIO; in hotkey_get_tablet_mode()
2086 return -EIO; in hotkey_mask_get()
2094 /* sync userspace-visible mask */ in hotkey_mask_get()
2132 rc = -EIO; in hotkey_mask_set()
2173 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2222 return -EIO; in hotkey_status_get()
2230 return -EIO; in hotkey_status_set()
2294 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2295 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2296 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2297 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2301 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2305 n->displayexp_toggle = in hotkey_read_nvram()
2310 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2312 n->brightness_toggle = in hotkey_read_nvram()
2317 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2319 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2320 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2327 oldn->__member != newn->__member) \
2345 i--; in issue_volchange()
2361 i--; in issue_brightnesschange()
2387 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2388 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2390 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2400 if (newn->mute) { in hotkey_compare_and_issue_event()
2402 if (!oldn->mute || in hotkey_compare_and_issue_event()
2403 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2404 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2407 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2413 if (oldn->mute) { in hotkey_compare_and_issue_event()
2417 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2418 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2420 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2422 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2424 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2430 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2431 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2432 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2433 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2435 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2437 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2450 * most of them are edge-based. We only issue those requested by
2542 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2597 return -EBUSY; in hotkey_inputdev_open()
2602 return -EBUSY; in hotkey_inputdev_open()
2613 /* sysfs hotkey enable ------------------------------------------------- */
2640 return -EINVAL; in hotkey_enable_store()
2643 return -EPERM; in hotkey_enable_store()
2650 /* sysfs hotkey mask --------------------------------------------------- */
2666 return -EINVAL; in hotkey_mask_store()
2669 return -ERESTARTSYS; in hotkey_mask_store()
2686 /* sysfs hotkey bios_enabled ------------------------------------------- */
2696 /* sysfs hotkey bios_mask ---------------------------------------------- */
2708 /* sysfs hotkey all_mask ----------------------------------------------- */
2719 /* sysfs hotkey all_mask ----------------------------------------------- */
2730 /* sysfs hotkey recommended_mask --------------------------------------- */
2744 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2762 return -EINVAL; in hotkey_source_mask_store()
2765 return -ERESTARTSYS; in hotkey_source_mask_store()
2795 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2810 return -EINVAL; in hotkey_poll_freq_store()
2813 return -ERESTARTSYS; in hotkey_poll_freq_store()
2829 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2851 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2855 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2873 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2877 /* sysfs wakeup reason (pollable) -------------------------------------- */
2889 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
2893 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
2906 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
2910 /* sysfs adaptive kbd mode --------------------------------------------- */
2944 return -EINVAL; in adaptive_kbd_mode_store()
2960 return tp_features.has_adaptive_kbd ? attr->mode : 0; in hadaptive_kbd_attr_is_visible()
2968 /* --------------------------------------------------------------------- */
3000 return attr->mode; in hotkey_attr_is_visible()
3028 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3032 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3075 tpacpi_inputdev->keybit); in hotkey_unmap()
3159 * firmware at driver load time, which means the firm- in hotkey_init()
3163 * 2. You must be subscribed to the linux-thinkpad and in hotkey_init()
3164 * ibm-acpi-devel mailing lists, and you should read the in hotkey_init()
3167 * know the past history of problems with the thinkpad- in hotkey_init()
3171 * 3. Do not send thinkpad-acpi specific patches directly to in hotkey_init()
3172 * for merging, *ever*. Send them to the linux-acpi in hotkey_init()
3174 * through acpi-test and the ACPI maintainer. in hotkey_init()
3177 * Ask the thinkpad-acpi maintainer to do it, instead. in hotkey_init()
3209 * the built-in *extra* mixer. Never map it to control in hotkey_init()
3250 /* These should be enabled --only-- when ACPI video in hotkey_init()
3262 * react to it and reprograms the built-in *extra* mixer. in hotkey_init()
3266 * these over the regular keyboard, so these are no-ops, in hotkey_init()
3381 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3382 tpacpi_inputdev->close != NULL); in hotkey_init()
3399 return -ENODEV; in hotkey_init()
3407 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3426 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3443 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3521 return -ENOMEM; in hotkey_init()
3525 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; in hotkey_init()
3526 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; in hotkey_init()
3527 tpacpi_inputdev->keycode = hotkey_keycode_map; in hotkey_init()
3554 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3586 if (res < 0 && res != -ENXIO) { in hotkey_init()
3596 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3597 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3605 * mode, Web conference mode, Function mode and Lay-flat mode.
3634 return -EIO; in adaptive_keyboard_get_mode()
3644 return -EINVAL; in adaptive_keyboard_set_mode()
3648 return -EIO; in adaptive_keyboard_set_mode()
3657 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3711 TP_ACPI_HOTKEYSCAN_EXTENDED_START - in adaptive_keyboard_hotkey_notify_hotkey()
3717 keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + in adaptive_keyboard_hotkey_notify_hotkey()
3749 scancode = (hkey & 0xfff) - (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); in hotkey_notify_extended_hotkey()
3763 /* 0x1000-0x1FFF: key presses */ in hotkey_notify_hotkey()
3778 scancode--; in hotkey_notify_hotkey()
3803 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify_wakeup()
3820 case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ in hotkey_notify_wakeup()
3821 case TP_HKEY_EV_WKUP_S4_BATLOW: /* Battery on critical low level/S4 */ in hotkey_notify_wakeup()
3822 pr_alert("EMERGENCY WAKEUP: battery almost empty\n"); in hotkey_notify_wakeup()
3823 /* how to auto-heal: */ in hotkey_notify_wakeup()
3833 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3843 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify_dockevent()
3864 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
3871 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
3888 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify_usrevent()
3897 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
3898 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
3923 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ in hotkey_notify_6xxx()
3935 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
3944 pr_crit("THERMAL ALARM: battery is too hot!\n"); in hotkey_notify_6xxx()
3948 pr_alert("THERMAL EMERGENCY: battery is extremely hot!\n"); in hotkey_notify_6xxx()
3990 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
4014 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4015 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4036 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
4041 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
4046 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
4063 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
4068 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
4073 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
4079 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
4100 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4101 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4146 /* procfs -------------------------------------------------------------- */
4157 return -ERESTARTSYS; in hotkey_read()
4192 return -ENODEV; in hotkey_write()
4195 return -ERESTARTSYS; in hotkey_write()
4205 res = -EPERM; in hotkey_write()
4214 res = -EINVAL; in hotkey_write()
4269 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4288 return -EIO; in bluetooth_get_status()
4315 return -EIO; in bluetooth_set_status()
4320 /* sysfs bluetooth enable ---------------------------------------------- */
4339 /* --------------------------------------------------------------------- */
4349 return tp_features.bluetooth ? attr->mode : 0; in bluetooth_attr_is_visible()
4397 .ident = "ThinkPad A285 - 20MW",
4405 .ident = "ThinkPad A285 - 20MX",
4413 .ident = "ThinkPad A485 - 20MU",
4421 .ident = "ThinkPad A485 - 20MV",
4513 * Lenovo laptops from a variety of generations run a SMI handler during the D3->D0
4527 res = request_mem_region_muxed(tp_features.quirks->s2idle_bug_mmio, 1, in thinkpad_acpi_amd_s2idle_restore()
4532 addr = ioremap(tp_features.quirks->s2idle_bug_mmio, 1); in thinkpad_acpi_amd_s2idle_restore()
4564 if (tp_features.quirks && tp_features.quirks->btusb_bug && in have_bt_fwbug()
4584 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4608 return -ENODEV; in bluetooth_init()
4618 /* procfs -------------------------------------------------------------- */
4662 return -EIO; in wan_get_status()
4689 return -EIO; in wan_set_status()
4694 /* sysfs wan enable ---------------------------------------------------- */
4714 /* --------------------------------------------------------------------- */
4724 return tp_features.wan ? attr->mode : 0; in wan_attr_is_visible()
4787 return -ENODEV; in wan_init()
4797 /* procfs -------------------------------------------------------------- */
4839 return -EIO; in uwb_get_status()
4865 return -EIO; in uwb_set_status()
4870 /* --------------------------------------------------------------------- */
4915 return -ENODEV; in uwb_init()
5008 return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV; in video_init()
5028 return -EIO; in video_outputsw_get()
5033 return -EIO; in video_outputsw_get()
5037 return -EIO; in video_outputsw_get()
5044 return -EIO; in video_outputsw_get()
5050 return -EIO; in video_outputsw_get()
5054 return -EIO; in video_outputsw_get()
5059 return -ENOSYS; in video_outputsw_get()
5088 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
5089 return -EIO; in video_outputsw_set()
5097 return -ENOSYS; in video_outputsw_set()
5100 return (res) ? 0 : -EIO; in video_outputsw_set()
5110 return -EIO; in video_autosw_get()
5115 return -EIO; in video_autosw_get()
5118 return -ENOSYS; in video_autosw_get()
5127 return -EIO; in video_autosw_set()
5154 return -ENOSYS; in video_outputsw_cycle()
5157 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
5158 return -EIO; in video_outputsw_cycle()
5161 return (res) ? 0 : -EIO; in video_outputsw_cycle()
5169 0 : -EIO; in video_expand_toggle()
5172 0 : -EIO; in video_expand_toggle()
5175 0 : -EIO; in video_expand_toggle()
5177 return -ENOSYS; in video_expand_toggle()
5193 return -EPERM; in video_read()
5226 return -ENODEV; in video_write()
5230 return -EPERM; in video_write()
5267 return -EINVAL; in video_write()
5303 return -ENXIO; in kbdlight_set_level()
5308 ret = -EIO; in kbdlight_set_level()
5322 return -ENXIO; in kbdlight_get_level()
5325 return -EIO; in kbdlight_get_level()
5360 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5361 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5362 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5363 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5367 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5368 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5369 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5416 return -ENODEV; in kbdlight_init()
5422 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5447 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5448 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5474 int res, level = -EINVAL; in kbdlight_write()
5477 return -ENODEV; in kbdlight_write()
5486 return -EINVAL; in kbdlight_write()
5524 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5533 return -EIO; in light_get_status()
5537 return -ENXIO; in light_get_status()
5554 return (rc) ? 0 : -EIO; in light_set_status()
5557 return -ENXIO; in light_set_status()
5606 return -ENODEV; in light_init()
5608 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5652 return -ENODEV; in light_write()
5660 return -EINVAL; in light_write()
5677 /* sysfs cmos_command -------------------------------------------------- */
5686 return -EINVAL; in cmos_command_store()
5702 return cmos_handle ? attr->mode : 0; in cmos_attr_is_visible()
5710 /* --------------------------------------------------------------------- */
5722 return cmos_handle ? 0 : -ENODEV; in cmos_init()
5728 R30, R31, T20-22, X20-21 */ in cmos_read()
5733 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5749 return -EINVAL; in cmos_write()
5772 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5825 return -EIO; in led_get_status()
5834 return -ENXIO; in led_get_status()
5853 return -EINVAL; in led_set_status()
5855 return -EPERM; in led_set_status()
5858 return -EIO; in led_set_status()
5861 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5863 return -EINVAL; in led_set_status()
5865 return -EPERM; in led_set_status()
5877 return -EINVAL; in led_set_status()
5879 return -EPERM; in led_set_status()
5882 return -EIO; in led_set_status()
5885 return -ENXIO; in led_set_status()
5903 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5908 return led_set_status(data->led, new_state); in led_sysfs_set()
5923 return -EINVAL; in led_sysfs_blink_set()
5925 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5935 rc = led_get_status(data->led); in led_sysfs_get()
5970 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5998 /* (1) - may have excess leds enabled on MSB */
6028 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
6068 return -ENODEV; in led_init()
6074 return -ENOMEM; in led_init()
6078 tpacpi_leds[i].led = -1; in led_init()
6111 return -EIO; in led_read()
6116 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
6128 return -ENODEV; in led_write()
6132 return -EINVAL; in led_write()
6134 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
6135 return -ENODEV; in led_write()
6138 return -ENODEV; in led_write()
6147 return -EINVAL; in led_write()
6175 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
6194 return (beep_handle) ? 0 : -ENODEV; in beep_init()
6203 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
6215 return -ENODEV; in beep_write()
6222 return -EINVAL; in beep_write()
6226 return -EIO; in beep_write()
6230 return -EIO; in beep_write()
6249 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
6250 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6259 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6261 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6273 /* idx is zero-based */
6287 idx -= 8; in thermal_get_sensor()
6294 return -EIO; in thermal_get_sensor()
6304 return -EIO; in thermal_get_sensor()
6306 return -EIO; in thermal_get_sensor()
6307 *value = (t - 2732) * 100; in thermal_get_sensor()
6316 return -EIO; in thermal_get_sensor()
6317 if (t > 127 || t < -127) in thermal_get_sensor()
6326 return -ENOSYS; in thermal_get_sensor()
6329 return -EINVAL; in thermal_get_sensor()
6341 return -EINVAL; in thermal_get_sensors()
6347 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6376 /* sysfs temp##_input -------------------------------------------------- */
6384 int idx = sensor_attr->index; in thermal_temp_input_show()
6392 return -ENXIO; in thermal_temp_input_show()
6457 return attr->mode; in thermal_attr_is_visible()
6489 return thermal_use_labels ? attr->mode : 0; in temp_label_attr_is_visible()
6497 /* --------------------------------------------------------------------- */
6512 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for in thermal_init()
6513 * non-implemented, thermal sensors return 0x80 when in thermal_init()
6518 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 in thermal_init()
6578 return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV; in thermal_init()
6593 for (i = 0; i < (n - 1); i++) in thermal_read()
6615 * CMOS NVRAM byte 0x5E, bits 0-3.
6622 * Bit 3-0: backlight brightness level
6643 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6722 return -EIO; in tpacpi_brightness_get_raw()
6726 return -ENXIO; in tpacpi_brightness_get_raw()
6737 return -EIO; in tpacpi_brightness_set_ec()
6742 return -EIO; in tpacpi_brightness_set_ec()
6761 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6765 return -EIO; in tpacpi_brightness_set_ucmsstep()
6776 return -EINVAL; in brightness_set()
6794 res = -ENXIO; in brightness_set()
6801 /* sysfs backlight class ----------------------------------------------- */
6845 /* --------------------------------------------------------------------- */
6854 status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); in tpacpi_evaluate_bcl()
6859 if (!obj || obj->type != ACPI_TYPE_PACKAGE) { in tpacpi_evaluate_bcl()
6860 acpi_handle_info(adev->handle, in tpacpi_evaluate_bcl()
6865 rc = obj->package.count; in tpacpi_evaluate_bcl()
6903 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6920 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6966 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6988 return -ENODEV; in brightness_init()
6993 return -ENODEV; in brightness_init()
6999 return -ENODEV; in brightness_init()
7002 return -ENODEV; in brightness_init()
7006 return -ENODEV; in brightness_init()
7017 return -EINVAL; in brightness_init()
7028 "driver auto-selected brightness_mode=%d\n", in brightness_init()
7036 return -EINVAL; in brightness_init()
7039 return -ENODEV; in brightness_init()
7110 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
7133 level--; in brightness_write()
7138 return -EINVAL; in brightness_write()
7152 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
7177 * Bit 3-0: Volume
7181 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7193 * To avoid confusing userspace, we simply disable all EC-based mute
7204 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7206 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7237 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7267 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7323 return -EIO; in volume_get_status_ec()
7340 return -EIO; in volume_set_status_ec()
7365 return -EINTR; in __volume_set_mute_ec()
7410 return -EINVAL; in __volume_set_volume_ec()
7413 return -EINTR; in __volume_set_volume_ec()
7437 return -ENODEV; in volume_set_software_mute()
7442 return -EIO; in volume_set_software_mute()
7451 return -EIO; in volume_set_software_mute()
7460 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7494 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7495 d = alsa_card->private_data; in volume_alsa_notify_change()
7496 if (d->ctl_mute_id) in volume_alsa_notify_change()
7499 d->ctl_mute_id); in volume_alsa_notify_change()
7500 if (d->ctl_vol_id) in volume_alsa_notify_change()
7503 d->ctl_vol_id); in volume_alsa_notify_change()
7510 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7511 uinfo->count = 1; in volume_alsa_vol_info()
7512 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7513 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7527 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7535 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7536 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7551 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7560 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7562 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7624 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7629 return -ENODEV; in volume_create_alsa_mixer()
7632 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7633 data = card->private_data; in volume_create_alsa_mixer()
7634 data->card = card; in volume_create_alsa_mixer()
7636 strscpy(card->driver, TPACPI_ALSA_DRVNAME, in volume_create_alsa_mixer()
7637 sizeof(card->driver)); in volume_create_alsa_mixer()
7638 strscpy(card->shortname, TPACPI_ALSA_SHRTNAME, in volume_create_alsa_mixer()
7639 sizeof(card->shortname)); in volume_create_alsa_mixer()
7640 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7643 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7644 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7666 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7675 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7688 return -ENODEV; in volume_create_alsa_mixer()
7691 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7710 /* Whitelist mute-only on all Lenovo by default */
7732 return -EINVAL; in volume_init()
7737 return -ENODEV; in volume_init()
7741 return -EINVAL; in volume_init()
7750 return -ENODEV; in volume_init()
7763 return -ENODEV; /* no mixer */ in volume_init()
7772 return -ENODEV; in volume_init()
7777 "using user-supplied volume_capabilities=%d\n", in volume_init()
7785 "driver auto-selected volume_mode=%d\n", in volume_init()
7789 "using user-supplied volume_mode=%d\n", in volume_init()
7841 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7868 return -EPERM; in volume_write()
7890 new_level--; in volume_write()
7903 return -EINVAL; in volume_write()
7918 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7943 return -ENODEV; in volume_init()
7991 * Speeds up fan to 100% duty-cycle, which is far above
7994 * 5-3 unused in some models. Extra bits for fan level
7997 * 2-0 fan level (0..7 usually)
8010 * ----
8015 * This register is present on all ThinkPads with a new-style EC, and
8021 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
8035 * ----
8047 * So far, only the firmware for the X60/X61 non-tablet versions
8048 * seem to support this (firmware TP-7M).
8082 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
8088 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
8126 "JFNS", /* 770x-JL */
8141 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8142 * TP-70 (T43, R52), which are known to be buggy.
8228 return -EIO; in fan_get_status()
8238 return -EIO; in fan_get_status()
8248 return -ENXIO; in fan_get_status()
8260 return -ERESTARTSYS; in fan_get_status_safe()
8282 return -EIO; in fan_get_speed()
8285 return -EIO; in fan_get_speed()
8293 return -ENXIO; in fan_get_speed()
8308 return -EIO; in fan2_get_speed()
8313 return -EIO; in fan2_get_speed()
8321 return -ENXIO; in fan2_get_speed()
8330 return -EPERM; in fan_set_level()
8335 return -EINVAL; in fan_set_level()
8346 return -EIO; in fan_set_level()
8354 return -EINVAL; in fan_set_level()
8373 return -EIO; in fan_set_level()
8379 return -ENXIO; in fan_set_level()
8392 return -EPERM; in fan_set_level_safe()
8395 return -ERESTARTSYS; in fan_set_level_safe()
8414 return -EPERM; in fan_set_enable()
8417 return -ERESTARTSYS; in fan_set_enable()
8433 rc = -EIO; in fan_set_enable()
8451 rc = -EIO; in fan_set_enable()
8457 rc = -ENXIO; in fan_set_enable()
8474 return -EPERM; in fan_set_disable()
8477 return -ERESTARTSYS; in fan_set_disable()
8484 rc = -EIO; in fan_set_disable()
8493 rc = -EIO; in fan_set_disable()
8499 rc = -ENXIO; in fan_set_disable()
8515 return -EPERM; in fan_set_speed()
8518 return -ERESTARTSYS; in fan_set_speed()
8526 rc = -EIO; in fan_set_speed()
8528 rc = -EINVAL; in fan_set_speed()
8532 rc = -ENXIO; in fan_set_speed()
8590 /* sysfs fan pwm1_enable ----------------------------------------------- */
8620 return -EINVAL; in fan_pwm1_enable_store()
8636 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8637 return -ENOSYS; in fan_pwm1_enable_store()
8639 return -EINVAL; in fan_pwm1_enable_store()
8643 if (res == -ENXIO) in fan_pwm1_enable_store()
8644 return -EINVAL; in fan_pwm1_enable_store()
8656 /* sysfs fan pwm1 ------------------------------------------------------ */
8687 return -EINVAL; in fan_pwm1_store()
8692 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8696 return -ERESTARTSYS; in fan_pwm1_store()
8702 if (rc == -ENXIO) in fan_pwm1_store()
8703 rc = -EINVAL; in fan_pwm1_store()
8716 /* sysfs fan fan1_input ------------------------------------------------ */
8733 /* sysfs fan fan2_input ------------------------------------------------ */
8750 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8762 return -EINVAL; in fan_watchdog_store()
8765 return -EPERM; in fan_watchdog_store()
8776 /* --------------------------------------------------------------------- */
8798 return attr->mode; in fan_attr_is_visible()
8869 return -ENODEV; in fan_init()
8876 /* all other ThinkPads: note that even old-style in fan_init()
8890 /* It responded - so let's assume it's there */ in fan_init()
8895 /* Fan not auto-detected */ in fan_init()
8909 return -ENODEV; in fan_init()
8914 /* 570, 770x-JL */ in fan_init()
8960 return -ENODEV; in fan_init()
9100 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9104 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9111 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9114 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9126 (strlencmp(cmd, "level full-speed") == 0)) in fan_write_cmd_level()
9132 if (*rc == -ENXIO) in fan_write_cmd_level()
9148 if (*rc == -ENXIO) in fan_write_cmd_enable()
9163 if (*rc == -ENXIO) in fan_write_cmd_disable()
9183 if (*rc == -ENXIO) in fan_write_cmd_speed()
9201 *rc = -EINVAL; in fan_write_cmd_watchdog()
9227 rc = -EINVAL; in fan_write()
9275 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9276 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9277 return -EIO; in mute_led_on_off()
9280 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9281 state ? t->on_value : t->off_value)) in mute_led_on_off()
9282 return -EIO; in mute_led_on_off()
9284 t->state = state; in mute_led_on_off()
9293 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9294 return t->state; in tpacpi_led_set()
9315 .default_trigger = "audio-mute",
9321 .default_trigger = "audio-micmute",
9332 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9333 t->state = -ENODEV; in mute_led_init()
9338 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9340 while (i--) in mute_led_init()
9364 if (t->state >= 0) in mute_led_resume()
9365 mute_led_on_off(t, t->state); in mute_led_resume()
9376 * Battery Wear Control Driver
9428 * This evaluates a ACPI method call specific to the battery
9449 static int tpacpi_battery_get(int what, int battery, int *ret) in tpacpi_battery_get() argument
9453 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_START, ret, battery)) in tpacpi_battery_get()
9454 return -ENODEV; in tpacpi_battery_get()
9460 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_STOP, ret, battery)) in tpacpi_battery_get()
9461 return -ENODEV; in tpacpi_battery_get()
9474 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_DISCHARGE, ret, battery)) in tpacpi_battery_get()
9475 return -ENODEV; in tpacpi_battery_get()
9480 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_INHIBIT, ret, battery)) in tpacpi_battery_get()
9481 return -ENODEV; in tpacpi_battery_get()
9487 return -EINVAL; in tpacpi_battery_get()
9491 static int tpacpi_battery_set(int what, int battery, int value) in tpacpi_battery_set() argument
9496 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9497 param |= battery << 8; in tpacpi_battery_set()
9502 pr_err("failed to set charge threshold on battery %d", in tpacpi_battery_set()
9503 battery); in tpacpi_battery_set()
9504 return -ENODEV; in tpacpi_battery_set()
9509 pr_err("failed to set stop threshold: %d", battery); in tpacpi_battery_set()
9510 return -ENODEV; in tpacpi_battery_set()
9516 * battery ID is in bits 8-9, 2 bits. in tpacpi_battery_set()
9519 pr_err("failed to set force discharge on %d", battery); in tpacpi_battery_set()
9520 return -ENODEV; in tpacpi_battery_set()
9527 * The battery ID is in bits 4-5, 2 bits, in tpacpi_battery_set()
9528 * the effective time is in bits 8-23, 2 bytes. in tpacpi_battery_set()
9532 param |= battery << 4; in tpacpi_battery_set()
9535 pr_err("failed to set inhibit charge on %d", battery); in tpacpi_battery_set()
9536 return -ENODEV; in tpacpi_battery_set()
9541 return -EINVAL; in tpacpi_battery_set()
9545 static int tpacpi_battery_set_validate(int what, int battery, int value) in tpacpi_battery_set_validate() argument
9549 ret = tpacpi_battery_set(what, battery, value); in tpacpi_battery_set_validate()
9553 ret = tpacpi_battery_get(what, battery, &v); in tpacpi_battery_set_validate()
9562 ret = tpacpi_battery_get(what, battery, &v); in tpacpi_battery_set_validate()
9569 return -EIO; in tpacpi_battery_set_validate()
9572 static int tpacpi_battery_probe(int battery) in tpacpi_battery_probe() argument
9576 memset(&battery_info.batteries[battery], 0, in tpacpi_battery_probe()
9577 sizeof(battery_info.batteries[battery])); in tpacpi_battery_probe()
9590 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_START, &ret, battery)) { in tpacpi_battery_probe()
9591 pr_err("Error probing battery %d\n", battery); in tpacpi_battery_probe()
9592 return -ENODEV; in tpacpi_battery_probe()
9599 battery_info.batteries[battery].start_support = 1; in tpacpi_battery_probe()
9601 return -ENODEV; in tpacpi_battery_probe()
9602 if (tpacpi_battery_get(THRESHOLD_START, battery, in tpacpi_battery_probe()
9603 &battery_info.batteries[battery].charge_start)) { in tpacpi_battery_probe()
9604 pr_err("Error probing battery %d\n", battery); in tpacpi_battery_probe()
9605 return -ENODEV; in tpacpi_battery_probe()
9609 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_STOP, &ret, battery)) { in tpacpi_battery_probe()
9610 pr_err("Error probing battery stop; %d\n", battery); in tpacpi_battery_probe()
9611 return -ENODEV; in tpacpi_battery_probe()
9615 battery_info.batteries[battery].stop_support = 1; in tpacpi_battery_probe()
9617 return -ENODEV; in tpacpi_battery_probe()
9618 if (tpacpi_battery_get(THRESHOLD_STOP, battery, in tpacpi_battery_probe()
9619 &battery_info.batteries[battery].charge_stop)) { in tpacpi_battery_probe()
9620 pr_err("Error probing battery stop: %d\n", battery); in tpacpi_battery_probe()
9621 return -ENODEV; in tpacpi_battery_probe()
9625 if (ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_DISCHARGE, &ret, battery))) { in tpacpi_battery_probe()
9626 pr_err("Error probing battery discharge; %d\n", battery); in tpacpi_battery_probe()
9627 return -ENODEV; in tpacpi_battery_probe()
9631 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9635 if (ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_INHIBIT, &ret, battery))) { in tpacpi_battery_probe()
9636 pr_err("Error probing battery inhibit charge; %d\n", battery); in tpacpi_battery_probe()
9637 return -ENODEV; in tpacpi_battery_probe()
9641 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9645 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9648 pr_info("battery %d registered (start %d, stop %d, behaviours: 0x%x)\n", in tpacpi_battery_probe()
9649 battery, in tpacpi_battery_probe()
9650 battery_info.batteries[battery].charge_start, in tpacpi_battery_probe()
9651 battery_info.batteries[battery].charge_stop, in tpacpi_battery_probe()
9652 battery_info.batteries[battery].charge_behaviours); in tpacpi_battery_probe()
9668 * If for some reason the battery is not BAT0 nor is it in tpacpi_battery_get_id()
9669 * BAT1, we will assume it's the default, first battery, in tpacpi_battery_get_id()
9672 pr_warn("unknown battery %s, assuming primary", battery_name); in tpacpi_battery_get_id()
9684 int battery, rval; in tpacpi_battery_store() local
9687 * one battery. If that is the case, in tpacpi_battery_store()
9694 * with "Any Battery" as the parameter. in tpacpi_battery_store()
9698 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9700 battery = BAT_PRIMARY; in tpacpi_battery_store()
9708 if (!battery_info.batteries[battery].start_support) in tpacpi_battery_store()
9709 return -ENODEV; in tpacpi_battery_store()
9712 return -EINVAL; in tpacpi_battery_store()
9713 if (value > battery_info.batteries[battery].charge_stop) in tpacpi_battery_store()
9714 return -EINVAL; in tpacpi_battery_store()
9715 if (tpacpi_battery_set(THRESHOLD_START, battery, value)) in tpacpi_battery_store()
9716 return -ENODEV; in tpacpi_battery_store()
9717 battery_info.batteries[battery].charge_start = value; in tpacpi_battery_store()
9721 if (!battery_info.batteries[battery].stop_support) in tpacpi_battery_store()
9722 return -ENODEV; in tpacpi_battery_store()
9725 return -EINVAL; in tpacpi_battery_store()
9726 if (value < battery_info.batteries[battery].charge_start) in tpacpi_battery_store()
9727 return -EINVAL; in tpacpi_battery_store()
9728 battery_info.batteries[battery].charge_stop = value; in tpacpi_battery_store()
9736 if (tpacpi_battery_set(THRESHOLD_STOP, battery, value)) in tpacpi_battery_store()
9737 return -EINVAL; in tpacpi_battery_store()
9741 return -EINVAL; in tpacpi_battery_store()
9751 int ret, battery; in tpacpi_battery_show() local
9754 * one battery. If that is the case, in tpacpi_battery_show()
9761 * with "Any Battery" as the parameter. in tpacpi_battery_show()
9765 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9767 battery = BAT_PRIMARY; in tpacpi_battery_show()
9768 if (tpacpi_battery_get(what, battery, &ret)) in tpacpi_battery_show()
9769 return -ENODEV; in tpacpi_battery_show()
9794 int ret, battery; in charge_behaviour_show() local
9796 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_show()
9797 available = battery_info.batteries[battery].charge_behaviours; in charge_behaviour_show()
9800 if (tpacpi_battery_get(FORCE_DISCHARGE, battery, &ret)) in charge_behaviour_show()
9801 return -ENODEV; in charge_behaviour_show()
9809 if (tpacpi_battery_get(INHIBIT_CHARGE, battery, &ret)) in charge_behaviour_show()
9810 return -ENODEV; in charge_behaviour_show()
9840 int selected, battery, ret = 0; in charge_behaviour_store() local
9843 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_store()
9844 available = battery_info.batteries[battery].charge_behaviours; in charge_behaviour_store()
9853 ret = tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 0); in charge_behaviour_store()
9855 ret = min(ret, tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 0)); in charge_behaviour_store()
9861 ret = tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 0); in charge_behaviour_store()
9862 ret = min(ret, tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 1)); in charge_behaviour_store()
9868 ret = tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 0); in charge_behaviour_store()
9869 ret = min(ret, tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 1)); in charge_behaviour_store()
9875 return -EINVAL; in charge_behaviour_store()
9908 /* ACPI battery hooking */
9910 static int tpacpi_battery_add(struct power_supply *battery) in tpacpi_battery_add() argument
9912 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9915 return -ENODEV; in tpacpi_battery_add()
9916 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9917 return -ENODEV; in tpacpi_battery_add()
9921 static int tpacpi_battery_remove(struct power_supply *battery) in tpacpi_battery_remove() argument
9923 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
9930 .name = "ThinkPad Battery Extension",
9938 * primary battery as BAT1.
9966 .name = "battery",
9983 if (WARN_ON(!mutex_is_locked(&priv->lock))) in lcdshadow_set_sw_state()
9984 return -EIO; in lcdshadow_set_sw_state()
9987 return -EIO; in lcdshadow_set_sw_state()
9989 priv->hw_state = priv->sw_state = state; in lcdshadow_set_sw_state()
10000 priv->hw_state = priv->sw_state = output & 0x1; in lcdshadow_get_hw_state()
10019 return -EIO; in tpacpi_lcdshadow_init()
10024 lcdshadow_dev = drm_privacy_screen_register(&tpacpi_pdev->dev, in tpacpi_lcdshadow_init()
10042 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_resume()
10043 lcdshadow_set_sw_state(lcdshadow_dev, lcdshadow_dev->sw_state); in lcdshadow_resume()
10044 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_resume()
10052 seq_printf(m, "status:\t\t%d\n", lcdshadow_dev->hw_state); in lcdshadow_read()
10062 int res, state = -EINVAL; in lcdshadow_write()
10065 return -ENODEV; in lcdshadow_write()
10074 return -EINVAL; in lcdshadow_write()
10076 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_write()
10078 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_write()
10097 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
10098 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
10099 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
10100 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
10120 return -ENODEV; in dytc_command()
10123 return -EIO; in dytc_command()
10148 return -ENODEV; in palmsensor_get()
10150 return -EIO; in palmsensor_get()
10168 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10184 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10230 return attr->mode; in proxsensor_attr_is_visible()
10244 /* If support isn't available for both devices return -ENODEV */ in tpacpi_proxsensor_init()
10245 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10246 return -ENODEV; in tpacpi_proxsensor_init()
10248 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10250 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10257 .name = "proximity-sensor",
10261 * DYTC Platform Profile interface
10273 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10274 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10276 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10277 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10278 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10298 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10317 static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *profile) in convert_dytc_to_profile() argument
10322 *profile = PLATFORM_PROFILE_LOW_POWER; in convert_dytc_to_profile()
10326 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
10329 *profile = PLATFORM_PROFILE_PERFORMANCE; in convert_dytc_to_profile()
10332 return -EINVAL; in convert_dytc_to_profile()
10339 *profile = PLATFORM_PROFILE_LOW_POWER; in convert_dytc_to_profile()
10342 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
10345 *profile = PLATFORM_PROFILE_PERFORMANCE; in convert_dytc_to_profile()
10348 return -EINVAL; in convert_dytc_to_profile()
10354 static int convert_profile_to_dytc(enum platform_profile_option profile, int *perfmode) in convert_profile_to_dytc() argument
10356 switch (profile) { in convert_profile_to_dytc()
10375 default: /* Unknown profile */ in convert_profile_to_dytc()
10376 return -EOPNOTSUPP; in convert_profile_to_dytc()
10383 * handler. Returns current platform profile.
10386 enum platform_profile_option *profile) in dytc_profile_get() argument
10388 *profile = dytc_current_profile; in dytc_profile_get()
10400 return -ENODEV; in dytc_control_amt()
10417 * Helper function - check if we are in CQL mode and if we are
10418 * - disable CQL,
10419 * - run the command
10420 * - enable CQL
10458 * handler. Sets current platform profile.
10461 enum platform_profile_option profile) in dytc_profile_set() argument
10471 err = convert_profile_to_dytc(profile, &perfmode); in dytc_profile_set()
10476 if (profile == PLATFORM_PROFILE_BALANCED) { in dytc_profile_set()
10479 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10500 dytc_control_amt(profile == PLATFORM_PROFILE_BALANCED); in dytc_profile_set()
10502 /* Success - update current profile */ in dytc_profile_set()
10503 dytc_current_profile = profile; in dytc_profile_set()
10511 enum platform_profile_option profile; in dytc_profile_refresh() local
10529 convert_dytc_to_profile(perfmode, &profile); in dytc_profile_refresh()
10530 if (profile != dytc_current_profile) { in dytc_profile_refresh()
10531 dytc_current_profile = profile; in dytc_profile_refresh()
10559 return -ENODEV; in tpacpi_dytc_profile_init()
10582 return -ENODEV; in tpacpi_dytc_profile_init()
10587 return -ENODEV; in tpacpi_dytc_profile_init()
10600 return -ENODEV; in tpacpi_dytc_profile_init()
10618 .name = "dytc-profile",
10640 {"fr-ch", 0x100c},
10660 return -ENODEV; in set_keyboard_lang_command()
10664 return -EIO; in set_keyboard_lang_command()
10676 return -ENODEV; in get_keyboard_lang()
10680 return -EIO; in get_keyboard_lang()
10684 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10687 return -ENODEV; in get_keyboard_lang()
10744 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10745 return -EINVAL; in keyboard_lang_store()
10748 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10751 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10765 return tp_features.kbd_lang ? attr->mode : 0; in kbdlang_attr_is_visible()
10802 return -ENODEV; in dprc_command()
10806 return -EIO; in dprc_command()
10814 return -ENODEV; in dprc_command()
10833 return -ENODEV; in get_wwan_antenna()
10849 return -ENODATA; in wwan_antenna_type_show()
10862 return has_antennatype ? attr->mode : 0; in dprc_attr_is_visible()
10886 /* --------------------------------------------------------------------- */
10919 return attr->mode; in tpacpi_attr_is_visible()
11035 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
11043 mutex_lock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11044 old_hw_state = lcdshadow_dev->hw_state; in tpacpi_driver_event()
11046 changed = lcdshadow_dev->hw_state != old_hw_state; in tpacpi_driver_event()
11047 mutex_unlock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11068 /* --------------------------------------------------------------------- */
11090 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
11092 list_del_init(&ibm->all_drivers); in ibm_exit()
11094 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
11096 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
11097 BUG_ON(!ibm->acpi); in ibm_exit()
11098 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
11099 ibm->acpi->type, in ibm_exit()
11101 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
11104 if (ibm->flags.proc_created) { in ibm_exit()
11106 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
11107 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
11108 ibm->flags.proc_created = 0; in ibm_exit()
11111 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
11113 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
11114 BUG_ON(!ibm->acpi); in ibm_exit()
11115 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
11116 kfree(ibm->acpi->driver); in ibm_exit()
11117 ibm->acpi->driver = NULL; in ibm_exit()
11118 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
11121 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
11122 ibm->exit(); in ibm_exit()
11123 ibm->flags.init_called = 0; in ibm_exit()
11126 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
11132 struct ibm_struct *ibm = iibm->data; in ibm_init()
11137 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
11139 if (ibm->flags.experimental && !experimental) in ibm_init()
11143 "probing for %s\n", ibm->name); in ibm_init()
11145 if (iibm->init) { in ibm_init()
11146 ret = iibm->init(iibm); in ibm_init()
11147 if (ret > 0 || ret == -ENODEV) in ibm_init()
11152 ibm->flags.init_called = 1; in ibm_init()
11155 if (ibm->acpi) { in ibm_init()
11156 if (ibm->acpi->hid) { in ibm_init()
11162 if (ibm->acpi->notify) { in ibm_init()
11164 if (ret == -ENODEV) { in ibm_init()
11166 ibm->name); in ibm_init()
11176 "%s installed\n", ibm->name); in ibm_init()
11178 if (ibm->read) { in ibm_init()
11179 umode_t mode = iibm->base_procfs_mode; in ibm_init()
11183 if (ibm->write) in ibm_init()
11185 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
11188 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
11189 ret = -ENODEV; in ibm_init()
11192 ibm->flags.proc_created = 1; in ibm_init()
11195 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
11202 ibm->name, ret); in ibm_init()
11225 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
11251 * ---------------------------------------------------- in find_new_ec_fwstr()
11264 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
11274 /* returns 0 - probe ok, or < 0 - probe error.
11276 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
11286 return -EINVAL; in get_thinkpad_model_data()
11291 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
11293 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11298 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11299 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
11300 return -ENOMEM; in get_thinkpad_model_data()
11303 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
11304 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
11311 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
11316 if (sscanf(dev->name, in get_thinkpad_model_data()
11317 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
11319 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
11330 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
11331 if (!tp->ec_version_str) in get_thinkpad_model_data()
11332 return -ENOMEM; in get_thinkpad_model_data()
11335 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
11345 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11346 if (!tp->model_str) in get_thinkpad_model_data()
11347 return -ENOMEM; in get_thinkpad_model_data()
11351 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11352 if (!tp->model_str) in get_thinkpad_model_data()
11353 return -ENOMEM; in get_thinkpad_model_data()
11358 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11359 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11360 return -ENOMEM; in get_thinkpad_model_data()
11370 return -ENODEV; in probe_for_thinkpad()
11374 return -ENODEV; in probe_for_thinkpad()
11377 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11389 return -ENODEV; in probe_for_thinkpad()
11393 return -ENODEV; in probe_for_thinkpad()
11522 if (!kp || !kp->name || !val) in set_ibm_param()
11523 return -EINVAL; in set_ibm_param()
11527 if (!ibm || !ibm->name) in set_ibm_param()
11530 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11531 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11532 return -ENOSPC; in set_ibm_param()
11538 return -EINVAL; in set_ibm_param()
11543 "Enables experimental features when non-zero");
11546 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11550 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11593 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11639 if (tp_features.quirks && tp_features.quirks->s2idle_bug_mmio) in thinkpad_acpi_module_exit()
11688 /* Driver-level probe */ in thinkpad_acpi_module_init()
11713 return -ENOMEM; in thinkpad_acpi_module_init()
11720 return -ENODEV; in thinkpad_acpi_module_init()
11725 tp_features.quirks = dmi_id->driver_data; in thinkpad_acpi_module_init()
11752 return -ENOMEM; in thinkpad_acpi_module_init()
11755 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
11756 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
11757 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
11758 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
11759 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
11760 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
11761 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
11771 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()
11797 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); in thinkpad_acpi_module_init()
11816 if (tp_features.quirks && tp_features.quirks->s2idle_bug_mmio) { in thinkpad_acpi_module_init()
11819 (dmi_id && dmi_id->ident) ? dmi_id->ident : ""); in thinkpad_acpi_module_init()