Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/qxl: Don't use drm_device->dev_private

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-28-daniel.vetter@ffwll.ch

+38 -40
+3 -4
drivers/gpu/drm/qxl/qxl_debugfs.c
··· 39 39 qxl_debugfs_irq_received(struct seq_file *m, void *data) 40 40 { 41 41 struct drm_info_node *node = (struct drm_info_node *) m->private; 42 - struct qxl_device *qdev = node->minor->dev->dev_private; 42 + struct qxl_device *qdev = to_qxl(node->minor->dev); 43 43 44 44 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received)); 45 45 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display)); ··· 53 53 qxl_debugfs_buffers_info(struct seq_file *m, void *data) 54 54 { 55 55 struct drm_info_node *node = (struct drm_info_node *) m->private; 56 - struct qxl_device *qdev = node->minor->dev->dev_private; 56 + struct qxl_device *qdev = to_qxl(node->minor->dev); 57 57 struct qxl_bo *bo; 58 58 59 59 list_for_each_entry(bo, &qdev->gem.objects, list) { ··· 83 83 qxl_debugfs_init(struct drm_minor *minor) 84 84 { 85 85 #if defined(CONFIG_DEBUG_FS) 86 - struct qxl_device *dev = 87 - (struct qxl_device *) minor->dev->dev_private; 86 + struct qxl_device *dev = to_qxl(minor->dev); 88 87 89 88 drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES, 90 89 minor->debugfs_root, minor);
+16 -16
drivers/gpu/drm/qxl/qxl_display.c
··· 221 221 bool preferred) 222 222 { 223 223 struct drm_device *dev = connector->dev; 224 - struct qxl_device *qdev = dev->dev_private; 224 + struct qxl_device *qdev = to_qxl(dev); 225 225 struct drm_display_mode *mode = NULL; 226 226 int rc; 227 227 ··· 242 242 static int qxl_add_monitors_config_modes(struct drm_connector *connector) 243 243 { 244 244 struct drm_device *dev = connector->dev; 245 - struct qxl_device *qdev = dev->dev_private; 245 + struct qxl_device *qdev = to_qxl(dev); 246 246 struct qxl_output *output = drm_connector_to_qxl_output(connector); 247 247 int h = output->index; 248 248 struct qxl_head *head; ··· 310 310 const char *reason) 311 311 { 312 312 struct drm_device *dev = crtc->dev; 313 - struct qxl_device *qdev = dev->dev_private; 313 + struct qxl_device *qdev = to_qxl(dev); 314 314 struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); 315 315 struct qxl_head head; 316 316 int oldcount, i = qcrtc->index; ··· 400 400 unsigned int num_clips) 401 401 { 402 402 /* TODO: vmwgfx where this was cribbed from had locking. Why? */ 403 - struct qxl_device *qdev = fb->dev->dev_private; 403 + struct qxl_device *qdev = to_qxl(fb->dev); 404 404 struct drm_clip_rect norect; 405 405 struct qxl_bo *qobj; 406 406 bool is_primary; ··· 462 462 static int qxl_primary_atomic_check(struct drm_plane *plane, 463 463 struct drm_plane_state *state) 464 464 { 465 - struct qxl_device *qdev = plane->dev->dev_private; 465 + struct qxl_device *qdev = to_qxl(plane->dev); 466 466 struct qxl_bo *bo; 467 467 468 468 if (!state->crtc || !state->fb) ··· 476 476 static int qxl_primary_apply_cursor(struct drm_plane *plane) 477 477 { 478 478 struct drm_device *dev = plane->dev; 479 - struct qxl_device *qdev = dev->dev_private; 479 + struct qxl_device *qdev = to_qxl(dev); 480 480 struct drm_framebuffer *fb = plane->state->fb; 481 481 struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc); 482 482 struct qxl_cursor_cmd *cmd; ··· 523 523 static void qxl_primary_atomic_update(struct drm_plane *plane, 524 524 struct drm_plane_state *old_state) 525 525 { 526 - struct qxl_device *qdev = plane->dev->dev_private; 526 + struct qxl_device *qdev = to_qxl(plane->dev); 527 527 struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]); 528 528 struct qxl_bo *primary; 529 529 struct drm_clip_rect norect = { ··· 554 554 static void qxl_primary_atomic_disable(struct drm_plane *plane, 555 555 struct drm_plane_state *old_state) 556 556 { 557 - struct qxl_device *qdev = plane->dev->dev_private; 557 + struct qxl_device *qdev = to_qxl(plane->dev); 558 558 559 559 if (old_state->fb) { 560 560 struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]); ··· 570 570 struct drm_plane_state *old_state) 571 571 { 572 572 struct drm_device *dev = plane->dev; 573 - struct qxl_device *qdev = dev->dev_private; 573 + struct qxl_device *qdev = to_qxl(dev); 574 574 struct drm_framebuffer *fb = plane->state->fb; 575 575 struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc); 576 576 struct qxl_release *release; ··· 679 679 static void qxl_cursor_atomic_disable(struct drm_plane *plane, 680 680 struct drm_plane_state *old_state) 681 681 { 682 - struct qxl_device *qdev = plane->dev->dev_private; 682 + struct qxl_device *qdev = to_qxl(plane->dev); 683 683 struct qxl_release *release; 684 684 struct qxl_cursor_cmd *cmd; 685 685 int ret; ··· 762 762 static int qxl_plane_prepare_fb(struct drm_plane *plane, 763 763 struct drm_plane_state *new_state) 764 764 { 765 - struct qxl_device *qdev = plane->dev->dev_private; 765 + struct qxl_device *qdev = to_qxl(plane->dev); 766 766 struct drm_gem_object *obj; 767 767 struct qxl_bo *user_bo; 768 768 struct qxl_surface surf; ··· 923 923 { 924 924 struct qxl_crtc *qxl_crtc; 925 925 struct drm_plane *primary, *cursor; 926 - struct qxl_device *qdev = dev->dev_private; 926 + struct qxl_device *qdev = to_qxl(dev); 927 927 int r; 928 928 929 929 qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL); ··· 965 965 static int qxl_conn_get_modes(struct drm_connector *connector) 966 966 { 967 967 struct drm_device *dev = connector->dev; 968 - struct qxl_device *qdev = dev->dev_private; 968 + struct qxl_device *qdev = to_qxl(dev); 969 969 struct qxl_output *output = drm_connector_to_qxl_output(connector); 970 970 unsigned int pwidth = 1024; 971 971 unsigned int pheight = 768; ··· 991 991 struct drm_display_mode *mode) 992 992 { 993 993 struct drm_device *ddev = connector->dev; 994 - struct qxl_device *qdev = ddev->dev_private; 994 + struct qxl_device *qdev = to_qxl(ddev); 995 995 996 996 if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0) 997 997 return MODE_BAD; ··· 1021 1021 struct qxl_output *output = 1022 1022 drm_connector_to_qxl_output(connector); 1023 1023 struct drm_device *ddev = connector->dev; 1024 - struct qxl_device *qdev = ddev->dev_private; 1024 + struct qxl_device *qdev = to_qxl(ddev); 1025 1025 bool connected = false; 1026 1026 1027 1027 /* The first monitor is always connected */ ··· 1071 1071 1072 1072 static int qdev_output_init(struct drm_device *dev, int num_output) 1073 1073 { 1074 - struct qxl_device *qdev = dev->dev_private; 1074 + struct qxl_device *qdev = to_qxl(dev); 1075 1075 struct qxl_output *qxl_output; 1076 1076 struct drm_connector *connector; 1077 1077 struct drm_encoder *encoder;
+4 -4
drivers/gpu/drm/qxl/qxl_drv.c
··· 137 137 138 138 static void qxl_drm_release(struct drm_device *dev) 139 139 { 140 - struct qxl_device *qdev = dev->dev_private; 140 + struct qxl_device *qdev = to_qxl(dev); 141 141 142 142 /* 143 143 * TODO: qxl_device_fini() call should be in qxl_pci_remove(), ··· 164 164 static int qxl_drm_freeze(struct drm_device *dev) 165 165 { 166 166 struct pci_dev *pdev = dev->pdev; 167 - struct qxl_device *qdev = dev->dev_private; 167 + struct qxl_device *qdev = to_qxl(dev); 168 168 int ret; 169 169 170 170 ret = drm_mode_config_helper_suspend(dev); ··· 186 186 187 187 static int qxl_drm_resume(struct drm_device *dev, bool thaw) 188 188 { 189 - struct qxl_device *qdev = dev->dev_private; 189 + struct qxl_device *qdev = to_qxl(dev); 190 190 191 191 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK; 192 192 if (!thaw) { ··· 245 245 { 246 246 struct pci_dev *pdev = to_pci_dev(dev); 247 247 struct drm_device *drm_dev = pci_get_drvdata(pdev); 248 - struct qxl_device *qdev = drm_dev->dev_private; 248 + struct qxl_device *qdev = to_qxl(drm_dev); 249 249 250 250 qxl_io_reset(qdev); 251 251 return qxl_drm_resume(drm_dev, false);
+2 -2
drivers/gpu/drm/qxl/qxl_drv.h
··· 192 192 193 193 int qxl_debugfs_fence_init(struct qxl_device *rdev); 194 194 195 - struct qxl_device; 196 - 197 195 struct qxl_device { 198 196 struct drm_device ddev; 199 197 ··· 270 272 int monitors_config_width; 271 273 int monitors_config_height; 272 274 }; 275 + 276 + #define to_qxl(dev) container_of(dev, struct qxl_device, ddev) 273 277 274 278 extern const struct drm_ioctl_desc qxl_ioctls[]; 275 279 extern int qxl_max_ioctl;
+1 -1
drivers/gpu/drm/qxl/qxl_dumb.c
··· 32 32 struct drm_device *dev, 33 33 struct drm_mode_create_dumb *args) 34 34 { 35 - struct qxl_device *qdev = dev->dev_private; 35 + struct qxl_device *qdev = to_qxl(dev); 36 36 struct qxl_bo *qobj; 37 37 uint32_t handle; 38 38 int r;
+1 -1
drivers/gpu/drm/qxl/qxl_gem.c
··· 34 34 struct qxl_device *qdev; 35 35 struct ttm_buffer_object *tbo; 36 36 37 - qdev = (struct qxl_device *)gobj->dev->dev_private; 37 + qdev = to_qxl(gobj->dev); 38 38 39 39 qxl_surface_evict(qdev, qobj, false); 40 40
+7 -7
drivers/gpu/drm/qxl/qxl_ioctl.c
··· 36 36 static int qxl_alloc_ioctl(struct drm_device *dev, void *data, 37 37 struct drm_file *file_priv) 38 38 { 39 - struct qxl_device *qdev = dev->dev_private; 39 + struct qxl_device *qdev = to_qxl(dev); 40 40 struct drm_qxl_alloc *qxl_alloc = data; 41 41 int ret; 42 42 struct qxl_bo *qobj; ··· 64 64 static int qxl_map_ioctl(struct drm_device *dev, void *data, 65 65 struct drm_file *file_priv) 66 66 { 67 - struct qxl_device *qdev = dev->dev_private; 67 + struct qxl_device *qdev = to_qxl(dev); 68 68 struct drm_qxl_map *qxl_map = data; 69 69 70 70 return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle, ··· 279 279 static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, 280 280 struct drm_file *file_priv) 281 281 { 282 - struct qxl_device *qdev = dev->dev_private; 282 + struct qxl_device *qdev = to_qxl(dev); 283 283 struct drm_qxl_execbuffer *execbuffer = data; 284 284 struct drm_qxl_command user_cmd; 285 285 int cmd_num; ··· 304 304 static int qxl_update_area_ioctl(struct drm_device *dev, void *data, 305 305 struct drm_file *file) 306 306 { 307 - struct qxl_device *qdev = dev->dev_private; 307 + struct qxl_device *qdev = to_qxl(dev); 308 308 struct drm_qxl_update_area *update_area = data; 309 309 struct qxl_rect area = {.left = update_area->left, 310 310 .top = update_area->top, ··· 354 354 static int qxl_getparam_ioctl(struct drm_device *dev, void *data, 355 355 struct drm_file *file_priv) 356 356 { 357 - struct qxl_device *qdev = dev->dev_private; 357 + struct qxl_device *qdev = to_qxl(dev); 358 358 struct drm_qxl_getparam *param = data; 359 359 360 360 switch (param->param) { ··· 373 373 static int qxl_clientcap_ioctl(struct drm_device *dev, void *data, 374 374 struct drm_file *file_priv) 375 375 { 376 - struct qxl_device *qdev = dev->dev_private; 376 + struct qxl_device *qdev = to_qxl(dev); 377 377 struct drm_qxl_clientcap *param = data; 378 378 int byte, idx; 379 379 ··· 394 394 static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, 395 395 struct drm_file *file) 396 396 { 397 - struct qxl_device *qdev = dev->dev_private; 397 + struct qxl_device *qdev = to_qxl(dev); 398 398 struct drm_qxl_alloc_surf *param = data; 399 399 struct qxl_bo *qobj; 400 400 int handle;
+1 -1
drivers/gpu/drm/qxl/qxl_irq.c
··· 32 32 irqreturn_t qxl_irq_handler(int irq, void *arg) 33 33 { 34 34 struct drm_device *dev = (struct drm_device *) arg; 35 - struct qxl_device *qdev = (struct qxl_device *)dev->dev_private; 35 + struct qxl_device *qdev = to_qxl(dev); 36 36 uint32_t pending; 37 37 38 38 pending = xchg(&qdev->ram_header->int_pending, 0);
-1
drivers/gpu/drm/qxl/qxl_kms.c
··· 114 114 115 115 qdev->ddev.pdev = pdev; 116 116 pci_set_drvdata(pdev, &qdev->ddev); 117 - qdev->ddev.dev_private = qdev; 118 117 119 118 mutex_init(&qdev->gem.mutex); 120 119 mutex_init(&qdev->update_area_mutex);
+1 -1
drivers/gpu/drm/qxl/qxl_object.c
··· 33 33 struct qxl_device *qdev; 34 34 35 35 bo = to_qxl_bo(tbo); 36 - qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private; 36 + qdev = to_qxl(bo->tbo.base.dev); 37 37 38 38 qxl_surface_evict(qdev, bo, false); 39 39 WARN_ON_ONCE(bo->map_count > 0);
+1 -1
drivers/gpu/drm/qxl/qxl_release.c
··· 243 243 return ret; 244 244 245 245 /* allocate a surface for reserved + validated buffers */ 246 - ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo); 246 + ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo); 247 247 if (ret) 248 248 return ret; 249 249 return 0;
+1 -1
drivers/gpu/drm/qxl/qxl_ttm.c
··· 243 243 if (!qxl_ttm_bo_is_qxl_bo(bo)) 244 244 return; 245 245 qbo = to_qxl_bo(bo); 246 - qdev = qbo->tbo.base.dev->dev_private; 246 + qdev = to_qxl(qbo->tbo.base.dev); 247 247 248 248 if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id) 249 249 qxl_surface_evict(qdev, qbo, new_mem ? true : false);