From: Sam Ravnborg <sam@ravnborg.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: linux-aspeed@lists.ozlabs.org, Andrew Jeffery <andrew@aj.id.au>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
DRI Development <dri-devel@lists.freedesktop.org>,
Joel Stanley <joel@jms.id.au>,
Daniel Vetter <daniel.vetter@intel.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
Date: Fri, 24 Apr 2020 20:02:46 +0200 [thread overview]
Message-ID: <20200424180246.GK7074@ravnborg.org> (raw)
In-Reply-To: <20200415074034.175360-56-daniel.vetter@ffwll.ch>
On Wed, Apr 15, 2020 at 09:40:30AM +0200, Daniel Vetter wrote:
> As usual, we can drop the drm_dev_put() and need to embed the
> drm_device. Since it's so few, also go right ahead and leave
> drm_device->dev_private set to NULL, so that we always use the
> container_of() upcast, which is faster anyway.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
> drivers/gpu/drm/aspeed/aspeed_gfx.h | 2 ++
> drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 2 +-
> drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 31 +++++++++---------------
> drivers/gpu/drm/aspeed/aspeed_gfx_out.c | 2 +-
> 4 files changed, 15 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index adc02940de6f..e7ca95827ae8 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -5,6 +5,7 @@
> #include <drm/drm_simple_kms_helper.h>
>
> struct aspeed_gfx {
> + struct drm_device drm;
> void __iomem *base;
> struct clk *clk;
> struct reset_control *rst;
> @@ -13,6 +14,7 @@ struct aspeed_gfx {
> struct drm_simple_display_pipe pipe;
> struct drm_connector connector;
> };
> +#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
>
> int aspeed_gfx_create_pipe(struct drm_device *drm);
> int aspeed_gfx_create_output(struct drm_device *drm);
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> index 2184b8be6fd4..e54686c31a90 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> @@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
>
> int aspeed_gfx_create_pipe(struct drm_device *drm)
> {
> - struct aspeed_gfx *priv = drm->dev_private;
> + struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>
> return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
> aspeed_gfx_formats,
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index ada2f6aca906..6b27242b9ee3 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> {
> struct drm_device *drm = data;
> - struct aspeed_gfx *priv = drm->dev_private;
> + struct aspeed_gfx *priv = to_aspeed_gfx(drm);
> u32 reg;
>
> reg = readl(priv->base + CRT_CTRL1);
> @@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> static int aspeed_gfx_load(struct drm_device *drm)
> {
> struct platform_device *pdev = to_platform_device(drm->dev);
> - struct aspeed_gfx *priv;
> + struct aspeed_gfx *priv = to_aspeed_gfx(drm);
> struct resource *res;
> int ret;
>
> - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> - if (!priv)
> - return -ENOMEM;
> - drm->dev_private = priv;
> -
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> priv->base = devm_ioremap_resource(drm->dev, res);
> if (IS_ERR(priv->base))
> @@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
> {
> drm_kms_helper_poll_fini(drm);
> drm_mode_config_cleanup(drm);
> -
> - drm->dev_private = NULL;
> }
>
> DEFINE_DRM_GEM_CMA_FOPS(fops);
> @@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
>
> static int aspeed_gfx_probe(struct platform_device *pdev)
> {
> - struct drm_device *drm;
> + struct aspeed_gfx *priv;
> int ret;
>
> - drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
> - if (IS_ERR(drm))
> - return PTR_ERR(drm);
> + priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
> + struct aspeed_gfx, drm);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
>
> - ret = aspeed_gfx_load(drm);
> + ret = aspeed_gfx_load(&priv->drm);
> if (ret)
> - goto err_free;
> + return ret;
>
> - ret = drm_dev_register(drm, 0);
> + ret = drm_dev_register(&priv->drm, 0);
> if (ret)
> goto err_unload;
>
> return 0;
>
> err_unload:
> - aspeed_gfx_unload(drm);
> -err_free:
> - drm_dev_put(drm);
> + aspeed_gfx_unload(&priv->drm);
>
> return ret;
> }
> @@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
>
> drm_dev_unregister(drm);
> aspeed_gfx_unload(drm);
> - drm_dev_put(drm);
>
> return 0;
> }
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> index 67ee5fa10055..6759cb88415a 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> @@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
>
> int aspeed_gfx_create_output(struct drm_device *drm)
> {
> - struct aspeed_gfx *priv = drm->dev_private;
> + struct aspeed_gfx *priv = to_aspeed_gfx(drm);
> int ret;
>
> priv->connector.dpms = DRM_MODE_DPMS_OFF;
> --
> 2.25.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-04-24 18:02 UTC|newest]
Thread overview: 142+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 7:39 [PATCH 00/59] devm_drm_dev_alloc, v2 Daniel Vetter
2020-04-15 7:39 ` [PATCH 01/59] drm: Add devm_drm_dev_alloc macro Daniel Vetter
2020-04-20 13:36 ` Thomas Zimmermann
2020-04-21 10:45 ` Daniel Vetter
2020-04-21 14:03 ` Thomas Zimmermann
2020-04-21 20:32 ` Sam Ravnborg
2020-04-28 13:06 ` Daniel Vetter
2020-04-15 7:39 ` [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define Daniel Vetter
2020-04-15 15:01 ` Hans de Goede
2020-04-15 7:39 ` [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 15:02 ` Hans de Goede
2020-04-24 16:33 ` Sam Ravnborg
2020-04-15 7:39 ` [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private Daniel Vetter
2020-04-15 15:02 ` Hans de Goede
2020-04-15 7:39 ` [PATCH 05/59] drm/vboxvidoe: use managed pci functions Daniel Vetter
2020-04-15 15:03 ` Hans de Goede
2020-04-15 17:44 ` Daniel Vetter
2020-04-20 13:16 ` Hans de Goede
2020-04-15 17:32 ` Thomas Zimmermann
2020-04-15 7:39 ` [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create Daniel Vetter
2020-04-15 15:04 ` Hans de Goede
2020-04-15 7:39 ` [PATCH 07/59] drm/v3d: Don't set drm_device->dev_private Daniel Vetter
2020-04-15 7:39 ` [PATCH 08/59] drm/v3d: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:39 ` [PATCH 09/59] drm/v3d: Delete v3d_dev->dev Daniel Vetter
2020-04-15 7:39 ` [PATCH 10/59] drm/v3d: Delete v3d_dev->pdev Daniel Vetter
2020-04-15 7:39 ` [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:55 ` Thomas Zimmermann
2020-04-24 14:55 ` Sam Ravnborg
2020-04-28 13:18 ` Daniel Vetter
2020-04-15 7:39 ` [PATCH 12/59] drm/udl: don't set drm_device->dev_private Daniel Vetter
2020-04-15 7:39 ` [PATCH 13/59] drm/st7735r: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:39 ` [PATCH 14/59] drm/st7586: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 15/59] drm/repaper: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 16/59] drm/mi0283qt: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 17/59] drm/ili9486: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 18/59] drm/ili9341: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 19/59] drm/ili9225: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 20/59] drm/hx8357d: " Daniel Vetter
2020-04-15 7:39 ` [PATCH 21/59] drm/gm12u320: " Daniel Vetter
2020-04-15 15:04 ` Hans de Goede
2020-04-15 7:39 ` [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private Daniel Vetter
2020-04-15 15:05 ` Hans de Goede
2020-04-15 7:39 ` [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc Daniel Vetter
2020-04-21 11:03 ` Tomi Valkeinen
2020-04-15 7:39 ` [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private Daniel Vetter
2020-04-21 11:05 ` Tomi Valkeinen
2020-04-15 7:40 ` [PATCH 25/59] drm/tidss: Delete tidss->saved_state Daniel Vetter
2020-04-21 11:05 ` Tomi Valkeinen
2020-04-15 7:40 ` [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc Daniel Vetter
2020-04-24 15:09 ` Sam Ravnborg
2020-04-28 14:00 ` Daniel Vetter
2020-04-28 17:00 ` Sam Ravnborg
2020-04-28 18:04 ` Daniel Vetter
2020-04-15 7:40 ` [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private Daniel Vetter
2020-04-24 15:12 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 12:20 ` Linus Walleij
2020-04-15 7:40 ` [PATCH 29/59] drm/mcde: Don't use drm_device->dev_private Daniel Vetter
2020-04-15 7:40 ` [PATCH 30/59] drm/ingenic: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:40 ` [PATCH 31/59] drm/ingenic: Don't set drm_device->dev_private Daniel Vetter
2020-04-15 7:40 ` [PATCH 32/59] drm/komeda: use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:40 ` [PATCH 33/59] drm/armada: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:40 ` [PATCH 34/59] drm/armada: Don't use drm_device->dev_private Daniel Vetter
2020-04-15 7:40 ` [PATCH 35/59] drm/cirrus: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15 7:40 ` [PATCH 36/59] drm/cirrus: Don't use drm_device->dev_private Daniel Vetter
2020-04-15 7:40 ` [PATCH 37/59] drm/cirrus: Move to drm/tiny Daniel Vetter
2020-04-15 8:01 ` Thomas Zimmermann
2020-04-15 8:19 ` Daniel Vetter
2020-04-15 8:46 ` Thomas Zimmermann
2020-04-15 9:31 ` Daniel Vetter
2020-04-21 7:37 ` Gerd Hoffmann
2020-04-24 16:37 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc Daniel Vetter
2020-04-28 18:52 ` Daniel Vetter
2020-04-15 7:40 ` [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc Daniel Vetter
2020-04-24 16:43 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private Daniel Vetter
2020-04-24 16:46 ` Sam Ravnborg
2020-09-04 13:42 ` Daniel Vetter
2020-09-04 14:42 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb Daniel Vetter
2020-04-24 16:47 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe Daniel Vetter
2020-04-24 17:34 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case Daniel Vetter
2020-04-24 17:34 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 44/59] drm/arc: Drop surplus connector registration Daniel Vetter
2020-04-24 16:51 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup Daniel Vetter
2020-04-24 17:36 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 46/59] drm/arc: Align with simple pipe helpers Daniel Vetter
2020-04-25 12:24 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper Daniel Vetter
2020-04-24 17:40 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update Daniel Vetter
2020-04-24 17:45 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c Daniel Vetter
2020-04-24 17:51 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init Daniel Vetter
2020-04-24 17:54 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 51/59] drm/arc: Inline remaining files Daniel Vetter
2020-04-24 17:56 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 52/59] drm/arc: Initialize sim connector before display pipe Daniel Vetter
2020-04-24 17:58 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 53/59] drm/arc: Move to drm/tiny Daniel Vetter
2020-04-15 8:04 ` Thomas Zimmermann
2020-04-15 8:22 ` Daniel Vetter
2020-04-15 9:45 ` Sam Ravnborg
2020-04-15 12:02 ` Alexey Brodkin
2020-04-15 12:20 ` Daniel Vetter
2020-04-28 14:08 ` Daniel Vetter
2020-05-08 13:56 ` Alexey Brodkin
2020-05-08 18:07 ` Daniel Vetter
2020-06-04 8:05 ` Daniel Vetter
2020-06-04 10:38 ` Eugeniy Paltsev
2020-06-04 11:19 ` Daniel Vetter
2020-06-04 19:00 ` Eugeniy Paltsev
2020-06-05 19:55 ` Daniel Vetter
2020-06-09 12:08 ` Eugeniy Paltsev
2020-06-09 13:02 ` Daniel Vetter
2020-07-17 9:04 ` Daniel Vetter
2020-04-15 7:40 ` [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev Daniel Vetter
2020-04-24 18:00 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc Daniel Vetter
2020-04-24 18:02 ` Sam Ravnborg [this message]
2020-04-15 7:40 ` [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup Daniel Vetter
2020-04-24 18:10 ` Sam Ravnborg
2020-04-28 14:12 ` Daniel Vetter
2020-04-28 17:03 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 57/59] drm/ast: Use managed pci functions Daniel Vetter
2020-04-15 7:52 ` Thomas Zimmermann
2020-04-15 8:09 ` Daniel Vetter
2020-04-15 8:17 ` Daniel Vetter
2020-04-15 12:23 ` Daniel Vetter
2020-06-11 12:04 ` Thomas Zimmermann
2020-06-16 11:55 ` Daniel Vetter
2020-04-15 7:40 ` [PATCH 58/59] drm/ast: Drop explicit connector register/unregister Daniel Vetter
2020-04-15 7:53 ` Thomas Zimmermann
2020-04-24 18:11 ` Sam Ravnborg
2020-04-15 7:40 ` [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register Daniel Vetter
2020-04-21 7:39 ` Gerd Hoffmann
2020-04-24 18:11 ` Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424180246.GK7074@ravnborg.org \
--to=sam@ravnborg.org \
--cc=andrew@aj.id.au \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).