lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWbQ8VAVPdLLpgV97=uY85-PfKWMmzyXpFZ6d=iJ2JOAQ@mail.gmail.com>
Date:   Wed, 12 Jul 2023 12:24:16 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Javier Martinez Canillas <javierm@...hat.com>
Cc:     linux-kernel@...r.kernel.org,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Maxime Ripard <mripard@...nel.org>,
        Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...il.com>,
        dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v2 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc()

Hi Javier,

Thanks for your patch!

On Fri, Jun 9, 2023 at 7:09 PM Javier Martinez Canillas
<javierm@...hat.com> wrote:
> The driver only supports OLED controllers that have a native DRM_FORMAT_C1

DRM_FORMAT_R1 (colormap is fixed to white-on-black).

> pixel format and that is why it has harcoded a division of the width by 8.

hardcoded.

> But the driver might be extended to support devices that have a different
> pixel format. So it's better to use the struct drm_format_info helpers to
> compute the size of the buffer, used to store the pixels in native format.
>
> Signed-off-by: Javier Martinez Canillas <javierm@...hat.com>
> Reviewed-by: Thomas Zimmermann <tzimmermann@...e.de>

> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -150,9 +150,16 @@ static int ssd130x_buf_alloc(struct ssd130x_device *ssd130x)
>  {
>         unsigned int page_height = ssd130x->device_info->page_height;
>         unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height);
> +       const struct drm_format_info *fi;
> +       unsigned int pitch;
>
> -       ssd130x->buffer = kcalloc(DIV_ROUND_UP(ssd130x->width, 8),
> -                                 ssd130x->height, GFP_KERNEL);
> +       fi = drm_format_info(DRM_FORMAT_C1);

DRM_FORMAT_R1.

> +       if (!fi)
> +               return -EINVAL;
> +
> +       pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width);
> +
> +       ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL);
>         if (!ssd130x->buffer)
>                 return -ENOMEM;

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ