int hw_vcm_register(struct platform_device *pdev, hw_vcm_intf_t* intf, struct hw_vcm_info *hw_vcm_info) { int rc = 0; hw_vcm_t *hw_vcm = NULL; struct v4l2_subdev *subdev = NULL; if (intf == NULL || pdev == NULL || hw_vcm_info == NULL) { rc = -ENOMEM; cam_err("%s, the parameters is a null pointer!", __func__); goto register_fail; } hw_vcm = (hw_vcm_t*)kzalloc(sizeof(hw_vcm_t), GFP_KERNEL); if (hw_vcm == NULL) { rc = -ENOMEM; cam_err("%s, vcm is null!!", __func__); goto register_fail; } subdev = &hw_vcm->subdev; mutex_init(&hw_vcm->lock); v4l2_subdev_init(subdev, &s_subdev_ops_hw_vcm); subdev->internal_ops = &s_subdev_internal_ops_hw_vcm; snprintf(subdev->name, sizeof(subdev->name), "%s", hw_vcm_info->vcm_name); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_set_subdevdata(subdev, pdev); media_entity_init(&subdev->entity, 0, NULL, 0); subdev->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; subdev->entity.group_id = hw_vcm_info->index ? HWCAM_SUBDEV_VCM1 : HWCAM_SUBDEV_VCM0; subdev->entity.name = subdev->name; hwcam_cfgdev_register_subdev(subdev); hw_vcm->intf = intf; hw_vcm->vcm_info = hw_vcm_info; hw_vcm->pdev = pdev; register_fail: return rc; }
int32_t hisi_pmic_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter; struct hisi_pmic_ctrl_t *pmic_ctrl; int32_t rc=0; cam_info("%s client name = %s.\n", __func__, client->name); adapter = client->adapter; if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { cam_err("%s i2c_check_functionality failed.\n", __func__); return -EIO; } pmic_ctrl = (struct hisi_pmic_ctrl_t *)id->driver_data; pmic_ctrl->pmic_i2c_client->client = client; pmic_ctrl->dev = &client->dev; pmic_ctrl->pmic_i2c_client->i2c_func_tbl = &hisi_pmic_i2c_func_tbl; rc = hisi_pmic_get_dt_data(pmic_ctrl); if (rc < 0) { cam_err("%s hisi_pmic_get_dt_data failed.", __func__); return -EFAULT; } rc = pmic_ctrl->func_tbl->pmic_get_dt_data(pmic_ctrl); if (rc < 0) { cam_err("%s flash_get_dt_data failed.", __func__); return -EFAULT; } rc = pmic_ctrl->func_tbl->pmic_init(pmic_ctrl); if (rc < 0) { cam_err("%s pmic init failed.\n", __func__); return -EFAULT; } rc = pmic_ctrl->func_tbl->pmic_match(pmic_ctrl); if (rc < 0) { cam_err("%s pmic match failed.\n", __func__); return -EFAULT; } if (!pmic_ctrl->pmic_v4l2_subdev_ops) pmic_ctrl->pmic_v4l2_subdev_ops = &hisi_pmic_subdev_ops; v4l2_subdev_init(&pmic_ctrl->subdev, pmic_ctrl->pmic_v4l2_subdev_ops); snprintf(pmic_ctrl->subdev.name, sizeof(pmic_ctrl->subdev.name), "%s", pmic_ctrl->pmic_info.name); v4l2_set_subdevdata(&pmic_ctrl->subdev, client); pmic_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; media_entity_init(&pmic_ctrl->subdev.entity, 0, NULL, 0); pmic_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; pmic_ctrl->subdev.entity.group_id = HWCAM_SUBDEV_PMIC; pmic_ctrl->subdev.entity.name = pmic_ctrl->subdev.name; hwcam_cfgdev_register_subdev(&pmic_ctrl->subdev); rc = pmic_ctrl->func_tbl->pmic_register_attribute(pmic_ctrl, &pmic_ctrl->subdev.devnode->dev); if (rc < 0) { cam_err("%s failed to register pmic attribute node.", __func__); return rc; } #ifdef CONFIG_HUAWEI_HW_DEV_DCT /* detect current device successful, set the flag as present */ set_hw_dev_flag(DEV_I2C_CAMERA_PMU); #endif hisi_set_pmic_ctrl(pmic_ctrl); return rc; }