[PATCH V2 4/7] platform/x86: lg-laptop.c: Get model name and year from DMI product name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Model year seems to be encoded simply in the DMI product name, so take it
from there. Tablet for factor is still not handled differently.

Signed-off-by: Matan Ziv-Av <matan@xxxxxxxxxxx>
---
 drivers/platform/x86/lg-laptop.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
index 2f0ce69d8e31..d4c49f822394 100644
--- a/drivers/platform/x86/lg-laptop.c
+++ b/drivers/platform/x86/lg-laptop.c
@@ -8,6 +8,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
 #include <linux/kernel.h>
@@ -606,6 +607,8 @@ static struct platform_driver pf_driver = {
 static int acpi_add(struct acpi_device *device)
 {
 	int ret;
+	const char *product;
+	int year = 2017;
 
 	if (pf_device)
 		return 0;
@@ -624,6 +627,27 @@ static int acpi_add(struct acpi_device *device)
 		goto out_platform_registered;
 	}
 
+	product = dmi_get_system_info(DMI_PRODUCT_NAME);
+	if (strlen(product) > 4)
+		switch (product[4]) {
+		case '5':
+		case '6':
+			year = 2016;
+			break;
+		case '7':
+			year = 2017;
+			break;
+		case '8':
+			year = 2018;
+			break;
+		case '9':
+			year = 2019;
+			break;
+		default:
+			year = 2019;
+		}
+	pr_info("product: %s  year: %d  debug v4\n", product, year);
+
 	ret = sysfs_create_group(&pf_device->dev.kobj, &dev_attribute_group);
 	if (ret)
 		goto out_platform_device;
-- 
2.21.0




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux