Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address compilation issues with higher warning levels #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions pinctrl/gpiochip_bcm2712.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct bcm2712_inst
};

static unsigned num_instances;
static struct bcm2712_inst bcm2712_instances[BCM2712_MAX_INSTANCES] = { 0 };
static struct bcm2712_inst bcm2712_instances[BCM2712_MAX_INSTANCES] = { {0,0,0,0,0,0,0} };
static unsigned shared_flags;

static const char *bcm2712_c0_gpio_alt_names[][BCM2712_FSEL_COUNT - 1] =
Expand Down Expand Up @@ -328,7 +328,7 @@ static volatile uint32_t *bcm2712_pad_base(struct bcm2712_inst *inst,

static int bcm2712_gpio_get_level(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);

Expand All @@ -340,7 +340,7 @@ static int bcm2712_gpio_get_level(void *priv, unsigned gpio)

static void bcm2712_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
uint32_t gpio_val;
Expand All @@ -355,7 +355,7 @@ static void bcm2712_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv)

static GPIO_DRIVE_T bcm2712_gpio_get_drive(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
uint32_t gpio_val;
Expand All @@ -369,7 +369,7 @@ static GPIO_DRIVE_T bcm2712_gpio_get_drive(void *priv, unsigned gpio)

static void bcm2712_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
uint32_t gpio_val;
Expand All @@ -385,7 +385,7 @@ static void bcm2712_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir)

static GPIO_DIR_T bcm2712_gpio_get_dir(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
uint32_t gpio_val;
Expand All @@ -399,30 +399,30 @@ static GPIO_DIR_T bcm2712_gpio_get_dir(void *priv, unsigned gpio)

static GPIO_FSEL_T bcm2712_pinctrl_get_fsel(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int pinmux_bit;
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
int fsel;

if (!pinmux_base)
return -1;
return (GPIO_FSEL_T)-1;

fsel = ((*pinmux_base >> pinmux_bit) & 0xf);

if (fsel == 0)
return GPIO_FSEL_GPIO;
else if (fsel < BCM2712_FSEL_COUNT)
return GPIO_FSEL_FUNC1 + (fsel - 1);
return (GPIO_FSEL_T)(GPIO_FSEL_FUNC1 + (fsel - 1));
else if (fsel == 0xf) // Choose one value as a considered NONE
return GPIO_FSEL_NONE;

/* Unknown FSEL */
return -1;
return (GPIO_FSEL_T)-1;
}

static void bcm2712_pinctrl_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int pinmux_bit;
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
uint32_t pinmux_val;
Expand Down Expand Up @@ -458,7 +458,7 @@ static void bcm2712_pinctrl_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_

static GPIO_PULL_T bcm2712_pinctrl_get_pull(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit;
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
uint32_t pad_val;
Expand All @@ -482,7 +482,7 @@ static GPIO_PULL_T bcm2712_pinctrl_get_pull(void *priv, unsigned gpio)

static void bcm2712_pinctrl_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned int bit = 0;
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
uint32_t padval;
Expand Down Expand Up @@ -589,14 +589,14 @@ static void *bcm2712_gpio_create_instance(const GPIO_CHIP_T *chip,

static int bcm2712_gpio_count(void *priv)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;

return inst->num_gpios;
}

static void *bcm2712_gpio_probe_instance(void *priv, volatile uint32_t *base)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;

inst->gpio_base = base;

Expand Down Expand Up @@ -672,7 +672,7 @@ static void *bcm2712_pinctrl_create_instance(const GPIO_CHIP_T *chip,

static int bcm2712_pinctrl_count(void *priv)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;

if (inst->flags & FLAGS_GPIO)
return 0; /* Don't occupy any GPIO space */
Expand Down Expand Up @@ -702,7 +702,7 @@ static int bcm2712_pinctrl_count(void *priv)

static void *bcm2712_pinctrl_probe_instance(void *priv, volatile uint32_t *base)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
unsigned pad_offset;

inst->pinmux_base = base;
Expand Down Expand Up @@ -731,7 +731,7 @@ static void *bcm2712_pinctrl_probe_instance(void *priv, volatile uint32_t *base)

static const char *bcm2712_pinctrl_get_fsel_name(void *priv, unsigned gpio, GPIO_FSEL_T fsel)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
const char *name = NULL;

switch (fsel)
Expand Down Expand Up @@ -788,7 +788,7 @@ static const char *bcm2712_pinctrl_get_fsel_name(void *priv, unsigned gpio, GPIO

static const char *bcm2712_gpio_get_name(void *priv, unsigned gpio)
{
struct bcm2712_inst *inst = priv;
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
const char *fsel_name;
static char name_buf[16];
unsigned gpio_offset;
Expand Down
14 changes: 7 additions & 7 deletions pinctrl/gpiochip_bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static const char *bcm2711_gpio_alt_names[BCM2711_NUM_GPIOS][BCM2711_ALT_COUNT]

static GPIO_FSEL_T bcm2835_gpio_get_fsel(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
/* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */
uint32_t reg = GPFSEL0 + (gpio / 10);
uint32_t lsb = (gpio % 10) * 3;
Expand All @@ -182,7 +182,7 @@ static GPIO_FSEL_T bcm2835_gpio_get_fsel(void *priv, unsigned gpio)

static void bcm2835_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
/* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */
uint32_t reg = GPFSEL0 + (gpio / 10);
uint32_t lsb = (gpio % 10) * 3;
Expand Down Expand Up @@ -232,7 +232,7 @@ static void bcm2835_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir)

static int bcm2835_gpio_get_level(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;

if (gpio >= BCM2835_NUM_GPIOS)
return -1;
Expand All @@ -250,7 +250,7 @@ GPIO_DRIVE_T bcm2835_gpio_get_drive(void *priv, unsigned gpio)

static void bcm2835_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;

if (gpio < BCM2835_NUM_GPIOS && drv <= DRIVE_HIGH)
base[(drv ? GPSET0 : GPCLR0) + (gpio / 32)] = (1 << (gpio % 32));
Expand All @@ -266,7 +266,7 @@ static GPIO_PULL_T bcm2835_gpio_get_pull(void *priv, unsigned gpio)

static void bcm2835_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int clkreg = GPPUDCLK0 + (gpio / 32);
int clkbit = 1 << (gpio % 32);

Expand Down Expand Up @@ -324,7 +324,7 @@ static const char *bcm2835_gpio_get_fsel_name(void *priv, unsigned gpio, GPIO_FS

static GPIO_PULL_T bcm2711_gpio_get_pull(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int reg = GPPUPPDN0 + (gpio / 16);
int lsb = (gpio % 16) * 2;

Expand All @@ -343,7 +343,7 @@ static GPIO_PULL_T bcm2711_gpio_get_pull(void *priv, unsigned gpio)

static void bcm2711_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int reg = GPPUPPDN0 + (gpio / 16);
int lsb = (gpio % 16) * 2;
int pull_val;
Expand Down
20 changes: 10 additions & 10 deletions pinctrl/gpiochip_rp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void rp1_gpio_sys_rio_oe_set(volatile uint32_t *base, int bank, int offse

static void rp1_gpio_set_dir(void *priv, uint32_t gpio, GPIO_DIR_T dir)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;

rp1_gpio_get_bank(gpio, &bank, &offset);
Expand All @@ -243,7 +243,7 @@ static void rp1_gpio_set_dir(void *priv, uint32_t gpio, GPIO_DIR_T dir)

static GPIO_DIR_T rp1_gpio_get_dir(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;
GPIO_DIR_T dir;
uint32_t reg;
Expand All @@ -258,15 +258,15 @@ static GPIO_DIR_T rp1_gpio_get_dir(void *priv, unsigned gpio)

static GPIO_FSEL_T rp1_gpio_get_fsel(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;
uint32_t reg;
GPIO_FSEL_T fsel;
RP1_FSEL_T rsel;

rp1_gpio_get_bank(gpio, &bank, &offset);
reg = rp1_gpio_ctrl_read(base, bank, offset);
rsel = ((reg & RP1_GPIO_CTRL_FSEL_MASK) >> RP1_GPIO_CTRL_FSEL_LSB);
rsel = (RP1_FSEL_T)((reg & RP1_GPIO_CTRL_FSEL_MASK) >> RP1_GPIO_CTRL_FSEL_LSB);
if (rsel == RP1_FSEL_SYS_RIO)
fsel = GPIO_FSEL_GPIO;
else if (rsel == RP1_FSEL_NULL)
Expand All @@ -281,7 +281,7 @@ static GPIO_FSEL_T rp1_gpio_get_fsel(void *priv, unsigned gpio)

static void rp1_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;
uint32_t ctrl_reg;
uint32_t pad_reg;
Expand Down Expand Up @@ -339,7 +339,7 @@ static void rp1_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func)

static int rp1_gpio_get_level(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;
uint32_t pad_reg;
uint32_t reg;
Expand All @@ -357,7 +357,7 @@ static int rp1_gpio_get_level(void *priv, unsigned gpio)

static void rp1_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
int bank, offset;

rp1_gpio_get_bank(gpio, &bank, &offset);
Expand All @@ -369,7 +369,7 @@ static void rp1_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv)

static void rp1_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
uint32_t reg;
int bank, offset;

Expand All @@ -385,7 +385,7 @@ static void rp1_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull)

static GPIO_PULL_T rp1_gpio_get_pull(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
uint32_t reg;
GPIO_PULL_T pull = PULL_NONE;
int bank, offset;
Expand All @@ -402,7 +402,7 @@ static GPIO_PULL_T rp1_gpio_get_pull(void *priv, unsigned gpio)

static GPIO_DRIVE_T rp1_gpio_get_drive(void *priv, unsigned gpio)
{
volatile uint32_t *base = priv;
volatile uint32_t *base = (volatile uint32_t*)priv;
uint32_t reg;
int bank, offset;

Expand Down
4 changes: 2 additions & 2 deletions pinctrl/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void *do_read_file(const char *fname, const char *mode, size_t *plen)

char *read_text_file(const char *fname, size_t *plen)
{
return do_read_file(fname, "rt", plen);
return (char*)do_read_file(fname, "rt", plen);
}

void *read_file(const char *fname, size_t *plen)
Expand All @@ -73,7 +73,7 @@ char *dt_read_prop(const char *node, const char *prop, size_t *plen)

filename[sizeof(filename) - 1] = '\0';

return read_file(filename, plen);
return (char*)read_file(filename, plen);
}

uint32_t *dt_read_cells(const char *node, const char *prop, unsigned *num_cells)
Expand Down