Commit 516c7409 authored by Sean Cross's avatar Sean Cross

fernly: fix gcc warnings

Several GCC warnings were getting generated on various compilers.  This
patch solves those warnings.

For various platforms, a uint32_t is not the same as an unsigned int. On
these platforms, printf("%x", (uint32_t)0) generates a warning.  Use the
<inttypes.h> formats (i.e. PRIx32) as formatters to silence these warnings.

There was also a security warning picked up by certain compilers when
calling printf(msg) in fernly-usb-loader.  This has been fixed.

Finally, lcd.c was refactored to fold the unused lcd_dat_slot() function
into the lcd_cmd_slot() function as a brand-new unified lcd_slot().
Signed-off-by: default avatarSean Cross <xobs@kosagi.com>
parent deced071
#include <string.h>
#include <inttypes.h>
#include "bionic.h"
#include "memio.h"
#include "printf.h"
......@@ -15,8 +16,8 @@ int cmd_peek(int argc, char **argv)
offset = strtoul(argv[0], NULL, 0);
printf("Value at 0x%08x: ", offset);
printf("0x%08x\n", *((volatile uint32_t *)offset));
printf("Value at 0x%08"PRIx32": ", offset);
printf("0x%08"PRIx32"\n", *((volatile uint32_t *)offset));
return 0;
}
......@@ -33,7 +34,8 @@ int cmd_poke(int argc, char **argv)
offset = strtoul(argv[0], NULL, 0);
val = strtoul(argv[1], NULL, 0);
printf("Setting value at 0x%08x to 0x%08x: ", offset, val);
printf("Setting value at 0x%08"PRIx32" to 0x%08"PRIx32": ",
offset, val);
writel(val, offset);
printf("Ok\n");
......
......@@ -1175,8 +1175,7 @@ static int fernvale_write_stage3(int serfd, int binfd)
}
static void cmd_begin(const char *msg) {
printf(msg);
printf("... ");
printf("%s... ", msg);
fflush(stdout);
}
......
#include <inttypes.h>
#include "serial.h"
#include "printf.h"
#include "irq.h"
......@@ -130,7 +131,7 @@ void irq_dispatch(void)
printf("Dispatching IRQs...\n");
reg = IRQ_BASE + IRQ_STATUS_OFF;
val = readl(reg);
printf("Lower Mask: 0x%08x\n", val);
printf("Lower Mask: 0x%08"PRIx32"\n", val);
for (i = 0; i < 32; i++)
if (val & (1 << i))
......@@ -138,7 +139,7 @@ void irq_dispatch(void)
reg += IRQ_BASE + IRQ_STATUS_OFF + 4;
val = readl(reg);
printf("Upper Mask: 0x%08x\n", val);
printf("Upper Mask: 0x%08"PRIx32"\n", val);
for (i = 0; i < (__irq_max__ - 32); i++)
if (val & (1 << i))
irq_dispatch_one(32 + i);
......
......@@ -25,13 +25,14 @@ static const uint32_t fb_bpp = 2;
* explicitly later on.
* [slot] is the order to execute.
*/
static void lcd_cmd_slot(uint16_t cmd, uint8_t slot)
{
writel(cmd | 0x800000, LCD_CMD_LIST_ADDR + (slot * 4));
}
static void lcd_dat_slot(uint16_t dat, uint8_t slot)
enum lcd_slot_type {
SLOT_DATA = 0,
SLOT_CMD = 0x800000,
};
static void lcd_slot(enum lcd_slot_type type, uint16_t cmd, uint8_t slot)
{
writel(dat, LCD_CMD_LIST_ADDR + (slot * 4));
writel(cmd | type, LCD_CMD_LIST_ADDR + (slot * 4));
}
static void lcd_setup_gpio(void)
......@@ -202,7 +203,7 @@ static void lcd_fill_cmd_buffer(void)
int ncommands = 0;
/* Memory write */
lcd_cmd_slot(0x2c, ncommands++);
lcd_slot(SLOT_CMD, 0x2c, ncommands++);
/* Count the number of cmmands and add it to AUTOCOPY_CTRL */
writel((readl(LCD_AUTOCOPY_CTRL_REG)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment