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

drm: Rename drm_plane_check_pixel_format() to drm_plane_has_format()

Rename drm_plane_check_pixel_format() to drm_plane_has_format()
and change the return type accordingly. Allows one to write
more natural code.

Also matches drm_any_plane_has_format() better.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240612204712.31404-2-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

+16 -23
+2 -5
drivers/gpu/drm/drm_atomic.c
··· 608 608 unsigned int fb_width, fb_height; 609 609 struct drm_mode_rect *clips; 610 610 uint32_t num_clips; 611 - int ret; 612 611 613 612 /* either *both* CRTC and FB must be set, or neither */ 614 613 if (crtc && !fb) { ··· 634 635 } 635 636 636 637 /* Check whether this plane supports the fb pixel format. */ 637 - ret = drm_plane_check_pixel_format(plane, fb->format->format, 638 - fb->modifier); 639 - if (ret) { 638 + if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) { 640 639 drm_dbg_atomic(plane->dev, 641 640 "[PLANE:%d:%s] invalid pixel format %p4cc, modifier 0x%llx\n", 642 641 plane->base.id, plane->name, 643 642 &fb->format->format, fb->modifier); 644 - return ret; 643 + return -EINVAL; 645 644 } 646 645 647 646 /* Give drivers some help against integer overflows */
+2 -4
drivers/gpu/drm/drm_crtc.c
··· 789 789 * case. 790 790 */ 791 791 if (!plane->format_default) { 792 - ret = drm_plane_check_pixel_format(plane, 793 - fb->format->format, 794 - fb->modifier); 795 - if (ret) { 792 + if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) { 796 793 drm_dbg_kms(dev, "Invalid pixel format %p4cc, modifier 0x%llx\n", 797 794 &fb->format->format, fb->modifier); 795 + ret = -EINVAL; 798 796 goto out; 799 797 } 800 798 }
+2 -2
drivers/gpu/drm/drm_crtc_internal.h
··· 272 272 /* drm_plane.c */ 273 273 int drm_plane_register_all(struct drm_device *dev); 274 274 void drm_plane_unregister_all(struct drm_device *dev); 275 - int drm_plane_check_pixel_format(struct drm_plane *plane, 276 - u32 format, u64 modifier); 275 + bool drm_plane_has_format(struct drm_plane *plane, 276 + u32 format, u64 modifier); 277 277 struct drm_mode_rect * 278 278 __drm_plane_get_damage_clips(const struct drm_plane_state *state); 279 279
+10 -12
drivers/gpu/drm/drm_plane.c
··· 877 877 return 0; 878 878 } 879 879 880 - int drm_plane_check_pixel_format(struct drm_plane *plane, 881 - u32 format, u64 modifier) 880 + bool drm_plane_has_format(struct drm_plane *plane, 881 + u32 format, u64 modifier) 882 882 { 883 883 unsigned int i; 884 884 ··· 887 887 break; 888 888 } 889 889 if (i == plane->format_count) 890 - return -EINVAL; 890 + return false; 891 891 892 892 if (plane->funcs->format_mod_supported) { 893 893 if (!plane->funcs->format_mod_supported(plane, format, modifier)) 894 - return -EINVAL; 894 + return false; 895 895 } else { 896 896 if (!plane->modifier_count) 897 - return 0; 897 + return true; 898 898 899 899 for (i = 0; i < plane->modifier_count; i++) { 900 900 if (modifier == plane->modifiers[i]) 901 901 break; 902 902 } 903 903 if (i == plane->modifier_count) 904 - return -EINVAL; 904 + return false; 905 905 } 906 906 907 - return 0; 907 + return true; 908 908 } 909 909 910 910 static int __setplane_check(struct drm_plane *plane, ··· 924 924 } 925 925 926 926 /* Check whether this plane supports the fb pixel format. */ 927 - ret = drm_plane_check_pixel_format(plane, fb->format->format, 928 - fb->modifier); 929 - if (ret) { 927 + if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) { 930 928 DRM_DEBUG_KMS("Invalid pixel format %p4cc, modifier 0x%llx\n", 931 929 &fb->format->format, fb->modifier); 932 - return ret; 930 + return -EINVAL; 933 931 } 934 932 935 933 /* Give drivers some help against integer overflows */ ··· 962 964 struct drm_plane *plane; 963 965 964 966 drm_for_each_plane(plane, dev) { 965 - if (drm_plane_check_pixel_format(plane, format, modifier) == 0) 967 + if (drm_plane_has_format(plane, format, modifier)) 966 968 return true; 967 969 } 968 970