drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
Mathieu Larouche
mathieu.larouche at matrox.com
Tue Oct 20 07:47:06 PDT 2015
On 19/10/2015 6:29 AM, Jan Beulich wrote:
> I can only guess that instead of testm/testn (which are either
> uninitialized or have pre-determined values at the end of the preceding
> loops) n and m were meant to be used by commit e829d7ef9f
> ("drm/mgag200: Add support for a new rev of G200e"). In any event the
> compiler is right in warning that testm/testn are possibly uninitalized
> at this point, i.e. some change is needed no matter what.
>
> Signed-off-by: Jan Beulich <jbeulich at suse.com>
> Cc: Mathieu Larouche <mathieu.larouche at matrox.com>
> ---
> drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
> }
> }
>
> - fvv = pllreffreq * testn / testm;
> + fvv = pllreffreq * n / m;
> fvv = (fvv - 800000) / 50000;
>
> if (fvv > 15)
>
>
>
>
If you are using n/m instead of testn/testm, you need to
add 1 to the variables to keep consistency. However, you
have the same issue where m/n could be used without being
initialized. So, I propose to keep testm, testn & testp
and initialized them with the default value.
Signed-off-by: Mathieu Larouche <mathieu.larouche at matrox.com>
---
drivers/gpu/drm/mgag200/mgag200_mode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index c99d3fe..055799c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -123,6 +123,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
vcomax = 320000;
vcomin = 160000;
pllreffreq = 25000;
+ testm = 1;
+ testn = 17;
+ testp = 8;
delta = 0xffffffff;
permitteddelta = clock * 5 / 1000;
@@ -157,6 +160,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
vcomax = 1600000;
vcomin = 800000;
pllreffreq = 25000;
+ testm = 1;
+ testn = 50;
+ testp = 16;
if (clock < 25000)
clock = 25000;
More information about the dri-devel
mailing list