Skip to content

Commit

Permalink
wlcore: Force checking of io functions' return values
Browse files Browse the repository at this point in the history
All io functions' return values should be propagated and handled. Add a
__must_check annotation to verify that the return values are checked and
to avoid future mistakes.

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
  • Loading branch information
Ido Yariv authored and Luciano Coelho committed Jun 22, 2012
1 parent 2b80040 commit f1a26e6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 40 deletions.
6 changes: 4 additions & 2 deletions drivers/net/wireless/ti/wl12xx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
return ret;
}

static int wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
static int __must_check wl12xx_top_reg_write(struct wl1271 *wl, int addr,
u16 val)
{
int ret;

Expand All @@ -712,7 +713,8 @@ static int wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
return ret;
}

static int wl12xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out)
static int __must_check wl12xx_top_reg_read(struct wl1271 *wl, int addr,
u16 *out)
{
u32 val;
int timeout = OCP_CMD_LOOP;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ti/wl18xx/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef __WL18XX_IO_H__
#define __WL18XX_IO_H__

int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val);
int wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out);
int __must_check wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val);
int __must_check wl18xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out);

#endif /* __WL18XX_IO_H__ */
61 changes: 37 additions & 24 deletions drivers/net/wireless/ti/wlcore/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,36 @@ void wl1271_io_init(struct wl1271 *wl);
int wlcore_translate_addr(struct wl1271 *wl, int addr);

/* Raw target IO, address is not translated */
static inline int wlcore_raw_write(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_raw_write(struct wl1271 *wl, int addr,
void *buf, size_t len,
bool fixed)
{
return wl->if_ops->write(wl->dev, addr, buf, len, fixed);
}

static inline int wlcore_raw_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_raw_read(struct wl1271 *wl, int addr,
void *buf, size_t len,
bool fixed)
{
return wl->if_ops->read(wl->dev, addr, buf, len, fixed);
}

static inline int wlcore_raw_read_data(struct wl1271 *wl, int reg, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_raw_read_data(struct wl1271 *wl, int reg,
void *buf, size_t len,
bool fixed)
{
return wlcore_raw_read(wl, wl->rtable[reg], buf, len, fixed);
}

static inline int wlcore_raw_write_data(struct wl1271 *wl, int reg, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_raw_write_data(struct wl1271 *wl, int reg,
void *buf, size_t len,
bool fixed)
{
return wlcore_raw_write(wl, wl->rtable[reg], buf, len, fixed);
}

static inline int wlcore_raw_read32(struct wl1271 *wl, int addr, u32 *val)
static inline int __must_check wlcore_raw_read32(struct wl1271 *wl, int addr,
u32 *val)
{
int ret;

Expand All @@ -92,15 +97,16 @@ static inline int wlcore_raw_read32(struct wl1271 *wl, int addr, u32 *val)
return 0;
}

static inline int wlcore_raw_write32(struct wl1271 *wl, int addr, u32 val)
static inline int __must_check wlcore_raw_write32(struct wl1271 *wl, int addr,
u32 val)
{
wl->buffer_32 = cpu_to_le32(val);
return wlcore_raw_write(wl, addr, &wl->buffer_32,
sizeof(wl->buffer_32), false);
}

static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_read(struct wl1271 *wl, int addr,
void *buf, size_t len, bool fixed)
{
int physical;

Expand All @@ -109,8 +115,8 @@ static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf,
return wlcore_raw_read(wl, physical, buf, len, fixed);
}

static inline int wlcore_write(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_write(struct wl1271 *wl, int addr,
void *buf, size_t len, bool fixed)
{
int physical;

Expand All @@ -119,20 +125,23 @@ static inline int wlcore_write(struct wl1271 *wl, int addr, void *buf,
return wlcore_raw_write(wl, physical, buf, len, fixed);
}

static inline int wlcore_write_data(struct wl1271 *wl, int reg, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_write_data(struct wl1271 *wl, int reg,
void *buf, size_t len,
bool fixed)
{
return wlcore_write(wl, wl->rtable[reg], buf, len, fixed);
}

static inline int wlcore_read_data(struct wl1271 *wl, int reg, void *buf,
size_t len, bool fixed)
static inline int __must_check wlcore_read_data(struct wl1271 *wl, int reg,
void *buf, size_t len,
bool fixed)
{
return wlcore_read(wl, wl->rtable[reg], buf, len, fixed);
}

static inline int wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
void *buf, size_t len, bool fixed)
static inline int __must_check wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
void *buf, size_t len,
bool fixed)
{
int physical;
int addr;
Expand All @@ -145,24 +154,28 @@ static inline int wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
return wlcore_raw_read(wl, physical, buf, len, fixed);
}

static inline int wlcore_read32(struct wl1271 *wl, int addr, u32 *val)
static inline int __must_check wlcore_read32(struct wl1271 *wl, int addr,
u32 *val)
{
return wlcore_raw_read32(wl, wlcore_translate_addr(wl, addr), val);
}

static inline int wlcore_write32(struct wl1271 *wl, int addr, u32 val)
static inline int __must_check wlcore_write32(struct wl1271 *wl, int addr,
u32 val)
{
return wlcore_raw_write32(wl, wlcore_translate_addr(wl, addr), val);
}

static inline int wlcore_read_reg(struct wl1271 *wl, int reg, u32 *val)
static inline int __must_check wlcore_read_reg(struct wl1271 *wl, int reg,
u32 *val)
{
return wlcore_raw_read32(wl,
wlcore_translate_addr(wl, wl->rtable[reg]),
val);
}

static inline int wlcore_write_reg(struct wl1271 *wl, int reg, u32 val)
static inline int __must_check wlcore_write_reg(struct wl1271 *wl, int reg,
u32 val)
{
return wlcore_raw_write32(wl,
wlcore_translate_addr(wl, wl->rtable[reg]),
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ti/wlcore/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ static void wl1271_sdio_set_block_size(struct device *child,
sdio_release_host(func);
}

static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,
size_t len, bool fixed)
static int __must_check wl12xx_sdio_raw_read(struct device *child, int addr,
void *buf, size_t len, bool fixed)
{
int ret;
struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
Expand Down Expand Up @@ -109,8 +109,8 @@ static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,
return ret;
}

static int wl12xx_sdio_raw_write(struct device *child, int addr, void *buf,
size_t len, bool fixed)
static int __must_check wl12xx_sdio_raw_write(struct device *child, int addr,
void *buf, size_t len, bool fixed)
{
int ret;
struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ti/wlcore/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ static int wl12xx_spi_read_busy(struct device *child)
return -ETIMEDOUT;
}

static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf,
size_t len, bool fixed)
static int __must_check wl12xx_spi_raw_read(struct device *child, int addr,
void *buf, size_t len, bool fixed)
{
struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
struct wl1271 *wl = dev_get_drvdata(child);
Expand Down Expand Up @@ -260,8 +260,8 @@ static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf,
return 0;
}

static int wl12xx_spi_raw_write(struct device *child, int addr, void *buf,
size_t len, bool fixed)
static int __must_check wl12xx_spi_raw_write(struct device *child, int addr,
void *buf, size_t len, bool fixed)
{
struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS];
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ti/wlcore/wlcore_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ struct wl1271_scan {
};

struct wl1271_if_operations {
int (*read)(struct device *child, int addr, void *buf, size_t len,
bool fixed);
int (*write)(struct device *child, int addr, void *buf, size_t len,
bool fixed);
int __must_check (*read)(struct device *child, int addr, void *buf,
size_t len, bool fixed);
int __must_check (*write)(struct device *child, int addr, void *buf,
size_t len, bool fixed);
void (*reset)(struct device *child);
void (*init)(struct device *child);
int (*power)(struct device *child, bool enable);
Expand Down

0 comments on commit f1a26e6

Please sign in to comment.