[PATCH v2 2/9] drm: Remove usage of deprecated DRM_ERROR

Siddh Raman Pant code at siddh.me
Thu Dec 22 15:40:36 UTC 2022


drm_print.h says DRM_ERROR is deprecated.
Thus, use newer printing macros drm_err() and pr_err().

Signed-off-by: Siddh Raman Pant <code at siddh.me>
---
 drivers/gpu/drm/drm_bridge.c         | 8 ++++----
 drivers/gpu/drm/drm_bufs.c           | 8 ++++----
 drivers/gpu/drm/drm_client_modeset.c | 4 ++--
 drivers/gpu/drm/drm_context.c        | 4 ++--
 drivers/gpu/drm/drm_crtc_helper.c    | 6 +++---
 drivers/gpu/drm/drm_debugfs_crc.c    | 3 ++-
 drivers/gpu/drm/drm_drv.c            | 8 ++++----
 drivers/gpu/drm/drm_framebuffer.c    | 3 ++-
 drivers/gpu/drm/drm_gem.c            | 2 +-
 drivers/gpu/drm/drm_gem_dma_helper.c | 2 +-
 drivers/gpu/drm/drm_mipi_dbi.c       | 2 +-
 drivers/gpu/drm/drm_mode_config.c    | 2 +-
 drivers/gpu/drm/drm_modeset_helper.c | 2 +-
 drivers/gpu/drm/drm_plane.c          | 2 +-
 drivers/gpu/drm/drm_scatter.c        | 9 +++++----
 drivers/gpu/drm/drm_vm.c             | 2 +-
 16 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 1545c50fd1c8..20a8cde70640 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -312,11 +312,11 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
 	list_del(&bridge->chain_node);
 
 #ifdef CONFIG_OF
-	DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n",
-		  bridge->of_node, encoder->name, ret);
+	drm_err(encoder->dev, "failed to attach bridge %pOF to encoder %s: %d\n",
+		bridge->of_node, encoder->name, ret);
 #else
-	DRM_ERROR("failed to attach bridge to encoder %s: %d\n",
-		  encoder->name, ret);
+	drm_err(encoder->dev, "failed to attach bridge to encoder %s: %d\n",
+		encoder->name, ret);
 #endif
 
 	return ret;
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index fcca21e8efac..98aaf3379a3b 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1474,15 +1474,15 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
 		if (copy_from_user(&idx, &request->list[i], sizeof(idx)))
 			return -EFAULT;
 		if (idx < 0 || idx >= dma->buf_count) {
-			DRM_ERROR("Index %d (of %d max)\n",
-				  idx, dma->buf_count - 1);
+			drm_err(dev, "Index %d (of %d max)\n",
+				idx, dma->buf_count - 1);
 			return -EINVAL;
 		}
 		idx = array_index_nospec(idx, dma->buf_count);
 		buf = dma->buflist[idx];
 		if (buf->file_priv != file_priv) {
-			DRM_ERROR("Process %d freeing buffer not owned\n",
-				  task_pid_nr(current));
+			drm_err(dev, "Process %d freeing buffer not owned\n",
+				task_pid_nr(current));
 			return -EINVAL;
 		}
 		drm_legacy_free_buffer(dev, buf);
diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index 2b76d4828c5f..c4517dea924e 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -812,7 +812,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 	offsets = kcalloc(connector_count, sizeof(*offsets), GFP_KERNEL);
 	enabled = kcalloc(connector_count, sizeof(bool), GFP_KERNEL);
 	if (!crtcs || !modes || !enabled || !offsets) {
-		DRM_ERROR("Memory allocation failed\n");
+		drm_err(client->dev, "Memory allocation failed\n");
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -836,7 +836,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 					      offsets, enabled, width, height) &&
 		    !drm_client_target_preferred(connectors, connector_count, modes,
 						 offsets, enabled, width, height))
-			DRM_ERROR("Unable to find initial modes\n");
+			drm_err(client->dev, "Unable to find initial modes\n");
 
 		DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n",
 			      width, height);
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index c6e6a3e7219a..f6d68fad8311 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -276,7 +276,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
 static int drm_context_switch(struct drm_device * dev, int old, int new)
 {
 	if (test_and_set_bit(0, &dev->context_flag)) {
-		DRM_ERROR("Reentering -- FIXME\n");
+		drm_err(dev, "Reentering -- FIXME\n");
 		return -EBUSY;
 	}
 
@@ -307,7 +307,7 @@ static int drm_context_switch_complete(struct drm_device *dev,
 	dev->last_context = new;	/* PRE/POST: This is the _only_ writer. */
 
 	if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
-		DRM_ERROR("Lock isn't held after context switch\n");
+		drm_err(dev, "Lock isn't held after context switch\n");
 	}
 
 	/* If a context switch is ever initiated
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index a209659a996c..ab41dc180c58 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -768,8 +768,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set,
 			if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
 						      set->x, set->y,
 						      save_set.fb)) {
-				DRM_ERROR("failed to set mode on [CRTC:%d:%s]\n",
-					  set->crtc->base.id, set->crtc->name);
+				drm_err(dev, "failed to set mode on [CRTC:%d:%s]\n",
+					set->crtc->base.id, set->crtc->name);
 				set->crtc->primary->fb = save_set.fb;
 				ret = -EINVAL;
 				goto fail;
@@ -996,7 +996,7 @@ void drm_helper_resume_force_mode(struct drm_device *dev)
 
 		/* Restoring the old config should never fail! */
 		if (ret == false)
-			DRM_ERROR("failed to set mode on crtc %p\n", crtc);
+			drm_err(dev, "failed to set mode on crtc %p\n", crtc);
 
 		/* Turn off outputs that were already powered off */
 		if (drm_helper_choose_crtc_dpms(crtc)) {
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
index bbc3bc4ba844..a59ef3f0e4a1 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -416,7 +416,8 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
 		spin_unlock_irqrestore(&crc->lock, flags);
 
 		if (!was_overflow)
-			DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n");
+			drm_err(crtc->dev,
+				"Overflow of CRC buffer, userspace reads too slow.\n");
 
 		return -ENOBUFS;
 	}
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index bc98e4bcf2c1..1295ecd98f12 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -177,7 +177,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 	} else {
 		ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root);
 		if (ret) {
-			DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
+			drm_err(dev, "DRM: Failed to initialize /sys/kernel/debug/dri.\n");
 			goto err_debugfs;
 		}
 	}
@@ -629,7 +629,7 @@ static int drm_dev_init(struct drm_device *dev,
 	if (drm_core_check_feature(dev, DRIVER_COMPUTE_ACCEL) &&
 				(drm_core_check_feature(dev, DRIVER_RENDER) ||
 				drm_core_check_feature(dev, DRIVER_MODESET))) {
-		DRM_ERROR("DRM driver can't be both a compute acceleration and graphics driver\n");
+		drm_err(dev, "DRM driver can't be both a compute acceleration and graphics driver\n");
 		return -EINVAL;
 	}
 
@@ -652,7 +652,7 @@ static int drm_dev_init(struct drm_device *dev,
 	inode = drm_fs_inode_new();
 	if (IS_ERR(inode)) {
 		ret = PTR_ERR(inode);
-		DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret);
+		drm_err(dev, "Cannot allocate anonymous inode: %d\n", ret);
 		goto err;
 	}
 
@@ -683,7 +683,7 @@ static int drm_dev_init(struct drm_device *dev,
 	if (drm_core_check_feature(dev, DRIVER_GEM)) {
 		ret = drm_gem_init(dev);
 		if (ret) {
-			DRM_ERROR("Cannot initialize graphics execution manager (GEM)\n");
+			drm_err(dev, "Cannot initialize graphics execution manager (GEM)\n");
 			goto err;
 		}
 	}
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 2dd97473ca10..5aea791f4341 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -1070,7 +1070,8 @@ static void legacy_remove_fb(struct drm_framebuffer *fb)
 
 			/* should turn off the crtc */
 			if (drm_crtc_force_disable(crtc))
-				DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
+				drm_err(dev, "failed to reset crtc %p when fb was deleted\n",
+					crtc);
 		}
 	}
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index b8db675e7fb5..3c99610afc0a 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -101,7 +101,7 @@ drm_gem_init(struct drm_device *dev)
 	vma_offset_manager = drmm_kzalloc(dev, sizeof(*vma_offset_manager),
 					  GFP_KERNEL);
 	if (!vma_offset_manager) {
-		DRM_ERROR("out of memory\n");
+		drm_err(dev, "out of memory\n");
 		return -ENOMEM;
 	}
 
diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c
index 1e658c448366..1ba551b0ab97 100644
--- a/drivers/gpu/drm/drm_gem_dma_helper.c
+++ b/drivers/gpu/drm/drm_gem_dma_helper.c
@@ -583,7 +583,7 @@ drm_gem_dma_prime_import_sg_table_vmap(struct drm_device *dev,
 
 	ret = dma_buf_vmap_unlocked(attach->dmabuf, &map);
 	if (ret) {
-		DRM_ERROR("Failed to vmap PRIME buffer\n");
+		drm_err(dev, "Failed to vmap PRIME buffer\n");
 		return ERR_PTR(ret);
 	}
 
diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index a6ac56580876..24af507bb687 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -527,7 +527,7 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
 	drm_mode_copy(&dbidev->mode, mode);
 	ret = mipi_dbi_rotate_mode(&dbidev->mode, rotation);
 	if (ret) {
-		DRM_ERROR("Illegal rotation value %u\n", rotation);
+		drm_err(drm, "Illegal rotation value %u\n", rotation);
 		return -EINVAL;
 	}
 
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 688c8afe0bf1..5dab605520b1 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -505,7 +505,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	if (WARN_ON(!list_empty(&dev->mode_config.connector_list))) {
 		drm_connector_list_iter_begin(dev, &conn_iter);
 		drm_for_each_connector_iter(connector, &conn_iter)
-			DRM_ERROR("connector %s leaked!\n", connector->name);
+			drm_err(dev, "connector %s leaked!\n", connector->name);
 		drm_connector_list_iter_end(&conn_iter);
 	}
 
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index f858dfedf2cf..e26b0285dde6 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -235,7 +235,7 @@ int drm_mode_config_helper_resume(struct drm_device *dev)
 
 	ret = drm_atomic_helper_resume(dev, dev->mode_config.suspend_state);
 	if (ret)
-		DRM_ERROR("Failed to resume (%d)\n", ret);
+		drm_err(dev, "Failed to resume (%d)\n", ret);
 	dev->mode_config.suspend_state = NULL;
 
 	drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 33357629a7f5..a650f06e4cea 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -606,7 +606,7 @@ void drm_plane_force_disable(struct drm_plane *plane)
 	plane->old_fb = plane->fb;
 	ret = plane->funcs->disable_plane(plane, NULL);
 	if (ret) {
-		DRM_ERROR("failed to disable plane with busy fb\n");
+		drm_err(plane->dev, "failed to disable plane with busy fb\n");
 		plane->old_fb = NULL;
 		return;
 	}
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index f4e6184d1877..5b0b2140d535 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -170,9 +170,10 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 			     j++, tmp++) {
 				if (*tmp != 0xcafebabe && error == 0) {
 					error = 1;
-					DRM_ERROR("Scatter allocation error, "
-						  "pagelist does not match "
-						  "virtual mapping\n");
+					drm_err(dev,
+						"Scatter allocation error, "
+						"pagelist does not match "
+						"virtual mapping\n");
 				}
 			}
 			tmp = page_address(entry->pagelist[i]);
@@ -183,7 +184,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 			}
 		}
 		if (error == 0)
-			DRM_ERROR("Scatter allocation matches pagelist\n");
+			drm_err(dev, "Scatter allocation matches pagelist\n");
 	}
 #endif
 
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index f024dc93939e..cdb956af2079 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -547,7 +547,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 		return drm_mmap_dma(filp, vma);
 
 	if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) {
-		DRM_ERROR("Could not find map\n");
+		drm_err(dev, "Could not find map\n");
 		return -EINVAL;
 	}
 
-- 
2.35.1




More information about the dri-devel mailing list