Skip to content

Commit 96e09b8

Browse files
committed
Merge tag 'platform-drivers-x86-v6.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver fixes from Hans de Goede: - Default silead touchscreen driver to 10 fingers and drop 10 finger setting from all DMI quirks. More of a cleanup then a pure fix, but since the DMI quirks always get updated through the fixes branch this avoids conflicts. - Kconfig fix for randconfig builds - dell-smbios: Fix wrong token data in sysfs - amd-hsmp: Fix driver poking unsupported hw when loaded manually * tag 'platform-drivers-x86-v6.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86/amd/hsmp: Check HSMP support on AMD family of processors platform/x86: dell-smbios: Simplify error handling platform/x86: dell-smbios: Fix wrong token data in sysfs platform/x86: yt2-1380: add CONFIG_EXTCON dependency platform/x86: touchscreen_dmi: Use 2-argument strscpy() platform/x86: touchscreen_dmi: Drop "silead,max-fingers" property Input: silead - Always support 10 fingers
2 parents f24b46e + 77f1972 commit 96e09b8

File tree

5 files changed

+90
-142
lines changed

5 files changed

+90
-142
lines changed

drivers/input/touchscreen/silead.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ struct silead_ts_data {
7171
struct regulator_bulk_data regulators[2];
7272
char fw_name[64];
7373
struct touchscreen_properties prop;
74-
u32 max_fingers;
7574
u32 chip_id;
7675
struct input_mt_pos pos[SILEAD_MAX_FINGERS];
7776
int slots[SILEAD_MAX_FINGERS];
@@ -136,7 +135,7 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data)
136135
touchscreen_parse_properties(data->input, true, &data->prop);
137136
silead_apply_efi_fw_min_max(data);
138137

139-
input_mt_init_slots(data->input, data->max_fingers,
138+
input_mt_init_slots(data->input, SILEAD_MAX_FINGERS,
140139
INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED |
141140
INPUT_MT_TRACK);
142141

@@ -256,10 +255,10 @@ static void silead_ts_read_data(struct i2c_client *client)
256255
return;
257256
}
258257

259-
if (buf[0] > data->max_fingers) {
258+
if (buf[0] > SILEAD_MAX_FINGERS) {
260259
dev_warn(dev, "More touches reported then supported %d > %d\n",
261-
buf[0], data->max_fingers);
262-
buf[0] = data->max_fingers;
260+
buf[0], SILEAD_MAX_FINGERS);
261+
buf[0] = SILEAD_MAX_FINGERS;
263262
}
264263

265264
if (silead_ts_handle_pen_data(data, buf))
@@ -315,7 +314,6 @@ static void silead_ts_read_data(struct i2c_client *client)
315314

316315
static int silead_ts_init(struct i2c_client *client)
317316
{
318-
struct silead_ts_data *data = i2c_get_clientdata(client);
319317
int error;
320318

321319
error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
@@ -325,7 +323,7 @@ static int silead_ts_init(struct i2c_client *client)
325323
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
326324

327325
error = i2c_smbus_write_byte_data(client, SILEAD_REG_TOUCH_NR,
328-
data->max_fingers);
326+
SILEAD_MAX_FINGERS);
329327
if (error)
330328
goto i2c_write_err;
331329
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
@@ -591,13 +589,6 @@ static void silead_ts_read_props(struct i2c_client *client)
591589
const char *str;
592590
int error;
593591

594-
error = device_property_read_u32(dev, "silead,max-fingers",
595-
&data->max_fingers);
596-
if (error) {
597-
dev_dbg(dev, "Max fingers read error %d\n", error);
598-
data->max_fingers = 5; /* Most devices handle up-to 5 fingers */
599-
}
600-
601592
error = device_property_read_string(dev, "firmware-name", &str);
602593
if (!error)
603594
snprintf(data->fw_name, sizeof(data->fw_name),

drivers/platform/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ config YOGABOOK
136136
config YT2_1380
137137
tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
138138
depends on SERIAL_DEV_BUS
139+
depends on EXTCON
139140
depends on ACPI
140141
help
141142
Say Y here to enable support for the custom fast charging protocol

drivers/platform/x86/amd/hsmp.c

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -907,16 +907,44 @@ static int hsmp_plat_dev_register(void)
907907
return ret;
908908
}
909909

910+
/*
911+
* This check is only needed for backward compatibility of previous platforms.
912+
* All new platforms are expected to support ACPI based probing.
913+
*/
914+
static bool legacy_hsmp_support(void)
915+
{
916+
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
917+
return false;
918+
919+
switch (boot_cpu_data.x86) {
920+
case 0x19:
921+
switch (boot_cpu_data.x86_model) {
922+
case 0x00 ... 0x1F:
923+
case 0x30 ... 0x3F:
924+
case 0x90 ... 0x9F:
925+
case 0xA0 ... 0xAF:
926+
return true;
927+
default:
928+
return false;
929+
}
930+
case 0x1A:
931+
switch (boot_cpu_data.x86_model) {
932+
case 0x00 ... 0x1F:
933+
return true;
934+
default:
935+
return false;
936+
}
937+
default:
938+
return false;
939+
}
940+
941+
return false;
942+
}
943+
910944
static int __init hsmp_plt_init(void)
911945
{
912946
int ret = -ENODEV;
913947

914-
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD || boot_cpu_data.x86 < 0x19) {
915-
pr_err("HSMP is not supported on Family:%x model:%x\n",
916-
boot_cpu_data.x86, boot_cpu_data.x86_model);
917-
return ret;
918-
}
919-
920948
/*
921949
* amd_nb_num() returns number of SMN/DF interfaces present in the system
922950
* if we have N SMN/DF interfaces that ideally means N sockets
@@ -930,7 +958,15 @@ static int __init hsmp_plt_init(void)
930958
return ret;
931959

932960
if (!plat_dev.is_acpi_device) {
933-
ret = hsmp_plat_dev_register();
961+
if (legacy_hsmp_support()) {
962+
/* Not ACPI device, but supports HSMP, register a plat_dev */
963+
ret = hsmp_plat_dev_register();
964+
} else {
965+
/* Not ACPI, Does not support HSMP */
966+
pr_info("HSMP is not supported on Family:%x model:%x\n",
967+
boot_cpu_data.x86, boot_cpu_data.x86_model);
968+
ret = -ENODEV;
969+
}
934970
if (ret)
935971
platform_driver_unregister(&amd_hsmp_driver);
936972
}

drivers/platform/x86/dell/dell-smbios-base.c

Lines changed: 40 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1313

14+
#include <linux/container_of.h>
1415
#include <linux/kernel.h>
1516
#include <linux/module.h>
1617
#include <linux/capability.h>
@@ -25,11 +26,16 @@ static u32 da_supported_commands;
2526
static int da_num_tokens;
2627
static struct platform_device *platform_device;
2728
static struct calling_interface_token *da_tokens;
28-
static struct device_attribute *token_location_attrs;
29-
static struct device_attribute *token_value_attrs;
29+
static struct token_sysfs_data *token_entries;
3030
static struct attribute **token_attrs;
3131
static DEFINE_MUTEX(smbios_mutex);
3232

33+
struct token_sysfs_data {
34+
struct device_attribute location_attr;
35+
struct device_attribute value_attr;
36+
struct calling_interface_token *token;
37+
};
38+
3339
struct smbios_device {
3440
struct list_head list;
3541
struct device *device;
@@ -416,47 +422,26 @@ static void __init find_tokens(const struct dmi_header *dm, void *dummy)
416422
}
417423
}
418424

419-
static int match_attribute(struct device *dev,
420-
struct device_attribute *attr)
421-
{
422-
int i;
423-
424-
for (i = 0; i < da_num_tokens * 2; i++) {
425-
if (!token_attrs[i])
426-
continue;
427-
if (strcmp(token_attrs[i]->name, attr->attr.name) == 0)
428-
return i/2;
429-
}
430-
dev_dbg(dev, "couldn't match: %s\n", attr->attr.name);
431-
return -EINVAL;
432-
}
433-
434425
static ssize_t location_show(struct device *dev,
435426
struct device_attribute *attr, char *buf)
436427
{
437-
int i;
428+
struct token_sysfs_data *data = container_of(attr, struct token_sysfs_data, location_attr);
438429

439430
if (!capable(CAP_SYS_ADMIN))
440431
return -EPERM;
441432

442-
i = match_attribute(dev, attr);
443-
if (i > 0)
444-
return sysfs_emit(buf, "%08x", da_tokens[i].location);
445-
return 0;
433+
return sysfs_emit(buf, "%08x", data->token->location);
446434
}
447435

448436
static ssize_t value_show(struct device *dev,
449437
struct device_attribute *attr, char *buf)
450438
{
451-
int i;
439+
struct token_sysfs_data *data = container_of(attr, struct token_sysfs_data, value_attr);
452440

453441
if (!capable(CAP_SYS_ADMIN))
454442
return -EPERM;
455443

456-
i = match_attribute(dev, attr);
457-
if (i > 0)
458-
return sysfs_emit(buf, "%08x", da_tokens[i].value);
459-
return 0;
444+
return sysfs_emit(buf, "%08x", data->token->value);
460445
}
461446

462447
static struct attribute_group smbios_attribute_group = {
@@ -473,55 +458,50 @@ static int build_tokens_sysfs(struct platform_device *dev)
473458
{
474459
char *location_name;
475460
char *value_name;
476-
size_t size;
477461
int ret;
478462
int i, j;
479463

480-
/* (number of tokens + 1 for null terminated */
481-
size = sizeof(struct device_attribute) * (da_num_tokens + 1);
482-
token_location_attrs = kzalloc(size, GFP_KERNEL);
483-
if (!token_location_attrs)
464+
token_entries = kcalloc(da_num_tokens, sizeof(*token_entries), GFP_KERNEL);
465+
if (!token_entries)
484466
return -ENOMEM;
485-
token_value_attrs = kzalloc(size, GFP_KERNEL);
486-
if (!token_value_attrs)
487-
goto out_allocate_value;
488467

489468
/* need to store both location and value + terminator*/
490-
size = sizeof(struct attribute *) * ((2 * da_num_tokens) + 1);
491-
token_attrs = kzalloc(size, GFP_KERNEL);
469+
token_attrs = kcalloc((2 * da_num_tokens) + 1, sizeof(*token_attrs), GFP_KERNEL);
492470
if (!token_attrs)
493471
goto out_allocate_attrs;
494472

495473
for (i = 0, j = 0; i < da_num_tokens; i++) {
496474
/* skip empty */
497475
if (da_tokens[i].tokenID == 0)
498476
continue;
477+
478+
token_entries[i].token = &da_tokens[i];
479+
499480
/* add location */
500481
location_name = kasprintf(GFP_KERNEL, "%04x_location",
501482
da_tokens[i].tokenID);
502483
if (location_name == NULL)
503484
goto out_unwind_strings;
504-
sysfs_attr_init(&token_location_attrs[i].attr);
505-
token_location_attrs[i].attr.name = location_name;
506-
token_location_attrs[i].attr.mode = 0444;
507-
token_location_attrs[i].show = location_show;
508-
token_attrs[j++] = &token_location_attrs[i].attr;
485+
486+
sysfs_attr_init(&token_entries[i].location_attr.attr);
487+
token_entries[i].location_attr.attr.name = location_name;
488+
token_entries[i].location_attr.attr.mode = 0444;
489+
token_entries[i].location_attr.show = location_show;
490+
token_attrs[j++] = &token_entries[i].location_attr.attr;
509491

510492
/* add value */
511493
value_name = kasprintf(GFP_KERNEL, "%04x_value",
512494
da_tokens[i].tokenID);
513-
if (value_name == NULL)
514-
goto loop_fail_create_value;
515-
sysfs_attr_init(&token_value_attrs[i].attr);
516-
token_value_attrs[i].attr.name = value_name;
517-
token_value_attrs[i].attr.mode = 0444;
518-
token_value_attrs[i].show = value_show;
519-
token_attrs[j++] = &token_value_attrs[i].attr;
520-
continue;
521-
522-
loop_fail_create_value:
523-
kfree(location_name);
524-
goto out_unwind_strings;
495+
if (!value_name) {
496+
kfree(location_name);
497+
goto out_unwind_strings;
498+
}
499+
500+
sysfs_attr_init(&token_entries[i].value_attr.attr);
501+
token_entries[i].value_attr.attr.name = value_name;
502+
token_entries[i].value_attr.attr.mode = 0444;
503+
token_entries[i].value_attr.show = value_show;
504+
token_attrs[j++] = &token_entries[i].value_attr.attr;
525505
}
526506
smbios_attribute_group.attrs = token_attrs;
527507

@@ -532,14 +512,12 @@ static int build_tokens_sysfs(struct platform_device *dev)
532512

533513
out_unwind_strings:
534514
while (i--) {
535-
kfree(token_location_attrs[i].attr.name);
536-
kfree(token_value_attrs[i].attr.name);
515+
kfree(token_entries[i].location_attr.attr.name);
516+
kfree(token_entries[i].value_attr.attr.name);
537517
}
538518
kfree(token_attrs);
539519
out_allocate_attrs:
540-
kfree(token_value_attrs);
541-
out_allocate_value:
542-
kfree(token_location_attrs);
520+
kfree(token_entries);
543521

544522
return -ENOMEM;
545523
}
@@ -551,12 +529,11 @@ static void free_group(struct platform_device *pdev)
551529
sysfs_remove_group(&pdev->dev.kobj,
552530
&smbios_attribute_group);
553531
for (i = 0; i < da_num_tokens; i++) {
554-
kfree(token_location_attrs[i].attr.name);
555-
kfree(token_value_attrs[i].attr.name);
532+
kfree(token_entries[i].location_attr.attr.name);
533+
kfree(token_entries[i].value_attr.attr.name);
556534
}
557535
kfree(token_attrs);
558-
kfree(token_value_attrs);
559-
kfree(token_location_attrs);
536+
kfree(token_entries);
560537
}
561538

562539
static int __init dell_smbios_init(void)

0 commit comments

Comments
 (0)