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 <quic_zhuo@quicinc.com>
This commit is contained in:
zhuo
2022-07-15 18:43:32 +08:00
committed by Camera Software Integration
parent a0ca9a026c
commit 3e05e54587
3 changed files with 89 additions and 44 deletions

View File

@@ -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