lynkco: Solve the compile error on user version

details:
Google don't support input_get_new_minor api, so modify to
alloc_chrdev_region.

Change-Id: I3dbc7ce102a32429cb336f17ecb88c5f6a1a0c51
Signed-off-by: wangdp11 <wangdp11@motorola.com>
Reviewed-on: https://gerrit.mot.com/2510100
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Zhichao Chen <chenzc2@motorola.com>
Reviewed-by: Zhenxin Xi <xizx@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wangdp11 committed 2023-02-13 19:46:20 -06:00
1 parent a90e5819ea
commit 6f341dd3dc
1 file changed
+12
@@ -35,6 +35,9 @@
*/
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
@@ -4694,10 +4697,19 @@ int stmvl53l1_sysfs_laser(struct stmvl53l1_data *data, bool create)
}
if (create) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 5, 0)
dev_t devid;
error = alloc_chrdev_region(&devid, 0, 1, "laser");
vl53l1_errmsg("MAJOR = %d MINOR = %d\n", MAJOR(devid),MINOR(devid));
minor = MINOR(devid);
if (minor < 0)
vl53l1_errmsg("alloc_chrdev_region error\n");
#else
minor = input_get_new_minor(data->sysfs_base, 1, false);
if (minor < 0)
minor = input_get_new_minor(LASERDEV_MINOR_BASE,
LASERDEV_MINOR_MAX, true);
#endif
vl53l1_info("assigned minor %d\n", minor);
laser_class = class_create(THIS_MODULE, "laser");