Skip to content

Commit 7281a59

Browse files
committed
Merge tag 'platform-drivers-x86-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform drivers fixes from Hans de Goede: - Documentation and compilation warning fixes - Kconfig dep fixes - Misc small code cleanups * tag 'platform-drivers-x86-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86: amd-pmc: Fix compilation without CONFIG_SUSPEND platform/x86: acerhdf: Cleanup str_starts_with() Documentation/ABI: sysfs-class-firmware-attributes: Misc. cleanups Documentation/ABI: sysfs-class-firmware-attributes: Fix Sphinx errors Documentation/ABI: sysfs-driver-intel_sdsi: Fix sphinx warnings platform/x86: barco-p50-gpio: Fix duplicate included linux/io.h platform/x86: samsung-laptop: Fix an unsigned comparison which can never be negative platform/x86: think-lmi: certificate support clean ups
2 parents ce522ba + 753ee98 commit 7281a59

8 files changed

Lines changed: 67 additions & 82 deletions

File tree

Documentation/ABI/testing/sysfs-class-firmware-attributes

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Description:
116116
<value>[ForceIf:<attribute>=<value>]
117117
<value>[ForceIfNot:<attribute>=<value>]
118118

119-
For example:
119+
For example::
120120

121121
LegacyOrom/dell_value_modifier has value:
122122
Disabled[ForceIf:SecureBoot=Enabled]
@@ -212,7 +212,7 @@ Description:
212212
the next boot.
213213

214214
Lenovo specific class extensions
215-
------------------------------
215+
--------------------------------
216216

217217
On Lenovo systems the following additional settings are available:
218218

@@ -246,9 +246,7 @@ Description:
246246
that is being referenced (e.g hdd0, hdd1 etc)
247247
This attribute defaults to device 0.
248248

249-
certificate:
250-
signature:
251-
save_signature:
249+
certificate, signature, save_signature:
252250
These attributes are used for certificate based authentication. This is
253251
used in conjunction with a signing server as an alternative to password
254252
based authentication.
@@ -257,22 +255,27 @@ Description:
257255
The attributes can be displayed to check the stored value.
258256

259257
Some usage examples:
260-
Installing a certificate to enable feature:
261-
echo <supervisor password > authentication/Admin/current_password
262-
echo <signed certificate> > authentication/Admin/certificate
263258

264-
Updating the installed certificate:
265-
echo <signature> > authentication/Admin/signature
266-
echo <signed certificate> > authentication/Admin/certificate
259+
Installing a certificate to enable feature::
260+
261+
echo "supervisor password" > authentication/Admin/current_password
262+
echo "signed certificate" > authentication/Admin/certificate
263+
264+
Updating the installed certificate::
265+
266+
echo "signature" > authentication/Admin/signature
267+
echo "signed certificate" > authentication/Admin/certificate
267268

268-
Removing the installed certificate:
269-
echo <signature> > authentication/Admin/signature
270-
echo '' > authentication/Admin/certificate
269+
Removing the installed certificate::
271270

272-
Changing a BIOS setting:
273-
echo <signature> > authentication/Admin/signature
274-
echo <save signature> > authentication/Admin/save_signature
275-
echo Enable > attribute/PasswordBeep/current_value
271+
echo "signature" > authentication/Admin/signature
272+
echo "" > authentication/Admin/certificate
273+
274+
Changing a BIOS setting::
275+
276+
echo "signature" > authentication/Admin/signature
277+
echo "save signature" > authentication/Admin/save_signature
278+
echo Enable > attribute/PasswordBeep/current_value
276279

277280
You cannot enable certificate authentication if a supervisor password
278281
has not been set.
@@ -288,9 +291,10 @@ Description:
288291
certificate_to_password:
289292
Write only attribute used to switch from certificate based authentication
290293
back to password based.
291-
Usage:
292-
echo <signature> > authentication/Admin/signature
293-
echo <password> > authentication/Admin/certificate_to_password
294+
Usage::
295+
296+
echo "signature" > authentication/Admin/signature
297+
echo "password" > authentication/Admin/certificate_to_password
294298

295299

296300
What: /sys/class/firmware-attributes/*/attributes/pending_reboot
@@ -345,7 +349,7 @@ Description:
345349

346350
# echo "factory" > /sys/class/firmware-attributes/*/device/attributes/reset_bios
347351
# cat /sys/class/firmware-attributes/*/device/attributes/reset_bios
348-
# builtinsafe lastknowngood [factory] custom
352+
builtinsafe lastknowngood [factory] custom
349353

350354
Note that any changes to this attribute requires a reboot
351355
for changes to take effect.

Documentation/ABI/testing/sysfs-driver-intel_sdsi

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ Description:
1313
Should the operation fail, one of the following error codes
1414
may be returned:
1515

16+
========== =====
1617
Error Code Cause
17-
---------- -----
18-
EIO General mailbox failure. Log may indicate cause.
19-
EBUSY Mailbox is owned by another agent.
20-
EPERM SDSI capability is not enabled in hardware.
21-
EPROTO Failure in mailbox protocol detected by driver.
18+
========== =====
19+
EIO General mailbox failure. Log may indicate cause.
20+
EBUSY Mailbox is owned by another agent.
21+
EPERM SDSI capability is not enabled in hardware.
22+
EPROTO Failure in mailbox protocol detected by driver.
2223
See log for details.
23-
EOVERFLOW For provision commands, the size of the data
24+
EOVERFLOW For provision commands, the size of the data
2425
exceeds what may be written.
25-
ESPIPE Seeking is not allowed.
26-
ETIMEDOUT Failure to complete mailbox transaction in time.
26+
ESPIPE Seeking is not allowed.
27+
ETIMEDOUT Failure to complete mailbox transaction in time.
28+
========== =====
2729

2830
What: /sys/bus/auxiliary/devices/intel_vsec.sdsi.X/guid
2931
Date: Feb 2022

drivers/platform/x86/acerhdf.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -584,21 +584,6 @@ static struct platform_driver acerhdf_driver = {
584584
.remove = acerhdf_remove,
585585
};
586586

587-
/* checks if str begins with start */
588-
static int str_starts_with(const char *str, const char *start)
589-
{
590-
unsigned long str_len = 0, start_len = 0;
591-
592-
str_len = strlen(str);
593-
start_len = strlen(start);
594-
595-
if (str_len >= start_len &&
596-
!strncmp(str, start, start_len))
597-
return 1;
598-
599-
return 0;
600-
}
601-
602587
/* check hardware */
603588
static int __init acerhdf_check_hardware(void)
604589
{
@@ -651,9 +636,9 @@ static int __init acerhdf_check_hardware(void)
651636
* check if actual hardware BIOS vendor, product and version
652637
* IDs start with the strings of BIOS table entry
653638
*/
654-
if (str_starts_with(vendor, bt->vendor) &&
655-
str_starts_with(product, bt->product) &&
656-
str_starts_with(version, bt->version)) {
639+
if (strstarts(vendor, bt->vendor) &&
640+
strstarts(product, bt->product) &&
641+
strstarts(version, bt->version)) {
657642
found = 1;
658643
break;
659644
}

drivers/platform/x86/amd-pmc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ MODULE_PARM_DESC(enable_stb, "Enable the STB debug mechanism");
160160

161161
static struct amd_pmc_dev pmc;
162162
static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
163-
static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
164163
static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
164+
#ifdef CONFIG_SUSPEND
165+
static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
166+
#endif
165167

166168
static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
167169
{
@@ -325,6 +327,7 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table
325327
return 0;
326328
}
327329

330+
#ifdef CONFIG_SUSPEND
328331
static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
329332
{
330333
struct smu_metrics table;
@@ -338,6 +341,7 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
338341
dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n",
339342
table.timein_s0i3_lastcapture);
340343
}
344+
#endif
341345

342346
#ifdef CONFIG_DEBUG_FS
343347
static int smu_fw_info_show(struct seq_file *s, void *unused)
@@ -569,6 +573,7 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg,
569573
return rc;
570574
}
571575

576+
#ifdef CONFIG_SUSPEND
572577
static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
573578
{
574579
switch (dev->cpu_id) {
@@ -694,6 +699,7 @@ static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = {
694699
.prepare = amd_pmc_s2idle_prepare,
695700
.restore = amd_pmc_s2idle_restore,
696701
};
702+
#endif
697703

698704
static const struct pci_device_id pmc_pci_ids[] = {
699705
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_YC) },
@@ -733,6 +739,7 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
733739
return 0;
734740
}
735741

742+
#ifdef CONFIG_SUSPEND
736743
static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
737744
{
738745
int err;
@@ -753,6 +760,7 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
753760

754761
return 0;
755762
}
763+
#endif
756764

757765
static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf)
758766
{
@@ -859,9 +867,11 @@ static int amd_pmc_probe(struct platform_device *pdev)
859867

860868
amd_pmc_get_smu_version(dev);
861869
platform_set_drvdata(pdev, dev);
870+
#ifdef CONFIG_SUSPEND
862871
err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
863872
if (err)
864873
dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
874+
#endif
865875

866876
amd_pmc_dbgfs_register(dev);
867877
return 0;
@@ -875,7 +885,9 @@ static int amd_pmc_remove(struct platform_device *pdev)
875885
{
876886
struct amd_pmc_dev *dev = platform_get_drvdata(pdev);
877887

888+
#ifdef CONFIG_SUSPEND
878889
acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
890+
#endif
879891
amd_pmc_dbgfs_unregister(dev);
880892
pci_dev_put(dev->rdev);
881893
mutex_destroy(&dev->lock);

drivers/platform/x86/barco-p50-gpio.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1212

13-
#include <linux/io.h>
1413
#include <linux/delay.h>
1514
#include <linux/dmi.h>
1615
#include <linux/err.h>

drivers/platform/x86/samsung-laptop.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,6 @@ static void kbd_led_set(struct led_classdev *led_cdev,
11211121

11221122
if (value > samsung->kbd_led.max_brightness)
11231123
value = samsung->kbd_led.max_brightness;
1124-
else if (value < 0)
1125-
value = 0;
11261124

11271125
samsung->kbd_led_wk = value;
11281126
queue_work(samsung->led_workqueue, &samsung->kbd_led_work);

drivers/platform/x86/think-lmi.c

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -740,16 +740,8 @@ static ssize_t certificate_store(struct kobject *kobj,
740740
if (!tlmi_priv.certificate_support)
741741
return -EOPNOTSUPP;
742742

743-
new_cert = kstrdup(buf, GFP_KERNEL);
744-
if (!new_cert)
745-
return -ENOMEM;
746-
/* Strip out CR if one is present */
747-
strip_cr(new_cert);
748-
749743
/* If empty then clear installed certificate */
750-
if (new_cert[0] == '\0') { /* Clear installed certificate */
751-
kfree(new_cert);
752-
744+
if ((buf[0] == '\0') || (buf[0] == '\n')) { /* Clear installed certificate */
753745
/* Check that signature is set */
754746
if (!setting->signature || !setting->signature[0])
755747
return -EACCES;
@@ -763,14 +755,16 @@ static ssize_t certificate_store(struct kobject *kobj,
763755

764756
ret = tlmi_simple_call(LENOVO_CLEAR_BIOS_CERT_GUID, auth_str);
765757
kfree(auth_str);
766-
if (ret)
767-
return ret;
768758

769-
kfree(setting->certificate);
770-
setting->certificate = NULL;
771-
return count;
759+
return ret ?: count;
772760
}
773761

762+
new_cert = kstrdup(buf, GFP_KERNEL);
763+
if (!new_cert)
764+
return -ENOMEM;
765+
/* Strip out CR if one is present */
766+
strip_cr(new_cert);
767+
774768
if (setting->cert_installed) {
775769
/* Certificate is installed so this is an update */
776770
if (!setting->signature || !setting->signature[0]) {
@@ -792,21 +786,14 @@ static ssize_t certificate_store(struct kobject *kobj,
792786
auth_str = kasprintf(GFP_KERNEL, "%s,%s",
793787
new_cert, setting->password);
794788
}
795-
if (!auth_str) {
796-
kfree(new_cert);
789+
kfree(new_cert);
790+
if (!auth_str)
797791
return -ENOMEM;
798-
}
799792

800793
ret = tlmi_simple_call(guid, auth_str);
801794
kfree(auth_str);
802-
if (ret) {
803-
kfree(new_cert);
804-
return ret;
805-
}
806795

807-
kfree(setting->certificate);
808-
setting->certificate = new_cert;
809-
return count;
796+
return ret ?: count;
810797
}
811798

812799
static struct kobj_attribute auth_certificate = __ATTR_WO(certificate);
@@ -1194,6 +1181,10 @@ static void tlmi_release_attr(void)
11941181

11951182
kset_unregister(tlmi_priv.attribute_kset);
11961183

1184+
/* Free up any saved signatures */
1185+
kfree(tlmi_priv.pwd_admin->signature);
1186+
kfree(tlmi_priv.pwd_admin->save_signature);
1187+
11971188
/* Authentication structures */
11981189
sysfs_remove_group(&tlmi_priv.pwd_admin->kobj, &auth_attr_group);
11991190
kobject_put(&tlmi_priv.pwd_admin->kobj);
@@ -1210,11 +1201,6 @@ static void tlmi_release_attr(void)
12101201
}
12111202

12121203
kset_unregister(tlmi_priv.authentication_kset);
1213-
1214-
/* Free up any saved certificates/signatures */
1215-
kfree(tlmi_priv.pwd_admin->certificate);
1216-
kfree(tlmi_priv.pwd_admin->signature);
1217-
kfree(tlmi_priv.pwd_admin->save_signature);
12181204
}
12191205

12201206
static int tlmi_sysfs_init(void)

drivers/platform/x86/think-lmi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct tlmi_pwd_setting {
6363
int index; /*Used for HDD and NVME auth */
6464
enum level_option level;
6565
bool cert_installed;
66-
char *certificate;
6766
char *signature;
6867
char *save_signature;
6968
};

0 commit comments

Comments
 (0)