Commit 8d8ff2a9 authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/mgag200: Convert struct drm_device to struct mga_device with helper



Mgag200 uses dev_private to look up struct mga_device for instances
of struct drm_device. Use of dev_private is deprecated, so hide it in
the helper function to_mga_device().

v2:
	* make to_mga_device() a function (Sam)

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200507090315.21274-2-tzimmermann@suse.de
parent 6e85bd73
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
			    uint32_t handle, uint32_t width, uint32_t height)
{
	struct drm_device *dev = crtc->dev;
	struct mga_device *mdev = (struct mga_device *)dev->dev_private;
	struct mga_device *mdev = to_mga_device(dev);
	struct drm_gem_object *obj;
	struct drm_gem_vram_object *gbo = NULL;
	int ret;
@@ -307,7 +307,7 @@ err_drm_gem_object_put_unlocked:

int mgag200_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
{
	struct mga_device *mdev = (struct mga_device *)crtc->dev->dev_private;
	struct mga_device *mdev = to_mga_device(crtc->dev);

	/* Our origin is at (64,64) */
	x += 64;
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ int mgag200_driver_dumb_create(struct drm_file *file,
			       struct drm_device *dev,
			       struct drm_mode_create_dumb *args)
{
	struct mga_device *mdev = dev->dev_private;
	struct mga_device *mdev = to_mga_device(dev);
	unsigned long pg_align;

	if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
+5 −0
Original line number Diff line number Diff line
@@ -182,6 +182,11 @@ struct mga_device {
	struct drm_encoder encoder;
};

static inline struct mga_device *to_mga_device(struct drm_device *dev)
{
	return dev->dev_private;
}

static inline enum mga_type
mgag200_type_from_driver_data(kernel_ulong_t driver_data)
{
+5 −5
Original line number Diff line number Diff line
@@ -61,34 +61,34 @@ static inline void mga_i2c_set(struct mga_device *mdev, int mask, int state)
static void mga_gpio_setsda(void *data, int state)
{
	struct mga_i2c_chan *i2c = data;
	struct mga_device *mdev = i2c->dev->dev_private;
	struct mga_device *mdev = to_mga_device(i2c->dev);
	mga_i2c_set(mdev, i2c->data, state);
}

static void mga_gpio_setscl(void *data, int state)
{
	struct mga_i2c_chan *i2c = data;
	struct mga_device *mdev = i2c->dev->dev_private;
	struct mga_device *mdev = to_mga_device(i2c->dev);
	mga_i2c_set(mdev, i2c->clock, state);
}

static int mga_gpio_getsda(void *data)
{
	struct mga_i2c_chan *i2c = data;
	struct mga_device *mdev = i2c->dev->dev_private;
	struct mga_device *mdev = to_mga_device(i2c->dev);
	return (mga_i2c_read_gpio(mdev) & i2c->data) ? 1 : 0;
}

static int mga_gpio_getscl(void *data)
{
	struct mga_i2c_chan *i2c = data;
	struct mga_device *mdev = i2c->dev->dev_private;
	struct mga_device *mdev = to_mga_device(i2c->dev);
	return (mga_i2c_read_gpio(mdev) & i2c->clock) ? 1 : 0;
}

struct mga_i2c_chan *mgag200_i2c_create(struct drm_device *dev)
{
	struct mga_device *mdev = dev->dev_private;
	struct mga_device *mdev = to_mga_device(dev);
	struct mga_i2c_chan *i2c;
	int ret;
	int data, clock;
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ static int mga_vram_init(struct mga_device *mdev)
static int mgag200_device_init(struct drm_device *dev,
			       uint32_t flags)
{
	struct mga_device *mdev = dev->dev_private;
	struct mga_device *mdev = to_mga_device(dev);
	int ret, option;

	mdev->flags = mgag200_flags_from_driver_data(flags);
@@ -195,7 +195,7 @@ err_mm:

void mgag200_driver_unload(struct drm_device *dev)
{
	struct mga_device *mdev = dev->dev_private;
	struct mga_device *mdev = to_mga_device(dev);

	if (mdev == NULL)
		return;
Loading