Skip to content

Commit e9d46f7

Browse files
committed
Merge tag 'chrome-platform-for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform
Pull chrome platform updates from Benson Leung: - move cros_ec_dev to drivers/mfd - other small maintenance fixes [ The cros_ec_dev movement came in earlier through the MFD tree - Linus ] * tag 'chrome-platform-for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform: platform/chrome: Use proper protocol transfer function platform/chrome: cros_ec_lpc: Add support for Google Glimmer platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing. platform/chrome: cros_ec_lpc: remove redundant pointer request cros_ec: fix nul-termination for firmware build info platform/chrome: chromeos_laptop: make chromeos_laptop const
2 parents 15303ba + d48b8c5 commit e9d46f7

File tree

4 files changed

+57
-19
lines changed

4 files changed

+57
-19
lines changed

drivers/platform/chrome/chromeos_laptop.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static int chromeos_laptop_probe(struct platform_device *pdev)
423423
return ret;
424424
}
425425

426-
static struct chromeos_laptop samsung_series_5_550 = {
426+
static const struct chromeos_laptop samsung_series_5_550 = {
427427
.i2c_peripherals = {
428428
/* Touchpad. */
429429
{ .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
@@ -432,14 +432,14 @@ static struct chromeos_laptop samsung_series_5_550 = {
432432
},
433433
};
434434

435-
static struct chromeos_laptop samsung_series_5 = {
435+
static const struct chromeos_laptop samsung_series_5 = {
436436
.i2c_peripherals = {
437437
/* Light Sensor. */
438438
{ .add = setup_tsl2583_als, I2C_ADAPTER_SMBUS },
439439
},
440440
};
441441

442-
static struct chromeos_laptop chromebook_pixel = {
442+
static const struct chromeos_laptop chromebook_pixel = {
443443
.i2c_peripherals = {
444444
/* Touch Screen. */
445445
{ .add = setup_atmel_1664s_ts, I2C_ADAPTER_PANEL },
@@ -450,14 +450,14 @@ static struct chromeos_laptop chromebook_pixel = {
450450
},
451451
};
452452

453-
static struct chromeos_laptop hp_chromebook_14 = {
453+
static const struct chromeos_laptop hp_chromebook_14 = {
454454
.i2c_peripherals = {
455455
/* Touchpad. */
456456
{ .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 },
457457
},
458458
};
459459

460-
static struct chromeos_laptop dell_chromebook_11 = {
460+
static const struct chromeos_laptop dell_chromebook_11 = {
461461
.i2c_peripherals = {
462462
/* Touchpad. */
463463
{ .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 },
@@ -466,28 +466,28 @@ static struct chromeos_laptop dell_chromebook_11 = {
466466
},
467467
};
468468

469-
static struct chromeos_laptop toshiba_cb35 = {
469+
static const struct chromeos_laptop toshiba_cb35 = {
470470
.i2c_peripherals = {
471471
/* Touchpad. */
472472
{ .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 },
473473
},
474474
};
475475

476-
static struct chromeos_laptop acer_c7_chromebook = {
476+
static const struct chromeos_laptop acer_c7_chromebook = {
477477
.i2c_peripherals = {
478478
/* Touchpad. */
479479
{ .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
480480
},
481481
};
482482

483-
static struct chromeos_laptop acer_ac700 = {
483+
static const struct chromeos_laptop acer_ac700 = {
484484
.i2c_peripherals = {
485485
/* Light Sensor. */
486486
{ .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS },
487487
},
488488
};
489489

490-
static struct chromeos_laptop acer_c720 = {
490+
static const struct chromeos_laptop acer_c720 = {
491491
.i2c_peripherals = {
492492
/* Touchscreen. */
493493
{ .add = setup_atmel_1664s_ts, I2C_ADAPTER_DESIGNWARE_1 },
@@ -500,14 +500,14 @@ static struct chromeos_laptop acer_c720 = {
500500
},
501501
};
502502

503-
static struct chromeos_laptop hp_pavilion_14_chromebook = {
503+
static const struct chromeos_laptop hp_pavilion_14_chromebook = {
504504
.i2c_peripherals = {
505505
/* Touchpad. */
506506
{ .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS },
507507
},
508508
};
509509

510-
static struct chromeos_laptop cr48 = {
510+
static const struct chromeos_laptop cr48 = {
511511
.i2c_peripherals = {
512512
/* Light Sensor. */
513513
{ .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS },

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#define DRV_NAME "cros_ec_lpcs"
3636
#define ACPI_DRV_NAME "GOOG0004"
3737

38+
/* True if ACPI device is present */
39+
static bool cros_ec_lpc_acpi_device_found;
40+
3841
static int ec_response_timed_out(void)
3942
{
4043
unsigned long one_second = jiffies + HZ;
@@ -54,7 +57,6 @@ static int ec_response_timed_out(void)
5457
static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec,
5558
struct cros_ec_command *msg)
5659
{
57-
struct ec_host_request *request;
5860
struct ec_host_response response;
5961
u8 sum;
6062
int ret = 0;
@@ -65,8 +67,6 @@ static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec,
6567
/* Write buffer */
6668
cros_ec_lpc_write_bytes(EC_LPC_ADDR_HOST_PACKET, ret, ec->dout);
6769

68-
request = (struct ec_host_request *)ec->dout;
69-
7070
/* Here we go */
7171
sum = EC_COMMAND_PROTOCOL_3;
7272
cros_ec_lpc_write_bytes(EC_LPC_ADDR_HOST_CMD, 1, &sum);
@@ -362,6 +362,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
362362
DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"),
363363
},
364364
},
365+
{
366+
/* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */
367+
.matches = {
368+
DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
369+
DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"),
370+
},
371+
},
365372
{ /* sentinel */ }
366373
};
367374
MODULE_DEVICE_TABLE(dmi, cros_ec_lpc_dmi_table);
@@ -396,9 +403,21 @@ static struct platform_driver cros_ec_lpc_driver = {
396403
.remove = cros_ec_lpc_remove,
397404
};
398405

406+
static struct platform_device cros_ec_lpc_device = {
407+
.name = DRV_NAME
408+
};
409+
410+
static acpi_status cros_ec_lpc_parse_device(acpi_handle handle, u32 level,
411+
void *context, void **retval)
412+
{
413+
*(bool *)context = true;
414+
return AE_CTRL_TERMINATE;
415+
}
416+
399417
static int __init cros_ec_lpc_init(void)
400418
{
401419
int ret;
420+
acpi_status status;
402421

403422
if (!dmi_check_system(cros_ec_lpc_dmi_table)) {
404423
pr_err(DRV_NAME ": unsupported system.\n");
@@ -415,11 +434,28 @@ static int __init cros_ec_lpc_init(void)
415434
return ret;
416435
}
417436

418-
return 0;
437+
status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
438+
&cros_ec_lpc_acpi_device_found, NULL);
439+
if (ACPI_FAILURE(status))
440+
pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
441+
442+
if (!cros_ec_lpc_acpi_device_found) {
443+
/* Register the device, and it'll get hooked up automatically */
444+
ret = platform_device_register(&cros_ec_lpc_device);
445+
if (ret) {
446+
pr_err(DRV_NAME ": can't register device: %d\n", ret);
447+
platform_driver_unregister(&cros_ec_lpc_driver);
448+
cros_ec_lpc_reg_destroy();
449+
}
450+
}
451+
452+
return ret;
419453
}
420454

421455
static void __exit cros_ec_lpc_exit(void)
422456
{
457+
if (!cros_ec_lpc_acpi_device_found)
458+
platform_device_unregister(&cros_ec_lpc_device);
423459
platform_driver_unregister(&cros_ec_lpc_driver);
424460
cros_ec_lpc_reg_destroy();
425461
}

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ static int send_command(struct cros_ec_device *ec_dev,
6060
struct cros_ec_command *msg)
6161
{
6262
int ret;
63+
int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
6364

6465
if (ec_dev->proto_version > 2)
65-
ret = ec_dev->pkt_xfer(ec_dev, msg);
66+
xfer_fxn = ec_dev->pkt_xfer;
6667
else
67-
ret = ec_dev->cmd_xfer(ec_dev, msg);
68+
xfer_fxn = ec_dev->cmd_xfer;
6869

70+
ret = (*xfer_fxn)(ec_dev, msg);
6971
if (msg->result == EC_RES_IN_PROGRESS) {
7072
int i;
7173
struct cros_ec_command *status_msg;
@@ -88,7 +90,7 @@ static int send_command(struct cros_ec_device *ec_dev,
8890
for (i = 0; i < EC_COMMAND_RETRIES; i++) {
8991
usleep_range(10000, 11000);
9092

91-
ret = ec_dev->cmd_xfer(ec_dev, status_msg);
93+
ret = (*xfer_fxn)(ec_dev, status_msg);
9294
if (ret < 0)
9395
break;
9496

drivers/platform/chrome/cros_ec_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static ssize_t show_ec_version(struct device *dev,
185185
count += scnprintf(buf + count, PAGE_SIZE - count,
186186
"Build info: EC error %d\n", msg->result);
187187
else {
188-
msg->data[sizeof(msg->data) - 1] = '\0';
188+
msg->data[EC_HOST_PARAM_SIZE - 1] = '\0';
189189
count += scnprintf(buf + count, PAGE_SIZE - count,
190190
"Build info: %s\n", msg->data);
191191
}

0 commit comments

Comments
 (0)