From 935ab8509ccb277c536c9fad96b1a90d3bed98fc Mon Sep 17 00:00:00 2001 From: Tom Saeger Date: Fri, 12 Mar 2021 18:55:35 -0700 Subject: ACPI: fix various typos in comments Fix trivial ACPI driver comment typos. s/notifcations/notifications/ s/Ajust/Adjust/ s/preform/perform/ s/atrributes/attributes/ s/Souce/Source/ s/Evalutes/Evaluates/ s/Evalutes/Evaluates/ s/specifiy/specify/ s/promixity/proximity/ s/presuambly/presumably/ s/Evalute/Evaluate/ s/specificed/specified/ s/rountine/routine/ s/previosuly/previously/ Change comment referencing pcc_send_cmd to send_pcc_cmd. Signed-off-by: Tom Saeger Reviewed-by: Randy Dunlap Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ac.c | 2 +- drivers/acpi/acpi_video.c | 4 ++-- drivers/acpi/apei/erst.c | 2 +- drivers/acpi/apei/hest.c | 2 +- drivers/acpi/cppc_acpi.c | 10 +++++----- drivers/acpi/numa/hmat.c | 2 +- drivers/acpi/pmic/intel_pmic_chtcrc.c | 2 +- drivers/acpi/power.c | 2 +- drivers/acpi/processor_perflib.c | 2 +- drivers/acpi/resource.c | 2 +- drivers/acpi/scan.c | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index b41180330cc1..b86ee6e3baa7 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -187,7 +187,7 @@ static int acpi_ac_battery_notify(struct notifier_block *nb, /* * On HP Pavilion dv6-6179er AC status notifications aren't triggered * when adapter is plugged/unplugged. However, battery status - * notifcations are triggered when battery starts charging or + * notifications are triggered when battery starts charging or * discharging. Re-reading AC status triggers lost AC notifications, * if AC status has changed. */ diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 2ea1781290cc..698c67f06e90 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1392,7 +1392,7 @@ acpi_video_get_next_level(struct acpi_video_device *device, break; } } - /* Ajust level_current to closest available level */ + /* Adjust level_current to closest available level */ level_current += delta; for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { l = device->brightness->levels[i]; @@ -1555,7 +1555,7 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, /* * Win8 requires setting bit2 of _DOS to let firmware know it shouldn't - * preform any automatic brightness change on receiving a notification. + * perform any automatic brightness change on receiving a notification. */ static int acpi_video_bus_start_devices(struct acpi_video_bus *video) { diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index b9597216d021..242f3c2d5533 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c @@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(erst_disable); static struct acpi_table_erst *erst_tab; -/* ERST Error Log Address Range atrributes */ +/* ERST Error Log Address Range attributes */ #define ERST_RANGE_RESERVED 0x0001 #define ERST_RANGE_NVRAM 0x0002 #define ERST_RANGE_SLOW 0x0004 diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index f220bb00e91b..277f00b288d1 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * APEI Hardware Error Souce Table support + * APEI Hardware Error Source Table support * * HEST describes error sources in detail; communicates operational * parameters (i.e. severity levels, masking bits, and threshold diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 69057fcd2c04..12478e62d8d1 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -101,14 +101,14 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); (cpc)->cpc_entry.reg.space_id == \ ACPI_ADR_SPACE_PLATFORM_COMM) -/* Evalutes to True if reg is a NULL register descriptor */ +/* Evaluates to True if reg is a NULL register descriptor */ #define IS_NULL_REG(reg) ((reg)->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY && \ (reg)->address == 0 && \ (reg)->bit_width == 0 && \ (reg)->bit_offset == 0 && \ (reg)->access_width == 0) -/* Evalutes to True if an optional cpc field is supported */ +/* Evaluates to True if an optional cpc field is supported */ #define CPC_SUPPORTED(cpc) ((cpc)->type == ACPI_TYPE_INTEGER ? \ !!(cpc)->cpc_entry.int_value : \ !IS_NULL_REG(&(cpc)->cpc_entry.reg)) @@ -1330,7 +1330,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * is still with OSPM. * pending_pcc_write_cmd can also be cleared by a different CPU, if * there was a pcc CMD_READ waiting on down_write and it steals the lock - * before the pcc CMD_WRITE is completed. pcc_send_cmd checks for this + * before the pcc CMD_WRITE is completed. send_pcc_cmd checks for this * case during a CMD_READ and if there are pending writes it delivers * the write command before servicing the read command */ @@ -1355,8 +1355,8 @@ EXPORT_SYMBOL_GPL(cppc_set_perf); /** * cppc_get_transition_latency - returns frequency transition latency in ns * - * ACPI CPPC does not explicitly specifiy how a platform can specify the - * transition latency for perfromance change requests. The closest we have + * ACPI CPPC does not explicitly specify how a platform can specify the + * transition latency for performance change requests. The closest we have * is the timing information from the PCCT tables which provides the info * on the number and frequency of PCC commands the platform can handle. */ diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index cb73a5d6ea76..a84d85d8333c 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -722,7 +722,7 @@ static void hmat_register_target(struct memory_target *target) /* * Skip offline nodes. This can happen when memory * marked EFI_MEMORY_SP, "specific purpose", is applied - * to all the memory in a promixity domain leading to + * to all the memory in a proximity domain leading to * the node being marked offline / unplugged, or if * memory-only "hotplug" node is offline. */ diff --git a/drivers/acpi/pmic/intel_pmic_chtcrc.c b/drivers/acpi/pmic/intel_pmic_chtcrc.c index ebf8d3187df1..2900dc3074d2 100644 --- a/drivers/acpi/pmic/intel_pmic_chtcrc.c +++ b/drivers/acpi/pmic/intel_pmic_chtcrc.c @@ -15,7 +15,7 @@ /* * We have no docs for the CHT Crystal Cove PMIC. The Asus Zenfone-2 kernel * code has 2 Crystal Cove regulator drivers, one calls the PMIC a "Crystal - * Cove Plus" PMIC and talks about Cherry Trail, so presuambly that one + * Cove Plus" PMIC and talks about Cherry Trail, so presumably that one * could be used to get register info for the regulators if we need to * implement regulator support in the future. * diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 9b608b55d2b2..a6498c9dc28d 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -935,7 +935,7 @@ int acpi_add_power_resource(acpi_handle handle) strcpy(acpi_device_class(device), ACPI_POWER_CLASS); device->power.state = ACPI_STATE_UNKNOWN; - /* Evalute the object to get the system level and resource order. */ + /* Evaluate the object to get the system level and resource order. */ status = acpi_evaluate_object(handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) goto err; diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 32f0f554ccae..a2a9371cff49 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -98,7 +98,7 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status * @handle: ACPI processor handle * @status: the status code of _PPC evaluation - * 0: success. OSPM is now using the performance state specificed. + * 0: success. OSPM is now using the performance state specified. * 1: failure. OSPM has not changed the number of P-states in use */ static void acpi_processor_ppc_ost(acpi_handle handle, int status) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index 20a7892c6d3f..ee78a210c606 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -596,7 +596,7 @@ static int __acpi_dev_get_resources(struct acpi_device *adev, * @preproc_data: Pointer passed to the caller's preprocessing routine. * * Evaluate the _CRS method for the given device node and process its output by - * (1) executing the @preproc() rountine provided by the caller, passing the + * (1) executing the @preproc() routine provided by the caller, passing the * resource pointer and @preproc_data to it as arguments, for each ACPI resource * returned and (2) converting all of the returned ACPI resources into struct * resource objects if possible. If the return value of @preproc() in step (1) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a184529d8fa4..dc97100ee6a8 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -561,7 +561,7 @@ static void acpi_scan_drop_device(acpi_handle handle, void *context) * prevents attempts to register device objects identical to those being * deleted from happening concurrently (such attempts result from * hotplug events handled via the ACPI hotplug workqueue). It also will - * run after all of the work items submitted previosuly, which helps + * run after all of the work items submitted previously, which helps * those work items to ensure that they are not accessing stale device * objects. */ -- cgit v1.2.3 From 9104457ea524391112f4a4fd685ea532550a29b1 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 11:47:01 +0800 Subject: ACPI: AC: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including the following types: ERROR: "foo * bar" should be "foo *bar" ERROR: code indent should use tabs where possible WARNING: Block comments use a trailing */ on a separate line WARNING: braces {} are not necessary for single statement blocks WARNING: void function return statements are not generally useful WARNING: CVS style keyword markers, these will _not_ be updated Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ac.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index b86ee6e3baa7..b0cb662233f1 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * acpi_ac.c - ACPI AC Adapter Driver ($Revision: 27 $) + * acpi_ac.c - ACPI AC Adapter Driver (Revision: 27) * * Copyright (C) 2001, 2002 Andy Grover * Copyright (C) 2001, 2002 Paul Diefenbaugh @@ -78,17 +78,14 @@ static struct acpi_driver acpi_ac_driver = { struct acpi_ac { struct power_supply *charger; struct power_supply_desc charger_desc; - struct acpi_device * device; + struct acpi_device *device; unsigned long long state; struct notifier_block battery_nb; }; #define to_acpi_ac(x) power_supply_get_drvdata(x) -/* -------------------------------------------------------------------------- - AC Adapter Management - -------------------------------------------------------------------------- */ - +/* AC Adapter Management */ static int acpi_ac_get_state(struct acpi_ac *ac) { acpi_status status = AE_OK; @@ -109,9 +106,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) return 0; } -/* -------------------------------------------------------------------------- - sysfs I/F - -------------------------------------------------------------------------- */ +/* sysfs I/F */ static int get_ac_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -138,10 +133,7 @@ static enum power_supply_property ac_props[] = { POWER_SUPPLY_PROP_ONLINE, }; -/* -------------------------------------------------------------------------- - Driver Model - -------------------------------------------------------------------------- */ - +/* Driver Model */ static void acpi_ac_notify(struct acpi_device *device, u32 event) { struct acpi_ac *ac = acpi_driver_data(device); @@ -174,8 +166,6 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event) acpi_notifier_call_chain(device, event, (u32) ac->state); kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE); } - - return; } static int acpi_ac_battery_notify(struct notifier_block *nb, @@ -282,9 +272,8 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify; register_acpi_notifier(&ac->battery_nb); end: - if (result) { + if (result) kfree(ac); - } return result; } @@ -293,7 +282,7 @@ end: static int acpi_ac_resume(struct device *dev) { struct acpi_ac *ac; - unsigned old_state; + unsigned int old_state; if (!dev) return -EINVAL; @@ -352,9 +341,8 @@ static int __init acpi_ac_init(void) } result = acpi_bus_register_driver(&acpi_ac_driver); - if (result < 0) { + if (result < 0) return -ENODEV; - } return 0; } -- cgit v1.2.3 From 0955b3a5c54a016172fb216f8263178c755d138c Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:13 +0800 Subject: ACPI: APD: fix a block comment align issue Fix the following coding style issue reported by checkpatch.pl: WARNING: Block comments should align the * on each line +/** +* Create platform device during acpi scan attach handle. Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_apd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c index 39359ce0eb2c..0ec5b3f69112 100644 --- a/drivers/acpi/acpi_apd.c +++ b/drivers/acpi/acpi_apd.c @@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = { #endif -/** -* Create platform device during acpi scan attach handle. -* Return value > 0 on success of creating device. -*/ +/* + * Create platform device during acpi scan attach handle. + * Return value > 0 on success of creating device. + */ static int acpi_apd_create_device(struct acpi_device *adev, const struct acpi_device_id *id) { -- cgit v1.2.3 From c8deb1c2576237d27aadce0e769be4b18518fab1 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:14 +0800 Subject: ACPI: processor: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including the following types: ERROR: code indent should use tabs where possible WARNING: Block comments use a trailing */ on a separate line WARNING: Missing a blank line after declarations WARNING: labels should not be indented Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_processor.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 2ee5e05a0d69..3ae3c48fb9bf 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -29,10 +29,7 @@ ACPI_MODULE_NAME("processor"); DEFINE_PER_CPU(struct acpi_processor *, processors); EXPORT_PER_CPU_SYMBOL(processors); -/* -------------------------------------------------------------------------- - Errata Handling - -------------------------------------------------------------------------- */ - +/* Errata Handling */ struct acpi_processor_errata errata __read_mostly; EXPORT_SYMBOL_GPL(errata); @@ -157,10 +154,7 @@ static int acpi_processor_errata(void) return result; } -/* -------------------------------------------------------------------------- - Initialization - -------------------------------------------------------------------------- */ - +/* Initialization */ #ifdef CONFIG_ACPI_HOTPLUG_CPU int __weak acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int *pcpu) @@ -314,6 +308,7 @@ static int acpi_processor_get_info(struct acpi_device *device) */ if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { int ret = acpi_processor_hotadd_init(pr); + if (ret) return ret; } @@ -440,10 +435,7 @@ static int acpi_processor_add(struct acpi_device *device, } #ifdef CONFIG_ACPI_HOTPLUG_CPU -/* -------------------------------------------------------------------------- - Removal - -------------------------------------------------------------------------- */ - +/* Removal */ static void acpi_processor_remove(struct acpi_device *device) { struct acpi_processor *pr; @@ -901,7 +893,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, info->count = last_index; - end: +end: kfree(buffer.pointer); return ret; -- cgit v1.2.3 From fc6a1f84e80b9113e1170151c7fca0e1c332ee22 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:15 +0800 Subject: ACPI: ipmi: remove useless return statement for void function Remove useless return statement for void function, reported by checkpatch.pl. WARNING: void function return statements are not generally useful FILE: drivers/acpi/acpi_ipmi.c:482: + return; +} Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_ipmi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c index 9d6c0fc120d7..bbd00d96b7a8 100644 --- a/drivers/acpi/acpi_ipmi.c +++ b/drivers/acpi/acpi_ipmi.c @@ -478,7 +478,6 @@ err_lock: ipmi_dev_release(ipmi_device); err_ref: put_device(smi_data.dev); - return; } static void ipmi_bmc_gone(int iface) -- cgit v1.2.3 From bb415ed540a18f7ad56ac18ce61b3164bf2dfcb6 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:16 +0800 Subject: ACPI: LPSS: add a missed blank line after declarations Add a missed blank line after declarations, reported by checkpatch.pl. Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index be73974ce449..ca742f16a507 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { static int is_memory(struct acpi_resource *res, void *not_used) { struct resource r; + return !acpi_dev_resource_memory(res, &r); } @@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev) if (pdata->dev_desc->resume_from_noirq) { /* This is analogous to the acpi_lpss_suspend_noirq() case. */ int ret = acpi_lpss_do_poweroff_late(dev); + if (ret) return ret; } -- cgit v1.2.3 From c8eb628cbdd98ed2abcc38e2196bcb5e6bb3ddf9 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:17 +0800 Subject: ACPI: acpi_pad: add a missed blank line after declarations Add a missed blank line after declarations, reported by checkpatch.pl. Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_pad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index b84ab722feb4..df4adeb335b2 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index) static void exit_round_robin(unsigned int tsk_index) { struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits); + cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus); tsk_in_cpu[tsk_index] = -1; } @@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long num; + if (kstrtoul(buf, 0, &num)) return -EINVAL; if (num < 1 || num >= 100) @@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long num; + if (kstrtoul(buf, 0, &num)) return -EINVAL; if (num < 1 || num >= 100) @@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long num; + if (kstrtoul(buf, 0, &num)) return -EINVAL; mutex_lock(&isolated_cpus_lock); -- cgit v1.2.3 From 65545abd8aa3a98c44472525bb459aacffa052c1 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:18 +0800 Subject: ACPI: battery: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including the following types: WARNING: Block comments use * on subsequent lines WARNING: Block comments use a trailing */ on a separate line ERROR: code indent should use tabs where possible WARNING: Missing a blank line after declarations ERROR: spaces required around that '?' (ctx:WxV) WARNING: Block comments should align the * on each line Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 63 +++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index b822f77afba6..dae91f906cea 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -74,16 +74,17 @@ enum { ACPI_BATTERY_XINFO_PRESENT, ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, /* On Lenovo Thinkpad models from 2010 and 2011, the power unit - switches between mWh and mAh depending on whether the system - is running on battery or not. When mAh is the unit, most - reported values are incorrect and need to be adjusted by - 10000/design_voltage. Verified on x201, t410, t410s, and x220. - Pre-2010 and 2012 models appear to always report in mWh and - are thus unaffected (tested with t42, t61, t500, x200, x300, - and x230). Also, in mid-2012 Lenovo issued a BIOS update for - the 2011 models that fixes the issue (tested on x220 with a - post-1.29 BIOS), but as of Nov. 2012, no such update is - available for the 2010 models. */ + * switches between mWh and mAh depending on whether the system + * is running on battery or not. When mAh is the unit, most + * reported values are incorrect and need to be adjusted by + * 10000/design_voltage. Verified on x201, t410, t410s, and x220. + * Pre-2010 and 2012 models appear to always report in mWh and + * are thus unaffected (tested with t42, t61, t500, x200, x300, + * and x230). Also, in mid-2012 Lenovo issued a BIOS update for + * the 2011 models that fixes the issue (tested on x220 with a + * post-1.29 BIOS), but as of Nov. 2012, no such update is + * available for the 2010 models. + */ ACPI_BATTERY_QUIRK_THINKPAD_MAH, /* for batteries reporting current capacity with design capacity * on a full charge, but showing degradation in full charge cap. @@ -371,9 +372,7 @@ static enum power_supply_property energy_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -/* -------------------------------------------------------------------------- - Battery Management - -------------------------------------------------------------------------- */ +/* Battery Management */ struct acpi_offsets { size_t offset; /* offset inside struct acpi_sbs_battery */ u8 mode; /* int or string? */ @@ -431,6 +430,7 @@ static int extract_package(struct acpi_battery *battery, { int i; union acpi_object *element; + if (package->type != ACPI_TYPE_PACKAGE) return -EFAULT; for (i = 0; i < num; ++i) { @@ -439,6 +439,7 @@ static int extract_package(struct acpi_battery *battery, element = &package->package.elements[i]; if (offsets[i].mode) { u8 *ptr = (u8 *)battery + offsets[i].offset; + if (element->type == ACPI_TYPE_STRING || element->type == ACPI_TYPE_BUFFER) strncpy(ptr, element->string.pointer, 32); @@ -497,10 +498,12 @@ static int extract_battery_info(const int use_bix, battery->design_capacity_warning * 10000 / battery->design_voltage; /* Curiously, design_capacity_low, unlike the rest of them, - is correct. */ + * is correct. + */ /* capacity_granularity_* equal 1 on the systems tested, so - it's impossible to tell if they would need an adjustment - or not if their values were higher. */ + * it's impossible to tell if they would need an adjustment + * or not if their values were higher. + */ } if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags) && battery->capacity_now > battery->full_charge_capacity) @@ -532,8 +535,8 @@ static int acpi_battery_get_info(struct acpi_battery *battery) if (ACPI_FAILURE(status)) { acpi_handle_info(battery->device->handle, "%s evaluation failed: %s\n", - use_bix ?"_BIX":"_BIF", - acpi_format_exception(status)); + use_bix ? "_BIX":"_BIF", + acpi_format_exception(status)); } else { result = extract_battery_info(use_bix, battery, @@ -648,6 +651,7 @@ static ssize_t acpi_battery_alarm_show(struct device *dev, char *buf) { struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); + return sprintf(buf, "%d\n", battery->alarm * 1000); } @@ -657,6 +661,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev, { unsigned long x; struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); + if (sscanf(buf, "%lu\n", &x) == 1) battery->alarm = x/1000; if (acpi_battery_present(battery)) @@ -743,7 +748,7 @@ EXPORT_SYMBOL_GPL(battery_hook_register); * This function gets called right after the battery sysfs * attributes have been added, so that the drivers that * define custom sysfs attributes can add their own. -*/ + */ static void battery_hook_add_battery(struct acpi_battery *battery) { struct acpi_battery_hook *hook_node, *tmp; @@ -872,10 +877,12 @@ static void find_battery(const struct dmi_header *dm, void *private) { struct acpi_battery *battery = (struct acpi_battery *)private; /* Note: the hardcoded offsets below have been extracted from - the source code of dmidecode. */ + * the source code of dmidecode. + */ if (dm->type == DMI_ENTRY_PORTABLE_BATTERY && dm->length >= 8) { const u8 *dmi_data = (const u8 *)(dm + 1); int dmi_capacity = get_unaligned((const u16 *)(dmi_data + 6)); + if (dm->length >= 18) dmi_capacity *= dmi_data[17]; if (battery->design_capacity * battery->design_voltage / 1000 @@ -917,6 +924,7 @@ static void acpi_battery_quirks(struct acpi_battery *battery) if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { const char *s; + s = dmi_get_system_info(DMI_PRODUCT_VERSION); if (s && !strncasecmp(s, "ThinkPad", 8)) { dmi_walk(find_battery, battery); @@ -1013,10 +1021,7 @@ static void acpi_battery_refresh(struct acpi_battery *battery) sysfs_add_battery(battery); } -/* -------------------------------------------------------------------------- - Driver Interface - -------------------------------------------------------------------------- */ - +/* Driver Interface */ static void acpi_battery_notify(struct acpi_device *device, u32 event) { struct acpi_battery *battery = acpi_driver_data(device); @@ -1026,11 +1031,11 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event) return; old = battery->bat; /* - * On Acer Aspire V5-573G notifications are sometimes triggered too - * early. For example, when AC is unplugged and notification is - * triggered, battery state is still reported as "Full", and changes to - * "Discharging" only after short delay, without any notification. - */ + * On Acer Aspire V5-573G notifications are sometimes triggered too + * early. For example, when AC is unplugged and notification is + * triggered, battery state is still reported as "Full", and changes to + * "Discharging" only after short delay, without any notification. + */ if (battery_notification_delay_ms > 0) msleep(battery_notification_delay_ms); if (event == ACPI_BATTERY_NOTIFY_INFO) -- cgit v1.2.3 From effbe6404e6c1cccaa351a50f1d431f83b34d9a5 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:19 +0800 Subject: ACPI: button: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including the following types: WARNING: Block comments use * on subsequent lines WARNING: Block comments use a trailing */ on a separate line ERROR: code indent should use tabs where possible Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/button.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 85e5e0328a2e..f25bd336113b 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -156,10 +156,7 @@ static unsigned long lid_report_interval __read_mostly = 500; module_param(lid_report_interval, ulong, 0644); MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events"); -/* -------------------------------------------------------------------------- - FS Interface (/proc) - -------------------------------------------------------------------------- */ - +/* FS Interface (/proc) */ static struct proc_dir_entry *acpi_button_dir; static struct proc_dir_entry *acpi_lid_dir; @@ -348,9 +345,7 @@ static int acpi_button_remove_fs(struct acpi_device *device) return 0; } -/* -------------------------------------------------------------------------- - Driver Interface - -------------------------------------------------------------------------- */ +/* Driver Interface */ int acpi_lid_open(void) { if (!lid_device) -- cgit v1.2.3 From e69ae675879d5e39602b9269f7b6a0363c864f77 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:20 +0800 Subject: ACPI: CPPC: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including the following types: WARNING: Missing a blank line after declarations WARNING: unnecessary whitespace before a quoted newline ERROR: spaces required around that '>=' ERROR: switch and case should be at the same indent Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/cppc_acpi.c | 71 ++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 12478e62d8d1..c383a51a3bab 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -327,6 +327,7 @@ end: if (unlikely(ret)) { for_each_possible_cpu(i) { struct cpc_desc *desc = per_cpu(cpc_desc_ptr, i); + if (!desc) continue; @@ -778,7 +779,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER; memcpy(&cpc_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, sizeof(*gas_t)); } else { - pr_debug("Err in entry:%d in CPC table of CPU:%d \n", i, pr->id); + pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, pr->id); goto out_free; } } @@ -868,7 +869,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr) void __iomem *addr; int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id); - if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) { + if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) { if (pcc_data[pcc_ss_id]->pcc_channel_acquired) { pcc_data[pcc_ss_id]->refcount--; if (!pcc_data[pcc_ss_id]->refcount) { @@ -955,22 +956,22 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) val, reg->bit_width); switch (reg->bit_width) { - case 8: - *val = readb_relaxed(vaddr); - break; - case 16: - *val = readw_relaxed(vaddr); - break; - case 32: - *val = readl_relaxed(vaddr); - break; - case 64: - *val = readq_relaxed(vaddr); - break; - default: - pr_debug("Error: Cannot read %u bit width from PCC for ss: %d\n", - reg->bit_width, pcc_ss_id); - ret_val = -EFAULT; + case 8: + *val = readb_relaxed(vaddr); + break; + case 16: + *val = readw_relaxed(vaddr); + break; + case 32: + *val = readl_relaxed(vaddr); + break; + case 64: + *val = readq_relaxed(vaddr); + break; + default: + pr_debug("Error: Cannot read %u bit width from PCC for ss: %d\n", + reg->bit_width, pcc_ss_id); + ret_val = -EFAULT; } return ret_val; @@ -994,23 +995,23 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) val, reg->bit_width); switch (reg->bit_width) { - case 8: - writeb_relaxed(val, vaddr); - break; - case 16: - writew_relaxed(val, vaddr); - break; - case 32: - writel_relaxed(val, vaddr); - break; - case 64: - writeq_relaxed(val, vaddr); - break; - default: - pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n", - reg->bit_width, pcc_ss_id); - ret_val = -EFAULT; - break; + case 8: + writeb_relaxed(val, vaddr); + break; + case 16: + writew_relaxed(val, vaddr); + break; + case 32: + writel_relaxed(val, vaddr); + break; + case 64: + writeq_relaxed(val, vaddr); + break; + default: + pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n", + reg->bit_width, pcc_ss_id); + ret_val = -EFAULT; + break; } return ret_val; -- cgit v1.2.3 From 4dea6e898c39358530d98edb4bfa043e6a0e71fe Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:21 +0800 Subject: ACPI: custom_method: fix a coding style issue Fix the following coding style issue reported by checkpatch.pl ERROR: "foo * bar" should be "foo *bar" FILE: drivers/acpi/custom_method.c:22: +static ssize_t cm_write(struct file *file, const char __user * user_buf, Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/custom_method.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c index 7b54dc95d36b..443fdf62dd22 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c @@ -19,7 +19,7 @@ static struct dentry *cm_dentry; /* /sys/kernel/debug/acpi/custom_method */ -static ssize_t cm_write(struct file *file, const char __user * user_buf, +static ssize_t cm_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { static char *buf; -- cgit v1.2.3 From 3da8236bb0d50c6842f5525216a948b5f1cd51cb Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:22 +0800 Subject: ACPI: PM: add a missed blank line after declarations Add a missed blank line after declarations, reported by checkpatch.pl. Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/device_pm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 096153761ebc..16c0fe8a72a7 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume); int acpi_subsys_runtime_suspend(struct device *dev) { int ret = pm_generic_runtime_suspend(dev); + return ret ? ret : acpi_dev_suspend(dev, true); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); @@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); int acpi_subsys_runtime_resume(struct device *dev) { int ret = acpi_dev_resume(dev); + return ret ? ret : pm_generic_runtime_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); @@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze); int acpi_subsys_restore_early(struct device *dev) { int ret = acpi_dev_resume(dev); + return ret ? ret : pm_generic_restore_early(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_restore_early); -- cgit v1.2.3 From d0fb66e999ffafe425833b8bdfcaabb3d7941c93 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:23 +0800 Subject: ACPI: sysfs: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including following types: WARNING: Missing a blank line after declarations WARNING: Block comments should align the * on each line ERROR: open brace '{' following function definitions go on the next line Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/device_sysfs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index da4ff2a8b06a..a07d4ade5835 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = { static void acpi_data_node_release(struct kobject *kobj) { struct acpi_data_node *dn = to_data_node(kobj); + complete(&dn->kobj_done); } @@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct acpi_device_data *data) * Return: 0: no _HID and no _CID * -EINVAL: output error * -ENOMEM: output is truncated -*/ + */ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, int size) { @@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path); /* sysfs file that shows description text from the ACPI _STR method */ static ssize_t description_show(struct device *dev, struct device_attribute *attr, - char *buf) { + char *buf) +{ struct acpi_device *acpi_dev = to_acpi_device(dev); int result; @@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description); static ssize_t sun_show(struct device *dev, struct device_attribute *attr, - char *buf) { + char *buf) +{ struct acpi_device *acpi_dev = to_acpi_device(dev); acpi_status status; unsigned long long sun; @@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun); static ssize_t hrv_show(struct device *dev, struct device_attribute *attr, - char *buf) { + char *buf) +{ struct acpi_device *acpi_dev = to_acpi_device(dev); acpi_status status; unsigned long long hrv; @@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(hrv); static ssize_t status_show(struct device *dev, struct device_attribute *attr, - char *buf) { + char *buf) +{ struct acpi_device *acpi_dev = to_acpi_device(dev); acpi_status status; unsigned long long sta; -- cgit v1.2.3 From 6ee4bdc27d1aee6fb4dde9b28c95fe87d87c1438 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Sat, 27 Mar 2021 20:08:24 +0800 Subject: ACPI: dock: fix some coding style issues Fix some coding style issues reported by checkpatch.pl, including following types: WARNING: Missing a blank line after declarations ERROR: spaces required around that ':' WARNING: Statements should start on a tabstop Signed-off-by: Xiaofei Tan Signed-off-by: Rafael J. Wysocki --- drivers/acpi/dock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 0937ceab052e..7cf92158008f 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) if (!acpi_device_enumerated(adev)) { int ret = acpi_bus_scan(adev->handle); + if (ret) dev_dbg(&adev->dev, "scan error %d\n", -ret); } @@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dock_station *dock_station = dev->platform_data; + return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); } @@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct device_attribute *attr, begin_undock(dock_station); ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); acpi_scan_lock_release(); - return ret ? ret: count; + return ret ? ret : count; } static DEVICE_ATTR_WO(undock); @@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev, { unsigned long long lbuf; struct dock_station *dock_station = dev->platform_data; + acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", NULL, &lbuf); if (ACPI_FAILURE(status)) - return 0; + return 0; return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf); } -- cgit v1.2.3