From c78b8b8fbf687bc3ce38779e538abf5bdab2ff7a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 30 Oct 2023 13:06:33 -0300 Subject: [PATCH] Chipone: Fix compatibility with 5.4.0 api This commit is a port from https://gerrit.mot.com/#/c/1795715/ to focaltech_0flash_v2_mmi At GKI 1.0 the VTS tests should use GKI and GKI does not allow the use of input_get_new_minor, so VTS tests does not have working touchscreen Fix it definitely using the correct alloc api Change-Id: Iacca8ddca0ac53e374eb18b6779b29f6467745ad Reviewed-on: https://gerrit.mot.com/2780951 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Rafael Ortolan Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key Reviewed-by: Claudio Junior --- .../focaltech_ex_fun.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c index 51b13c1478e7..6179f80169b6 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c @@ -1788,15 +1788,14 @@ static int fts_sysfs_class(void *_data, bool create) int i, error = 0; static struct class *touchscreen_class; static struct device *ts_class_dev; - static int minor; + dev_t devno; if (create) { - minor = input_get_new_minor(data->spi->chip_select, - 1, false); - if (minor < 0) - minor = input_get_new_minor(TSDEV_MINOR_BASE, - TSDEV_MINOR_MAX, true); - pr_info("assigned minor %d\n", minor); + error = alloc_chrdev_region(&devno, 0, 1, FTS_CHIP_NAME); + if (error) { + pr_err("Alloc input devno failed\n"); + return error; + } touchscreen_class = class_create(THIS_MODULE, "touchscreen"); if (IS_ERR(touchscreen_class)) { @@ -1807,11 +1806,11 @@ static int fts_sysfs_class(void *_data, bool create) #ifdef FTS_LAST_TIME_EN ts_class_dev = device_create(touchscreen_class, NULL, - MKDEV(INPUT_MAJOR, minor), + devno, data, FTS_PRIMARY_NAME); #else ts_class_dev = device_create(touchscreen_class, NULL, - MKDEV(INPUT_MAJOR, minor), + devno, data, FTS_CHIP_NAME); #endif @@ -1845,7 +1844,7 @@ static int fts_sysfs_class(void *_data, bool create) device_destroy: for (--i; i >= 0; --i) device_remove_file(ts_class_dev, &attrs[i]); - device_destroy(touchscreen_class, MKDEV(INPUT_MAJOR, minor)); + device_destroy(touchscreen_class, devno); ts_class_dev = NULL; class_unregister(touchscreen_class); pr_err("error creating touchscreen class\n");