From 4fe11fc5ab1ff8bbd4e05b843e240fff2100c85e Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 4 Apr 2024 07:20:56 +0000 Subject: drm/probe-helper: warn about negative .get_modes() From Jani Nikula 12bbe2c25cdb571190d523fd814e7696964a84d9 in linux-6.6.y/6.6.24 7af03e688792293ba33149fb8df619a8dff90e80 in mainline linux --- sys/dev/pci/drm/drm_probe_helper.c | 7 +++++++ sys/dev/pci/drm/include/drm/drm_modeset_helper_vtables.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/drm/drm_probe_helper.c b/sys/dev/pci/drm/drm_probe_helper.c index e5ccdc8f29b..169df0488e6 100644 --- a/sys/dev/pci/drm/drm_probe_helper.c +++ b/sys/dev/pci/drm/drm_probe_helper.c @@ -419,6 +419,13 @@ static int drm_helper_probe_get_modes(struct drm_connector *connector) count = connector_funcs->get_modes(connector); + /* The .get_modes() callback should not return negative values. */ + if (count < 0) { + drm_err(connector->dev, ".get_modes() returned %pe\n", + ERR_PTR(count)); + count = 0; + } + /* * Fallback for when DDC probe failed in drm_get_edid() and thus skipped * override/firmware EDID. diff --git a/sys/dev/pci/drm/include/drm/drm_modeset_helper_vtables.h b/sys/dev/pci/drm/include/drm/drm_modeset_helper_vtables.h index e3c3ac61590..159213786e6 100644 --- a/sys/dev/pci/drm/include/drm/drm_modeset_helper_vtables.h +++ b/sys/dev/pci/drm/include/drm/drm_modeset_helper_vtables.h @@ -898,7 +898,8 @@ struct drm_connector_helper_funcs { * * RETURNS: * - * The number of modes added by calling drm_mode_probed_add(). + * The number of modes added by calling drm_mode_probed_add(). Return 0 + * on failures (no modes) instead of negative error codes. */ int (*get_modes)(struct drm_connector *connector); -- cgit v1.2.3