Commit 0454bc59 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/tiny/gm12u320: 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 gm12u320_to_usb_device()
v2:
	* upcast dev with drm_dev_get_usb_device()
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20201103113456.3066-2-tzimmermann@suse.de
parent 2d26123d
...@@ -45,7 +45,7 @@ MODULE_PARM_DESC(eco_mode, "Turn on Eco mode (less bright, more silent)"); ...@@ -45,7 +45,7 @@ MODULE_PARM_DESC(eco_mode, "Turn on Eco mode (less bright, more silent)");
#define GM12U320_BLOCK_COUNT 20 #define GM12U320_BLOCK_COUNT 20
#define GM12U320_ERR(fmt, ...) \ #define GM12U320_ERR(fmt, ...) \
DRM_DEV_ERROR(&gm12u320->udev->dev, fmt, ##__VA_ARGS__) DRM_DEV_ERROR(gm12u320->dev.dev, fmt, ##__VA_ARGS__)
#define MISC_RCV_EPT 1 #define MISC_RCV_EPT 1
#define DATA_RCV_EPT 2 #define DATA_RCV_EPT 2
...@@ -85,7 +85,6 @@ struct gm12u320_device { ...@@ -85,7 +85,6 @@ struct gm12u320_device {
struct drm_device dev; struct drm_device dev;
struct drm_simple_display_pipe pipe; struct drm_simple_display_pipe pipe;
struct drm_connector conn; struct drm_connector conn;
struct usb_device *udev;
unsigned char *cmd_buf; unsigned char *cmd_buf;
unsigned char *data_buf[GM12U320_BLOCK_COUNT]; unsigned char *data_buf[GM12U320_BLOCK_COUNT];
struct { struct {
...@@ -155,6 +154,11 @@ static const char data_block_footer[DATA_BLOCK_FOOTER_SIZE] = { ...@@ -155,6 +154,11 @@ static const char data_block_footer[DATA_BLOCK_FOOTER_SIZE] = {
0x80, 0x00, 0x00, 0x4f 0x80, 0x00, 0x00, 0x4f
}; };
static inline struct usb_device *gm12u320_to_usb_device(struct gm12u320_device *gm12u320)
{
return interface_to_usbdev(to_usb_interface(gm12u320->dev.dev));
}
static int gm12u320_usb_alloc(struct gm12u320_device *gm12u320) static int gm12u320_usb_alloc(struct gm12u320_device *gm12u320)
{ {
int i, block_size; int i, block_size;
...@@ -191,6 +195,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320, ...@@ -191,6 +195,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
u8 req_a, u8 req_b, u8 req_a, u8 req_b,
u8 arg_a, u8 arg_b, u8 arg_c, u8 arg_d) u8 arg_a, u8 arg_b, u8 arg_c, u8 arg_d)
{ {
struct usb_device *udev = gm12u320_to_usb_device(gm12u320);
int ret, len; int ret, len;
memcpy(gm12u320->cmd_buf, &cmd_misc, CMD_SIZE); memcpy(gm12u320->cmd_buf, &cmd_misc, CMD_SIZE);
...@@ -202,8 +207,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320, ...@@ -202,8 +207,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
gm12u320->cmd_buf[25] = arg_d; gm12u320->cmd_buf[25] = arg_d;
/* Send request */ /* Send request */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, MISC_SND_EPT),
usb_sndbulkpipe(gm12u320->udev, MISC_SND_EPT),
gm12u320->cmd_buf, CMD_SIZE, &len, CMD_TIMEOUT); gm12u320->cmd_buf, CMD_SIZE, &len, CMD_TIMEOUT);
if (ret || len != CMD_SIZE) { if (ret || len != CMD_SIZE) {
GM12U320_ERR("Misc. req. error %d\n", ret); GM12U320_ERR("Misc. req. error %d\n", ret);
...@@ -211,8 +215,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320, ...@@ -211,8 +215,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
} }
/* Read value */ /* Read value */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, MISC_RCV_EPT),
usb_rcvbulkpipe(gm12u320->udev, MISC_RCV_EPT),
gm12u320->cmd_buf, MISC_VALUE_SIZE, &len, gm12u320->cmd_buf, MISC_VALUE_SIZE, &len,
DATA_TIMEOUT); DATA_TIMEOUT);
if (ret || len != MISC_VALUE_SIZE) { if (ret || len != MISC_VALUE_SIZE) {
...@@ -222,8 +225,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320, ...@@ -222,8 +225,7 @@ static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
/* cmd_buf[0] now contains the read value, which we don't use */ /* cmd_buf[0] now contains the read value, which we don't use */
/* Read status */ /* Read status */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, MISC_RCV_EPT),
usb_rcvbulkpipe(gm12u320->udev, MISC_RCV_EPT),
gm12u320->cmd_buf, READ_STATUS_SIZE, &len, gm12u320->cmd_buf, READ_STATUS_SIZE, &len,
CMD_TIMEOUT); CMD_TIMEOUT);
if (ret || len != READ_STATUS_SIZE) { if (ret || len != READ_STATUS_SIZE) {
...@@ -331,6 +333,7 @@ static void gm12u320_fb_update_work(struct work_struct *work) ...@@ -331,6 +333,7 @@ static void gm12u320_fb_update_work(struct work_struct *work)
struct gm12u320_device *gm12u320 = struct gm12u320_device *gm12u320 =
container_of(to_delayed_work(work), struct gm12u320_device, container_of(to_delayed_work(work), struct gm12u320_device,
fb_update.work); fb_update.work);
struct usb_device *udev = gm12u320_to_usb_device(gm12u320);
int block, block_size, len; int block, block_size, len;
int ret = 0; int ret = 0;
...@@ -350,43 +353,41 @@ static void gm12u320_fb_update_work(struct work_struct *work) ...@@ -350,43 +353,41 @@ static void gm12u320_fb_update_work(struct work_struct *work)
gm12u320->cmd_buf[21] = gm12u320->cmd_buf[21] =
block | (gm12u320->fb_update.frame << 7); block | (gm12u320->fb_update.frame << 7);
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev,
usb_sndbulkpipe(gm12u320->udev, DATA_SND_EPT), usb_sndbulkpipe(udev, DATA_SND_EPT),
gm12u320->cmd_buf, CMD_SIZE, &len, gm12u320->cmd_buf, CMD_SIZE, &len,
CMD_TIMEOUT); CMD_TIMEOUT);
if (ret || len != CMD_SIZE) if (ret || len != CMD_SIZE)
goto err; goto err;
/* Send data block to device */ /* Send data block to device */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev,
usb_sndbulkpipe(gm12u320->udev, DATA_SND_EPT), usb_sndbulkpipe(udev, DATA_SND_EPT),
gm12u320->data_buf[block], block_size, gm12u320->data_buf[block], block_size,
&len, DATA_TIMEOUT); &len, DATA_TIMEOUT);
if (ret || len != block_size) if (ret || len != block_size)
goto err; goto err;
/* Read status */ /* Read status */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev,
usb_rcvbulkpipe(gm12u320->udev, DATA_RCV_EPT), usb_rcvbulkpipe(udev, DATA_RCV_EPT),
gm12u320->cmd_buf, READ_STATUS_SIZE, &len, gm12u320->cmd_buf, READ_STATUS_SIZE, &len,
CMD_TIMEOUT); CMD_TIMEOUT);
if (ret || len != READ_STATUS_SIZE) if (ret || len != READ_STATUS_SIZE)
goto err; goto err;
} }
/* Send draw command to device */ /* Send draw command to device */
memcpy(gm12u320->cmd_buf, cmd_draw, CMD_SIZE); memcpy(gm12u320->cmd_buf, cmd_draw, CMD_SIZE);
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, DATA_SND_EPT),
usb_sndbulkpipe(gm12u320->udev, DATA_SND_EPT), gm12u320->cmd_buf, CMD_SIZE, &len, CMD_TIMEOUT);
gm12u320->cmd_buf, CMD_SIZE, &len, CMD_TIMEOUT);
if (ret || len != CMD_SIZE) if (ret || len != CMD_SIZE)
goto err; goto err;
/* Read status */ /* Read status */
ret = usb_bulk_msg(gm12u320->udev, ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, DATA_RCV_EPT),
usb_rcvbulkpipe(gm12u320->udev, DATA_RCV_EPT), gm12u320->cmd_buf, READ_STATUS_SIZE, &len,
gm12u320->cmd_buf, READ_STATUS_SIZE, &len, gm12u320->fb_update.draw_status_timeout);
gm12u320->fb_update.draw_status_timeout);
if (ret || len != READ_STATUS_SIZE) if (ret || len != READ_STATUS_SIZE)
goto err; goto err;
...@@ -638,7 +639,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface, ...@@ -638,7 +639,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
if (IS_ERR(gm12u320)) if (IS_ERR(gm12u320))
return PTR_ERR(gm12u320); return PTR_ERR(gm12u320);
gm12u320->udev = interface_to_usbdev(interface);
INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work); INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
mutex_init(&gm12u320->fb_update.lock); mutex_init(&gm12u320->fb_update.lock);
......
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