summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/udl
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2020-11-03 12:34:56 +0100
committerThomas Zimmermann <tzimmermann@suse.de>2020-11-09 09:16:13 +0100
commit3fb91f56aea4608adebf7798788ac98b42a13838 (patch)
treef32432ff79d83624a73291f4aa1b69918f40ccf9 /drivers/gpu/drm/udl
parent0454bc59be9e988422793f55a089ee4e86f11f25 (diff)
drm/udl: Retrieve USB device from struct drm_device.dev
Drop the driver's udev field in favor of struct drm_device.dev. No functional changes made. v3: * upcast dev with udl_to_usb_device() v2: * upcast dev with drm_dev_get_usb_device() Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20201103113456.3066-3-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/udl')
-rw-r--r--drivers/gpu/drm/udl/udl_connector.c8
-rw-r--r--drivers/gpu/drm/udl/udl_drv.c3
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h6
-rw-r--r--drivers/gpu/drm/udl/udl_main.c23
4 files changed, 21 insertions, 19 deletions
diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index cdc1c42e1669..3750fd216131 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -20,6 +20,7 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block,
int ret, i;
u8 *read_buff;
struct udl_device *udl = data;
+ struct usb_device *udev = udl_to_usb_device(udl);
read_buff = kmalloc(2, GFP_KERNEL);
if (!read_buff)
@@ -27,10 +28,9 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block,
for (i = 0; i < len; i++) {
int bval = (i + block * EDID_LENGTH) << 8;
- ret = usb_control_msg(udl->udev,
- usb_rcvctrlpipe(udl->udev, 0),
- (0x02), (0x80 | (0x02 << 5)), bval,
- 0xA1, read_buff, 2, HZ);
+ ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ 0x02, (0x80 | (0x02 << 5)), bval,
+ 0xA1, read_buff, 2, HZ);
if (ret < 1) {
DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
kfree(read_buff);
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 46df4d07bd7b..b5a8dd9fdf02 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -53,7 +53,6 @@ static const struct drm_driver driver = {
static struct udl_device *udl_driver_create(struct usb_interface *interface)
{
- struct usb_device *udev = interface_to_usbdev(interface);
struct udl_device *udl;
int r;
@@ -62,8 +61,6 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
if (IS_ERR(udl))
return udl;
- udl->udev = udev;
-
r = udl_init(udl);
if (r)
return ERR_PTR(r);
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index b1461f30780b..875e73551ae9 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -50,7 +50,6 @@ struct urb_list {
struct udl_device {
struct drm_device drm;
struct device *dev;
- struct usb_device *udev;
struct drm_simple_display_pipe display_pipe;
@@ -66,6 +65,11 @@ struct udl_device {
#define to_udl(x) container_of(x, struct udl_device, drm)
+static inline struct usb_device *udl_to_usb_device(struct udl_device *udl)
+{
+ return interface_to_usbdev(to_usb_interface(udl->drm.dev));
+}
+
/* modeset */
int udl_modeset_init(struct drm_device *dev);
struct drm_connector *udl_connector_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index f5d27f2a5654..0e2a376cb075 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -26,10 +26,9 @@
#define GET_URB_TIMEOUT HZ
#define FREE_URB_TIMEOUT (HZ*2)
-static int udl_parse_vendor_descriptor(struct drm_device *dev,
- struct usb_device *usbdev)
+static int udl_parse_vendor_descriptor(struct udl_device *udl)
{
- struct udl_device *udl = to_udl(dev);
+ struct usb_device *udev = udl_to_usb_device(udl);
char *desc;
char *buf;
char *desc_end;
@@ -41,7 +40,7 @@ static int udl_parse_vendor_descriptor(struct drm_device *dev,
return false;
desc = buf;
- total_len = usb_get_descriptor(usbdev, 0x5f, /* vendor specific */
+ total_len = usb_get_descriptor(udev, 0x5f, /* vendor specific */
0, desc, MAX_VENDOR_DESCRIPTOR_SIZE);
if (total_len > 5) {
DRM_INFO("vendor descriptor length:%x data:%11ph\n",
@@ -98,19 +97,20 @@ success:
*/
static int udl_select_std_channel(struct udl_device *udl)
{
- int ret;
static const u8 set_def_chn[] = {0x57, 0xCD, 0xDC, 0xA7,
0x1C, 0x88, 0x5E, 0x15,
0x60, 0xFE, 0xC6, 0x97,
0x16, 0x3D, 0x47, 0xF2};
+
void *sendbuf;
+ int ret;
+ struct usb_device *udev = udl_to_usb_device(udl);
sendbuf = kmemdup(set_def_chn, sizeof(set_def_chn), GFP_KERNEL);
if (!sendbuf)
return -ENOMEM;
- ret = usb_control_msg(udl->udev,
- usb_sndctrlpipe(udl->udev, 0),
+ ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
NR_USB_REQUEST_CHANNEL,
(USB_DIR_OUT | USB_TYPE_VENDOR), 0, 0,
sendbuf, sizeof(set_def_chn),
@@ -202,6 +202,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
struct urb_node *unode;
char *buf;
size_t wanted_size = count * size;
+ struct usb_device *udev = udl_to_usb_device(udl);
spin_lock_init(&udl->urbs.lock);
@@ -229,7 +230,7 @@ retry:
}
unode->urb = urb;
- buf = usb_alloc_coherent(udl->udev, size, GFP_KERNEL,
+ buf = usb_alloc_coherent(udev, size, GFP_KERNEL,
&urb->transfer_dma);
if (!buf) {
kfree(unode);
@@ -243,8 +244,8 @@ retry:
}
/* urb->transfer_buffer_length set to actual before submit */
- usb_fill_bulk_urb(urb, udl->udev, usb_sndbulkpipe(udl->udev, 1),
- buf, size, udl_urb_completion, unode);
+ usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, 1),
+ buf, size, udl_urb_completion, unode);
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
list_add_tail(&unode->entry, &udl->urbs.list);
@@ -316,7 +317,7 @@ int udl_init(struct udl_device *udl)
mutex_init(&udl->gem_lock);
- if (!udl_parse_vendor_descriptor(dev, udl->udev)) {
+ if (!udl_parse_vendor_descriptor(udl)) {
ret = -ENODEV;
DRM_ERROR("firmware not recognized. Assume incompatible device\n");
goto err;