return linux error value instead of 0 or 1 and use -EINVAL. Related codes
also changed together.
Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 14 +++-----------
drivers/staging/wilc1000/wilc_spi.c | 18 +++++++++---------
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index 6111405..c7d2542 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -104,13 +104,9 @@ int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len)
dev_err(&spi->dev,
"FAILED due to NULL buffer or ZERO length check the following length: %d\n",
len);
- ret = -1;
+ ret = -EINVAL;
}
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
-
-
return ret;
}
@@ -148,10 +144,8 @@ int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen)
dev_err(&spi->dev,
"can't read data with the following length: %u\n",
rlen);
- ret = -1;
+ ret = -EINVAL;
}
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
@@ -185,10 +179,8 @@ int wilc_spi_write_read(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen)
dev_err(&spi->dev,
"can't read data with the following length: %u\n",
rlen);
- ret = -1;
+ ret = -EINVAL;
}
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
return ret;
}
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index f54072b..450adc0 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -250,7 +250,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
}
rix = len;
- if (!wilc_spi_write_read(wilc, wb, rb, len2)) {
+ if (wilc_spi_write_read(wilc, wb, rb, len2)) {
dev_err(&spi->dev, "Failed cmd write, bus error...\n");
result = N_FAIL;
return result;
@@ -366,7 +366,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
/**
* Read bytes
**/
- if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
+ if (wilc_spi_read(wilc, &b[ix], nbytes)) {
dev_err(&spi->dev, "Failed data block read, bus error...\n");
result = N_FAIL;
goto _error_;
@@ -376,7 +376,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
* Read Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_read(wilc, crc, 2)) {
+ if (wilc_spi_read(wilc, crc, 2)) {
dev_err(&spi->dev, "Failed data block crc read, bus error...\n");
result = N_FAIL;
goto _error_;
@@ -407,7 +407,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
**/
retry = 10;
do {
- if (!wilc_spi_read(wilc, &rsp, 1)) {
+ if (wilc_spi_read(wilc, &rsp, 1)) {
dev_err(&spi->dev, "Failed data response read, bus error...\n");
result = N_FAIL;
break;
@@ -423,7 +423,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
/**
* Read bytes
**/
- if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
+ if (wilc_spi_read(wilc, &b[ix], nbytes)) {
dev_err(&spi->dev, "Failed data block read, bus error...\n");
result = N_FAIL;
break;
@@ -433,7 +433,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
* Read Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_read(wilc, crc, 2)) {
+ if (wilc_spi_read(wilc, crc, 2)) {
dev_err(&spi->dev, "Failed data block crc read, bus error...\n");
result = N_FAIL;
break;
@@ -484,7 +484,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
order = 0x2;
}
cmd |= order;
- if (!wilc_spi_write(wilc, &cmd, 1)) {
+ if (wilc_spi_write(wilc, &cmd, 1)) {
dev_err(&spi->dev,
"Failed data block cmd write, bus error...\n");
result = N_FAIL;
@@ -494,7 +494,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
/**
* Write data
**/
- if (!wilc_spi_write(wilc, &b[ix], nbytes)) {
+ if (wilc_spi_write(wilc, &b[ix], nbytes)) {
dev_err(&spi->dev,
"Failed data block write, bus error...\n");
result = N_FAIL;
@@ -505,7 +505,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
* Write Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_write(wilc, crc, 2)) {
+ if (wilc_spi_write(wilc, crc, 2)) {
dev_err(&spi->dev,"Failed data block crc write, bus error...\n");
result = N_FAIL;
break;
--
1.9.1
Return ret from wilc_netdev_init instead of -1 for proper error handling.
Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_sdio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
index e25811d..4b9cb55 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -91,7 +91,7 @@ static int linux_sdio_probe(struct sdio_func *func,
const struct sdio_device_id *id)
{
struct wilc *wilc;
- int gpio;
+ int gpio, ret;
gpio = -1;
if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
@@ -101,10 +101,11 @@ static int linux_sdio_probe(struct sdio_func *func,
}
dev_dbg(&func->dev, "Initializing netdev\n");
- if (wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio,
- &wilc_hif_sdio)) {
+ ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio,
+ &wilc_hif_sdio);
+ if (ret) {
dev_err(&func->dev, "Couldn't initialize netdev\n");
- return -1;
+ return ret;
}
sdio_set_drvdata(func, wilc);
wilc->dev = &func->dev;
--
1.9.1
To Combine linux_wlan_sdio.c and wilc_sdio.c as one file, move all the codes
in linux_wlan_sdio.c to wilc_sdio.c, and make functions static only.
No Modification has not been made except static, just moved them.
Function declaration in linux_wlan_sdio.h is needless, so just remove them.
linux_wlan_sdio.[ch] will be deleted in the next patch.
Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_sdio.c | 160 ----------------------------
drivers/staging/wilc1000/linux_wlan_sdio.h | 7 --
drivers/staging/wilc1000/wilc_sdio.c | 164 ++++++++++++++++++++++++++++-
3 files changed, 163 insertions(+), 168 deletions(-)
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
index 4b9cb55..67d99e9 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -8,163 +8,3 @@
#include <linux/of_gpio.h>
#include "linux_wlan_sdio.h"
-
-#define SDIO_MODALIAS "wilc1000_sdio"
-
-#define SDIO_VENDOR_ID_WILC 0x0296
-#define SDIO_DEVICE_ID_WILC 0x5347
-
-static const struct sdio_device_id wilc_sdio_ids[] = {
- { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
- { },
-};
-
-
-static void wilc_sdio_interrupt(struct sdio_func *func)
-{
- sdio_release_host(func);
- wilc_handle_isr(sdio_get_drvdata(func));
- sdio_claim_host(func);
-}
-
-int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd)
-{
- struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
- int ret;
- u8 data;
-
- sdio_claim_host(func);
-
- func->num = cmd->function;
- if (cmd->read_write) { /* write */
- if (cmd->raw) {
- sdio_writeb(func, cmd->data, cmd->address, &ret);
- data = sdio_readb(func, cmd->address, &ret);
- cmd->data = data;
- } else {
- sdio_writeb(func, cmd->data, cmd->address, &ret);
- }
- } else { /* read */
- data = sdio_readb(func, cmd->address, &ret);
- cmd->data = data;
- }
-
- sdio_release_host(func);
-
- if (ret)
- dev_err(&func->dev, "wilc_sdio_cmd52..failed, err(%d)\n", ret);
- return ret;
-}
-
-
-int wilc_sdio_cmd53(struct wilc *wilc, sdio_cmd53_t *cmd)
-{
- struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
- int size, ret;
-
- sdio_claim_host(func);
-
- func->num = cmd->function;
- func->cur_blksize = cmd->block_size;
- if (cmd->block_mode)
- size = cmd->count * cmd->block_size;
- else
- size = cmd->count;
-
- if (cmd->read_write) { /* write */
- ret = sdio_memcpy_toio(func, cmd->address,
- (void *)cmd->buffer, size);
- } else { /* read */
- ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
- cmd->address, size);
- }
-
- sdio_release_host(func);
-
- if (ret)
- dev_err(&func->dev, "wilc_sdio_cmd53..failed, err(%d)\n", ret);
-
- return ret;
-}
-
-static int linux_sdio_probe(struct sdio_func *func,
- const struct sdio_device_id *id)
-{
- struct wilc *wilc;
- int gpio, ret;
-
- gpio = -1;
- if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
- gpio = of_get_gpio(func->dev.of_node, 0);
- if (gpio < 0)
- gpio = GPIO_NUM;
- }
-
- dev_dbg(&func->dev, "Initializing netdev\n");
- ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio,
- &wilc_hif_sdio);
- if (ret) {
- dev_err(&func->dev, "Couldn't initialize netdev\n");
- return ret;
- }
- sdio_set_drvdata(func, wilc);
- wilc->dev = &func->dev;
-
- dev_info(&func->dev, "Driver Initializing success\n");
- return 0;
-}
-
-static void linux_sdio_remove(struct sdio_func *func)
-{
- wilc_netdev_cleanup(sdio_get_drvdata(func));
-}
-
-static struct sdio_driver wilc1000_sdio_driver = {
- .name = SDIO_MODALIAS,
- .id_table = wilc_sdio_ids,
- .probe = linux_sdio_probe,
- .remove = linux_sdio_remove,
-};
-module_driver(wilc1000_sdio_driver,
- sdio_register_driver,
- sdio_unregister_driver);
-MODULE_LICENSE("GPL");
-
-int wilc_sdio_enable_interrupt(struct wilc *dev)
-{
- struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev);
- int ret = 0;
-
- sdio_claim_host(func);
- ret = sdio_claim_irq(func, wilc_sdio_interrupt);
- sdio_release_host(func);
-
- if (ret < 0) {
- dev_err(&func->dev, "can't claim sdio_irq, err(%d)\n", ret);
- ret = -EIO;
- }
- return ret;
-}
-
-void wilc_sdio_disable_interrupt(struct wilc *dev)
-{
- struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev);
- int ret;
-
- dev_dbg(&func->dev, "wilc_sdio_disable_interrupt IN\n");
-
- sdio_claim_host(func);
- ret = sdio_release_irq(func);
- if (ret < 0)
- dev_err(&func->dev, "can't release sdio_irq, err(%d)\n", ret);
- sdio_release_host(func);
-
- dev_info(&func->dev, "wilc_sdio_disable_interrupt OUT\n");
-}
-
-int wilc_sdio_init(void)
-{
- return 1;
-}
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
index 8d276c6..abb2312 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.h
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.h
@@ -1,8 +1 @@
#include <linux/mmc/sdio_func.h>
-
-int wilc_sdio_init(void);
-int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd);
-int wilc_sdio_cmd53(struct wilc *wilc, sdio_cmd53_t *cmd);
-
-int wilc_sdio_enable_interrupt(struct wilc *);
-void wilc_sdio_disable_interrupt(struct wilc *);
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index fd640f1..464d27d 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -10,8 +10,23 @@
#include <linux/string.h>
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
-#include "linux_wlan_sdio.h"
#include "wilc_wfi_netdevice.h"
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
+#include <linux/of_gpio.h>
+
+#define SDIO_MODALIAS "wilc1000_sdio"
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+ { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+ { },
+};
#define WILC_SDIO_BLOCK_SIZE 512
@@ -28,6 +43,153 @@ static wilc_sdio_t g_sdio;
static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data);
static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data);
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+ sdio_release_host(func);
+ wilc_handle_isr(sdio_get_drvdata(func));
+ sdio_claim_host(func);
+}
+
+static int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd)
+{
+ struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+ int ret;
+ u8 data;
+
+ sdio_claim_host(func);
+
+ func->num = cmd->function;
+ if (cmd->read_write) { /* write */
+ if (cmd->raw) {
+ sdio_writeb(func, cmd->data, cmd->address, &ret);
+ data = sdio_readb(func, cmd->address, &ret);
+ cmd->data = data;
+ } else {
+ sdio_writeb(func, cmd->data, cmd->address, &ret);
+ }
+ } else { /* read */
+ data = sdio_readb(func, cmd->address, &ret);
+ cmd->data = data;
+ }
+
+ sdio_release_host(func);
+
+ if (ret)
+ dev_err(&func->dev, "wilc_sdio_cmd52..failed, err(%d)\n", ret);
+ return ret;
+}
+
+
+static int wilc_sdio_cmd53(struct wilc *wilc, sdio_cmd53_t *cmd)
+{
+ struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
+ int size, ret;
+
+ sdio_claim_host(func);
+
+ func->num = cmd->function;
+ func->cur_blksize = cmd->block_size;
+ if (cmd->block_mode)
+ size = cmd->count * cmd->block_size;
+ else
+ size = cmd->count;
+
+ if (cmd->read_write) { /* write */
+ ret = sdio_memcpy_toio(func, cmd->address,
+ (void *)cmd->buffer, size);
+ } else { /* read */
+ ret = sdio_memcpy_fromio(func, (void *)cmd->buffer,
+ cmd->address, size);
+ }
+
+ sdio_release_host(func);
+
+ if (ret)
+ dev_err(&func->dev, "wilc_sdio_cmd53..failed, err(%d)\n", ret);
+
+ return ret;
+}
+
+static int linux_sdio_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ struct wilc *wilc;
+ int gpio, ret;
+
+ gpio = -1;
+ if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+ gpio = of_get_gpio(func->dev.of_node, 0);
+ if (gpio < 0)
+ gpio = GPIO_NUM;
+ }
+
+ dev_dbg(&func->dev, "Initializing netdev\n");
+ ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio,
+ &wilc_hif_sdio);
+ if (ret) {
+ dev_err(&func->dev, "Couldn't initialize netdev\n");
+ return ret;
+ }
+ sdio_set_drvdata(func, wilc);
+ wilc->dev = &func->dev;
+
+ dev_info(&func->dev, "Driver Initializing success\n");
+ return 0;
+}
+
+static void linux_sdio_remove(struct sdio_func *func)
+{
+ wilc_netdev_cleanup(sdio_get_drvdata(func));
+}
+
+static struct sdio_driver wilc1000_sdio_driver = {
+ .name = SDIO_MODALIAS,
+ .id_table = wilc_sdio_ids,
+ .probe = linux_sdio_probe,
+ .remove = linux_sdio_remove,
+};
+module_driver(wilc1000_sdio_driver,
+ sdio_register_driver,
+ sdio_unregister_driver);
+MODULE_LICENSE("GPL");
+
+static int wilc_sdio_enable_interrupt(struct wilc *dev)
+{
+ struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev);
+ int ret = 0;
+
+ sdio_claim_host(func);
+ ret = sdio_claim_irq(func, wilc_sdio_interrupt);
+ sdio_release_host(func);
+
+ if (ret < 0) {
+ dev_err(&func->dev, "can't claim sdio_irq, err(%d)\n", ret);
+ ret = -EIO;
+ }
+ return ret;
+}
+
+static void wilc_sdio_disable_interrupt(struct wilc *dev)
+{
+ struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev);
+ int ret;
+
+ dev_dbg(&func->dev, "wilc_sdio_disable_interrupt IN\n");
+
+ sdio_claim_host(func);
+ ret = sdio_release_irq(func);
+ if (ret < 0)
+ dev_err(&func->dev, "can't release sdio_irq, err(%d)\n", ret);
+ sdio_release_host(func);
+
+ dev_info(&func->dev, "wilc_sdio_disable_interrupt OUT\n");
+}
+
+static int wilc_sdio_init(void)
+{
+ return 1;
+}
+
/********************************************
*
* Function 0
--
1.9.1
This patch removes linux_wlan_sdio.[ch] which is not used anymore.
Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/Makefile | 2 +-
drivers/staging/wilc1000/linux_wlan_sdio.c | 10 ----------
drivers/staging/wilc1000/linux_wlan_sdio.h | 1 -
3 files changed, 1 insertion(+), 12 deletions(-)
delete mode 100644 drivers/staging/wilc1000/linux_wlan_sdio.c
delete mode 100644 drivers/staging/wilc1000/linux_wlan_sdio.h
diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile
index 2076743..09f0ddb 100644
--- a/drivers/staging/wilc1000/Makefile
+++ b/drivers/staging/wilc1000/Makefile
@@ -14,7 +14,7 @@ wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
wilc_wlan.o
obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o
-wilc1000-sdio-objs += linux_wlan_sdio.o wilc_sdio.o
+wilc1000-sdio-objs += wilc_sdio.o
obj-$(CONFIG_WILC1000_SPI) += wilc1000-spi.o
wilc1000-spi-objs += linux_wlan_spi.o wilc_spi.o
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
deleted file mode 100644
index 67d99e9..0000000
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "wilc_wfi_netdevice.h"
-
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/host.h>
-#include <linux/of_gpio.h>
-
-#include "linux_wlan_sdio.h"
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
deleted file mode 100644
index abb2312..0000000
--- a/drivers/staging/wilc1000/linux_wlan_sdio.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/mmc/sdio_func.h>
--
1.9.1
On Wed, Nov 25, 2015 at 06:35:26PM +0900, Glen Lee wrote:
> return linux error value instead of 0 or 1 and use -EINVAL. Related codes
> also changed together.
>
> Signed-off-by: Glen Lee <[email protected]>
> ---
> drivers/staging/wilc1000/linux_wlan_spi.c | 14 +++-----------
> drivers/staging/wilc1000/wilc_spi.c | 18 +++++++++---------
> 2 files changed, 12 insertions(+), 20 deletions(-)
Series did not apply :(