Commit 24cb483b authored by Dave Airlie's avatar Dave Airlie Committed by Greg Kroah-Hartman

drm/udl: introduce a macro to convert dev to udl.

commit fd96e0dba19c53c2d66f2a398716bb74df8ca85e upstream.

This just makes it easier to later embed drm into udl.

[rez] Regarding the backport to v4.14.y, the only difference is due to
the fact that in v4.14.y the udl_gem_mmap() function doesn't have a
local 'struct udl_device' pointer so it didn't need to be converted.
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190405031715.5959-3-airlied@gmail.comSigned-off-by: default avatarRoss Zwisler <zwisler@google.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 772cabe2
...@@ -68,6 +68,8 @@ struct udl_device { ...@@ -68,6 +68,8 @@ struct udl_device {
atomic_t cpu_kcycles_used; /* transpired during pixel processing */ atomic_t cpu_kcycles_used; /* transpired during pixel processing */
}; };
#define to_udl(x) ((x)->dev_private)
struct udl_gem_object { struct udl_gem_object {
struct drm_gem_object base; struct drm_gem_object base;
struct page **pages; struct page **pages;
......
...@@ -82,7 +82,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, ...@@ -82,7 +82,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
int width, int height) int width, int height)
{ {
struct drm_device *dev = fb->base.dev; struct drm_device *dev = fb->base.dev;
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
int i, ret; int i, ret;
char *cmd; char *cmd;
cycles_t start_cycles, end_cycles; cycles_t start_cycles, end_cycles;
...@@ -210,7 +210,7 @@ static int udl_fb_open(struct fb_info *info, int user) ...@@ -210,7 +210,7 @@ static int udl_fb_open(struct fb_info *info, int user)
{ {
struct udl_fbdev *ufbdev = info->par; struct udl_fbdev *ufbdev = info->par;
struct drm_device *dev = ufbdev->ufb.base.dev; struct drm_device *dev = ufbdev->ufb.base.dev;
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
/* If the USB device is gone, we don't accept new opens */ /* If the USB device is gone, we don't accept new opens */
if (drm_dev_is_unplugged(udl->ddev)) if (drm_dev_is_unplugged(udl->ddev))
...@@ -441,7 +441,7 @@ static void udl_fbdev_destroy(struct drm_device *dev, ...@@ -441,7 +441,7 @@ static void udl_fbdev_destroy(struct drm_device *dev,
int udl_fbdev_init(struct drm_device *dev) int udl_fbdev_init(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
int bpp_sel = fb_bpp; int bpp_sel = fb_bpp;
struct udl_fbdev *ufbdev; struct udl_fbdev *ufbdev;
int ret; int ret;
...@@ -480,7 +480,7 @@ int udl_fbdev_init(struct drm_device *dev) ...@@ -480,7 +480,7 @@ int udl_fbdev_init(struct drm_device *dev)
void udl_fbdev_cleanup(struct drm_device *dev) void udl_fbdev_cleanup(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
if (!udl->fbdev) if (!udl->fbdev)
return; return;
...@@ -491,7 +491,7 @@ void udl_fbdev_cleanup(struct drm_device *dev) ...@@ -491,7 +491,7 @@ void udl_fbdev_cleanup(struct drm_device *dev)
void udl_fbdev_unplug(struct drm_device *dev) void udl_fbdev_unplug(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
struct udl_fbdev *ufbdev; struct udl_fbdev *ufbdev;
if (!udl->fbdev) if (!udl->fbdev)
return; return;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
static int udl_parse_vendor_descriptor(struct drm_device *dev, static int udl_parse_vendor_descriptor(struct drm_device *dev,
struct usb_device *usbdev) struct usb_device *usbdev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
char *desc; char *desc;
char *buf; char *buf;
char *desc_end; char *desc_end;
...@@ -164,7 +164,7 @@ void udl_urb_completion(struct urb *urb) ...@@ -164,7 +164,7 @@ void udl_urb_completion(struct urb *urb)
static void udl_free_urb_list(struct drm_device *dev) static void udl_free_urb_list(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
int count = udl->urbs.count; int count = udl->urbs.count;
struct list_head *node; struct list_head *node;
struct urb_node *unode; struct urb_node *unode;
...@@ -198,7 +198,7 @@ static void udl_free_urb_list(struct drm_device *dev) ...@@ -198,7 +198,7 @@ static void udl_free_urb_list(struct drm_device *dev)
static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size) static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
struct urb *urb; struct urb *urb;
struct urb_node *unode; struct urb_node *unode;
char *buf; char *buf;
...@@ -262,7 +262,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size) ...@@ -262,7 +262,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
struct urb *udl_get_urb(struct drm_device *dev) struct urb *udl_get_urb(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
int ret = 0; int ret = 0;
struct list_head *entry; struct list_head *entry;
struct urb_node *unode; struct urb_node *unode;
...@@ -296,7 +296,7 @@ struct urb *udl_get_urb(struct drm_device *dev) ...@@ -296,7 +296,7 @@ struct urb *udl_get_urb(struct drm_device *dev)
int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len) int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
int ret; int ret;
BUG_ON(len > udl->urbs.size); BUG_ON(len > udl->urbs.size);
...@@ -372,7 +372,7 @@ int udl_drop_usb(struct drm_device *dev) ...@@ -372,7 +372,7 @@ int udl_drop_usb(struct drm_device *dev)
void udl_driver_unload(struct drm_device *dev) void udl_driver_unload(struct drm_device *dev)
{ {
struct udl_device *udl = dev->dev_private; struct udl_device *udl = to_udl(dev);
if (udl->urbs.count) if (udl->urbs.count)
udl_free_urb_list(dev); udl_free_urb_list(dev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment