Commit f1a26e63 authored by Ido Yariv's avatar Ido Yariv Committed by Luciano Coelho

wlcore: Force checking of io functions' return values

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: default avatarIdo Yariv <ido@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 2b800407
...@@ -688,7 +688,8 @@ static int wl12xx_identify_chip(struct wl1271 *wl) ...@@ -688,7 +688,8 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
return ret; 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; int ret;
...@@ -712,7 +713,8 @@ static int wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val) ...@@ -712,7 +713,8 @@ static int wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)
return ret; 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; u32 val;
int timeout = OCP_CMD_LOOP; int timeout = OCP_CMD_LOOP;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef __WL18XX_IO_H__ #ifndef __WL18XX_IO_H__
#define __WL18XX_IO_H__ #define __WL18XX_IO_H__
int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val); int __must_check 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_read(struct wl1271 *wl, int addr, u16 *out);
#endif /* __WL18XX_IO_H__ */ #endif /* __WL18XX_IO_H__ */
...@@ -53,31 +53,36 @@ void wl1271_io_init(struct wl1271 *wl); ...@@ -53,31 +53,36 @@ void wl1271_io_init(struct wl1271 *wl);
int wlcore_translate_addr(struct wl1271 *wl, int addr); int wlcore_translate_addr(struct wl1271 *wl, int addr);
/* Raw target IO, address is not translated */ /* Raw target IO, address is not translated */
static inline int wlcore_raw_write(struct wl1271 *wl, int addr, void *buf, static inline int __must_check wlcore_raw_write(struct wl1271 *wl, int addr,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wl->if_ops->write(wl->dev, addr, buf, len, 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, static inline int __must_check wlcore_raw_read(struct wl1271 *wl, int addr,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wl->if_ops->read(wl->dev, addr, buf, len, 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, static inline int __must_check wlcore_raw_read_data(struct wl1271 *wl, int reg,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wlcore_raw_read(wl, wl->rtable[reg], buf, len, 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, static inline int __must_check wlcore_raw_write_data(struct wl1271 *wl, int reg,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wlcore_raw_write(wl, wl->rtable[reg], buf, len, 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; int ret;
...@@ -92,15 +97,16 @@ static inline int wlcore_raw_read32(struct wl1271 *wl, int addr, u32 *val) ...@@ -92,15 +97,16 @@ static inline int wlcore_raw_read32(struct wl1271 *wl, int addr, u32 *val)
return 0; 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); wl->buffer_32 = cpu_to_le32(val);
return wlcore_raw_write(wl, addr, &wl->buffer_32, return wlcore_raw_write(wl, addr, &wl->buffer_32,
sizeof(wl->buffer_32), false); sizeof(wl->buffer_32), false);
} }
static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf, static inline int __must_check wlcore_read(struct wl1271 *wl, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
int physical; int physical;
...@@ -109,8 +115,8 @@ static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf, ...@@ -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); return wlcore_raw_read(wl, physical, buf, len, fixed);
} }
static inline int wlcore_write(struct wl1271 *wl, int addr, void *buf, static inline int __must_check wlcore_write(struct wl1271 *wl, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
int physical; int physical;
...@@ -119,20 +125,23 @@ static inline int wlcore_write(struct wl1271 *wl, int addr, void *buf, ...@@ -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); return wlcore_raw_write(wl, physical, buf, len, fixed);
} }
static inline int wlcore_write_data(struct wl1271 *wl, int reg, void *buf, static inline int __must_check wlcore_write_data(struct wl1271 *wl, int reg,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wlcore_write(wl, wl->rtable[reg], buf, len, fixed); return wlcore_write(wl, wl->rtable[reg], buf, len, fixed);
} }
static inline int wlcore_read_data(struct wl1271 *wl, int reg, void *buf, static inline int __must_check wlcore_read_data(struct wl1271 *wl, int reg,
size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
return wlcore_read(wl, wl->rtable[reg], buf, len, fixed); return wlcore_read(wl, wl->rtable[reg], buf, len, fixed);
} }
static inline int wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr, static inline int __must_check wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
void *buf, size_t len, bool fixed) void *buf, size_t len,
bool fixed)
{ {
int physical; int physical;
int addr; int addr;
...@@ -145,24 +154,28 @@ static inline int wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr, ...@@ -145,24 +154,28 @@ static inline int wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
return wlcore_raw_read(wl, physical, buf, len, fixed); 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); 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); 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, return wlcore_raw_read32(wl,
wlcore_translate_addr(wl, wl->rtable[reg]), wlcore_translate_addr(wl, wl->rtable[reg]),
val); 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, return wlcore_raw_write32(wl,
wlcore_translate_addr(wl, wl->rtable[reg]), wlcore_translate_addr(wl, wl->rtable[reg]),
......
...@@ -71,8 +71,8 @@ static void wl1271_sdio_set_block_size(struct device *child, ...@@ -71,8 +71,8 @@ static void wl1271_sdio_set_block_size(struct device *child,
sdio_release_host(func); sdio_release_host(func);
} }
static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, static int __must_check wl12xx_sdio_raw_read(struct device *child, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
int ret; int ret;
struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
...@@ -109,8 +109,8 @@ static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, ...@@ -109,8 +109,8 @@ static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,
return ret; return ret;
} }
static int wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, static int __must_check wl12xx_sdio_raw_write(struct device *child, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
int ret; int ret;
struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
......
...@@ -193,8 +193,8 @@ static int wl12xx_spi_read_busy(struct device *child) ...@@ -193,8 +193,8 @@ static int wl12xx_spi_read_busy(struct device *child)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf, static int __must_check wl12xx_spi_raw_read(struct device *child, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
struct wl1271 *wl = dev_get_drvdata(child); struct wl1271 *wl = dev_get_drvdata(child);
...@@ -260,8 +260,8 @@ static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf, ...@@ -260,8 +260,8 @@ static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf,
return 0; return 0;
} }
static int wl12xx_spi_raw_write(struct device *child, int addr, void *buf, static int __must_check wl12xx_spi_raw_write(struct device *child, int addr,
size_t len, bool fixed) void *buf, size_t len, bool fixed)
{ {
struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS];
......
...@@ -209,10 +209,10 @@ struct wl1271_scan { ...@@ -209,10 +209,10 @@ struct wl1271_scan {
}; };
struct wl1271_if_operations { struct wl1271_if_operations {
int (*read)(struct device *child, int addr, void *buf, size_t len, int __must_check (*read)(struct device *child, int addr, void *buf,
bool fixed); size_t len, bool fixed);
int (*write)(struct device *child, int addr, void *buf, size_t len, int __must_check (*write)(struct device *child, int addr, void *buf,
bool fixed); size_t len, bool fixed);
void (*reset)(struct device *child); void (*reset)(struct device *child);
void (*init)(struct device *child); void (*init)(struct device *child);
int (*power)(struct device *child, bool enable); int (*power)(struct device *child, bool enable);
......
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