dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, david@lechnology.com,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 09/12] drm/tinydrm: Drop using tinydrm_device
Date: Sun, 10 Feb 2019 22:27:56 +0100	[thread overview]
Message-ID: <20190210212756.GE2983@ravnborg.org> (raw)
In-Reply-To: <20190210131039.52664-10-noralf@tronnes.org>

Hi Noralf.

On Sun, Feb 10, 2019 at 02:10:36PM +0100, Noralf Trønnes wrote:
> Use devm_drm_dev_init() and drop using tinydrm_device.
> 
> v2: devm_drm_dev_register() was dropped so add driver release callbacks.
> 
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
>  drivers/gpu/drm/tinydrm/hx8357d.c  |  40 +++++++++--
>  drivers/gpu/drm/tinydrm/ili9225.c  |  40 +++++++++--
>  drivers/gpu/drm/tinydrm/ili9341.c  |  40 +++++++++--
>  drivers/gpu/drm/tinydrm/mi0283qt.c |  40 +++++++++--
>  drivers/gpu/drm/tinydrm/mipi-dbi.c |  67 +++++++++++-------
>  drivers/gpu/drm/tinydrm/st7586.c   | 105 ++++++++++++++++-------------
>  drivers/gpu/drm/tinydrm/st7735r.c  |  40 +++++++++--
>  include/drm/tinydrm/mipi-dbi.h     |  26 ++++---
>  8 files changed, 294 insertions(+), 104 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c b/drivers/gpu/drm/tinydrm/hx8357d.c
> index 84dda622df85..e9b9e08fafc7 100644
> --- a/drivers/gpu/drm/tinydrm/hx8357d.c
> +++ b/drivers/gpu/drm/tinydrm/hx8357d.c
> @@ -18,6 +18,7 @@
>  
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_drv.h>
> +#include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_modeset_helper.h>
> @@ -189,6 +190,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
>  static struct drm_driver hx8357d_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
>  	.fops			= &hx8357d_fops,
> +	.release		= mipi_dbi_release,
>  	DRM_GEM_CMA_VMAP_DRIVER_OPS,
>  	.debugfs_init		= mipi_dbi_debugfs_init,
>  	.name			= "hx8357d",
> @@ -213,15 +215,25 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id);
>  static int hx8357d_probe(struct spi_device *spi)
>  {
>  	struct device *dev = &spi->dev;
> +	struct drm_device *drm;
>  	struct mipi_dbi *mipi;
>  	struct gpio_desc *dc;
>  	u32 rotation = 0;
>  	int ret;
>  
> -	mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
> +	mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
>  	if (!mipi)
>  		return -ENOMEM;
>  
> +	drm = &mipi->drm;
> +	ret = devm_drm_dev_init(dev, drm, &hx8357d_driver);
> +	if (ret) {
> +		kfree(mipi);
> +		return ret;
> +	}
> +
> +	drm_mode_config_init(drm);
> +
>  	dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
>  	if (IS_ERR(dc)) {
>  		DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
> @@ -238,14 +250,31 @@ static int hx8357d_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> -	ret = mipi_dbi_init(&spi->dev, mipi, &hx8357d_pipe_funcs,
> -			    &hx8357d_driver, &yx350hv15_mode, rotation);
> +	ret = mipi_dbi_init(mipi, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation);
>  	if (ret)
>  		return ret;
>  
> -	spi_set_drvdata(spi, mipi->tinydrm.drm);
> +	drm_mode_config_reset(drm);
>  
> -	return devm_tinydrm_register(&mipi->tinydrm);
> +	ret = drm_dev_register(drm, 0);
> +	if (ret)
> +		return ret;
> +
> +	spi_set_drvdata(spi, drm);
> +
> +	drm_fbdev_generic_setup(drm, 32);
> +
> +	return 0;
> +}
> +
> +static int hx8357d_remove(struct spi_device *spi)
> +{
> +	struct drm_device *drm = spi_get_drvdata(spi);
> +
> +	drm_dev_unplug(drm);
> +	drm_atomic_helper_shutdown(drm);
> +
> +	return 0;
>  }
The sample code uses drm_dev_unregister() in the _remove() function.
Do I miss something obvious?

	Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-02-10 21:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-10 13:10 [PATCH v2 00/12] drm/tinydrm: Remove tinydrm_device Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 01/12] drm/drv: Hold ref on parent device during drm_device lifetime Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 02/12] drm: Add devm_drm_dev_init() Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 03/12] drm/drv: DOC: Add driver example code Noralf Trønnes
2019-02-10 21:03   ` Sam Ravnborg
2019-02-12 13:20     ` Noralf Trønnes
2019-02-12 14:06   ` Daniel Vetter
2019-02-12 14:37     ` Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 04/12] drm/modes: Add DRM_SIMPLE_MODE() Noralf Trønnes
2019-02-10 21:05   ` Sam Ravnborg
2019-02-10 13:10 ` [PATCH v2 05/12] drm/tinydrm: tinydrm_display_pipe_init() don't use tinydrm_device Noralf Trønnes
2019-02-10 21:08   ` Sam Ravnborg
2019-02-10 13:10 ` [PATCH v2 06/12] drm/tinydrm: Remove tinydrm_shutdown() Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 07/12] drm/tinydrm/mipi-dbi: Add drm_to_mipi_dbi() Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 08/12] drm/tinydrm/repaper: Drop using tinydrm_device Noralf Trønnes
2019-02-10 21:25   ` Sam Ravnborg
2019-02-10 13:10 ` [PATCH v2 09/12] drm/tinydrm: " Noralf Trønnes
2019-02-10 21:27   ` Sam Ravnborg [this message]
2019-02-10 13:10 ` [PATCH v2 10/12] drm/tinydrm: Remove tinydrm_device Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 11/12] drm/tinydrm: Use drm_dev_enter/exit() Noralf Trønnes
2019-02-10 13:10 ` [PATCH v2 12/12] drm/fb-helper: generic: Don't take module ref for fbcon Noralf Trønnes

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=20190210212756.GE2983@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=noralf@tronnes.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