Skip to contentSkip to conversation

atmel_lcdfb: fix negative check on unsigned

PATCH In review Roel Kluin 2 participants 2 messages Apr 17, 2008 – Apr 19, 2008

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 atmel_lcdfb: fix negative check on unsigned

No signed negative values will get noticed

---

drivers/video/atmel_lcdfb.c +4 -4
index fc65c02..4b927da 100644
@@ -422,13 +422,13 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
 
 	value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
 
-	value = (value / 2) - 1;
-	dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", value);
-
-	if (value <= 0) {
+	if ((value / 2) <= 1) {
+		dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", (value/2)-1);
 		dev_notice(info->device, "Bypassing pixel clock divider\n");
 		lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
 	} else {
+		value = (value / 2) - 1;
+		dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", value);
 		lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET);
 		info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1)));
 		dev_dbg(info->device, "  updated pixclk:     %lu KHz\n",
#1 lore raw

Cc'ing the atmel_lcdfb maintainer...

Quoted 9 lines · On Thu, 17 Apr 2008 06:31:28 +0200 Roel Kluin <[email protected]> wrote:

No signed negative values will get noticed

---

drivers/video/atmel_lcdfb.c +0 -0
index fc65c02..4b927da 100644

drivers/video/atmel_lcdfb.c static int atmel_lcdfb_set_par(struct fb_info *info) · line 426

Quoted 9 lines
drivers/video/atmel_lcdfb.c +2 -4
@@ -422,13 +422,13 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
 
 	value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
 
-	value = (value / 2) - 1;
-	dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", value);
-
-	if (value <= 0) {
+	if ((value / 2) <= 1) {
+		dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", (value/2)-1);

Makes sense...although I think there's another patch in the queue that fixes this as well.

drivers/video/atmel_lcdfb.c static int atmel_lcdfb_set_par(struct fb_info *info) · line 434

Quoted 8 lines
drivers/video/atmel_lcdfb.c +2 -0
 		dev_notice(info->device, "Bypassing pixel clock divider\n");
 		lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
 	} else {
+		value = (value / 2) - 1;
+		dev_dbg(info->device, "  * programming CLKVAL = 0x%08lx\n", value);
 		lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET);
 		info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1)));
 		dev_dbg(info->device, "  updated pixclk:     %lu KHz\n",

Haavard