Răsfoiți Sursa

NFC: driver: Support new i2c_driver remove api

"struct i2c_driver".remove function's return type is
changed from int to void in kernel version 6.1.0.
Support new i2c_driver remove API for NFC driver.

Change-Id: I2fc0d4a044afd49cc08c8b2486ce355a5857e202
Signed-off-by: Maria Yu <[email protected]>
Signed-off-by: Amruth Naga <[email protected]>
Maria Yu 2 ani în urmă
părinte
comite
e24f9d0b47
2 a modificat fișierele cu 17 adăugiri și 4 ștergeri
  1. 12 4
      nfc/i2c_drv.c
  2. 5 0
      nfc/i2c_drv.h

+ 12 - 4
nfc/i2c_drv.c

@@ -461,21 +461,27 @@ err:
 	return ret;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
+void nfc_i2c_dev_remove(struct i2c_client *client)
+#else
 int nfc_i2c_dev_remove(struct i2c_client *client)
+#endif
 {
-	int ret = 0;
 	struct nfc_dev *nfc_dev = NULL;
 
 	pr_info("%s: remove device\n", __func__);
 	nfc_dev = i2c_get_clientdata(client);
 	if (!nfc_dev) {
 		pr_err("%s: device doesn't exist anymore\n", __func__);
-		ret = -ENODEV;
-		return ret;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+		return -ENODEV;
+#endif
 	}
 	if (nfc_dev->dev_ref_count > 0) {
 		pr_err("%s: device already in use\n", __func__);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
 		return -EBUSY;
+#endif
 	}
 
 	gpio_set_value(nfc_dev->configs.gpio.ven, 0);
@@ -496,7 +502,9 @@ int nfc_i2c_dev_remove(struct i2c_client *client)
 	kfree(nfc_dev->read_kbuf);
 	kfree(nfc_dev->write_kbuf);
 	kfree(nfc_dev);
-	return ret;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+	return 0;
+#endif
 }
 
 int nfc_i2c_dev_suspend(struct device *device)

+ 5 - 0
nfc/i2c_drv.h

@@ -25,6 +25,7 @@
 #define _I2C_DRV_H_
 
 #include <linux/i2c.h>
+#include <linux/version.h>
 
 #define NFC_I2C_DRV_STR   "qcom,sn-nci"	/*kept same as dts */
 #define NFC_I2C_DEV_ID	  "sn-i2c"
@@ -44,7 +45,11 @@ struct i2c_dev {
 long nfc_i2c_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg);
 int nfc_i2c_dev_probe(struct i2c_client *client,
 		      const struct i2c_device_id *id);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
+void nfc_i2c_dev_remove(struct i2c_client *client);
+#else
 int nfc_i2c_dev_remove(struct i2c_client *client);
+#endif
 int nfc_i2c_dev_suspend(struct device *device);
 int nfc_i2c_dev_resume(struct device *device);