[PATCH v2] staging/android/ion : fix a race condition in the ion driver

2016-02-19 Thread EunTaik Lee
There is a use-after-free problem in the ion driver.
This is caused by a race condition in the ion_ioctl()
function.

A handle has ref count of 1 and two tasks on different
cpus calls ION_IOC_FREE simultaneously.

cpu 0   cpu 1
---
ion_handle_get_by_id()
(ref == 2)
ion_handle_get_by_id()
(ref == 3)

ion_free()
(ref == 2)

ion_handle_put()
(ref == 1)

ion_free()
(ref == 0 so ion_handle_destroy() is
called
and the handle is freed.)

ion_handle_put() is called and it
decreases the slub's next free pointer

The problem is detected as an unaligned access in the
spin lock functions since it uses load exclusive
 instruction. In some cases it corrupts the slub's
free pointer which causes a mis-aligned access to the
next free pointer.(kmalloc returns a pointer like
c0745b4580aa). And it causes lots of other
hard-to-debug problems.

This symptom is caused since the first member in the
ion_handle structure is the reference count and the
ion driver decrements the reference after it has been
freed.

To fix this problem client->lock mutex is extended
to protect all the codes that uses the handle.

Signed-off-by: Eun Taik Lee 
---
 drivers/staging/android/ion/ion.c | 102 ++
 1 file changed, 82 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e237e9f..c6fbe48 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -385,13 +385,22 @@ static void ion_handle_get(struct ion_handle *handle)
kref_get(&handle->ref);
 }
 
+static int ion_handle_put_nolock(struct ion_handle *handle)
+{
+   int ret;
+
+   ret = kref_put(&handle->ref, ion_handle_destroy);
+
+   return ret;
+}
+
 static int ion_handle_put(struct ion_handle *handle)
 {
struct ion_client *client = handle->client;
int ret;
 
mutex_lock(&client->lock);
-   ret = kref_put(&handle->ref, ion_handle_destroy);
+   ret = ion_handle_put_nolock(handle);
mutex_unlock(&client->lock);
 
return ret;
@@ -415,20 +424,30 @@ static struct ion_handle *ion_handle_lookup(struct 
ion_client *client,
return ERR_PTR(-EINVAL);
 }
 
-static struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
-   int id)
+static struct ion_handle *ion_handle_get_by_id_nolock(struct ion_client 
*client,
+ int id)
 {
struct ion_handle *handle;
 
-   mutex_lock(&client->lock);
handle = idr_find(&client->idr, id);
if (handle)
ion_handle_get(handle);
-   mutex_unlock(&client->lock);
 
return handle ? handle : ERR_PTR(-EINVAL);
 }
 
+struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
+   int id)
+{
+   struct ion_handle *handle;
+
+   mutex_lock(&client->lock);
+   handle = ion_handle_get_by_id_nolock(client, id);
+   mutex_unlock(&client->lock);
+
+   return handle;
+}
+
 static bool ion_handle_validate(struct ion_client *client,
struct ion_handle *handle)
 {
@@ -530,7 +549,8 @@ struct ion_handle *ion_alloc(struct ion_client *client, 
size_t len,
 }
 EXPORT_SYMBOL(ion_alloc);
 
-void ion_free(struct ion_client *client, struct ion_handle *handle)
+static void ion_free_nolock(struct ion_client *client,
+   struct ion_handle *handle)
 {
bool valid_handle;
 
@@ -538,15 +558,24 @@ void ion_free(struct ion_client *client, struct 
ion_handle *handle)
 
mutex_lock(&client->lock);
valid_handle = ion_handle_validate(client, handle);
-
if (!valid_handle) {
WARN(1, "%s: invalid handle passed to free.\n", __func__);
mutex_unlock(&client->lock);
return;
}
+   ion_handle_put_nolock(handle);
+}
+
+void ion_free(struct ion_client *client, struct ion_handle *handle)
+{
+   BUG_ON(client != handle->client);
+
+   mutex_lock(&client->lock);
+   ion_free_nolock(client, handle);
mutex_unlock(&client->lock);
ion_handle_put(handle);
 }
+
 EXPORT_SYMBOL(ion_free);
 
 int ion_phys(struct ion_client *client, struct ion_handle *handle,
@@ -830,6 +859,7 @@ void ion_client_destroy(struct ion_client *client)
struct rb_node *n;
 
pr_debug("%s: %d\n", __func__, __LINE__);
+   mutex_lock(&client->lock);
while ((n = rb_first(&client->handles))) {
struct ion_handle *handle = rb_entry(n, struct ion_handle,
 node);
@@ -837,6 +867,7 

[PATCH 3/6] staging: wilc1000: removes unnecessary wilc_debug print log

2016-02-19 Thread Leo Kim
This patch removes unnecessary wilc_debug print log and the check routine.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/wilc_wlan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 2719c3d..a51c66b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -529,9 +529,6 @@ void chip_wakeup(struct wilc *wilc)
 
wilc->hif_func->hif_read_reg(wilc, 0xf1,
 &clk_status_reg);
-
-   if ((clk_status_reg & 0x1) == 0)
-   wilc_debug(N_ERR, "clocks still OFF. 
Wake up failed\n");
}
if ((clk_status_reg & 0x1) == 0) {
wilc->hif_func->hif_write_reg(wilc, 0xf0,
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] staging: wilc1000: removes unnecessary variable of wilc_mac_cfg_t structure

2016-02-19 Thread Leo Kim
This patch removes unnecessary variable of wilc_mac_cfg_t structure.
The variable is debug print function pointer.
Removes all what used this variable.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/wilc_wlan_cfg.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index 2bb684a..e73381d 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -20,8 +20,6 @@
  /
 
 typedef struct {
-   wilc_debug_func dPrint;
-
int mac_status;
u8 mac_address[7];
u8 ip_address[5];
@@ -389,8 +387,6 @@ int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 
*buf, int size)
ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size);
} else if (type == 4) { /* binary command */
ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size);
-   } else {
-   g_mac.dPrint(N_ERR, "illegal id\n");
}
 
return ret;
@@ -481,8 +477,6 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 
buffer_size)
}
i++;
} while (1);
-   } else {
-   g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid);
}
 
return ret;
@@ -540,6 +534,5 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, 
int size,
 int wilc_wlan_cfg_init(wilc_debug_func func)
 {
memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t));
-   g_mac.dPrint = func;
return 1;
 }
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] staging: wilc1000: removes wilc_dbg()

2016-02-19 Thread Leo Kim
This patch removes wilc_dbg function because it's not any more.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/linux_wlan.c | 4 
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 --
 drivers/staging/wilc1000/wilc_wlan.c  | 2 --
 3 files changed, 8 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 660bf63..b0cd21b 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -224,10 +224,6 @@ static void deinit_irq(struct net_device *dev)
}
 }
 
-void wilc_dbg(u8 *buff)
-{
-}
-
 int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout)
 {
/* FIXME: replace with mutex_lock or wait_for_completion */
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 3077f5d4..786f5fd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -228,8 +228,6 @@ int wilc1000_wlan_init(struct net_device *dev, struct 
wilc_vif *vif);
 
 void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
 void wilc_mac_indicate(struct wilc *wilc, int flag);
-void wilc_dbg(u8 *buff);
-
 int wilc_lock_timeout(struct wilc *wilc, void *, u32 timeout);
 void wilc_netdev_cleanup(struct wilc *wilc);
 int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int 
gpio,
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 0cd3ed8..81a40e8 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -15,8 +15,6 @@ static void wilc_debug(u32 flag, char *fmt, ...)
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
-
-   wilc_dbg(buf);
}
 }
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/6] staging: wilc1000: removes unnecessary wilc_debug print log

2016-02-19 Thread Leo Kim
This patch removes unnecessary wilc_debug print log.
The print log was written when if condition fail.
The condition is chip-id check function.
Also, replaces this condition with normal function.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/wilc_wlan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index a51c66b..4873106 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -508,9 +508,7 @@ void chip_wakeup(struct wilc *wilc)
 
do {
usleep_range(2 * 1000, 2 * 1000);
-   if ((wilc_get_chipid(wilc, true) == 0))
-   wilc_debug(N_ERR, "Couldn't read chip 
id. Wake up failed\n");
-
+   wilc_get_chipid(wilc, true);
} while ((wilc_get_chipid(wilc, true) == 0) && 
((++trials % 3) == 0));
 
} while (wilc_get_chipid(wilc, true) == 0);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] staging: wilc1000: replaces wilc_debug with netdev_err

2016-02-19 Thread Leo Kim
This patches replaces wilc_debug with netdev_err.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/wilc_wlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 81a40e8..2719c3d 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1401,18 +1401,18 @@ static u32 init_chip(struct net_device *dev)
if ((chipid & 0xfff) != 0xa0) {
ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®);
if (!ret) {
-   wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 
...\n");
+   netdev_err(dev, "fail read reg 0x1118\n");
return ret;
}
reg |= BIT(0);
ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg);
if (!ret) {
-   wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 
...\n");
+   netdev_err(dev, "fail write reg 0x1118\n");
return ret;
}
ret = wilc->hif_func->hif_write_reg(wilc, 0xc, 0x71);
if (!ret) {
-   wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc 
...\n");
+   netdev_err(dev, "fail write reg 0xc\n");
return ret;
}
}
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] staging: wilc1000: wilc_wlan_cfg_init: changes unused argument

2016-02-19 Thread Leo Kim
This patch changes the argument of the wilc_wlan_cfg_init function,
wilc_debug to void type because wilc_debug function is not used any more.
In addition, finally removes wilc_debug and related variables.

Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/wilc_wlan.c | 17 +
 drivers/staging/wilc1000/wilc_wlan_cfg.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_cfg.h |  2 +-
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 4873106..461abfc 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -3,21 +3,6 @@
 #include "wilc_wfi_netdevice.h"
 #include "wilc_wlan_cfg.h"
 
-static u32 dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ;
-
-/* FIXME: replace with dev_debug() */
-static void wilc_debug(u32 flag, char *fmt, ...)
-{
-   char buf[256];
-   va_list args;
-
-   if (flag & dbgflag) {
-   va_start(args, fmt);
-   vsprintf(buf, fmt, args);
-   va_end(args);
-   }
-}
-
 static CHIP_PS_STATE_T chip_ps_state = CHIP_WAKEDUP;
 
 static inline void acquire_bus(struct wilc *wilc, BUS_ACQUIRE_T acquire)
@@ -1460,7 +1445,7 @@ int wilc_wlan_init(struct net_device *dev)
goto _fail_;
}
 
-   if (!wilc_wlan_cfg_init(wilc_debug)) {
+   if (!wilc_wlan_cfg_init()) {
ret = -ENOBUFS;
goto _fail_;
}
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index e73381d..631bbf1 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -531,7 +531,7 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, 
int size,
return ret;
 }
 
-int wilc_wlan_cfg_init(wilc_debug_func func)
+int wilc_wlan_cfg_init(void)
 {
memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t));
return 1;
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h 
b/drivers/staging/wilc1000/wilc_wlan_cfg.h
index 5f74eb8..00e5dd5 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.h
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h
@@ -36,6 +36,6 @@ int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id);
 int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size);
 int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
  struct wilc_cfg_rsp *rsp);
-int wilc_wlan_cfg_init(wilc_debug_func func);
+int wilc_wlan_cfg_init(void);
 
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8712: Improve suspend/resume functionality.

2016-02-19 Thread Dan Carpenter
Run your patch through scripts/checkpatch.pl

ERROR: that open brace { should be on the previous line

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH] drivers: android: correct the size of struct binder_uintptr_t for BC_DEAD_BINDER_DONE

2016-02-19 Thread Dan Carpenter
On Wed, Feb 17, 2016 at 09:32:52AM +0800, Nicolas Boichat wrote:
> This patch was first sent upstream here: https://lkml.org/lkml/2015/5/28/747,
> but was not picked up (probably because it was part of a bigger series that
> refactored binder).

Riley was supposed to resend it with a proper sign off but he must have
lost track.  Anyway, thanks for doing follow up on this.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: wilc1000: remove useless define in linux_wlan_common.h file

2016-02-19 Thread Leo Kim
From: Chris Park 

This patch removes useless define in linux_wlan_common.h file

Signed-off-by: Chris Park 
Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/linux_wlan_common.h | 32 
 1 file changed, 32 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_common.h 
b/drivers/staging/wilc1000/linux_wlan_common.h
index 37848c0..18d902b 100644
--- a/drivers/staging/wilc1000/linux_wlan_common.h
+++ b/drivers/staging/wilc1000/linux_wlan_common.h
@@ -1,35 +1,3 @@
 #ifndef LINUX_WLAN_COMMON_H
 #define LINUX_WLAN_COMMON_H
-
-#if defined(BEAGLE_BOARD)
-   #define SPI_CHANNEL 4
-
-   #if SPI_CHANNEL == 4
-   #define MODALIAS"wilc_spi4"
-   #define GPIO_NUM162
-   #else
-   #define MODALIAS"wilc_spi3"
-   #define GPIO_NUM133
-   #endif
-#elif defined(PLAT_WMS8304) /* rachel */
-   #define MODALIAS"wilc_spi"
-   #define GPIO_NUM139
-#elif defined(PLAT_RK)
- #define MODALIAS  "WILC_IRQ"
- #define GPIO_NUM  RK30_PIN3_PD2 /* RK30_PIN3_PA1 */
-/* RK30_PIN3_PD2 */
-/* RK2928_PIN1_PA7 */
-
-#elif defined(CUSTOMER_PLATFORM)
-/*
- TODO : specify MODALIAS name and GPIO number. This is certainly necessary for 
SPI interface.
- *
- * ex)
- * #define MODALIAS  "WILC_SPI"
- * #define GPIO_NUM  139
- */
-
-#else
-/* base on SAMA5D3_Xplained Board */
-#endif
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: wilc1000: move MODALIS and GPIO_NUM define to wilc_wlan.h file

2016-02-19 Thread Leo Kim
From: Chris Park 

This patch moves MODALIS and GPIO_NUM define to wilc_wlan.h file.
MODALIS and GPIO_NUM define are used to two files (wilc_sdio.c,
wilc_spi.c), these files already include wilc_wlan.h file in common.

Signed-off-by: Chris Park 
Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/linux_wlan_common.h | 2 --
 drivers/staging/wilc1000/wilc_wlan.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_common.h 
b/drivers/staging/wilc1000/linux_wlan_common.h
index 5a53512..37848c0 100644
--- a/drivers/staging/wilc1000/linux_wlan_common.h
+++ b/drivers/staging/wilc1000/linux_wlan_common.h
@@ -31,7 +31,5 @@
 
 #else
 /* base on SAMA5D3_Xplained Board */
-   #define MODALIAS"WILC_SPI"
-   #define GPIO_NUM0x44
 #endif
 #endif
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 792d338..bcd4bfa 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -131,6 +131,8 @@
 #define LINUX_RX_SIZE  (96 * 1024)
 #define LINUX_TX_SIZE  (64 * 1024)
 
+#define MODALIAS   "WILC_SPI"
+#define GPIO_NUM   0x44
 /***/
 /*E0 and later Interrupt flags.*/
 /***/
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: wilc1000: move WILC_MULTICAST_TABLE_SIZE define to wilc_wlan_if.h file

2016-02-19 Thread Leo Kim
From: Chris Park 

This patch moves WILC_MULTICAST_TABLE_SIZE define to wilc_wlan_if.h file.
This define is used to three files(host_interface.c,host_interface.h,
linux_wlan.c) these files already include wilc_wlan_if.h file in common.

Signed-off-by: Chris Park 
Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/linux_wlan_common.h | 2 --
 drivers/staging/wilc1000/wilc_wlan_if.h  | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_common.h 
b/drivers/staging/wilc1000/linux_wlan_common.h
index aa2c026..5a53512 100644
--- a/drivers/staging/wilc1000/linux_wlan_common.h
+++ b/drivers/staging/wilc1000/linux_wlan_common.h
@@ -1,8 +1,6 @@
 #ifndef LINUX_WLAN_COMMON_H
 #define LINUX_WLAN_COMMON_H
 
-#define WILC_MULTICAST_TABLE_SIZE  8
-
 #if defined(BEAGLE_BOARD)
#define SPI_CHANNEL 4
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index 269c56e..c33f7a6 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -95,7 +95,7 @@ typedef void (*wilc_tx_complete_func_t)(void *, int);
  *  Wlan Configuration ID
  *
  /
-
+#define WILC_MULTICAST_TABLE_SIZE  8
 #define MAX_SSID_LEN33
 #define MAX_RATES_SUPPORTED 12
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: wilc1000: removes linux_wlan_common.h file

2016-02-19 Thread Leo Kim
From: Chris Park 

This patch removes linux_wlan_common.h file and also removes the following
preprocessor at files that include it:
 - #include 'linux_wlan_common.h'

Signed-off-by: Chris Park 
Signed-off-by: Leo Kim 
---
 drivers/staging/wilc1000/linux_mon.c | 1 -
 drivers/staging/wilc1000/linux_wlan.c| 1 -
 drivers/staging/wilc1000/linux_wlan_common.h | 3 ---
 drivers/staging/wilc1000/wilc_msgqueue.c | 1 -
 drivers/staging/wilc1000/wilc_spi.c  | 1 -
 drivers/staging/wilc1000/wilc_wlan_if.h  | 1 -
 6 files changed, 8 deletions(-)
 delete mode 100644 drivers/staging/wilc1000/linux_wlan_common.h

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index 28e52eb..637233b 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -7,7 +7,6 @@
  *  @version   1.0
  */
 #include "wilc_wfi_cfgoperations.h"
-#include "linux_wlan_common.h"
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
 
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index b0cd21b..4bf3440 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1,5 +1,4 @@
 #include "wilc_wfi_cfgoperations.h"
-#include "linux_wlan_common.h"
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
 
diff --git a/drivers/staging/wilc1000/linux_wlan_common.h 
b/drivers/staging/wilc1000/linux_wlan_common.h
deleted file mode 100644
index 18d902b..000
--- a/drivers/staging/wilc1000/linux_wlan_common.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef LINUX_WLAN_COMMON_H
-#define LINUX_WLAN_COMMON_H
-#endif
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 780ddd3..6cb894e 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -1,7 +1,6 @@
 
 #include "wilc_msgqueue.h"
 #include 
-#include "linux_wlan_common.h"
 #include 
 #include 
 
diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 2928712..83b6910 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 
-#include "linux_wlan_common.h"
 #include 
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index c33f7a6..fbe34eb 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -11,7 +11,6 @@
 #define WILC_WLAN_IF_H
 
 #include 
-#include "linux_wlan_common.h"
 #include 
 
 /
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8712: reduce stack usage

2016-02-19 Thread Dan Carpenter
Of course, we still reach almost the same maximum stack usage as before
because we're going to put the function on stack in the end anyway.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [lustre-devel] [PATCH] staging: lustre: Fixed the parenthesis

2016-02-19 Thread Dan Carpenter
On Tue, Feb 16, 2016 at 10:39:05PM -0800, shalin mehta wrote:
> Hello,
> 
> Should I send this patch again due the spelling mistake in the patch
> description?
> 


Yes.  And put what Oleg Drokin said about it worked because there were
no users in the changelog.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/6] staging: wilc1000: removes unnecessary wilc_debug print log

2016-02-19 Thread Dan Carpenter
On Fri, Feb 19, 2016 at 05:37:10PM +0900, Leo Kim wrote:
> This patch removes unnecessary wilc_debug print log.
> The print log was written when if condition fail.
> The condition is chip-id check function.
> Also, replaces this condition with normal function.
> 
> Signed-off-by: Leo Kim 
> ---
>  drivers/staging/wilc1000/wilc_wlan.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
> b/drivers/staging/wilc1000/wilc_wlan.c
> index a51c66b..4873106 100644
> --- a/drivers/staging/wilc1000/wilc_wlan.c
> +++ b/drivers/staging/wilc1000/wilc_wlan.c
> @@ -508,9 +508,7 @@ void chip_wakeup(struct wilc *wilc)
>  
>   do {
>   usleep_range(2 * 1000, 2 * 1000);
> - if ((wilc_get_chipid(wilc, true) == 0))
> - wilc_debug(N_ERR, "Couldn't read chip 
> id. Wake up failed\n");
> -
> + wilc_get_chipid(wilc, true);

Why do we need this function when we call it again on the next line?

>   } while ((wilc_get_chipid(wilc, true) == 0) && 
> ((++trials % 3) == 0));
  ^^^

Also what the heck is ((++trials % 3) == 0))???  It looks like we are
supposed to retry 3 times but actually we don't retry at all.  :P

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging/android/ion : fix a race condition in the ion driver

2016-02-19 Thread EunTaik Lee
There is a use-after-free problem in the ion driver.
This is caused by a race condition in the ion_ioctl()
function.

A handle has ref count of 1 and two tasks on different
cpus calls ION_IOC_FREE simultaneously.

cpu 0   cpu 1
---
ion_handle_get_by_id()
(ref == 2)
ion_handle_get_by_id()
(ref == 3)

ion_free()
(ref == 2)

ion_handle_put()
(ref == 1)

ion_free()
(ref == 0 so ion_handle_destroy() is
called
and the handle is freed.)

ion_handle_put() is called and it
decreases the slub's next free pointer

The problem is detected as an unaligned access in the
spin lock functions since it uses load exclusive
 instruction. In some cases it corrupts the slub's
free pointer which causes a mis-aligned access to the
next free pointer.(kmalloc returns a pointer like
c0745b4580aa). And it causes lots of other
hard-to-debug problems.

This symptom is caused since the first member in the
ion_handle structure is the reference count and the
ion driver decrements the reference after it has been
freed.

To fix this problem client->lock mutex is extended
to protect all the codes that uses the handle.

Signed-off-by: Eun Taik Lee 
---
changes in v2 : 
 1. add problem description in the comment
 2. fix un-matching mutex_lock/unlock pair in ion_share_dma_buf()

 drivers/staging/android/ion/ion.c | 102 ++
 1 file changed, 82 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e237e9f..c6fbe48 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -385,13 +385,22 @@ static void ion_handle_get(struct ion_handle *handle)
kref_get(&handle->ref);
 }
 
+static int ion_handle_put_nolock(struct ion_handle *handle)
+{
+   int ret;
+
+   ret = kref_put(&handle->ref, ion_handle_destroy);
+
+   return ret;
+}
+
 static int ion_handle_put(struct ion_handle *handle)
 {
struct ion_client *client = handle->client;
int ret;
 
mutex_lock(&client->lock);
-   ret = kref_put(&handle->ref, ion_handle_destroy);
+   ret = ion_handle_put_nolock(handle);
mutex_unlock(&client->lock);
 
return ret;
@@ -415,20 +424,30 @@ static struct ion_handle *ion_handle_lookup(struct 
ion_client *client,
return ERR_PTR(-EINVAL);
 }
 
-static struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
-   int id)
+static struct ion_handle *ion_handle_get_by_id_nolock(struct ion_client 
*client,
+ int id)
 {
struct ion_handle *handle;
 
-   mutex_lock(&client->lock);
handle = idr_find(&client->idr, id);
if (handle)
ion_handle_get(handle);
-   mutex_unlock(&client->lock);
 
return handle ? handle : ERR_PTR(-EINVAL);
 }
 
+struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
+   int id)
+{
+   struct ion_handle *handle;
+
+   mutex_lock(&client->lock);
+   handle = ion_handle_get_by_id_nolock(client, id);
+   mutex_unlock(&client->lock);
+
+   return handle;
+}
+
 static bool ion_handle_validate(struct ion_client *client,
struct ion_handle *handle)
 {
@@ -530,7 +549,8 @@ struct ion_handle *ion_alloc(struct ion_client *client, 
size_t len,
 }
 EXPORT_SYMBOL(ion_alloc);
 
-void ion_free(struct ion_client *client, struct ion_handle *handle)
+static void ion_free_nolock(struct ion_client *client,
+   struct ion_handle *handle)
 {
bool valid_handle;
 
@@ -538,15 +558,24 @@ void ion_free(struct ion_client *client, struct 
ion_handle *handle)
 
mutex_lock(&client->lock);
valid_handle = ion_handle_validate(client, handle);
-
if (!valid_handle) {
WARN(1, "%s: invalid handle passed to free.\n", __func__);
mutex_unlock(&client->lock);
return;
}
+   ion_handle_put_nolock(handle);
+}
+
+void ion_free(struct ion_client *client, struct ion_handle *handle)
+{
+   BUG_ON(client != handle->client);
+
+   mutex_lock(&client->lock);
+   ion_free_nolock(client, handle);
mutex_unlock(&client->lock);
ion_handle_put(handle);
 }
+
 EXPORT_SYMBOL(ion_free);
 
 int ion_phys(struct ion_client *client, struct ion_handle *handle,
@@ -830,6 +859,7 @@ void ion_client_destroy(struct ion_client *client)
struct rb_node *n;
 
pr_debug("%s: %d\n", __func__, __LINE__);
+   mutex_lock(&client->lock);
while ((n = rb_first(&client->handles))) {
struct io

Re: [RESEND PATCH] drivers: android: correct the size of struct binder_uintptr_t for BC_DEAD_BINDER_DONE

2016-02-19 Thread Olof Johansson
Hi,

On Tue, Feb 16, 2016 at 5:32 PM, Nicolas Boichat  wrote:
> From: Lisa Du 
>
> There's one point was missed in the patch commit da49889deb34 ("staging:
> binder: Support concurrent 32 bit and 64 bit processes."). When configure
> BINDER_IPC_32BIT, the size of binder_uintptr_t was 32bits, but size of
> void * is 64bit on 64bit system. Correct it here.
>
> Signed-off-by: Lisa Du 
> Signed-off-by: Nicolas Boichat 

Fixes: da49889deb34 ("staging: binder: Support concurrent 32 bit and
64 bit processes.")
Cc: 
Acked-by: Olof Johansson 

(Hopefully Greg's script adds all 3 tags when he applies the patch. :)


-Olof
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: sm750fb: use BIT() macro for single-bit fields definition

2016-02-19 Thread Mike Rapoport
Replace complex definition of single-bit fields with BIT() macro for the
registers that are not currently referenced by the driver.

Signed-off-by: Mike Rapoport 
---
 drivers/staging/sm750fb/ddk750_reg.h  | 1071 +
 drivers/staging/sm750fb/sm750_accel.h |   36 +-
 2 files changed, 290 insertions(+), 817 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_reg.h 
b/drivers/staging/sm750fb/ddk750_reg.h
index 95c5cac..d96ea9e 100644
--- a/drivers/staging/sm750fb/ddk750_reg.h
+++ b/drivers/staging/sm750fb/ddk750_reg.h
@@ -109,9 +109,7 @@
 #define GPIO_MUX_0BIT(0)
 
 #define LOCALMEM_ARBITRATION  0x0C
-#define LOCALMEM_ARBITRATION_ROTATE   28:28
-#define LOCALMEM_ARBITRATION_ROTATE_OFF   0
-#define LOCALMEM_ARBITRATION_ROTATE_ON1
+#define LOCALMEM_ARBITRATION_ROTATE   BIT(28)
 #define LOCALMEM_ARBITRATION_VGA  26:24
 #define LOCALMEM_ARBITRATION_VGA_OFF  0
 #define LOCALMEM_ARBITRATION_VGA_PRIORITY_1   1
@@ -177,9 +175,7 @@
 #define LOCALMEM_ARBITRATION_CRT_PRIORITY_7   7
 
 #define PCIMEM_ARBITRATION0x10
-#define PCIMEM_ARBITRATION_ROTATE 28:28
-#define PCIMEM_ARBITRATION_ROTATE_OFF 0
-#define PCIMEM_ARBITRATION_ROTATE_ON  1
+#define PCIMEM_ARBITRATION_ROTATE BIT(28)
 #define PCIMEM_ARBITRATION_VGA26:24
 #define PCIMEM_ARBITRATION_VGA_OFF0
 #define PCIMEM_ARBITRATION_VGA_PRIORITY_1 1
@@ -245,150 +241,55 @@
 #define PCIMEM_ARBITRATION_CRT_PRIORITY_7 7
 
 #define RAW_INT   0x20
-#define RAW_INT_ZVPORT1_VSYNC 4:4
-#define RAW_INT_ZVPORT1_VSYNC_INACTIVE0
-#define RAW_INT_ZVPORT1_VSYNC_ACTIVE  1
-#define RAW_INT_ZVPORT1_VSYNC_CLEAR   1
-#define RAW_INT_ZVPORT0_VSYNC 3:3
-#define RAW_INT_ZVPORT0_VSYNC_INACTIVE0
-#define RAW_INT_ZVPORT0_VSYNC_ACTIVE  1
-#define RAW_INT_ZVPORT0_VSYNC_CLEAR   1
-#define RAW_INT_CRT_VSYNC 2:2
-#define RAW_INT_CRT_VSYNC_INACTIVE0
-#define RAW_INT_CRT_VSYNC_ACTIVE  1
-#define RAW_INT_CRT_VSYNC_CLEAR   1
-#define RAW_INT_PANEL_VSYNC   1:1
-#define RAW_INT_PANEL_VSYNC_INACTIVE  0
-#define RAW_INT_PANEL_VSYNC_ACTIVE1
-#define RAW_INT_PANEL_VSYNC_CLEAR 1
-#define RAW_INT_VGA_VSYNC 0:0
-#define RAW_INT_VGA_VSYNC_INACTIVE0
-#define RAW_INT_VGA_VSYNC_ACTIVE  1
-#define RAW_INT_VGA_VSYNC_CLEAR   1
+#define RAW_INT_ZVPORT1_VSYNC BIT(4)
+#define RAW_INT_ZVPORT0_VSYNC BIT(3)
+#define RAW_INT_CRT_VSYNC BIT(2)
+#define RAW_INT_PANEL_VSYNC   BIT(1)
+#define RAW_INT_VGA_VSYNC BIT(0)
 
 #define INT_STATUS0x24
-#define INT_STATUS_GPIO31 31:31
-#define INT_STATUS_GPIO31_INACTIVE0
-#define INT_STATUS_GPIO31_ACTIVE  1
-#define INT_STATUS_GPIO30 30:30
-#define INT_STATUS_GPIO30_INACTIVE0
-#define INT_STATUS_GPIO30_ACTIVE  1
-#define INT_STATUS_GPIO29 29:29
-#define INT_STATUS_GPIO29_INACTIVE0
-#define INT_STATUS_GPIO29_ACTIVE  1
-#define INT_STATUS_GPIO28 28:28
-#define INT_STATUS_GPIO28_INACTIVE0
-#define INT_STATUS_GPIO28_ACTIVE  1
-#define INT_STATUS_GPIO27 27:27
-#define INT_STATUS_GPIO27_INACTIVE0
-#define INT_STATUS_GPIO27_ACTIVE  1
-#define INT_STATUS_GPIO26 26:26
-#define INT_STATUS_GPIO26_INACTIVE0
-#define INT_STATUS_GPIO26_ACTIVE  1
-#define INT_STATUS_GPIO25 25:25
-#define INT_STATUS_GPIO25_INACTIVE0
-#define INT_STATUS_GPIO25_ACTIVE  1
-#define INT_STATUS_I2C12:12
-#define INT_STATUS_I2C_INACTIVE   0
-#define INT_STATUS_I2C_ACTIVE 1
-#define INT_STATUS_PWM11:11
-#define INT_STATUS_PWM_INACTIVE   0
-#define INT_STATUS_PWM_ACTIVE 1
-#define INT_STATUS_DMA1   10:10
-#define INT_STAT

[PATCH 0/5] staging: sm750fb: complete changing register defines

2016-02-19 Thread Mike Rapoport
Hi,

This is the fourth (and final) set of patches that aim to replace custom
defines for register fields. The MSB:LSB notation for register fields is
completely removed and replaced by BIT() for single-bit fields and with
*_MASK for multi-bit fields. The removal of MSB:LSB notation allowed to get
rid of FIELD_*() macros. 

Mike Rapoport (5):
  staging: sm750fb: use BIT() macro for single-bit fields definition
  staging: sm750: change definition of multi-bit register fields
  staging: sm750fb: replace absDiff with kernel standard abs macro
  staging: sm750fb: move MHz() and roundedDiv() close to their usage
  staging: sm750fb: remove sm750_help.h

 drivers/staging/sm750fb/ddk750_chip.c  |7 +-
 drivers/staging/sm750fb/ddk750_help.h  |1 -
 drivers/staging/sm750fb/ddk750_reg.h   | 1978 
 drivers/staging/sm750fb/sm750_accel.c  |1 -
 drivers/staging/sm750fb/sm750_accel.h  |   98 +-
 drivers/staging/sm750fb/sm750_cursor.c |1 -
 drivers/staging/sm750fb/sm750_help.h   |   56 -
 7 files changed, 780 insertions(+), 1362 deletions(-)
 delete mode 100644 drivers/staging/sm750fb/sm750_help.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: sm750fb: move MHz() and roundedDiv() close to their usage

2016-02-19 Thread Mike Rapoport
The MHz() and roundedDiv macros are used only by ddk750_chip.c, so move
their definition there.

Signed-off-by: Mike Rapoport 
---
 drivers/staging/sm750fb/ddk750_chip.c | 4 
 drivers/staging/sm750fb/sm750_help.h  | 7 ---
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 02157f8..95f7cae 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -6,6 +6,10 @@
 #include "ddk750_chip.h"
 #include "ddk750_power.h"
 
+/* n / d + 1 / 2 = (2n + d) / 2d */
+#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
+#define MHz(x) ((x) * 100)
+
 logical_chip_type_t getChipType(void)
 {
unsigned short physicalID;
diff --git a/drivers/staging/sm750fb/sm750_help.h 
b/drivers/staging/sm750fb/sm750_help.h
index ce94d29..833cf16 100644
--- a/drivers/staging/sm750fb/sm750_help.h
+++ b/drivers/staging/sm750fb/sm750_help.h
@@ -38,11 +38,4 @@
 #define FIELD_SIZE(field)   (1 + FIELD_END(field) - 
FIELD_START(field))
 #define FIELD_MASK(field)   (((1 << (FIELD_SIZE(field)-1)) | ((1 
<< (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field))
 
-/* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
-#define MHz(x) ((x) * 100)
-
-
-
-
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: sm750fb: remove sm750_help.h

2016-02-19 Thread Mike Rapoport
This header only contains unused FIELD_*() macros and friends and may be
removed

Signed-off-by: Mike Rapoport 
---
 drivers/staging/sm750fb/ddk750_help.h  |  1 -
 drivers/staging/sm750fb/sm750_accel.c  |  1 -
 drivers/staging/sm750fb/sm750_cursor.c |  1 -
 drivers/staging/sm750fb/sm750_help.h   | 41 --
 4 files changed, 44 deletions(-)
 delete mode 100644 drivers/staging/sm750fb/sm750_help.h

diff --git a/drivers/staging/sm750fb/ddk750_help.h 
b/drivers/staging/sm750fb/ddk750_help.h
index 5be814e..009db92 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -6,7 +6,6 @@
 #include 
 #include 
 #include 
-#include "sm750_help.h"
 
 /* software control endianness */
 #define PEEK32(addr) readl(addr + mmio750)
diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 5975bd0..9aa4066 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -17,7 +17,6 @@
 
 #include "sm750.h"
 #include "sm750_accel.h"
-#include "sm750_help.h"
 static inline void write_dpr(struct lynx_accel *accel, int offset, u32 
regValue)
 {
writel(regValue, accel->dprBase + offset);
diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 37decce..2d348c6 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -16,7 +16,6 @@
 #include 
 
 #include "sm750.h"
-#include "sm750_help.h"
 #include "sm750_cursor.h"
 
 
diff --git a/drivers/staging/sm750fb/sm750_help.h 
b/drivers/staging/sm750fb/sm750_help.h
deleted file mode 100644
index 833cf16..000
--- a/drivers/staging/sm750fb/sm750_help.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef LYNX_HELP_H__
-#define LYNX_HELP_H__
-
-/* Internal macros */
-#define _F_START(f) (0 ? f)
-#define _F_END(f)   (1 ? f)
-#define _F_SIZE(f)  (1 + _F_END(f) - _F_START(f))
-#define _F_MASK(f)  (((1 << _F_SIZE(f)) - 1) << _F_START(f))
-#define _F_NORMALIZE(v, f)  (((v) & _F_MASK(f)) >> _F_START(f))
-#define _F_DENORMALIZE(v, f)(((v) << _F_START(f)) & _F_MASK(f))
-
-/* Global macros */
-#define FIELD_GET(x, reg, field) \
-( \
-   _F_NORMALIZE((x), reg ## _ ## field) \
-)
-
-#define FIELD_SET(x, reg, field, value) \
-( \
-   (x & ~_F_MASK(reg ## _ ## field)) \
-   | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \
-)
-
-#define FIELD_VALUE(x, reg, field, value) \
-( \
-   (x & ~_F_MASK(reg ## _ ## field)) \
-   | _F_DENORMALIZE(value, reg ## _ ## field) \
-)
-
-#define FIELD_CLEAR(reg, field) \
-( \
-   ~_F_MASK(reg ## _ ## field) \
-)
-
-/* Field Macros */
-#define FIELD_START(field)  (0 ? field)
-#define FIELD_END(field)(1 ? field)
-#define FIELD_SIZE(field)   (1 + FIELD_END(field) - 
FIELD_START(field))
-#define FIELD_MASK(field)   (((1 << (FIELD_SIZE(field)-1)) | ((1 
<< (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field))
-
-#endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: sm750: change definition of multi-bit register fields

2016-02-19 Thread Mike Rapoport
Use stratigh-forward of multi-bit register fields

Signed-off-by: Mike Rapoport 
---
 drivers/staging/sm750fb/ddk750_reg.h  | 907 +-
 drivers/staging/sm750fb/sm750_accel.h |  62 +--
 2 files changed, 484 insertions(+), 485 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_reg.h 
b/drivers/staging/sm750fb/ddk750_reg.h
index d96ea9e..9552479 100644
--- a/drivers/staging/sm750fb/ddk750_reg.h
+++ b/drivers/staging/sm750fb/ddk750_reg.h
@@ -110,135 +110,135 @@
 
 #define LOCALMEM_ARBITRATION  0x0C
 #define LOCALMEM_ARBITRATION_ROTATE   BIT(28)
-#define LOCALMEM_ARBITRATION_VGA  26:24
-#define LOCALMEM_ARBITRATION_VGA_OFF  0
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_1   1
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_2   2
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_3   3
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_4   4
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_5   5
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_6   6
-#define LOCALMEM_ARBITRATION_VGA_PRIORITY_7   7
-#define LOCALMEM_ARBITRATION_DMA  22:20
-#define LOCALMEM_ARBITRATION_DMA_OFF  0
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_1   1
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_2   2
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_3   3
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_4   4
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_5   5
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_6   6
-#define LOCALMEM_ARBITRATION_DMA_PRIORITY_7   7
-#define LOCALMEM_ARBITRATION_ZVPORT1  18:16
-#define LOCALMEM_ARBITRATION_ZVPORT1_OFF  0
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_1   1
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_2   2
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_3   3
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_4   4
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_5   5
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_6   6
-#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_7   7
-#define LOCALMEM_ARBITRATION_ZVPORT0  14:12
-#define LOCALMEM_ARBITRATION_ZVPORT0_OFF  0
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_1   1
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_2   2
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_3   3
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_4   4
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_5   5
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_6   6
-#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_7   7
-#define LOCALMEM_ARBITRATION_VIDEO10:8
-#define LOCALMEM_ARBITRATION_VIDEO_OFF0
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_1 1
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_2 2
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_3 3
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_4 4
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_5 5
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_6 6
-#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_7 7
-#define LOCALMEM_ARBITRATION_PANEL6:4
-#define LOCALMEM_ARBITRATION_PANEL_OFF0
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_1 1
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_2 2
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_3 3
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_4 4
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_5 5
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_6 6
-#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_7 7
-#define LOCALMEM_ARBITRATION_CRT  2:0
-#define LOCALMEM_ARBITRATION_CRT_OFF  0
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_1   1
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_2   2
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_3   3
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_4   4
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_5   5
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_6   6
-#define LOCALMEM_ARBITRATION_CRT_PRIORITY_7   7
+#define LOCALMEM_ARBITRATION_VGA_MASK (0x7 << 24)
+#define LOCALMEM_ARBITRATION_VGA_OFF  (0x0 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_1   (0x1 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_2   (0x2 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_3   (0x3 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_4   (0x4 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_5   (0x5 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_6   (0x6 << 24)
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_7   (0x7 << 24)
+#define LOCALMEM_ARBITRATION_DMA_MASK (0x7 << 20)
+#define LOCALMEM_ARBITRATION_DMA_OFF  (0x0 << 20)
+#define LOCALMEM_AR

[PATCH 3/5] staging: sm750fb: replace absDiff with kernel standard abs macro

2016-02-19 Thread Mike Rapoport
 already has 'abs', use it instead of custom absDiff

Signed-off-by: Mike Rapoport 
---
 drivers/staging/sm750fb/ddk750_chip.c | 3 ++-
 drivers/staging/sm750fb/sm750_help.h  | 8 
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index e53a3d1..02157f8 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 
 #include "ddk750_help.h"
@@ -335,7 +336,7 @@ unsigned int calcPllValue(unsigned int request_orig, 
pll_value_t *pll)
unsigned int diff;
 
tmpClock = pll->inputFreq * M / N / X;
-   diff = absDiff(tmpClock, request_orig);
+   diff = abs(tmpClock - request_orig);
if (diff < mini_diff) {
pll->M = M;
pll->N = N;
diff --git a/drivers/staging/sm750fb/sm750_help.h 
b/drivers/staging/sm750fb/sm750_help.h
index c070cf2..ce94d29 100644
--- a/drivers/staging/sm750fb/sm750_help.h
+++ b/drivers/staging/sm750fb/sm750_help.h
@@ -38,14 +38,6 @@
 #define FIELD_SIZE(field)   (1 + FIELD_END(field) - 
FIELD_START(field))
 #define FIELD_MASK(field)   (((1 << (FIELD_SIZE(field)-1)) | ((1 
<< (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field))
 
-static inline unsigned int absDiff(unsigned int a, unsigned int b)
-{
-   if (a < b)
-   return b-a;
-   else
-   return a-b;
-}
-
 /* n / d + 1 / 2 = (2n + d) / 2d */
 #define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 100)
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


staging: comedi: COMEDI_BUFINFO: some behavioural changes

2016-02-19 Thread Ian Abbott
These patches change the behavior of the `COMEDI_BUFINFO` ioctl, which
is used to manage buffer positions for a previously set up asynchronous
acquisition command.  It is used instead of the read and write file
operations when the buffer has been mmapped.

Patches 1 to 4 are fairly innocuous.  Patches 5 to 8 change the error
handling when the asynchronous command is no longer running, allow the
subdevice to become "non-busy" automatically in more cases (causing
subsequent calls to return `-EINVAL`), and report abnormal command
termination with return value `-EPIPE` (which also makes the subdevice
become non-busy).

1) staging: comedi: COMEDI_BUFINFO: get amount freed, not amount
   allocated
2) staging: comedi: COMEDI_BUFINFO: force bytes_read or bytes_written to
   0
3) staging: comedi: COMEDI_BUFINFO: update buffer before becoming
   non-busy
4) staging: comedi: COMEDI_BUFINFO: force bytes_written to 0 if stopped
5) staging: comedi: COMEDI_BUFINFO: return error if no active command
6) staging: comedi: COMEDI_BUFINFO: become non-busy even if bytes_read
   is 0
7) staging: comedi: COMEDI_BUFINFO: return -EPIPE for abnormal read
8) staging: comedi: COMEDI_BUFINFO: terminate "write" command when
   stopped

 drivers/staging/comedi/comedi_fops.c | 84 +++-
 1 file changed, 44 insertions(+), 40 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/8] staging: comedi: COMEDI_BUFINFO: get amount freed, not amount allocated

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the new
position.  On input, the `bytes_read` member of `struct comedi_bufinfo`
specifies the amount to advance the "read" position for an asynchronous
command in the "read" direction, and the `bytes_written` member
specifies the amount to advance the "write" position for a command in
the "write" direction.  The handler `do_bufinfo_ioctl()` may limit the
specified values according to amount of readable or writable space in
the buffer.  On output, the `struct comedi_bufinfo` is filled in with
the updated position information, along with the adjusted `bytes_read`
and `bytes_written` members.

Advancing the buffer position occurs in two steps: first, some buffer
space is allocated, and second, it is freed, advancing the current
"read" or "write" position.  Currently, `do_bufinfo_ioctl()` limits
`bytes_read` or `bytes_written` to the amount it could allocate in the
first step, but that is invisible and irrelevant to the ioctl user.
It's mostly irrelevant to the COMEDI internals as well, apart from
limiting how much can be freed in the second step.  Change it to ignore
how much it managed to allocate in the first step and just use the
amount that was actually freed in the second step, which is the amount
the current buffer position was actually moved by this ioctl call.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index d57fade..2cfb61e 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1142,8 +1142,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
return -EACCES;
 
if (bi.bytes_read && !(async->cmd.flags & CMDF_WRITE)) {
-   bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read);
-   comedi_buf_read_free(s, bi.bytes_read);
+   comedi_buf_read_alloc(s, bi.bytes_read);
+   bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read);
 
if (comedi_is_subdevice_idle(s) &&
comedi_buf_read_n_available(s) == 0) {
@@ -1152,9 +1152,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
}
 
if (bi.bytes_written && (async->cmd.flags & CMDF_WRITE)) {
-   bi.bytes_written =
-   comedi_buf_write_alloc(s, bi.bytes_written);
-   comedi_buf_write_free(s, bi.bytes_written);
+   comedi_buf_write_alloc(s, bi.bytes_written);
+   bi.bytes_written = comedi_buf_write_free(s, bi.bytes_written);
}
 
 copyback_position:
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/8] staging: comedi: COMEDI_BUFINFO: force bytes_read or bytes_written to 0

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the new
position.  On input, the `bytes_read` member of `struct comedi_bufinfo`
specifies the amount to advance the "read" position for an asynchronous
command in the "read" direction, and the `bytes_written` member
specifies the amount to advance the "write" position for a command in
the "write" direction.  The handler `do_bufinfo_ioctl()` may adjust
these by the amount the position is actually advanced before copying
them back to the user.  Currently, it ignores the specified `bytes_read`
value for a command in the "write" direction, and ignores the specified
`bytes_written` for a command in the "read" direction, so the values
copied back to the user are unchanged.  Change it to force the ignored
value to 0 before copying the values back to the user.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 2cfb61e..04d6040 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1141,19 +1141,25 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
if (s->busy != file)
return -EACCES;
 
-   if (bi.bytes_read && !(async->cmd.flags & CMDF_WRITE)) {
-   comedi_buf_read_alloc(s, bi.bytes_read);
-   bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read);
-
-   if (comedi_is_subdevice_idle(s) &&
-   comedi_buf_read_n_available(s) == 0) {
-   do_become_nonbusy(dev, s);
+   if (!(async->cmd.flags & CMDF_WRITE)) {
+   /* command was set up in "read" direction */
+   if (bi.bytes_read) {
+   comedi_buf_read_alloc(s, bi.bytes_read);
+   bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read);
+
+   if (comedi_is_subdevice_idle(s) &&
+   comedi_buf_read_n_available(s) == 0)
+   do_become_nonbusy(dev, s);
}
-   }
-
-   if (bi.bytes_written && (async->cmd.flags & CMDF_WRITE)) {
-   comedi_buf_write_alloc(s, bi.bytes_written);
-   bi.bytes_written = comedi_buf_write_free(s, bi.bytes_written);
+   bi.bytes_written = 0;
+   } else {
+   /* command was set up in "write" direction */
+   if (bi.bytes_written) {
+   comedi_buf_write_alloc(s, bi.bytes_written);
+   bi.bytes_written =
+   comedi_buf_write_free(s, bi.bytes_written);
+   }
+   bi.bytes_read = 0;
}
 
 copyback_position:
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/8] staging: comedi: COMEDI_BUFINFO: become non-busy even if bytes_read is 0

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the new
position.  On input, the `bytes_read` member of `struct comedi_bufinfo`
specified the amount to advance the "read" position for an asynchronous
command in the "read" direction.  If the command has already stopped
normally, and the "read" position has been advanced to the end of all
available data, the command is terminated by calling
`do_become_nonbusy()`.  (That is not currently done if the command
stopped with an error.)  Currently, the command is only terminated if
the user is trying to advance the "read" position by a non-zero amount.
Change it to allow the command to be terminated even if the user is not
trying to advance the "read" position.  This is justifiable, as the only
time a command stops without error is when it has been set up to read a
finite amount of data.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index a9fabf7..ffe58208 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1131,11 +1131,10 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
if (bi.bytes_read) {
comedi_buf_read_alloc(s, bi.bytes_read);
bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read);
-
-   if (comedi_is_subdevice_idle(s) &&
-   comedi_buf_read_n_available(s) == 0)
-   become_nonbusy = true;
}
+   if (comedi_is_subdevice_idle(s) &&
+   comedi_buf_read_n_available(s) == 0)
+   become_nonbusy = true;
bi.bytes_written = 0;
} else {
/* command was set up in "write" direction */
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/8] staging: comedi: COMEDI_BUFINFO: terminate "write" command when stopped

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the current
position.  An asynchronous command in the "read" direction is terminated
automatically once it has stopped and information about the final
position and error has been reported back to the user.  That is not
currently done for commands in the "write" direction.  Change it to
terminate the command in the "write" direction automatically.  If the
command stopped with an error, report an `EPIPE` error back to the user,
otherwise just report the final buffer position back to the user.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 7cb1d06..d1cf6a1 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1121,6 +1121,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
if (!async || s->busy != file)
return -EINVAL;
 
+   runflags = comedi_get_subdevice_runflags(s);
if (!(async->cmd.flags & CMDF_WRITE)) {
/* command was set up in "read" direction */
if (bi.bytes_read) {
@@ -1132,7 +1133,6 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
 * {"read" position not updated or command stopped normally},
 * then become non-busy.
 */
-   runflags = comedi_get_subdevice_runflags(s);
if (comedi_buf_read_n_available(s) == 0 &&
!comedi_is_runflags_running(runflags) &&
(bi.bytes_read == 0 ||
@@ -1144,9 +1144,12 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
bi.bytes_written = 0;
} else {
/* command was set up in "write" direction */
-   if (!comedi_is_subdevice_running(s))
+   if (!comedi_is_runflags_running(runflags)) {
bi.bytes_written = 0;
-   if (bi.bytes_written) {
+   become_nonbusy = true;
+   if (comedi_is_runflags_in_error(runflags))
+   retval = -EPIPE;
+   } else if (bi.bytes_written) {
comedi_buf_write_alloc(s, bi.bytes_written);
bi.bytes_written =
comedi_buf_write_free(s, bi.bytes_written);
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/8] staging: comedi: COMEDI_BUFINFO: update buffer before becoming non-busy

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the new
position.  For an asynchronous command in the "read" direction, if the
command has finished acquiring data normally, `do_become_nonbusy()` is
called to terminate the command.  That resets the buffer position, and
currently, the position information returned back to the user is after
the buffer has been reset.  It should be more useful to return the
buffer position before the reset, so move the call to
`do_become_nonbusy()` after the code that gets the updated buffer
position.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 04d6040..e625ef2 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -,6 +,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
struct comedi_bufinfo bi;
struct comedi_subdevice *s;
struct comedi_async *async;
+   bool become_nonbusy = false;
 
if (copy_from_user(&bi, arg, sizeof(bi)))
return -EFAULT;
@@ -1149,7 +1150,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
 
if (comedi_is_subdevice_idle(s) &&
comedi_buf_read_n_available(s) == 0)
-   do_become_nonbusy(dev, s);
+   become_nonbusy = true;
}
bi.bytes_written = 0;
} else {
@@ -1168,6 +1169,9 @@ copyback_position:
bi.buf_read_count = async->buf_read_count;
bi.buf_read_ptr = async->buf_read_ptr;
 
+   if (become_nonbusy)
+   do_become_nonbusy(dev, s);
+
 copyback:
if (copy_to_user(arg, &bi, sizeof(bi)))
return -EFAULT;
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/8] staging: comedi: COMEDI_BUFINFO: force bytes_written to 0 if stopped

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the new
position.  On input, the `bytes_written` member of `struct
comedi_bufinfo` specifies the amount to advance the "write" position for
an asynchronous command in the "write" direction.  On output, the member
indicates the amount the "write" position has actually been advanced.
Advancing the "write" position is current done even if the command has
stopped and cannot use any more written data.  Change it to force the
amount successfully written to 0 in that case.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index e625ef2..b7c9270 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1155,6 +1155,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
bi.bytes_written = 0;
} else {
/* command was set up in "write" direction */
+   if (!comedi_is_subdevice_running(s))
+   bi.bytes_written = 0;
if (bi.bytes_written) {
comedi_buf_write_alloc(s, bi.bytes_written);
bi.bytes_written =
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/8] staging: comedi: COMEDI_BUFINFO: return -EPIPE for abnormal read

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer by a specified amount (which can be 0) and get the current
position.  If an asynchronous command in the "read" direction has
stopped normally, the command is terminated as soon as the position has
been advanced to the end of all available data.  This is not currently
done if the command terminated with an error.  Change it to allow the
command to be terminated even if it stopped with an error, but report an
`EPIPE` error to the user first.  The `EPIPE` error will not be
reported until the "read" position reported back to the user has been
advanced to the end of all available data.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 27 ++-
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index ffe58208..7cb1d06 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -686,13 +686,6 @@ static bool __comedi_is_subdevice_running(struct 
comedi_subdevice *s)
return comedi_is_runflags_running(runflags);
 }
 
-static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
-{
-   unsigned runflags = comedi_get_subdevice_runflags(s);
-
-   return !(runflags & COMEDI_SRF_BUSY_MASK);
-}
-
 bool comedi_can_auto_free_spriv(struct comedi_subdevice *s)
 {
unsigned runflags = __comedi_get_subdevice_runflags(s);
@@ -,6 +1104,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
struct comedi_bufinfo bi;
struct comedi_subdevice *s;
struct comedi_async *async;
+   unsigned int runflags;
+   int retval = 0;
bool become_nonbusy = false;
 
if (copy_from_user(&bi, arg, sizeof(bi)))
@@ -1132,9 +1127,20 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
comedi_buf_read_alloc(s, bi.bytes_read);
bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read);
}
-   if (comedi_is_subdevice_idle(s) &&
-   comedi_buf_read_n_available(s) == 0)
+   /*
+* If nothing left to read, and command has stopped, and
+* {"read" position not updated or command stopped normally},
+* then become non-busy.
+*/
+   runflags = comedi_get_subdevice_runflags(s);
+   if (comedi_buf_read_n_available(s) == 0 &&
+   !comedi_is_runflags_running(runflags) &&
+   (bi.bytes_read == 0 ||
+!comedi_is_runflags_in_error(runflags))) {
become_nonbusy = true;
+   if (comedi_is_runflags_in_error(runflags))
+   retval = -EPIPE;
+   }
bi.bytes_written = 0;
} else {
/* command was set up in "write" direction */
@@ -1156,6 +1162,9 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
if (become_nonbusy)
do_become_nonbusy(dev, s);
 
+   if (retval)
+   return retval;
+
if (copy_to_user(arg, &bi, sizeof(bi)))
return -EFAULT;
 
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/8] staging: comedi: COMEDI_BUFINFO: return error if no active command

2016-02-19 Thread Ian Abbott
The `COMEDI_BUFINFO` ioctl is used to advance the current position in
the buffer and/or get the current buffer position.  If no asynchronous
command is active (started via the file object that issued this ioctl),
this information is meaningless.  Change it to return an error
(`-EINVAL`) in this case.  Prior to this change, if a command was
started via a different file object, the ioctl returned `-EACCES`, but
now it will return `-EINVAL`, which is consistent with the current
behavior of the "read" and "write" file operation handlers.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 22 ++
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index b7c9270..a9fabf7 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1123,24 +1123,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
 
async = s->async;
 
-   if (!async) {
-   dev_dbg(dev->class_dev,
-   "subdevice does not have async capability\n");
-   bi.buf_write_ptr = 0;
-   bi.buf_read_ptr = 0;
-   bi.buf_write_count = 0;
-   bi.buf_read_count = 0;
-   bi.bytes_read = 0;
-   bi.bytes_written = 0;
-   goto copyback;
-   }
-   if (!s->busy) {
-   bi.bytes_read = 0;
-   bi.bytes_written = 0;
-   goto copyback_position;
-   }
-   if (s->busy != file)
-   return -EACCES;
+   if (!async || s->busy != file)
+   return -EINVAL;
 
if (!(async->cmd.flags & CMDF_WRITE)) {
/* command was set up in "read" direction */
@@ -1165,7 +1149,6 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
bi.bytes_read = 0;
}
 
-copyback_position:
bi.buf_write_count = async->buf_write_count;
bi.buf_write_ptr = async->buf_write_ptr;
bi.buf_read_count = async->buf_read_count;
@@ -1174,7 +1157,6 @@ copyback_position:
if (become_nonbusy)
do_become_nonbusy(dev, s);
 
-copyback:
if (copy_to_user(arg, &bi, sizeof(bi)))
return -EFAULT;
 
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: comedi: COMEDI_BUFINFO: some behavioural changes

2016-02-19 Thread Ian Abbott

On 19/02/16 16:13, Ian Abbott wrote:
...stuff...

Sorry, I forgot to tag that email as "[PATCH 0/8]".

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon: use atomic_long_t

2016-02-19 Thread David Daney

On 02/18/2016 03:45 PM, Greg Kroah-Hartman wrote:

On Fri, Feb 19, 2016 at 12:20:45AM +0200, Aaro Koskinen wrote:

Use atomic_long_t, so that we can avoid some 32 vs. 64-bit ifdeffery.


Why are these atomic at all?  There's no reason they can't just be a
u64 like all other network drivers have, right?


In the original code, they were incremented by multiple threads/CPUs, so 
atomic operations perform better than putting a spinlock around the 
whole thing.


If the invariant holds that there is exactly one napi_struct per 
net_device, then the atomic business may not be necessary.  There is 
still the possibility of whatever is reading the statistics racing with 
the update, but perhaps that doesn't matter.


David Daney



thanks,

greg k-h



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon: use atomic_long_t

2016-02-19 Thread Greg Kroah-Hartman
On Fri, Feb 19, 2016 at 10:08:07AM -0800, David Daney wrote:
> On 02/18/2016 03:45 PM, Greg Kroah-Hartman wrote:
> >On Fri, Feb 19, 2016 at 12:20:45AM +0200, Aaro Koskinen wrote:
> >>Use atomic_long_t, so that we can avoid some 32 vs. 64-bit ifdeffery.
> >
> >Why are these atomic at all?  There's no reason they can't just be a
> >u64 like all other network drivers have, right?
> 
> In the original code, they were incremented by multiple threads/CPUs, so
> atomic operations perform better than putting a spinlock around the whole
> thing.
> 
> If the invariant holds that there is exactly one napi_struct per net_device,
> then the atomic business may not be necessary.  There is still the
> possibility of whatever is reading the statistics racing with the update,
> but perhaps that doesn't matter.

I don't think that matters, the stats are there just to see what is
happening at a macro level, look at all of the other network drivers in
the kernel, they don't need a lock or an atomic type for this type of
statistic from what I can tell.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: speakup: Change simple_strtoul usage to kstrtoul

2016-02-19 Thread Joseph Bisch
This fixes the checkpatch.pl warning:

WARNING: simple_strtoul is obsolete, use kstrtoul instead

Signed-off-by: Joseph Bisch 
---
 drivers/staging/speakup/kobjects.c| 12 ++--
 drivers/staging/speakup/main.c|  6 +-
 drivers/staging/speakup/varhandlers.c |  6 +-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/kobjects.c 
b/drivers/staging/speakup/kobjects.c
index fdfeb42..8eb4fdf 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -126,6 +126,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
int do_characters = !strcmp(attr->attr.name, "characters");
size_t desc_length = 0;
int i;
+   int err;
 
spin_lock_irqsave(&speakup_info.spinlock, flags);
while (cp < end) {
@@ -153,7 +154,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
continue;
}
 
-   index = simple_strtoul(cp, &temp, 10);
+   temp = cp;
+   err = kstrtoul(temp, 10, &index);
+   if (err)
+   return err;
if (index > 255) {
rejected++;
cp = linefeed + 1;
@@ -754,6 +758,7 @@ static ssize_t message_store_helper(const char *buf, size_t 
count,
int used = 0;
int rejected = 0;
int reset = 0;
+   int err;
enum msg_index_t firstmessage = group->start;
enum msg_index_t lastmessage = group->end;
enum msg_index_t curmessage;
@@ -783,7 +788,10 @@ static ssize_t message_store_helper(const char *buf, 
size_t count,
continue;
}
 
-   index = simple_strtoul(cp, &temp, 10);
+   temp = cp;
+   err = kstrtoul(temp, 10, &index);
+   if (err)
+   return err;
 
while ((temp < linefeed) && (*temp == ' ' || *temp == '\t'))
temp++;
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 30cf973..9add4ab 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1904,6 +1904,7 @@ static int handle_goto(struct vc_data *vc, u_char type, 
u_char ch, u_short key)
static int num;
int maxlen;
char *cp;
+   int ret;
 
if (type == KT_SPKUP && ch == SPEAKUP_GOTO)
goto do_goto;
@@ -1940,7 +1941,10 @@ oops:
return 1;
}
 
-   goto_pos = simple_strtoul(goto_buf, &cp, 10);
+   cp = goto_buf;
+   ret = kstrtoul(cp, 10, &goto_pos);
+   if (ret)
+   return ret;
 
if (*cp == 'x') {
if (*goto_buf < '0')
diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index ab4fe8d..7a640e3 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -324,8 +324,12 @@ char *spk_strlwr(char *s)
 char *spk_s2uchar(char *start, char *dest)
 {
int val;
+   int ret;
 
-   val = simple_strtoul(skip_spaces(start), &start, 10);
+   start = skip_spaces(start);
+   ret = kstrtoul(start, 10, (unsigned long *)&val);
+   if (ret)
+   return NULL;
if (*start == ',')
start++;
*dest = (u_char)val;
-- 
2.7.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon: use atomic_long_t

2016-02-19 Thread Aaro Koskinen
Hi,

On Fri, Feb 19, 2016 at 10:17:54AM -0800, Greg Kroah-Hartman wrote:
> On Fri, Feb 19, 2016 at 10:08:07AM -0800, David Daney wrote:
> > On 02/18/2016 03:45 PM, Greg Kroah-Hartman wrote:
> > >On Fri, Feb 19, 2016 at 12:20:45AM +0200, Aaro Koskinen wrote:
> > >>Use atomic_long_t, so that we can avoid some 32 vs. 64-bit ifdeffery.
> > >
> > >Why are these atomic at all?  There's no reason they can't just be a
> > >u64 like all other network drivers have, right?
> > 
> > In the original code, they were incremented by multiple threads/CPUs, so
> > atomic operations perform better than putting a spinlock around the whole
> > thing.
> > 
> > If the invariant holds that there is exactly one napi_struct per net_device,
> > then the atomic business may not be necessary.  There is still the
> > possibility of whatever is reading the statistics racing with the update,
> > but perhaps that doesn't matter.
> 
> I don't think that matters, the stats are there just to see what is
> happening at a macro level, look at all of the other network drivers in
> the kernel, they don't need a lock or an atomic type for this type of
> statistic from what I can tell.

I'll send an updated patch that removes the atomic stuff.

A.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: rtl8712: Improve suspend/resume functionality.

2016-02-19 Thread Hemmo Nieminen
Fix a driver hang caused by earlier suspend/resume cycles. By handling a
ENODEV error during suspend as a real error we eventually end up stopping
the whole driver.

Fix this by handling the ENODEV error (during suspend) essentially by
retrying.

Signed-off-by: Hemmo Nieminen 
---
 drivers/staging/rtl8712/usb_ops_linux.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index e77be2a..c2ac581 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -228,16 +228,18 @@ static void r8712_usb_read_port_complete(struct urb *purb)
}
} else {
switch (purb->status) {
-   case -ENOENT:
-   if (padapter->bSuspended)
-   break;
-   /* Fall through. */
case -EINVAL:
case -EPIPE:
case -ENODEV:
case -ESHUTDOWN:
padapter->bDriverStopped = true;
break;
+   case -ENOENT:
+   if (!padapter->bSuspended) {
+   padapter->bDriverStopped = true;
+   break;
+   }
+   /* Fall through. */
case -EPROTO:
precvbuf->reuse = true;
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
-- 
2.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging/android/ion : fix a race condition in the ion driver

2016-02-19 Thread Laura Abbott
On 02/19/2016 04:03 AM, EunTaik Lee wrote:
> There is a use-after-free problem in the ion driver.
> This is caused by a race condition in the ion_ioctl()
> function.
> 
> A handle has ref count of 1 and two tasks on different
> cpus calls ION_IOC_FREE simultaneously.
> 
> cpu 0   cpu 1
> ---
> ion_handle_get_by_id()
> (ref == 2)
>  ion_handle_get_by_id()
>  (ref == 3)
> 
> ion_free()
> (ref == 2)
> 
> ion_handle_put()
> (ref == 1)
> 
>  ion_free()
>  (ref == 0 so ion_handle_destroy() is
>  called
>  and the handle is freed.)
> 
>  ion_handle_put() is called and it
>  decreases the slub's next free pointer
> 
> The problem is detected as an unaligned access in the
> spin lock functions since it uses load exclusive
>   instruction. In some cases it corrupts the slub's
> free pointer which causes a mis-aligned access to the
> next free pointer.(kmalloc returns a pointer like
> c0745b4580aa). And it causes lots of other
> hard-to-debug problems.
> 
> This symptom is caused since the first member in the
> ion_handle structure is the reference count and the
> ion driver decrements the reference after it has been
> freed.
> 
> To fix this problem client->lock mutex is extended
> to protect all the codes that uses the handle.
> 
> Signed-off-by: Eun Taik Lee 
> ---
> changes in v2 :
>   1. add problem description in the comment
>   2. fix un-matching mutex_lock/unlock pair in ion_share_dma_buf()
> 
>   drivers/staging/android/ion/ion.c | 102 
> ++
>   1 file changed, 82 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c 
> b/drivers/staging/android/ion/ion.c
> index e237e9f..c6fbe48 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -385,13 +385,22 @@ static void ion_handle_get(struct ion_handle *handle)
>   kref_get(&handle->ref);
>   }
>   
> +static int ion_handle_put_nolock(struct ion_handle *handle)
> +{
> + int ret;
> +
> + ret = kref_put(&handle->ref, ion_handle_destroy);
> +
> + return ret;
> +}
> +

the 

>   static int ion_handle_put(struct ion_handle *handle)
>   {
>   struct ion_client *client = handle->client;
>   int ret;
>   
>   mutex_lock(&client->lock);
> - ret = kref_put(&handle->ref, ion_handle_destroy);
> + ret = ion_handle_put_nolock(handle);
>   mutex_unlock(&client->lock);
>   
>   return ret;
> @@ -415,20 +424,30 @@ static struct ion_handle *ion_handle_lookup(struct 
> ion_client *client,
>   return ERR_PTR(-EINVAL);
>   }
>   
> -static struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
> - int id)
> +static struct ion_handle *ion_handle_get_by_id_nolock(struct ion_client 
> *client,
> +   int id)
>   {
>   struct ion_handle *handle;
>   
> - mutex_lock(&client->lock);
>   handle = idr_find(&client->idr, id);
>   if (handle)
>   ion_handle_get(handle);
> - mutex_unlock(&client->lock);
>   
>   return handle ? handle : ERR_PTR(-EINVAL);
>   }
>   
> +struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
> + int id)
> +{
> + struct ion_handle *handle;
> +
> + mutex_lock(&client->lock);
> + handle = ion_handle_get_by_id_nolock(client, id);
> + mutex_unlock(&client->lock);
> +
> + return handle;
> +}
> +
>   static bool ion_handle_validate(struct ion_client *client,
>   struct ion_handle *handle)
>   {
> @@ -530,7 +549,8 @@ struct ion_handle *ion_alloc(struct ion_client *client, 
> size_t len,
>   }
>   EXPORT_SYMBOL(ion_alloc);
>   
> -void ion_free(struct ion_client *client, struct ion_handle *handle)
> +static void ion_free_nolock(struct ion_client *client,
> + struct ion_handle *handle)
>   {
>   bool valid_handle;
>   
> @@ -538,15 +558,24 @@ void ion_free(struct ion_client *client, struct 
> ion_handle *handle)
>   
>   mutex_lock(&client->lock);
>   valid_handle = ion_handle_validate(client, handle);
> -
>   if (!valid_handle) {
>   WARN(1, "%s: invalid handle passed to free.\n", __func__);
>   mutex_unlock(&client->lock);
>   return;
>   }
> + ion_handle_put_nolock(handle);
> +}
> +
> +void ion_free(struct ion_client *client, struct ion_handle *handle)
> +{
> + BUG_ON(client != handle->client);
> +
> + mutex_lock(&client->lock);
> + ion_free_nolock(client, handle);
>   mutex_unlock(&client->lock);
>   ion_handle_put(handle);
>   }
> +
>   EXPORT_SYMBOL(ion_free);
>

This still doesn

Re: [PATCH net-next] hv_netvsc: add software transmit timestamp support

2016-02-19 Thread David Miller
From: Simon Xiao 
Date: Wed, 17 Feb 2016 16:43:59 -0800

> Enable skb_tx_timestamp in hyperv netvsc.
> 
> Signed-off-by: Simon Xiao 
> Reviewed-by: K. Y. Srinivasan 
> Reviewed-by: Haiyang Zhang 

Applied.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: octeon: drop atomic usage from rx counters

2016-02-19 Thread Aaro Koskinen
We have only one NAPI poll running at a time, so virtual port rx counters
can be updated normally.

Update of rx_dropped can still race with the gathering of statistics,
but full accuracy is not required there.

Signed-off-by: Aaro Koskinen 
---

Replaces this patch: http://marc.info/?t=14558340838&r=1&w=2

 drivers/staging/octeon/ethernet-rx.c | 23 +++
 drivers/staging/octeon/ethernet.c| 13 +
 2 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rx.c 
b/drivers/staging/octeon/ethernet-rx.c
index 6aed3cf..ed55304 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -26,8 +26,6 @@
 #include 
 #endif /* CONFIG_XFRM */
 
-#include 
-
 #include 
 
 #include "ethernet-defines.h"
@@ -364,17 +362,8 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int 
budget)
 
/* Increment RX stats for virtual ports */
if (port >= CVMX_PIP_NUM_INPUT_PORTS) {
-#ifdef CONFIG_64BIT
-   atomic64_add(1,
-(atomic64_t 
*)&priv->stats.rx_packets);
-   atomic64_add(skb->len,
-(atomic64_t 
*)&priv->stats.rx_bytes);
-#else
-   atomic_add(1,
-  (atomic_t 
*)&priv->stats.rx_packets);
-   atomic_add(skb->len,
-  (atomic_t 
*)&priv->stats.rx_bytes);
-#endif
+   priv->stats.rx_packets++;
+   priv->stats.rx_bytes += skb->len;
}
netif_receive_skb(skb);
} else {
@@ -383,13 +372,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int 
budget)
  printk_ratelimited("%s: Device not up, packet 
dropped\n",
   dev->name);
*/
-#ifdef CONFIG_64BIT
-   atomic64_add(1,
-(atomic64_t 
*)&priv->stats.rx_dropped);
-#else
-   atomic_add(1,
-  (atomic_t *)&priv->stats.rx_dropped);
-#endif
+   priv->stats.rx_dropped++;
dev_kfree_skb_irq(skb);
}
} else {
diff --git a/drivers/staging/octeon/ethernet.c 
b/drivers/staging/octeon/ethernet.c
index 8d239e2..9fa552f 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -226,18 +226,7 @@ static struct net_device_stats 
*cvm_oct_common_get_stats(struct net_device *dev)
priv->stats.multicast += rx_status.multicast_packets;
priv->stats.rx_crc_errors += rx_status.inb_errors;
priv->stats.rx_frame_errors += rx_status.fcs_align_err_packets;
-
-   /*
-* The drop counter must be incremented atomically
-* since the RX tasklet also increments it.
-*/
-#ifdef CONFIG_64BIT
-   atomic64_add(rx_status.dropped_packets,
-(atomic64_t *)&priv->stats.rx_dropped);
-#else
-   atomic_add(rx_status.dropped_packets,
-(atomic_t *)&priv->stats.rx_dropped);
-#endif
+   priv->stats.rx_dropped += rx_status.dropped_packets;
}
 
return &priv->stats;
-- 
2.4.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: octeon: drop atomic usage from rx counters

2016-02-19 Thread David Daney

On 02/19/2016 12:47 PM, Aaro Koskinen wrote:

We have only one NAPI poll running at a time, so virtual port rx counters
can be updated normally.

Update of rx_dropped can still race with the gathering of statistics,
but full accuracy is not required there.

Signed-off-by: Aaro Koskinen 


Acked-by: David Daney 

---

Replaces this patch: http://marc.info/?t=14558340838&r=1&w=2

  drivers/staging/octeon/ethernet-rx.c | 23 +++
  drivers/staging/octeon/ethernet.c| 13 +
  2 files changed, 4 insertions(+), 32 deletions(-)




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2 01/24] staging: wilc1000: wilc_wlan.c: removes PRINT_ER

2016-02-19 Thread Greg KH
On Thu, Feb 18, 2016 at 08:30:01PM +0900, Leo Kim wrote:
> This patches removes PRINT_ER that is unnecessary debug logs.
> 
> Signed-off-by: Leo Kim 
> ---
>  drivers/staging/wilc1000/wilc_wlan.c | 2 --
>  1 file changed, 2 deletions(-)

What changed in this series from v1?  Why should I take it?

Please resend a v3 that says exactly what differs.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/6] staging: wilc1000: removes wilc_dbg()

2016-02-19 Thread Greg KH
On Fri, Feb 19, 2016 at 05:37:07PM +0900, Leo Kim wrote:
> This patch removes wilc_dbg function because it's not any more.
> 
> Signed-off-by: Leo Kim 
> ---
>  drivers/staging/wilc1000/linux_wlan.c | 4 
>  drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 --
>  drivers/staging/wilc1000/wilc_wlan.c  | 2 --
>  3 files changed, 8 deletions(-)

I didn't apply the other series, so I can't apply this one, please
resend this after fixing it up as part of the other series.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4] staging: wilc1000: move WILC_MULTICAST_TABLE_SIZE define to wilc_wlan_if.h file

2016-02-19 Thread Greg KH
On Fri, Feb 19, 2016 at 06:57:42PM +0900, Leo Kim wrote:
> From: Chris Park 
> 
> This patch moves WILC_MULTICAST_TABLE_SIZE define to wilc_wlan_if.h file.
> This define is used to three files(host_interface.c,host_interface.h,
> linux_wlan.c) these files already include wilc_wlan_if.h file in common.
> 
> Signed-off-by: Chris Park 
> Signed-off-by: Leo Kim 
> ---
>  drivers/staging/wilc1000/linux_wlan_common.h | 2 --
>  drivers/staging/wilc1000/wilc_wlan_if.h  | 2 +-
>  2 files changed, 1 insertion(+), 3 deletions(-)

Series doesn't apply :(

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] rtlwifi: Change long delays to sleeps

2016-02-19 Thread ByeoungWook Kim
2016-02-16 7:12 GMT+09:00 Larry Finger :
> Routine rtl_addr_delay() uses delay statements in code that can
> sleep. To improve system responsiveness, the various delay statements
> are changed.
>
> In addition, routines rtl_rfreg_delay() and rtl_bb_delay() are
> rewritten to use the code in rtl_addr_delay() for most of their
> input values.
>
> Suggested-by: Byeoungwook Kim 
> Signed-off-by: Larry Finger 
> ---

Why you are using 'Suggested-by:' of me?
I think to that your commit was included a part of my
commit(https://patchwork.kernel.org/patch/8197071/).

>
> Kalle,
>
> This patch will interfere with a set of 3 patches submitted by Byeoungwook Kim
>  on Feb. 3, 2016 that are currently in the deferred list
> at patchwork.
>
> Larry
>
>  drivers/net/wireless/realtek/rtlwifi/core.c | 44 
> -
>  1 file changed, 12 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
> b/drivers/net/wireless/realtek/rtlwifi/core.c
> index 02eba0e..16ad0d6 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/core.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/core.c
> @@ -54,59 +54,39 @@ EXPORT_SYMBOL(channel5g_80m);
>  void rtl_addr_delay(u32 addr)
>  {
> if (addr == 0xfe)
> -   mdelay(50);
> +   msleep(50);
> else if (addr == 0xfd)
> -   mdelay(5);
> +   msleep(5);
> else if (addr == 0xfc)
> -   mdelay(1);
> +   msleep(1);
> else if (addr == 0xfb)
> -   udelay(50);
> +   usleep_range(50, 100);
> else if (addr == 0xfa)
> -   udelay(5);
> +   usleep_range(5, 10);
> else if (addr == 0xf9)
> -   udelay(1);
> +   usleep_range(1, 2);
>  }
>  EXPORT_SYMBOL(rtl_addr_delay);
>
>  void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 
> addr,
>  u32 mask, u32 data)
>  {
> -   if (addr == 0xfe) {
> -   mdelay(50);
> -   } else if (addr == 0xfd) {
> -   mdelay(5);
> -   } else if (addr == 0xfc) {
> -   mdelay(1);
> -   } else if (addr == 0xfb) {
> -   udelay(50);
> -   } else if (addr == 0xfa) {
> -   udelay(5);
> -   } else if (addr == 0xf9) {
> -   udelay(1);
> +   if (addr >= 0xf9 && addr <= 0xfe) {
> +   rtl_addr_delay(addr);
> } else {
> rtl_set_rfreg(hw, rfpath, addr, mask, data);
> -   udelay(1);
> +   usleep_range(1, 2);
> }
>  }
>  EXPORT_SYMBOL(rtl_rfreg_delay);
>
>  void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
>  {
> -   if (addr == 0xfe) {
> -   mdelay(50);
> -   } else if (addr == 0xfd) {
> -   mdelay(5);
> -   } else if (addr == 0xfc) {
> -   mdelay(1);
> -   } else if (addr == 0xfb) {
> -   udelay(50);
> -   } else if (addr == 0xfa) {
> -   udelay(5);
> -   } else if (addr == 0xf9) {
> -   udelay(1);
> +   if (addr >= 0xf9 && addr <= 0xfe) {
> +   rtl_addr_delay(addr);
> } else {
> rtl_set_bbreg(hw, addr, MASKDWORD, data);
> -   udelay(1);
> +   usleep_range(1, 2);
> }
>  }
>  EXPORT_SYMBOL(rtl_bb_delay);
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Regards,
Byeoungwook
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel