Hello,
This patch series simplifies the code by replacing custom code with generic helper.
Best regards Marek Szyprowski Samsung R&D Institute Poland
Patch summary:
Marek Szyprowski (7): drm/exynos: exynos5433_decon: use generic of_device_get_match_data helper drm/exynos: dsi: use generic of_device_get_match_data helper drm/exynos: fimd: use generic of_device_get_match_data helper drm/exynos: rotator: use generic of_device_get_match_data helper drm/exynos: hdmi: use generic of_device_get_match_data helper drm/exynos: mixer: remove support for non-dt platforms drm/exynos: mixer: use generic of_device_get_match_data helper
drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 5 +---- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 11 +---------- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 11 +---------- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 11 +++-------- drivers/gpu/drm/exynos/exynos_hdmi.c | 7 +------ drivers/gpu/drm/exynos/exynos_mixer.c | 26 +++----------------------- 6 files changed, 10 insertions(+), 61 deletions(-)
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 5245bc5e82e9..fa3dd6e91fd5 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -629,7 +629,6 @@ MODULE_DEVICE_TABLE(of, exynos5433_decon_driver_dt_match);
static int exynos5433_decon_probe(struct platform_device *pdev) { - const struct of_device_id *of_id; struct device *dev = &pdev->dev; struct decon_context *ctx; struct resource *res; @@ -642,9 +641,7 @@ static int exynos5433_decon_probe(struct platform_device *pdev)
__set_bit(BIT_SUSPENDED, &ctx->flags); ctx->dev = dev; - - of_id = of_match_device(exynos5433_decon_driver_dt_match, &pdev->dev); - ctx->out_type = (enum decon_iftype)of_id->data; + ctx->out_type = (enum decon_iftype)of_device_get_match_data(dev);
if (ctx->out_type == IFTYPE_HDMI) ctx->first_win = 1;
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 63c84a106c0b..b6518df2411d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -532,15 +532,6 @@ static const struct of_device_id exynos_dsi_of_match[] = { { } };
-static inline struct exynos_dsi_driver_data *exynos_dsi_get_driver_data( - struct platform_device *pdev) -{ - const struct of_device_id *of_id = - of_match_device(exynos_dsi_of_match, &pdev->dev); - - return (struct exynos_dsi_driver_data *)of_id->data; -} - static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi) { if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300))) @@ -1833,7 +1824,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi->dsi_host.dev = dev;
dsi->dev = dev; - dsi->driver_data = exynos_dsi_get_driver_data(pdev); + dsi->driver_data = of_device_get_match_data(dev);
ret = exynos_dsi_parse_dt(dsi); if (ret)
Hi Marek,
2016년 04월 01일 22:17에 Marek Szyprowski 이(가) 쓴 글:
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com
drivers/gpu/drm/exynos/exynos_drm_dsi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 63c84a106c0b..b6518df2411d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -532,15 +532,6 @@ static const struct of_device_id exynos_dsi_of_match[] = { { } };
-static inline struct exynos_dsi_driver_data *exynos_dsi_get_driver_data(
struct platform_device *pdev)
-{
- const struct of_device_id *of_id =
of_match_device(exynos_dsi_of_match, &pdev->dev);
- return (struct exynos_dsi_driver_data *)of_id->data;
-}
static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi) { if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300))) @@ -1833,7 +1824,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi->dsi_host.dev = dev;
dsi->dev = dev;
- dsi->driver_data = exynos_dsi_get_driver_data(pdev);
- dsi->driver_data = of_device_get_match_data(dev);
drivers/gpu/drm/exynos/exynos_drm_dsi.c: In function 'exynos_dsi_probe': drivers/gpu/drm/exynos/exynos_drm_dsi.c:1827:19: warning: assignment discards 'const' qualifier from pointer target type
Looks you missed const prefix and for patch 3 also but I can fix them.
Thanks, Inki Dae
ret = exynos_dsi_parse_dt(dsi); if (ret)
Simplify code by replacing custom code by generic helper and add missing const qualifier to driver data structures.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- v2: - added missing const qualifier to driver data structures --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 63c84a106c0b..72c3565d22ee 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -280,7 +280,7 @@ struct exynos_dsi { spinlock_t transfer_lock; /* protects transfer_list */ struct list_head transfer_list;
- struct exynos_dsi_driver_data *driver_data; + const struct exynos_dsi_driver_data *driver_data; struct device_node *bridge_node; };
@@ -532,15 +532,6 @@ static const struct of_device_id exynos_dsi_of_match[] = { { } };
-static inline struct exynos_dsi_driver_data *exynos_dsi_get_driver_data( - struct platform_device *pdev) -{ - const struct of_device_id *of_id = - of_match_device(exynos_dsi_of_match, &pdev->dev); - - return (struct exynos_dsi_driver_data *)of_id->data; -} - static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi) { if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300))) @@ -564,7 +555,7 @@ static void exynos_dsi_reset(struct exynos_dsi *dsi) static unsigned long exynos_dsi_pll_find_pms(struct exynos_dsi *dsi, unsigned long fin, unsigned long fout, u8 *p, u16 *m, u8 *s) { - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; unsigned long best_freq = 0; u32 min_delta = 0xffffffff; u8 p_min, p_max; @@ -618,7 +609,7 @@ static unsigned long exynos_dsi_pll_find_pms(struct exynos_dsi *dsi, static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi, unsigned long freq) { - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; unsigned long fin, fout; int timeout; u8 p, s; @@ -712,7 +703,7 @@ static int exynos_dsi_enable_clock(struct exynos_dsi *dsi)
static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi) { - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; const unsigned int *reg_values = driver_data->reg_values; u32 reg;
@@ -790,7 +781,7 @@ static void exynos_dsi_enable_lane(struct exynos_dsi *dsi, u32 lane)
static int exynos_dsi_init_link(struct exynos_dsi *dsi) { - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int timeout; u32 reg; u32 lanes_mask; @@ -1334,7 +1325,7 @@ static void exynos_dsi_disable_irq(struct exynos_dsi *dsi)
static int exynos_dsi_init(struct exynos_dsi *dsi) { - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
exynos_dsi_reset(dsi); exynos_dsi_enable_irq(dsi); @@ -1833,7 +1824,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi->dsi_host.dev = dev;
dsi->dev = dev; - dsi->driver_data = exynos_dsi_get_driver_data(pdev); + dsi->driver_data = of_device_get_match_data(dev);
ret = exynos_dsi_parse_dt(dsi); if (ret) @@ -1917,7 +1908,7 @@ static int __maybe_unused exynos_dsi_suspend(struct device *dev) { struct drm_encoder *encoder = dev_get_drvdata(dev); struct exynos_dsi *dsi = encoder_to_dsi(encoder); - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i;
usleep_range(10000, 20000); @@ -1948,7 +1939,7 @@ static int __maybe_unused exynos_dsi_resume(struct device *dev) { struct drm_encoder *encoder = dev_get_drvdata(dev); struct exynos_dsi *dsi = encoder_to_dsi(encoder); - struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i;
ret = regulator_bulk_enable(ARRAY_SIZE(dsi->supplies), dsi->supplies);
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 018449f8d557..4f31a8aa17dd 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -219,15 +219,6 @@ static const uint32_t fimd_formats[] = { DRM_FORMAT_ARGB8888, };
-static inline struct fimd_driver_data *drm_fimd_get_driver_data( - struct platform_device *pdev) -{ - const struct of_device_id *of_id = - of_match_device(fimd_driver_dt_match, &pdev->dev); - - return (struct fimd_driver_data *)of_id->data; -} - static int fimd_enable_vblank(struct exynos_drm_crtc *crtc) { struct fimd_context *ctx = crtc->ctx; @@ -1035,7 +1026,7 @@ static int fimd_probe(struct platform_device *pdev)
ctx->dev = dev; ctx->suspended = true; - ctx->driver_data = drm_fimd_get_driver_data(pdev); + ctx->driver_data = of_device_get_match_data(dev);
if (of_property_read_bool(dev->of_node, "samsung,invert-vden")) ctx->vidcon1 |= VIDCON1_INV_VDEN;
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index f18fbe43f55f..404367a430b5 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c @@ -15,6 +15,7 @@ #include <linux/io.h> #include <linux/platform_device.h> #include <linux/clk.h> +#include <linux/of_device.h> #include <linux/pm_runtime.h>
#include <drm/drmP.h> @@ -696,7 +697,6 @@ static int rotator_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct rot_context *rot; struct exynos_drm_ippdrv *ippdrv; - const struct of_device_id *match; int ret;
if (!dev->of_node) { @@ -708,13 +708,8 @@ static int rotator_probe(struct platform_device *pdev) if (!rot) return -ENOMEM;
- match = of_match_node(exynos_rotator_match, dev->of_node); - if (!match) { - dev_err(dev, "failed to match node\n"); - return -ENODEV; - } - rot->limit_tbl = (struct rot_limit_table *)match->data; - + rot->limit_tbl = (struct rot_limit_table *) + of_device_get_match_data(dev); rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); rot->regs = devm_ioremap_resource(dev, rot->regs_res); if (IS_ERR(rot->regs))
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_hdmi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 06105feb6c87..fb1c0f2850dc 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -2015,7 +2015,6 @@ static struct device_node *hdmi_legacy_phy_dt_binding(struct device *dev) static int hdmi_probe(struct platform_device *pdev) { struct device_node *ddc_node, *phy_node; - const struct of_device_id *match; struct device *dev = &pdev->dev; struct hdmi_context *hdata; struct resource *res; @@ -2025,11 +2024,7 @@ static int hdmi_probe(struct platform_device *pdev) if (!hdata) return -ENOMEM;
- match = of_match_device(hdmi_match_types, dev); - if (!match) - return -ENODEV; - - hdata->drv_data = match->data; + hdata->drv_data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, hdata);
There are no non-devicetree based Exynos platforms in mainline, so there no point keeping old platform driver data for them.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_mixer.c | 16 ---------------- 1 file changed, 16 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 0a5a60005f7e..ffafb744154e 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -1155,18 +1155,6 @@ static struct mixer_drv_data exynos4210_mxr_drv_data = { .has_sclk = 1, };
-static const struct platform_device_id mixer_driver_types[] = { - { - .name = "s5p-mixer", - .driver_data = (unsigned long)&exynos4210_mxr_drv_data, - }, { - .name = "exynos5-mixer", - .driver_data = (unsigned long)&exynos5250_mxr_drv_data, - }, { - /* end node */ - } -}; - static struct of_device_id mixer_match_types[] = { { .compatible = "samsung,exynos4210-mixer", @@ -1258,9 +1246,6 @@ static int mixer_probe(struct platform_device *pdev)
match = of_match_node(mixer_match_types, dev->of_node); drv = (struct mixer_drv_data *)match->data; - } else { - drv = (struct mixer_drv_data *) - platform_get_device_id(pdev)->driver_data; }
ctx->pdev = pdev; @@ -1355,5 +1340,4 @@ struct platform_driver mixer_driver = { }, .probe = mixer_probe, .remove = mixer_remove, - .id_table = mixer_driver_types, };
Simplify code by replacing custom code by generic helper.
Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- drivers/gpu/drm/exynos/exynos_mixer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index ffafb744154e..caec5e4fb349 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -31,6 +31,7 @@ #include <linux/clk.h> #include <linux/regulator/consumer.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/component.h>
#include <drm/exynos_drm.h> @@ -1231,7 +1232,7 @@ static const struct component_ops mixer_component_ops = { static int mixer_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct mixer_drv_data *drv; + const struct mixer_drv_data *drv; struct mixer_context *ctx; int ret;
@@ -1241,12 +1242,7 @@ static int mixer_probe(struct platform_device *pdev) return -ENOMEM; }
- if (dev->of_node) { - const struct of_device_id *match; - - match = of_match_node(mixer_match_types, dev->of_node); - drv = (struct mixer_drv_data *)match->data; - } + drv = of_device_get_match_data(dev);
ctx->pdev = pdev; ctx->dev = dev;
dri-devel@lists.freedesktop.org