[Nouveau] [PATCH v3 23/44] drm/nouveau/disp: add output backlight control methods

Timur Tabi ttabi at nvidia.com
Wed Sep 20 19:29:56 UTC 2023


On Tue, 2023-09-19 at 17:56 -0400, Lyude Paul wrote:
> +static int
> +gt215_sor_bl_set(struct nvkm_ior *ior, int lvl)
> +{
> +       struct nvkm_device *device = ior->disp->engine.subdev.device;
> +       const u32 soff = nv50_ior_base(ior);
> +       u32 div, val;
> +
> +       div = nvkm_rd32(device, 0x61c080 + soff);
> +       val = (lvl * div) / 100;

Integer promotion rules always throw me for a loop, but since 'lvl' is a
signed integer, and div is a u32, are we sure this won't overflow?  Maybe
lvl should be unsigned and val should be a u64?


> +       if (div)
> +               nvkm_wr32(device, 0x61c084 + soff, 0xc0000000 | val);

Also, maybe calculate 'val' in this if-block?



More information about the dri-devel mailing list