staging: wilc1000: wilc_spi_read: pass struct wilc
authorGlen Lee <glen.lee@atmel.com>
Wed, 18 Nov 2015 06:11:30 +0000 (15:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Dec 2015 22:30:50 +0000 (14:30 -0800)
This patch adds new function parameter struct wilc and use it instead of
global variable wilc_dev, and pass wilc to the functions as well.

Signed-off-by: Glen Lee <glen.lee@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_wlan_spi.c
drivers/staging/wilc1000/linux_wlan_spi.h
drivers/staging/wilc1000/wilc_spi.c

index 7be750bbe9da8769433b1edc94d354be93ba0bff..5066191b9013065b3f80aa2d49a6365af76c06d9 100644 (file)
@@ -112,9 +112,9 @@ int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len)
        return ret;
 }
 
-int wilc_spi_read(u8 *rb, u32 rlen)
+int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen)
 {
-       struct spi_device *spi = to_spi_device(wilc_dev->dev);
+       struct spi_device *spi = to_spi_device(wilc->dev);
        int ret;
 
        if (rlen > 0) {
index 41d47dc9cf95966c4cfd55e92ff723989eb0cd43..16f0b9fb82f8cd1395144e816e400ce1e846b3d9 100644 (file)
@@ -6,6 +6,6 @@
 
 int wilc_spi_init(void);
 int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len);
-int wilc_spi_read(u8 *rb, u32 rlen);
+int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen);
 int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen);
 #endif
index 46f7ea83577024eacd6a04c09e7c11ac8d7294ba..5e21109ceadf6884bbf3a9e3dc8cb7f7822e6de2 100644 (file)
@@ -365,7 +365,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
                                /**
                                 * Read bytes
                                 **/
-                               if (!wilc_spi_read(&b[ix], nbytes)) {
+                               if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
                                        PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
                                        result = N_FAIL;
                                        goto _error_;
@@ -375,7 +375,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(crc, 2)) {
+                                       if (!wilc_spi_read(wilc, crc, 2)) {
                                                PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
                                                result = N_FAIL;
                                                goto _error_;
@@ -406,7 +406,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
                                 **/
                                retry = 10;
                                do {
-                                       if (!wilc_spi_read(&rsp, 1)) {
+                                       if (!wilc_spi_read(wilc, &rsp, 1)) {
                                                PRINT_ER("[wilc spi]: Failed data response read, bus error...\n");
                                                result = N_FAIL;
                                                break;
@@ -422,7 +422,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
                                /**
                                 * Read bytes
                                 **/
-                               if (!wilc_spi_read(&b[ix], nbytes)) {
+                               if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
                                        PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
                                        result = N_FAIL;
                                        break;
@@ -432,7 +432,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(crc, 2)) {
+                                       if (!wilc_spi_read(wilc, crc, 2)) {
                                                PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
                                                result = N_FAIL;
                                                break;