Pārlūkot izejas kodu

msm: camera: common: Change spi driver remove function signature

Spi driver remove function signature changed between kernel version
5.15 and 5.18.

CRs-Fixed: 3245727
Change-Id: I0352e8b9b5f5990a89b082df9f9ca4000bcd5da0
Signed-off-by: zhuo <[email protected]>
zhuo 3 gadi atpakaļ
vecāks
revīzija
3e05e54587

+ 0 - 44
drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c

@@ -451,50 +451,6 @@ static int cam_eeprom_spi_driver_probe(struct spi_device *spi)
 	return cam_eeprom_spi_setup(spi);
 }
 
-static int cam_eeprom_spi_driver_remove(struct spi_device *sdev)
-{
-	int                             i;
-	struct v4l2_subdev             *sd = spi_get_drvdata(sdev);
-	struct cam_eeprom_ctrl_t       *e_ctrl;
-	struct cam_eeprom_soc_private  *soc_private;
-	struct cam_hw_soc_info         *soc_info;
-
-	if (!sd) {
-		CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
-		return -EINVAL;
-	}
-
-	e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
-	if (!e_ctrl) {
-		CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
-		return -EINVAL;
-	}
-
-	soc_info = &e_ctrl->soc_info;
-	for (i = 0; i < soc_info->num_clk; i++)
-		devm_clk_put(soc_info->dev, soc_info->clk[i]);
-
-	mutex_lock(&(e_ctrl->eeprom_mutex));
-	cam_eeprom_shutdown(e_ctrl);
-	mutex_unlock(&(e_ctrl->eeprom_mutex));
-	mutex_destroy(&(e_ctrl->eeprom_mutex));
-	cam_unregister_subdev(&(e_ctrl->v4l2_dev_str));
-	kfree(e_ctrl->io_master_info.spi_client);
-	e_ctrl->io_master_info.spi_client = NULL;
-	soc_private =
-		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
-	if (soc_private) {
-		kfree(soc_private->power_info.gpio_num_info);
-		soc_private->power_info.gpio_num_info = NULL;
-		kfree(soc_private);
-		soc_private = NULL;
-	}
-	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, NULL);
-	kfree(e_ctrl);
-
-	return 0;
-}
-
 static int cam_eeprom_component_bind(struct device *dev,
 	struct device *master_dev, void *data)
 {

+ 82 - 0
drivers/cam_utils/cam_compat.c

@@ -15,6 +15,8 @@
 #include "cam_debug_util.h"
 #include "cam_cpas_api.h"
 #include "camera_main.h"
+#include "cam_eeprom_dev.h"
+#include "cam_eeprom_core.h"
 
 #if IS_ENABLED(CONFIG_USE_RPMH_DRV_API)
 #define CAM_RSC_DRV_IDENTIFIER "cam_rsc"
@@ -530,3 +532,83 @@ long cam_dma_buf_set_name(struct dma_buf *dmabuf, const char *name)
 	return 0;
 }
 #endif
+
+#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
+void cam_eeprom_spi_driver_remove(struct spi_device *sdev)
+{
+	struct v4l2_subdev             *sd = spi_get_drvdata(sdev);
+	struct cam_eeprom_ctrl_t       *e_ctrl;
+	struct cam_eeprom_soc_private  *soc_private;
+	struct cam_hw_soc_info         *soc_info;
+
+	if (!sd) {
+		CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
+		return;
+	}
+
+	e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
+	if (!e_ctrl) {
+		CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
+		return;
+	}
+
+	soc_info = &e_ctrl->soc_info;
+	mutex_lock(&(e_ctrl->eeprom_mutex));
+	cam_eeprom_shutdown(e_ctrl);
+	mutex_unlock(&(e_ctrl->eeprom_mutex));
+	mutex_destroy(&(e_ctrl->eeprom_mutex));
+	cam_unregister_subdev(&(e_ctrl->v4l2_dev_str));
+	kfree(e_ctrl->io_master_info.spi_client);
+	e_ctrl->io_master_info.spi_client = NULL;
+	soc_private =
+		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+	if (soc_private) {
+		kfree(soc_private->power_info.gpio_num_info);
+		soc_private->power_info.gpio_num_info = NULL;
+		kfree(soc_private);
+		soc_private = NULL;
+	}
+	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, NULL);
+	kfree(e_ctrl);
+}
+#else
+int cam_eeprom_spi_driver_remove(struct spi_device *sdev)
+{
+	struct v4l2_subdev             *sd = spi_get_drvdata(sdev);
+	struct cam_eeprom_ctrl_t       *e_ctrl;
+	struct cam_eeprom_soc_private  *soc_private;
+	struct cam_hw_soc_info         *soc_info;
+
+	if (!sd) {
+		CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
+		return -EINVAL;
+	}
+
+	e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
+	if (!e_ctrl) {
+		CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
+		return -EINVAL;
+	}
+
+	soc_info = &e_ctrl->soc_info;
+	mutex_lock(&(e_ctrl->eeprom_mutex));
+	cam_eeprom_shutdown(e_ctrl);
+	mutex_unlock(&(e_ctrl->eeprom_mutex));
+	mutex_destroy(&(e_ctrl->eeprom_mutex));
+	cam_unregister_subdev(&(e_ctrl->v4l2_dev_str));
+	kfree(e_ctrl->io_master_info.spi_client);
+	e_ctrl->io_master_info.spi_client = NULL;
+	soc_private =
+		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+	if (soc_private) {
+		kfree(soc_private->power_info.gpio_num_info);
+		soc_private->power_info.gpio_num_info = NULL;
+		kfree(soc_private);
+		soc_private = NULL;
+	}
+	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, NULL);
+	kfree(e_ctrl);
+
+	return 0;
+}
+#endif

+ 7 - 0
drivers/cam_utils/cam_compat.h

@@ -15,6 +15,7 @@
 #include <linux/list_sort.h>
 #include <linux/dma-iommu.h>
 #include <soc/qcom/of_common.h>
+#include <linux/spi/spi.h>
 
 #include "cam_csiphy_dev.h"
 #include "cam_cpastop_hw.h"
@@ -79,4 +80,10 @@ int cam_i3c_driver_remove(struct i3c_device *client);
 
 long cam_dma_buf_set_name(struct dma_buf *dmabuf, const char *name);
 
+#if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
+void cam_eeprom_spi_driver_remove(struct spi_device *sdev);
+#else
+int cam_eeprom_spi_driver_remove(struct spi_device *sdev);
+#endif
+
 #endif /* _CAM_COMPAT_H_ */