From: Sylwester Nawrocki Date: Thu, 5 Apr 2018 14:35:44 +0000 (+0200) Subject: fimc-is: Use struct device * for companion device X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb7e907d21209fab658bad87543badae159b0798;p=platform%2Fkernel%2Flinux-exynos.git fimc-is: Use struct device * for companion device Change-Id: I365f652a10d62b4949561b673de93774fbae77a6 Signed-off-by: Sylwester Nawrocki --- diff --git a/drivers/media/platform/exynos/fimc-is/exynos-fimc-is-sensor.h b/drivers/media/platform/exynos/fimc-is/exynos-fimc-is-sensor.h index 0a2c767de946..ffd469489e13 100644 --- a/drivers/media/platform/exynos/fimc-is/exynos-fimc-is-sensor.h +++ b/drivers/media/platform/exynos/fimc-is/exynos-fimc-is-sensor.h @@ -253,7 +253,7 @@ struct exynos_sensor_pin { * struct exynos_platform_fimc_is_sensor - platform data for exynos_sensor driver */ struct exynos_platform_fimc_is_sensor { - int (*gpio_cfg)(struct platform_device *pdev, u32 scenario, u32 enable); + int (*gpio_cfg)(struct device *pdev, u32 scenario, u32 enable); int (*iclk_cfg)(struct device *dev, u32 scenario, u32 channel); int (*iclk_on)(struct device *dev,u32 scenario, u32 channel); int (*iclk_off)(struct device *dev, u32 scenario, u32 channel); @@ -278,7 +278,7 @@ struct exynos_platform_fimc_is_sensor { struct pinctrl *pinctrl; }; -extern int exynos_fimc_is_sensor_pins_cfg(struct platform_device *pdev, +extern int exynos_fimc_is_sensor_pins_cfg(struct device *dev, u32 scenario, u32 enable); extern int exynos_fimc_is_sensor_iclk_cfg(struct device *dev, diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-companion.c b/drivers/media/platform/exynos/fimc-is/fimc-is-companion.c index ff21ba7c0ddf..61259d8eb5b4 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-companion.c +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-companion.c @@ -391,7 +391,7 @@ static int fimc_is_comp_load_binary(struct fimc_is_core *core, char *name) BUG_ON(!core); BUG_ON(!core->pdev); BUG_ON(!core->companion); - BUG_ON(!core->companion->pdev); + BUG_ON(!core->companion->dev); BUG_ON(!name); fimc_is_sec_get_sysfs_finfo(&sysfs_finfo); @@ -430,10 +430,10 @@ request_fw: snprintf(fw_name, sizeof(fw_name), "%s", name); set_fs(old_fs); retry_count = 3; - ret = request_firmware(&fw_blob, fw_name, &core->companion->pdev->dev); + ret = request_firmware(&fw_blob, fw_name, core->companion->dev); while (--retry_count && ret == -EAGAIN) { err("request_firmware retry(count:%d)", retry_count); - ret = request_firmware(&fw_blob, fw_name, &core->companion->pdev->dev); + ret = request_firmware(&fw_blob, fw_name, core->companion->dev); } if (ret) { diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.c b/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.c index 8be018e96fa5..e35e61228d52 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.c +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.c @@ -64,14 +64,12 @@ static void fimc_is_companion_wakeup(struct fimc_is_device_companion *device) static int fimc_is_companion_mclk_on(struct fimc_is_device_companion *device) { int ret = 0; - struct platform_device *pdev; struct exynos_platform_fimc_is_sensor *pdata; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); - pdev = device->pdev; pdata = device->pdata; if (test_bit(FIMC_IS_COMPANION_MCLK_ON, &device->state)) { @@ -85,7 +83,7 @@ static int fimc_is_companion_mclk_on(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->mclk_on(&pdev->dev, pdata->scenario, pdata->mclk_ch); + ret = pdata->mclk_on(device->dev, pdata->scenario, pdata->mclk_ch); if (ret) { err("mclk_on failed(%d)", ret); goto p_err; @@ -100,14 +98,12 @@ p_err: static int fimc_is_companion_mclk_off(struct fimc_is_device_companion *device) { int ret = 0; - struct platform_device *pdev; struct exynos_platform_fimc_is_sensor *pdata; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); - pdev = device->pdev; pdata = device->pdata; if (!test_bit(FIMC_IS_COMPANION_MCLK_ON, &device->state)) { @@ -121,7 +117,7 @@ static int fimc_is_companion_mclk_off(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->mclk_off(&pdev->dev, pdata->scenario, pdata->mclk_ch); + ret = pdata->mclk_off(device->dev, pdata->scenario, pdata->mclk_ch); if (ret) { err("mclk_off failed(%d)", ret); goto p_err; @@ -135,15 +131,13 @@ p_err: static int fimc_is_companion_iclk_on(struct fimc_is_device_companion *device) { - int ret = 0; - struct platform_device *pdev; struct exynos_platform_fimc_is_sensor *pdata; + int ret = 0; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); - pdev = device->pdev; pdata = device->pdata; if (test_bit(FIMC_IS_COMPANION_ICLK_ON, &device->state)) { @@ -163,13 +157,13 @@ static int fimc_is_companion_iclk_on(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->iclk_cfg(&pdev->dev, pdata->scenario, 0); + ret = pdata->iclk_cfg(device->dev, pdata->scenario, 0); if (ret) { err("iclk_cfg failed(%d)", ret); goto p_err; } - ret = pdata->iclk_on(&pdev->dev, pdata->scenario, 0); + ret = pdata->iclk_on(device->dev, pdata->scenario, 0); if (ret) { err("iclk_on failed(%d)", ret); goto p_err; @@ -183,15 +177,13 @@ p_err: static int fimc_is_companion_iclk_off(struct fimc_is_device_companion *device) { - int ret = 0; - struct platform_device *pdev; struct exynos_platform_fimc_is_sensor *pdata; + int ret = 0; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); - pdev = device->pdev; pdata = device->pdata; if (!test_bit(FIMC_IS_COMPANION_ICLK_ON, &device->state)) { @@ -205,7 +197,7 @@ static int fimc_is_companion_iclk_off(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->iclk_off(&pdev->dev, pdata->scenario, 0); + ret = pdata->iclk_off(device->dev, pdata->scenario, 0); if (ret) { err("iclk_off failed(%d)", ret); goto p_err; @@ -226,7 +218,7 @@ static int fimc_is_companion_gpio_on(struct fimc_is_device_companion *device) struct fimc_is_core *core; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); pdata = device->pdata; @@ -269,7 +261,7 @@ static int fimc_is_companion_gpio_on(struct fimc_is_device_companion *device) } } - ret = pdata->gpio_cfg(device->pdev, pdata->scenario, GPIO_SCENARIO_ON); + ret = pdata->gpio_cfg(device->dev, pdata->scenario, GPIO_SCENARIO_ON); if (ret) { err("gpio_cfg failed(%d)", ret); goto p_err; @@ -288,7 +280,7 @@ static int fimc_is_companion_gpio_off(struct fimc_is_device_companion *device) struct fimc_is_core *core = dev_get_drvdata(fimc_is_dev); BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); pdata = device->pdata; @@ -304,7 +296,7 @@ static int fimc_is_companion_gpio_off(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->gpio_cfg(device->pdev, pdata->scenario, GPIO_SCENARIO_OFF); + ret = pdata->gpio_cfg(device->dev, pdata->scenario, GPIO_SCENARIO_OFF); if (ret) { err("gpio_cfg failed(%d)", ret); goto p_err; @@ -344,13 +336,14 @@ int fimc_is_companion_open(struct fimc_is_device_companion *device) device->companion_status = FIMC_IS_COMPANION_OPENNING; core->running_rear_camera = true; - pm_runtime_get_sync(&device->pdev->dev); - ret = fimc_is_sec_fw_sel(core, &device->pdev->dev, fw_name, setf_name, false); + pm_runtime_get_sync(device->dev); + ret = fimc_is_sec_fw_sel(core, device->dev, fw_name, setf_name, false); if (ret < 0) { err("failed to select firmware (%d)", ret); goto p_err_pm; } - ret = fimc_is_sec_concord_fw_sel(core, &device->pdev->dev, companion_fw_name, master_setf_name, mode_setf_name); + ret = fimc_is_sec_concord_fw_sel(core, device->dev, companion_fw_name, + master_setf_name, mode_setf_name); /* TODO: loading firmware */ fimc_is_s_int_comb_isp(core, false, INTMR2_INTMCIS(22)); @@ -393,7 +386,7 @@ int fimc_is_companion_open(struct fimc_is_device_companion *device) return ret; p_err_pm: - pm_runtime_put_sync(&device->pdev->dev); + pm_runtime_put_sync(device->dev); p_err: err("[COMP:D] open fail(%d)status(%d)", ret, device->companion_status); @@ -404,6 +397,7 @@ int fimc_is_companion_close(struct fimc_is_device_companion *device) { int ret = 0; struct fimc_is_core *core = dev_get_drvdata(fimc_is_dev); + if (!core) { err("core is NULL"); return -EINVAL; @@ -417,7 +411,7 @@ int fimc_is_companion_close(struct fimc_is_device_companion *device) goto p_err; } - pm_runtime_put_sync(&device->pdev->dev); + pm_runtime_put_sync(device->dev); #if 0 if (core != NULL && !test_bit(FIMC_IS_ISCHAIN_POWER_ON, &core->state)) { u32 timeout; @@ -486,7 +480,7 @@ static int fimc_is_companion_probe(struct platform_device *pdev) goto p_err; } - device->pdev = pdev; + device->dev = &pdev->dev; device->private_data = core; device->regs = core->regs; device->pdata = pdata; diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.h b/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.h index 60027363cc68..d767e6e2a6e6 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.h +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.h @@ -35,7 +35,7 @@ enum fimc_is_companion_status { struct fimc_is_device_companion { struct v4l2_device *v4l2_dev; - struct platform_device *pdev; + struct device *dev; void __iomem *regs; struct fimc_is_mem mem; diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-device-ois.c b/drivers/media/platform/exynos/fimc-is/fimc-is-device-ois.c index 896d10414fa7..e3e3ba1f6f90 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-device-ois.c +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-device-ois.c @@ -253,7 +253,7 @@ int fimc_is_ois_gpio_on(struct fimc_is_device_companion *device) struct exynos_platform_fimc_is_sensor *pdata; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); pdata = device->pdata; @@ -264,7 +264,8 @@ int fimc_is_ois_gpio_on(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->gpio_cfg(device->pdev, SENSOR_SCENARIO_OIS_FACTORY, GPIO_SCENARIO_ON); + ret = pdata->gpio_cfg(device->dev, SENSOR_SCENARIO_OIS_FACTORY, + GPIO_SCENARIO_ON); if (ret) { err("gpio_cfg failed(%d)", ret); goto p_err; @@ -280,7 +281,7 @@ int fimc_is_ois_gpio_off(struct fimc_is_device_companion *device) struct exynos_platform_fimc_is_sensor *pdata; BUG_ON(!device); - BUG_ON(!device->pdev); + BUG_ON(!device->dev); BUG_ON(!device->pdata); pdata = device->pdata; @@ -291,7 +292,8 @@ int fimc_is_ois_gpio_off(struct fimc_is_device_companion *device) goto p_err; } - ret = pdata->gpio_cfg(device->pdev, SENSOR_SCENARIO_OIS_FACTORY, GPIO_SCENARIO_OFF); + ret = pdata->gpio_cfg(device->dev, SENSOR_SCENARIO_OIS_FACTORY, + GPIO_SCENARIO_OFF); if (ret) { err("gpio_cfg failed(%d)", ret); goto p_err; @@ -932,10 +934,10 @@ request_fw: snprintf(fw_name, sizeof(fw_name), "%s", name); set_fs(old_fs); retry_count = 3; - ret = request_firmware(&fw_blob, fw_name, &core->companion->pdev->dev); + ret = request_firmware(&fw_blob, fw_name, core->companion->dev); while (--retry_count && ret == -EAGAIN) { err("request_firmware retry(count:%d)", retry_count); - ret = request_firmware(&fw_blob, fw_name, &core->companion->pdev->dev); + ret = request_firmware(&fw_blob, fw_name, core->companion->dev); } if (ret) { diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-device-sensor.c b/drivers/media/platform/exynos/fimc-is/fimc-is-device-sensor.c index 2fc5f6e4b28b..fea2064775d0 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-device-sensor.c +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-device-sensor.c @@ -336,7 +336,8 @@ static int fimc_is_sensor_gpio_on(struct fimc_is_device_sensor *device) core->running_front_camera = true; } - ret = pdata->gpio_cfg(device->pdev, pdata->scenario, GPIO_SCENARIO_ON); + ret = pdata->gpio_cfg(&device->pdev->dev, pdata->scenario, + GPIO_SCENARIO_ON); if (ret) { merr("gpio_cfg failed(%d)", device, ret); goto p_err; @@ -371,7 +372,8 @@ static int fimc_is_sensor_gpio_off(struct fimc_is_device_sensor *device) goto p_err; } - ret = pdata->gpio_cfg(device->pdev, pdata->scenario, GPIO_SCENARIO_OFF); + ret = pdata->gpio_cfg(&device->pdev->dev, pdata->scenario, + GPIO_SCENARIO_OFF); if (ret) { merr("gpio_cfg failed(%d)", device, ret); goto p_err; @@ -1875,7 +1877,8 @@ int fimc_is_sensor_gpio_off_softlanding(struct fimc_is_device_sensor *device) goto p_err; } - ret = pdata->gpio_cfg(device->pdev, pdata->scenario, GPIO_SCENARIO_OFF); + ret = pdata->gpio_cfg(&device->pdev->dev, pdata->scenario, + GPIO_SCENARIO_OFF); if (ret) { merr("gpio_cfg failed(%d)", device, ret); goto p_err; diff --git a/drivers/media/platform/exynos/fimc-is/fimc-is-video-companion.c b/drivers/media/platform/exynos/fimc-is/fimc-is-video-companion.c index 3f2bb5d14143..83223eb04f84 100644 --- a/drivers/media/platform/exynos/fimc-is/fimc-is-video-companion.c +++ b/drivers/media/platform/exynos/fimc-is/fimc-is-video-companion.c @@ -51,12 +51,6 @@ int fimc_is_comp_video_probe(void *data) snprintf(name, sizeof(name), "%s%d", FIMC_IS_VIDEO_SENSOR_NAME, 9); number = FIMC_IS_VIDEO_SS0_NUM + 9; - if (!device->pdev) { - err("pdev is NULL"); - ret = -EINVAL; - goto p_err; - } - ret = fimc_is_video_probe(video, name, number, @@ -67,9 +61,8 @@ int fimc_is_comp_video_probe(void *data) &fimc_is_comp_video_fops, &fimc_is_comp_video_ioctl_ops); if (ret) - dev_err(&device->pdev->dev, "%s failed(%d)\n", __func__, ret); + dev_err(device->dev, "%s failed(%d)\n", __func__, ret); -p_err: info("[CP%d:V:X] %s(%d)\n", number, __func__, ret); return ret; } @@ -88,8 +81,8 @@ static int fimc_is_comp_video_s_ctrl(struct file *file, void *priv, video = video_drvdata(file); device = container_of(video, struct fimc_is_device_companion, video); - if (!device->pdev) { - err("pdev is NULL"); + if (!device->dev) { + err("dev is NULL"); ret = -EINVAL; goto p_err; } diff --git a/drivers/media/platform/exynos/fimc-is/setup-fimc-is-sensor.c b/drivers/media/platform/exynos/fimc-is/setup-fimc-is-sensor.c index 365832874887..a4244ef39a2e 100644 --- a/drivers/media/platform/exynos/fimc-is/setup-fimc-is-sensor.c +++ b/drivers/media/platform/exynos/fimc-is/setup-fimc-is-sensor.c @@ -26,7 +26,7 @@ #include "exynos-fimc-is.h" #include "exynos-fimc-is-sensor.h" -static int exynos_fimc_is_sensor_pin_control(struct platform_device *pdev, +static int exynos_fimc_is_sensor_pin_control(struct device *dev, struct pinctrl *pinctrl, struct exynos_sensor_pin *pin_ctrls, int channel) { int ret = 0; @@ -90,7 +90,7 @@ static int exynos_fimc_is_sensor_pin_control(struct platform_device *pdev, { struct regulator *regulator = NULL; - regulator = regulator_get(&pdev->dev, name); + regulator = regulator_get(dev, name); if (IS_ERR_OR_NULL(regulator)) { pr_err("%s : regulator_get(%s) failed\n", __func__, name); return PTR_ERR(regulator); @@ -117,7 +117,7 @@ static int exynos_fimc_is_sensor_pin_control(struct platform_device *pdev, { struct regulator *regulator = NULL; - regulator = regulator_get(&pdev->dev, name); + regulator = regulator_get(dev, name); if (IS_ERR_OR_NULL(regulator)) { pr_err("%s : regulator_get(%s) fail\n", __func__, name); return PTR_ERR(regulator); @@ -140,21 +140,20 @@ static int exynos_fimc_is_sensor_pin_control(struct platform_device *pdev, return ret; } -int exynos_fimc_is_sensor_pins_cfg(struct platform_device *pdev, - u32 scenario, - u32 enable) +int exynos_fimc_is_sensor_pins_cfg(struct device *dev, u32 scenario, + u32 enable) { int ret = 0; u32 i = 0; struct exynos_sensor_pin (*pin_ctrls)[2][GPIO_CTRL_MAX]; struct exynos_platform_fimc_is_sensor *pdata; - BUG_ON(!pdev); - BUG_ON(!pdev->dev.platform_data); + BUG_ON(!dev); + BUG_ON(!dev->platform_data); BUG_ON(enable > 1); BUG_ON(scenario > SENSOR_SCENARIO_MAX); - pdata = pdev->dev.platform_data; + pdata = dev->platform_data; pin_ctrls = pdata->pin_ctrls; for (i = 0; i < GPIO_CTRL_MAX; ++i) { @@ -163,7 +162,7 @@ int exynos_fimc_is_sensor_pins_cfg(struct platform_device *pdev, break; } - ret = exynos_fimc_is_sensor_pin_control(pdev, + ret = exynos_fimc_is_sensor_pin_control(dev, pdata->pinctrl, &pin_ctrls[scenario][enable][i], pdata->csi_ch);