[PATCH] drm/i915/dp: use seq buf for printing rates

Raag Jadav raag.jadav at intel.com
Wed Nov 27 15:34:32 UTC 2024


On Wed, Nov 27, 2024 at 03:18:38PM +0200, Jani Nikula wrote:
> Hand rolling the buffer overflow handling with snprintf() is a bit
> tedious. The seq_buf interface is made for this. Switch to it.
> 
> Use struct intel_display while at it.
> 
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 36 ++++++++++---------------
>  1 file changed, 14 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 053a9a4182e7..4471c8fcd478 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -28,6 +28,7 @@
>  #include <linux/export.h>
>  #include <linux/i2c.h>
>  #include <linux/notifier.h>
> +#include <linux/seq_buf.h>
>  #include <linux/slab.h>
>  #include <linux/sort.h>
>  #include <linux/string_helpers.h>
> @@ -1506,41 +1507,32 @@ bool intel_dp_source_supports_tps4(struct drm_i915_private *i915)
>  	return DISPLAY_VER(i915) >= 10;
>  }
>  
> -static void snprintf_int_array(char *str, size_t len,
> -			       const int *array, int nelem)
> +static void seq_buf_print_array(struct seq_buf *s, const int *array, int nelem)

Perhaps with more users worth introducing as part of core lib?

Andy and I did something similar with kmemdup.
https://lore.kernel.org/linux-gpio/20241126172240.6044-1-raag.jadav@intel.com/

Raag


More information about the Intel-gfx mailing list