[PATCH] Staging: ks7010: Fix Unnecessary parentheses in ks_hostif.c

2018-02-16 Thread Yash Omer
This patch fixes up unnecessary parenthesis issue found by checkpatch.pl

Signed-off-by: Yash Omer 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 975dbbb3abd0..7bd567e233d7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -850,7 +850,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
-  &(priv->aplist.ap[priv->scan_ind_count - 
1]));
+  &(priv->aplist.ap priv->scan_ind_count - 1));
priv->aplist.size = priv->scan_ind_count;
} else {
DPRINTK(4, " count over :: scan_ind_count=%d\n",
-- 
2.14.3

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


[PATCH 4/4] Staging: ks7010: hostif: Fix multiple use of arguments in ps_confirm_wait_inc() macro.

2018-02-16 Thread Quytelda Kahja
Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 30c9592b3a00..92035e8ac843 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1306,11 +1306,10 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
return ret;
 }
 
-#define ps_confirm_wait_inc(priv)   \
-   do { \
-   if (atomic_read(>psstatus.status) > PS_ACTIVE_SET) \
-   atomic_inc(>psstatus.confirm_wait);\
-   } while (0)
+#define ps_confirm_wait_inc(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   if (atomic_read(_->psstatus.status) > PS_ACTIVE_SET) \
+   atomic_inc(_->psstatus.confirm_wait); })
 
 static
 void hostif_mib_get_request(struct ks_wlan_private *priv,
-- 
2.16.1

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


[PATCH 2/4] Staging: ks7010: hostif: Fix multiple use of arguments in SME queue macros.

2018-02-16 Thread Quytelda Kahja
Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 975dbbb3abd0..30c9592b3a00 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -22,12 +22,19 @@
 #include /* New driver API */
 
 /* macro */
-#define inc_smeqhead(priv) \
-   (priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE)
-#define inc_smeqtail(priv) \
-   (priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE)
-#define cnt_smeqbody(priv) \
-   (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % 
SME_EVENT_BUFF_SIZE)
+#define inc_smeqhead(priv) \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qhead = priv_->sme_i.qhead + 1;   \
+   priv_->sme_i.qhead = next_qhead % SME_EVENT_BUFF_SIZE; })
+#define inc_smeqtail(priv) \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qtail = priv_->sme_i.qtail + 1;   \
+   priv_->sme_i.qtail = next_qtail % SME_EVENT_BUFF_SIZE; })
+#define cnt_smeqbody(priv) \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int left_cnt = \
+   priv_->sme_i.qtail + SME_EVENT_BUFF_SIZE;   \
+(left_cnt - (priv_->sme_i.qhead)) % SME_EVENT_BUFF_SIZE; })
 
 #define KS_WLAN_MEM_FLAG (GFP_ATOMIC)
 
-- 
2.16.1

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


[PATCH 3/4] Staging: ks7010: hostif: Fix multiple use of arguments in rate and event masking macros.

2018-02-16 Thread Quytelda Kahja
Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.h | 74 +-
 1 file changed, 50 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 5bae8d468e23..750ac86cee77 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -599,19 +599,39 @@ struct hostif_mic_failure_confirm_t {
 #define TX_RATE_48M(uint8_t)(480 / 5)
 #define TX_RATE_54M(uint8_t)(540 / 5)
 
-#define IS_11B_RATE(A) (((A & RATE_MASK) == TX_RATE_1M) || ((A & RATE_MASK) == 
TX_RATE_2M) || \
-   ((A & RATE_MASK) == TX_RATE_5M) || ((A & RATE_MASK) == 
TX_RATE_11M))
-
-#define IS_OFDM_RATE(A) (((A & RATE_MASK) == TX_RATE_6M) || ((A & RATE_MASK) 
== TX_RATE_12M) || \
-((A & RATE_MASK) == TX_RATE_24M) || ((A & RATE_MASK) 
== TX_RATE_9M) || \
-((A & RATE_MASK) == TX_RATE_18M) || ((A & RATE_MASK) 
== TX_RATE_36M) || \
-((A & RATE_MASK) == TX_RATE_48M) || ((A & RATE_MASK) 
== TX_RATE_54M))
-
-#define IS_11BG_RATE(A) (IS_11B_RATE(A) || IS_OFDM_RATE(A))
-
-#define IS_OFDM_EXT_RATE(A) (((A & RATE_MASK) == TX_RATE_9M) || ((A & 
RATE_MASK) == TX_RATE_18M) || \
-((A & RATE_MASK) == TX_RATE_36M) || ((A & 
RATE_MASK) == TX_RATE_48M) || \
-((A & RATE_MASK) == TX_RATE_54M))
+#define IS_11B_RATE(A) \
+   ({  \
+   typeof(A) A_ = (A); \
+   ((A_ & RATE_MASK) == TX_RATE_1M) || \
+   ((A_ & RATE_MASK) == TX_RATE_2M) || \
+   ((A_ & RATE_MASK) == TX_RATE_5M) || \
+   ((A_ & RATE_MASK) == TX_RATE_11M); })
+
+#define IS_OFDM_RATE(A)
\
+   ({  \
+   typeof(A) A_ = (A); \
+   ((A_ & RATE_MASK) == TX_RATE_6M) || \
+   ((A_ & RATE_MASK) == TX_RATE_12M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_24M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_9M) || \
+   ((A_ & RATE_MASK) == TX_RATE_18M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_36M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_48M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_54M); })
+
+#define IS_11BG_RATE(A)\
+   ({  \
+   typeof(A) A_ = (A); \
+   IS_11B_RATE(A_) || IS_OFDM_RATE(A_); })
+
+#define IS_OFDM_EXT_RATE(A)\
+   ({  \
+   typeof(A) A_ = (A); \
+   ((A_ & RATE_MASK) == TX_RATE_9M) || \
+   ((A_ & RATE_MASK) == TX_RATE_18M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_36M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_48M) ||\
+   ((A_ & RATE_MASK) == TX_RATE_54M); })
 
 enum connect_status_type {
CONNECT_STATUS,
@@ -633,17 +653,23 @@ enum multicast_filter_type {
 
 /* macro function */
 #define HIF_EVENT_MASK 0xE800
-#define IS_HIF_IND(_EVENT)  ((_EVENT & HIF_EVENT_MASK) == 0xE800  && \
-((_EVENT & ~HIF_EVENT_MASK) == 0x0001 || \
-(_EVENT & ~HIF_EVENT_MASK) == 0x0006 || \
-(_EVENT & ~HIF_EVENT_MASK) == 0x000C || \
-(_EVENT & ~HIF_EVENT_MASK) == 0x0011 || \
-(_EVENT & ~HIF_EVENT_MASK) == 0x0012))
-
-#define IS_HIF_CONF(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800  && \
-(_EVENT & ~HIF_EVENT_MASK) > 0x  && \
-(_EVENT & ~HIF_EVENT_MASK) < 0x0012  && \
-!IS_HIF_IND(_EVENT))
+#define IS_HIF_IND(_EVENT)   \
+   ({\
+   typeof(_EVENT) EVENT_ = (_EVENT); \
+   (EVENT_ & HIF_EVENT_MASK) == 0xE800  &&   \
+   ((EVENT_ & ~HIF_EVENT_MASK) == 0x0001 ||  \
+(EVENT_ & ~HIF_EVENT_MASK) == 

[PATCH 1/4] Staging: ks7010: sdio: Fix multiple use of arguments in RX/TX queue macros.

2018-02-16 Thread Quytelda Kahja
Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c | 40 
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 8cfdff198334..ffa7e2382353 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -32,19 +32,33 @@ static const struct sdio_device_id ks7010_sdio_ids[] = {
 };
 MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
 
-#define inc_txqhead(priv) \
-   (priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE)
-#define inc_txqtail(priv) \
-   (priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE)
-#define cnt_txqbody(priv) \
-   (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - (priv->tx_dev.qhead)) % 
TX_DEVICE_BUFF_SIZE)
-
-#define inc_rxqhead(priv) \
-   (priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE)
-#define inc_rxqtail(priv) \
-   (priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE)
-#define cnt_rxqbody(priv) \
-   (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % 
RX_DEVICE_BUFF_SIZE)
+#define inc_txqhead(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qhead = priv_->tx_dev.qhead + 1;  \
+   priv_->tx_dev.qhead = next_qhead % TX_DEVICE_BUFF_SIZE; })
+#define inc_txqtail(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qtail = priv_->tx_dev.qtail + 1;  \
+   priv_->tx_dev.qtail = next_qtail % TX_DEVICE_BUFF_SIZE; })
+#define cnt_txqbody(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int left_cnt = \
+   priv_->tx_dev.qtail + TX_DEVICE_BUFF_SIZE;  \
+   (left_cnt - (priv_->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE; })
+
+#define inc_rxqhead(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qhead = priv_->rx_dev.qhead + 1;  \
+   priv_->rx_dev.qhead = next_qhead % RX_DEVICE_BUFF_SIZE; })
+#define inc_rxqtail(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int next_qtail = priv_->rx_dev.qtail + 1;  \
+   priv_->rx_dev.qtail = next_qtail % RX_DEVICE_BUFF_SIZE; })
+#define cnt_rxqbody(priv)  \
+   ({ typeof(priv) priv_ = (priv); \
+   unsigned int left_cnt = \
+   priv_->rx_dev.qtail + RX_DEVICE_BUFF_SIZE;  \
+   (left_cnt - (priv_->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE; })
 
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int 
address,
-- 
2.16.1

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Laura Abbott

On 02/16/2018 04:17 AM, Alexey Skidanov wrote:



On 02/16/2018 01:48 AM, Laura Abbott wrote:

On 02/12/2018 02:33 PM, Alexey Skidanov wrote:

Current ion kernel mapping implementation uses vmap() to map previously
allocated buffers into kernel virtual address space.

On 32-bit platforms, vmap() might fail on large enough buffers due to the
limited available vmalloc space. dma_buf_kmap() should guarantee that
only one page is mapped at a time.

To fix this, kmap()/kmap_atomic() is used to implement the appropriate
interfaces.

Signed-off-by: Alexey Skidanov 
---
   drivers/staging/android/ion/ion.c | 97
+++
   drivers/staging/android/ion/ion.h |  1 -
   2 files changed, 48 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c
b/drivers/staging/android/ion/ion.c
index 57e0d80..75830e3 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -27,6 +27,7 @@
   #include 
   #include 
   #include 
+#include 
     #include "ion.h"
   @@ -119,8 +120,6 @@ static struct ion_buffer
*ion_buffer_create(struct ion_heap *heap,
     void ion_buffer_destroy(struct ion_buffer *buffer)
   {
-    if (WARN_ON(buffer->kmap_cnt > 0))
-    buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
   buffer->heap->ops->free(buffer);
   kfree(buffer);
   }
@@ -140,34 +139,6 @@ static void _ion_buffer_destroy(struct ion_buffer
*buffer)
   ion_buffer_destroy(buffer);
   }
   -static void *ion_buffer_kmap_get(struct ion_buffer *buffer)
-{
-    void *vaddr;
-
-    if (buffer->kmap_cnt) {
-    buffer->kmap_cnt++;
-    return buffer->vaddr;
-    }
-    vaddr = buffer->heap->ops->map_kernel(buffer->heap, buffer);
-    if (WARN_ONCE(!vaddr,
-  "heap->ops->map_kernel should return ERR_PTR on error"))
-    return ERR_PTR(-EINVAL);
-    if (IS_ERR(vaddr))
-    return vaddr;
-    buffer->vaddr = vaddr;
-    buffer->kmap_cnt++;
-    return vaddr;
-}
-
-static void ion_buffer_kmap_put(struct ion_buffer *buffer)
-{
-    buffer->kmap_cnt--;
-    if (!buffer->kmap_cnt) {
-    buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
-    buffer->vaddr = NULL;
-    }
-}
-
   static struct sg_table *dup_sg_table(struct sg_table *table)
   {
   struct sg_table *new_table;
@@ -305,34 +276,68 @@ static void ion_dma_buf_release(struct dma_buf
*dmabuf)
   _ion_buffer_destroy(buffer);
   }
   +static inline int sg_page_count(struct scatterlist *sg)
+{
+    return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT;
+}
+
+static struct page *ion_dma_buf_get_page(struct sg_table *sg_table,
+ unsigned long offset)
+{
+    struct page *page;
+    struct scatterlist *sg;
+    int i;
+    unsigned int nr_pages;
+
+    nr_pages = 0;
+    page = NULL;
+    /* Find the page with specified offset */
+    for_each_sg(sg_table->sgl, sg, sg_table->nents, i) {
+    if (nr_pages + sg_page_count(sg) > offset) {
+    page = nth_page(sg_page(sg), offset - nr_pages);
+    break;
+    }
+
+    nr_pages += sg_page_count(sg);
+    }
+
+    return page;
+}
   static void *ion_dma_buf_kmap(struct dma_buf *dmabuf, unsigned long
offset)
   {
   struct ion_buffer *buffer = dmabuf->priv;
   -    return buffer->vaddr + offset * PAGE_SIZE;
+    return kmap(ion_dma_buf_get_page(buffer->sg_table, offset));
   }


This unfortunately doesn't work for uncached buffers. We need to create
an uncached alias otherwise we break what little coherency that guarantees.
I'm still convinced that we can't actually do the uncached buffers
correctly and they should be removed...

Thanks,
Laura


I assume that your concern is possible cache coherency issue as result
of the memory access with the different cache attributes. Especially, if
these accesses are from different context.

But dma-buf requires that the cpu access should be started with
dma_buf_start_cpu_access() and ended with dma_buf_end_cpu_access() (and
with appropriate ioctl calls from the user space) to ensure that there
is no IO coherency issues. That is, the appropriate cache lines are
invalidated before the access and are flushed after the access (in case
of read/write access).

So, it seems, that in the end of each CPU access, the most update copy
of the buffer is in the RAM.

Probably, I'm wrong but I don't see the issue.



Part of the issue is that uncached buffers are often used so we don't
need to do any cache operations. We do the sync currently but there's
interest in removing it for uncached buffers.

I also haven't looked at aliasing rules on x86 closely but at least
on arm, coherency with different cache attributes is difficult to
get right and has a big "not recommended" warning in the description.
You may be right that the above sequence would work out with the
cpu accessors but it would need some careful review. The trade off
of "might run out of vmalloc space" vs. "cache alias nightmare" doesn't

[PATCH v2 char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling

2018-02-16 Thread Michael Kelley
Fix bugs in signaling the Hyper-V host when freeing space in the
host->guest ring buffer:

1. The interrupt_mask must not be used to determine whether to signal
   on the host->guest ring buffer
2. The ring buffer write_index must be read (via hv_get_bytes_to_write)
   *after* pending_send_sz is read in order to avoid a race condition
3. Comparisons with pending_send_sz must treat the "equals" case as
   not-enough-space
4. Don't signal if the pending_send_sz feature is not present. Older
   versions of Hyper-V that don't implement this feature will poll.

Fixes: 03bad714a161 ("vmbus: more host signalling avoidance")
Signed-off-by: Michael Kelley 
---

Changes in v2:
* Restructured to do signaling calcuations only if needed. Makes
  the most common path faster [KY Srinivasan, Steve Hemminger]
* Moved bytes read calculation to new routine hv_pkt_iter_bytes_read
  [Steve Hemminger]

---
 drivers/hv/ring_buffer.c | 52 
 1 file changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 50e0714..8699bb9 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -417,13 +417,24 @@ struct vmpacket_descriptor *
 }
 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
 
+/* How many bytes were read in this iterator cycle */
+static u32 hv_pkt_iter_bytes_read(const struct hv_ring_buffer_info *rbi,
+   u32 start_read_index)
+{
+   if (rbi->priv_read_index >= start_read_index)
+   return rbi->priv_read_index - start_read_index;
+   else
+   return rbi->ring_datasize - start_read_index +
+   rbi->priv_read_index;
+}
+
 /*
  * Update host ring buffer after iterating over packets.
  */
 void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = >inbound;
-   u32 orig_write_sz = hv_get_bytes_to_write(rbi);
+   u32 curr_write_sz, pending_sz, bytes_read, start_read_index;
 
/*
 * Make sure all reads are done before we update the read index since
@@ -431,8 +442,12 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
 * is updated.
 */
virt_rmb();
+   start_read_index = rbi->ring_buffer->read_index;
rbi->ring_buffer->read_index = rbi->priv_read_index;
 
+   if (!rbi->ring_buffer->feature_bits.feat_pending_send_sz)
+   return;
+
/*
 * Issue a full memory barrier before making the signaling decision.
 * Here is the reason for having this barrier:
@@ -446,26 +461,29 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
 */
virt_mb();
 
-   /* If host has disabled notifications then skip */
-   if (rbi->ring_buffer->interrupt_mask)
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
+   if (!pending_sz)
return;
 
-   if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
-   u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
+   /*
+* Ensure the read of write_index in hv_get_bytes_to_write()
+* happens after the read of pending_send_sz.
+*/
+   virt_rmb();
+   curr_write_sz = hv_get_bytes_to_write(rbi);
+   bytes_read = hv_pkt_iter_bytes_read(rbi, start_read_index);
 
-   /*
-* If there was space before we began iteration,
-* then host was not blocked. Also handles case where
-* pending_sz is zero then host has nothing pending
-* and does not need to be signaled.
-*/
-   if (orig_write_sz > pending_sz)
-   return;
+   /*
+* If there was space before we began iteration,
+* then host was not blocked.
+*/
 
-   /* If pending write will not fit, don't give false hope. */
-   if (hv_get_bytes_to_write(rbi) < pending_sz)
-   return;
-   }
+   if (curr_write_sz - bytes_read > pending_sz)
+   return;
+
+   /* If pending write will not fit, don't give false hope. */
+   if (curr_write_sz <= pending_sz)
+   return;
 
vmbus_setevent(channel);
 }
-- 
1.8.3.1

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


[PATCH] Staging: gdm724x: tty: Fix macro argument reuse that could cause side-effects.

2018-02-16 Thread Quytelda Kahja
Fix a coding style warning from checkpatch.pl.  Use GNU extensions to create
references to the results of problem macro arguments when they are evaluated so
that they can be used safely multiple times.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/gdm724x/gdm_tty.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index fc7682c18f20..73d39fa86d10 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -37,14 +37,22 @@
 
 #define MUX_TX_MAX_SIZE 2048
 
-#define gdm_tty_send(n, d, l, i, c, b) (\
-   n->tty_dev->send_func(n->tty_dev->priv_dev, d, l, i, c, b))
-#define gdm_tty_recv(n, c) (\
-   n->tty_dev->recv_func(n->tty_dev->priv_dev, c))
-#define gdm_tty_send_control(n, r, v, d, l) (\
-   n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
-
-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
+#define gdm_tty_send(n, d, l, i, c, b) \
+   ({ typeof(n) n_ = (n);  \
+   void *priv_dev = n_->tty_dev->priv_dev; \
+   n_->tty_dev->send_func(priv_dev, d, l, i, c, b); })
+#define gdm_tty_recv(n, c) \
+   ({ typeof(n) n_ = (n);  \
+   void *priv_dev = n_->tty_dev->priv_dev; \
+   n_->tty_dev->recv_func(priv_dev, c); })
+#define gdm_tty_send_control(n, r, v, d, l)\
+   ({ typeof(n) n_ = (n);  \
+   void *priv_dev = n_->tty_dev->priv_dev; \
+   n_->tty_dev->send_control(priv_dev, r, v, d, l); })
+
+#define GDM_TTY_READY(gdm) \
+   ({ typeof(gdm) gdm_ = gdm;  \
+   gdm_ && gdm_->tty_dev && gdm_->port.count; })
 
 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
-- 
2.16.1

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


[PATCH 2/2] Staging: gdm724x: LTE: Fix argument list not aligned with parenthesis.

2018-02-16 Thread Quytelda Kahja
Fix coding style warning from checkpatch.pl.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/gdm724x/gdm_lte.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c 
b/drivers/staging/gdm724x/gdm_lte.c
index ff3fed9c4a81..26a81fdd0044 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -311,7 +311,8 @@ static int gdm_lte_emulate_ndp(struct sk_buff *skb_in, u32 
nic_type)
   sizeof(struct neighbour_advertisement));
 
icmp6_out.icmp6_cksum = icmp6_checksum(_out,
-   (u16 *)icmp_na, sizeof(icmp_na));
+  (u16 *)icmp_na,
+  sizeof(icmp_na));
} else {
return -EINVAL;
}
-- 
2.16.1

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


[PATCH] Staging: gdm724x: LTE: Fix trailing open parenthesis code style issue.

2018-02-16 Thread Quytelda Kahja
Fix a coding style problem causing warnings from checkpatch.pl.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/gdm724x/gdm_lte.c | 50 ++-
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c 
b/drivers/staging/gdm724x/gdm_lte.c
index 0527b0d1c1d0..ff3fed9c4a81 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -204,9 +204,12 @@ static __sum16 icmp6_checksum(struct ipv6hdr *ipv6, u16 
*ptr, int len)
pseudo_header.ph.ph_nxt = ipv6->nexthdr;
 
w = (u16 *)_header;
-   for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++)
-   sum = csum_add(sum, csum_unfold(
-   (__force __sum16)pseudo_header.pa[i]));
+   for (i = 0; i < ARRAY_SIZE(pseudo_header.pa); i++) {
+   __wsum tmp_sum;
+
+   tmp_sum = csum_unfold((__force __sum16)pseudo_header.pa[i]);
+   sum = csum_add(sum, tmp_sum);
+   }
 
w = ptr;
while (len > 1) {
@@ -510,18 +513,18 @@ static int gdm_lte_event_send(struct net_device *dev, 
char *buf, int len)
 {
struct nic *nic = netdev_priv(dev);
struct hci_packet *hci = (struct hci_packet *)buf;
+   struct gdm_endian *phy_endian;
int idx;
+   u16 cpu;
int ret;
 
ret = sscanf(dev->name, "lte%d", );
if (ret != 1)
return -EINVAL;
 
-   return netlink_send(lte_event.sock, idx, 0, buf,
-   gdm_dev16_to_cpu(
-   nic->phy_dev->get_endian(
-   nic->phy_dev->priv_dev), hci->len)
-   + HCI_HEADER_SIZE);
+   phy_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev);
+   cpu = gdm_dev16_to_cpu(phy_endian, hci->len);
+   return netlink_send(lte_event.sock, idx, 0, buf, cpu + HCI_HEADER_SIZE);
 }
 
 static void gdm_lte_event_rcv(struct net_device *dev, u16 type,
@@ -728,17 +731,21 @@ static void gdm_lte_pdn_table(struct net_device *dev, 
char *buf, int len)
 {
struct nic *nic = netdev_priv(dev);
struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf;
+   struct gdm_endian *dft_endian;
+   struct gdm_endian *nic_endian;
 
if (pdn_table->activate) {
nic->pdn_table.activate = pdn_table->activate;
-   nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(
-   nic->phy_dev->get_endian(
-   nic->phy_dev->priv_dev),
-   pdn_table->dft_eps_id);
-   nic->pdn_table.nic_type = gdm_dev32_to_cpu(
-   nic->phy_dev->get_endian(
-   nic->phy_dev->priv_dev),
-   pdn_table->nic_type);
+
+   dft_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev);
+   nic_endian = nic->phy_dev->get_endian(nic->phy_dev->priv_dev);
+
+   nic->pdn_table.dft_eps_id =
+   gdm_dev32_to_cpu(dft_endian,
+pdn_table->dft_eps_id);
+   nic->pdn_table.nic_type =
+   gdm_dev32_to_cpu(nic_endian,
+pdn_table->nic_type);
 
netdev_info(dev, "pdn activated, nic_type=0x%x\n",
nic->pdn_table.nic_type);
@@ -896,12 +903,11 @@ int register_lte_device(struct phy_dev *phy_dev,
nic->phy_dev = phy_dev;
nic->nic_id = index;
 
-   form_mac_address(
-   net->dev_addr,
-   nic->src_mac_addr,
-   nic->dest_mac_addr,
-   mac_address,
-   index);
+   form_mac_address(net->dev_addr,
+nic->src_mac_addr,
+nic->dest_mac_addr,
+mac_address,
+index);
 
SET_NETDEV_DEV(net, dev);
SET_NETDEV_DEVTYPE(net, _type);
-- 
2.16.1

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 11:13:03PM +0200, Alexey Skidanov wrote:
> 
> 
> On 02/16/2018 10:49 PM, Greg KH wrote:
> > On Fri, Feb 16, 2018 at 10:43:03PM +0200, Alexey Skidanov wrote:
> >>
> >>
> >> On 02/16/2018 04:46 PM, Greg KH wrote:
> >>> On Tue, Feb 13, 2018 at 12:33:53AM +0200, Alexey Skidanov wrote:
>  Current ion kernel mapping implementation uses vmap() to map previously
>  allocated buffers into kernel virtual address space.
> 
>  On 32-bit platforms, vmap() might fail on large enough buffers due to the
>  limited available vmalloc space. dma_buf_kmap() should guarantee that
>  only one page is mapped at a time.
> 
>  To fix this, kmap()/kmap_atomic() is used to implement the appropriate
>  interfaces.
> 
>  Signed-off-by: Alexey Skidanov 
> >>>
> >>> Again, I said I required another intel.com signed-off-by on any of your
> >>> ion patches before I would take them.  Please get internal review first
> >>> before asking for review from the community.
> >>>
> >>> greg k-h
> >>> Is there any issue with this patch?
> > 
> > Given that no other Intel developer reviewed it, I don't know. Again,
> > use the resources you have, to ignore that is folly.
> > 
> > greg k-h
> > 
> 
> I try to improve the current ion implementation by fixing the existing
> (potential) bugs. If it's rejected even without being reviewed -
> probably it doesn't make sense to continue ...

Again, I told you what you needed to do for your future patches, I don't
know why you are ignoring that.

> BTW, it has been reviewed internally ...

Great, then have those reviewers put their names on it, that is exactly
what I asked for!  To not do so is really odd...

thanks,

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Alexey Skidanov


On 02/16/2018 10:49 PM, Greg KH wrote:
> On Fri, Feb 16, 2018 at 10:43:03PM +0200, Alexey Skidanov wrote:
>>
>>
>> On 02/16/2018 04:46 PM, Greg KH wrote:
>>> On Tue, Feb 13, 2018 at 12:33:53AM +0200, Alexey Skidanov wrote:
 Current ion kernel mapping implementation uses vmap() to map previously
 allocated buffers into kernel virtual address space.

 On 32-bit platforms, vmap() might fail on large enough buffers due to the
 limited available vmalloc space. dma_buf_kmap() should guarantee that
 only one page is mapped at a time.

 To fix this, kmap()/kmap_atomic() is used to implement the appropriate
 interfaces.

 Signed-off-by: Alexey Skidanov 
>>>
>>> Again, I said I required another intel.com signed-off-by on any of your
>>> ion patches before I would take them.  Please get internal review first
>>> before asking for review from the community.
>>>
>>> greg k-h
>>> Is there any issue with this patch?
> 
> Given that no other Intel developer reviewed it, I don't know. Again,
> use the resources you have, to ignore that is folly.
> 
> greg k-h
> 

I try to improve the current ion implementation by fixing the existing
(potential) bugs. If it's rejected even without being reviewed -
probably it doesn't make sense to continue ...

BTW, it has been reviewed internally ...

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


Re: [RFC patch] checkpatch: test identifier lengths

2018-02-16 Thread Joe Perches
On Fri, 2018-02-16 at 12:31 -0800, Andrew Morton wrote:
> On Fri, 16 Feb 2018 09:13:27 -0800 Joe Perches  wrote:
> 
> > On Fri, 2018-02-16 at 15:55 +0300, Dan Carpenter wrote:
> > > On Fri, Feb 16, 2018 at 05:06:34PM +0530, Yash Omer wrote:
> > > > This patch fix line should not end with open parenthesis found by 
> > > > checkpatch.plscript.
> > > > 
> > > > Signed-off-by: Yash Omer 
> > > > ---
> > > >  drivers/staging/nvec/nvec.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> > > > index 52054a528723..39fb737543b5 100644
> > > > --- a/drivers/staging/nvec/nvec.c
> > > > +++ b/drivers/staging/nvec/nvec.c
> > > > @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct 
> > > > *work)
> > > > msg = list_first_entry(>tx_data, struct nvec_msg, 
> > > > node);
> > > > spin_unlock_irqrestore(>tx_lock, flags);
> > > > nvec_gpio_set_value(nvec, 0);
> > > > -   err = wait_for_completion_interruptible_timeout(
> > > > -   >ec_transfer, 
> > > > msecs_to_jiffies(5000));
> > > > +   err = wait_for_completion_interruptible_timeout
> > > > +   (>ec_transfer, msecs_to_jiffies(5000));
> > > 
> > > The original code is basically fine...  It's OK to ignore checkpatch in
> > > this situation.
> > 
> > Right.
> 
> Yes, I'd say that checkpatch is simply wrong here.  I'd prefer that a
> function call always have the opening paren hard up against the
> function name.  Because I often search for "foo(" to find the callsites
> of foo() and I expect that some code-parsing tools do the same thing. 
> The "(" is the application of an operator to an identifier.
> 
> So I'd vote for simply nuking that checkpatch warning altogether. 
> Maybe there are other situations in which it is useful, dunno.

Doubtful.

The idea was to have functions have at least 1 argument
on the same line as the function name.

Care to comment on the identifier maximum length check?

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 10:43:03PM +0200, Alexey Skidanov wrote:
> 
> 
> On 02/16/2018 04:46 PM, Greg KH wrote:
> > On Tue, Feb 13, 2018 at 12:33:53AM +0200, Alexey Skidanov wrote:
> >> Current ion kernel mapping implementation uses vmap() to map previously
> >> allocated buffers into kernel virtual address space.
> >>
> >> On 32-bit platforms, vmap() might fail on large enough buffers due to the
> >> limited available vmalloc space. dma_buf_kmap() should guarantee that
> >> only one page is mapped at a time.
> >>
> >> To fix this, kmap()/kmap_atomic() is used to implement the appropriate
> >> interfaces.
> >>
> >> Signed-off-by: Alexey Skidanov 
> > 
> > Again, I said I required another intel.com signed-off-by on any of your
> > ion patches before I would take them.  Please get internal review first
> > before asking for review from the community.
> > 
> > greg k-h
> > Is there any issue with this patch?

Given that no other Intel developer reviewed it, I don't know. Again,
use the resources you have, to ignore that is folly.

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


Re: [RFC patch] checkpatch: test identifier lengths

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 12:31:39PM -0800, Andrew Morton wrote:
> On Fri, 16 Feb 2018 09:13:27 -0800 Joe Perches  wrote:
> 
> > On Fri, 2018-02-16 at 15:55 +0300, Dan Carpenter wrote:
> > > On Fri, Feb 16, 2018 at 05:06:34PM +0530, Yash Omer wrote:
> > > > This patch fix line should not end with open parenthesis found by 
> > > > checkpatch.plscript.
> > > > 
> > > > Signed-off-by: Yash Omer 
> > > > ---
> > > >  drivers/staging/nvec/nvec.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> > > > index 52054a528723..39fb737543b5 100644
> > > > --- a/drivers/staging/nvec/nvec.c
> > > > +++ b/drivers/staging/nvec/nvec.c
> > > > @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct 
> > > > *work)
> > > > msg = list_first_entry(>tx_data, struct nvec_msg, 
> > > > node);
> > > > spin_unlock_irqrestore(>tx_lock, flags);
> > > > nvec_gpio_set_value(nvec, 0);
> > > > -   err = wait_for_completion_interruptible_timeout(
> > > > -   >ec_transfer, 
> > > > msecs_to_jiffies(5000));
> > > > +   err = wait_for_completion_interruptible_timeout
> > > > +   (>ec_transfer, msecs_to_jiffies(5000));
> > > 
> > > The original code is basically fine...  It's OK to ignore checkpatch in
> > > this situation.
> > 
> > Right.
> 
> Yes, I'd say that checkpatch is simply wrong here.  I'd prefer that a
> function call always have the opening paren hard up against the
> function name.  Because I often search for "foo(" to find the callsites
> of foo() and I expect that some code-parsing tools do the same thing. 
> The "(" is the application of an operator to an identifier.
> 
> So I'd vote for simply nuking that checkpatch warning altogether. 

That's my vote as well, I do that same type of search.

thanks,

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Alexey Skidanov


On 02/16/2018 04:46 PM, Greg KH wrote:
> On Tue, Feb 13, 2018 at 12:33:53AM +0200, Alexey Skidanov wrote:
>> Current ion kernel mapping implementation uses vmap() to map previously
>> allocated buffers into kernel virtual address space.
>>
>> On 32-bit platforms, vmap() might fail on large enough buffers due to the
>> limited available vmalloc space. dma_buf_kmap() should guarantee that
>> only one page is mapped at a time.
>>
>> To fix this, kmap()/kmap_atomic() is used to implement the appropriate
>> interfaces.
>>
>> Signed-off-by: Alexey Skidanov 
> 
> Again, I said I required another intel.com signed-off-by on any of your
> ion patches before I would take them.  Please get internal review first
> before asking for review from the community.
> 
> greg k-h
> Is there any issue with this patch?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC patch] checkpatch: test identifier lengths

2018-02-16 Thread Andrew Morton
On Fri, 16 Feb 2018 09:13:27 -0800 Joe Perches  wrote:

> On Fri, 2018-02-16 at 15:55 +0300, Dan Carpenter wrote:
> > On Fri, Feb 16, 2018 at 05:06:34PM +0530, Yash Omer wrote:
> > > This patch fix line should not end with open parenthesis found by 
> > > checkpatch.plscript.
> > > 
> > > Signed-off-by: Yash Omer 
> > > ---
> > >  drivers/staging/nvec/nvec.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> > > index 52054a528723..39fb737543b5 100644
> > > --- a/drivers/staging/nvec/nvec.c
> > > +++ b/drivers/staging/nvec/nvec.c
> > > @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct 
> > > *work)
> > >   msg = list_first_entry(>tx_data, struct nvec_msg, node);
> > >   spin_unlock_irqrestore(>tx_lock, flags);
> > >   nvec_gpio_set_value(nvec, 0);
> > > - err = wait_for_completion_interruptible_timeout(
> > > - >ec_transfer, msecs_to_jiffies(5000));
> > > + err = wait_for_completion_interruptible_timeout
> > > + (>ec_transfer, msecs_to_jiffies(5000));
> > 
> > The original code is basically fine...  It's OK to ignore checkpatch in
> > this situation.
> 
> Right.

Yes, I'd say that checkpatch is simply wrong here.  I'd prefer that a
function call always have the opening paren hard up against the
function name.  Because I often search for "foo(" to find the callsites
of foo() and I expect that some code-parsing tools do the same thing. 
The "(" is the application of an operator to an identifier.

So I'd vote for simply nuking that checkpatch warning altogether. 
Maybe there are other situations in which it is useful, dunno.

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


[PATCH v2] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
Fix the dup_sg_table function to initialize the dma_address of the new
sg list entries instead of the source dma_address entries.

Since ION duplicates the sg_list this issue does not appear to result in
an actual bug.

Signed-off-by: Liam Mark 
Acked-by: Laura Abbott 
---
Changes in v2:
  - Add to commit message that it doesn't cause an actual bug
  - Remove 'Fixes:' since it doesn't cause a bug
  - Add Acked-by from Laura Abbott

 drivers/staging/android/ion/ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 57e0d8035b2e..517d4f40d1b7 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -187,7 +187,7 @@ static struct sg_table *dup_sg_table(struct sg_table *table)
new_sg = new_table->sgl;
for_each_sg(table->sgl, sg, table->nents, i) {
memcpy(new_sg, sg, sizeof(*sg));
-   sg->dma_address = 0;
+   new_sg->dma_address = 0;
new_sg = sg_next(new_sg);
}
 
-- 
1.8.5.2


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 09:57:12AM -0800, Liam Mark wrote:
> On Fri, 16 Feb 2018, Greg KH wrote:
> 
> > On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote:
> > > Fix the dup_sg_table function to initialize the dma_address of the new
> > > sg list entries instead of the source dma_address entries.
> > > 
> > > Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")
> > 
> > So this should be sent to the stable trees as well, right?
> > 
> > Please add that when you resend...
> 
> My understanding was that I should only send this to the stable branch if 
> it fixes a real bug.
> 
> Both myself and Laura can't see any actual problems that result from this 
> issue, the change is more to help future proof the code.
> 
> My commit message wasn't clear about this and could have mislead people 
> into thinking there was a bug.
> I will update the commit message to make it clear that this issue doesn't 
> currently result in any problem.
> 
> Do you still want me to send it to the stable trees?

If it's not a bugfix, no need to.  But please clean up your changelog
text as it implies that it is a bugfix...

thanks,

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


[PATCH] Staging: xgifb: fix lines should not end with open parenthesis in vb_setmode.c

2018-02-16 Thread Yash Omer
This patch fixes up line should not end with open parenthesis found by 
checkpatch.pl script.

Signed-off-by: Yash Omer 
---
 drivers/staging/xgifb/vb_setmode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 1fa0dc66406e..1d6ac724fd61 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -1228,8 +1228,8 @@ static void const *XGI_GetLcdPtr(struct 
XGI330_LCDDataTablStruct const *table,
return table[i].DATAPTR;
 }
 
-static struct SiS_TVData const *XGI_GetTVPtr(
-   unsigned short ModeIdIndex,
+static struct SiS_TVData const *XGI_GetTVPtr
+(unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex,
struct vb_device_info *pVBInfo)
 {
-- 
2.14.3

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


Re: [PATCH 5/6] staging: wilc1000: fix line over 80 characters in wilc_spi_read_int()

2018-02-16 Thread Claudiu Beznea


On 14.02.2018 13:10, Ajay Singh wrote:
> Refactor wilc_spi_read_int() to fix the line over 80 char issues reported
> by checkpatch.pl script.
> 
> Signed-off-by: Ajay Singh 
> ---
>  drivers/staging/wilc1000/wilc_spi.c | 57 
> +++--
>  1 file changed, 29 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_spi.c 
> b/drivers/staging/wilc1000/wilc_spi.c
> index fddc0db..7c58beb8 100644
> --- a/drivers/staging/wilc1000/wilc_spi.c
> +++ b/drivers/staging/wilc1000/wilc_spi.c
> @@ -939,45 +939,46 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 
> *int_status)
>   int happened, j;
>   u32 unknown_mask;
>   u32 irq_flags;
> + int k = IRG_FLAGS_OFFSET + 5;
>  
>   if (g_spi.has_thrpt_enh) {
>   ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
>   int_status);
> - } else {
> - ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
> - _cnt);
> - if (!ret) {
> - dev_err(>dev,
> - "Failed read WILC_VMM_TO_HOST_SIZE ...\n");
> - goto _fail_;
> - }
> - tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
> + return ret;
> + }
> + ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, _cnt);
> + if (!ret) {
> + dev_err(>dev,
> + "Failed read WILC_VMM_TO_HOST_SIZE ...\n");
> + goto _fail_;
> + }
> + tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
>  
> - j = 0;
> - do {
> - happened = 0;
> + j = 0;
> + do {
> + happened = 0;
You could remove this happen
>  
> - wilc_spi_read_reg(wilc, 0x1a90, _flags);
> - tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
> + wilc_spi_read_reg(wilc, 0x1a90, _flags);
> + tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
>  
> - if (g_spi.nint > 5) {
> - wilc_spi_read_reg(wilc, 0x1a94,
> -   _flags);
> - tmp |= (((irq_flags >> 0) & 0x7) << 
> (IRG_FLAGS_OFFSET + 5));
> - }
> + if (g_spi.nint > 5) {
> + wilc_spi_read_reg(wilc, 0x1a94, _flags);
> + tmp |= (((irq_flags >> 0) & 0x7) << k);
> + }
>  
> - unknown_mask = ~((1ul << g_spi.nint) - 1);
> + unknown_mask = ~((1ul << g_spi.nint) - 1);
You could use GENMASK(g_spi.nint - 1, 0) instead of ~((1ul << g_spi.nint) - 1)
>  
> - if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) {
> - dev_err(>dev, "Unexpected interrupt (2): 
> j=%d, tmp=%x, mask=%x\n", j, tmp, unknown_mask);
> - happened = 1;
> - }
> + if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) {
> + dev_err(>dev,
> + "Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
> + j, tmp, unknown_mask);
> + happened = 1;
And here just break;
> + }
>  
> - j++;
> - } while (happened);
And here use while (true);
> + j++;
> + } while (happened);
>  
> - *int_status = tmp;
> - }
> + *int_status = tmp;
>  
>  _fail_:
>   return ret;
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 6/6] staging: wilc1000: fix line over 80 chars in wilc_spi_clear_int_ext()

2018-02-16 Thread Claudiu Beznea


On 14.02.2018 13:10, Ajay Singh wrote:
> Refactor wilc_spi_clear_int_ext() to fix the "line over 80 char" issue
> reported by checkpatch.pl script.
> 
> Signed-off-by: Ajay Singh 
> ---
>  drivers/staging/wilc1000/wilc_spi.c | 113 
> +---
>  1 file changed, 54 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_spi.c 
> b/drivers/staging/wilc1000/wilc_spi.c
> index 7c58beb8..6b392c9 100644
> --- a/drivers/staging/wilc1000/wilc_spi.c
> +++ b/drivers/staging/wilc1000/wilc_spi.c
> @@ -988,74 +988,69 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, 
> u32 val)
>  {
>   struct spi_device *spi = to_spi_device(wilc->dev);
>   int ret;
> + u32 flags;
> + u32 tbl_ctl;
>  
>   if (g_spi.has_thrpt_enh) {
>   ret = spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
>val);
> - } else {
> - u32 flags;
> -
> - flags = val & (BIT(MAX_NUM_INT) - 1);> -if 
> (flags) {
> - int i;
> -
> - ret = 1;
> - for (i = 0; i < g_spi.nint; i++) {
> - /*
> -  * No matter what you write 1 or 0,
> -  * it will clear interrupt.
> -  */
> - if (flags & 1)
> - ret = wilc_spi_write_reg(wilc, 0x10c8 + 
> i * 4, 1);
> - if (!ret)
> - break;
> - flags >>= 1;
> - }
> - if (!ret) {
> + return ret;
> + }
> +
> + flags = val & (BIT(MAX_NUM_INT) - 1);

Or you could use:
unsigned long expected_irqs, unexpected_irqs;

expected_irqs = val & GENMASK(g_spi.int - 1, 0);
unexpected_irq = val & GENMASK(MAX_NUM_INT - 1, g_spi.int);

for (i = 0; i < g_spi.nint && expected_irqs; i++) {
if (expected_irqs & BIT(i)) {
ret = wilc_spi_write_reg(wilc, 0x10c8 + i * 4, 1);
if (ret) {
dev_err(...);
goto _fail_;
}
}
}

for (i = g_spi.nint; i < MAX_NUM_INT && unexpected_irq; i++) {
if (unexpected_irqs & BIT(i))
dev_err(...);

Instead of this:
> + if (flags) {
> + int i;
> +
> + ret = 1;
> + for (i = 0; i < g_spi.nint; i++) {
> + /*
> +  * No matter what you write 1 or 0,
> +  * it will clear interrupt.
> +  */> +  if (flags & 1)
> + ret = wilc_spi_write_reg(wilc,
> +  0x10c8 + i * 4, 1);
> + if (!ret)
> + break;
> + flags >>= 1;
> + }
> + if (!ret) {
> + dev_err(>dev,
> + "Failed wilc_spi_write_reg, set reg %x ...\n",
> + 0x10c8 + i * 4);
> + goto _fail_;
> + }
> + for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
> + if (flags & 1)
>   dev_err(>dev,
> - "Failed wilc_spi_write_reg, set reg %x 
> ...\n",
> - 0x10c8 + i * 4);
> - goto _fail_;
> - }
> - for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
> - if (flags & 1)
> - dev_err(>dev,
> - "Unexpected interrupt cleared 
> %d...\n",
> - i);
> - flags >>= 1;
> - }
> + "Unexpected interrupt cleared %d...\n",
> + i);
> + flags >>= 1;
>   }
> + }
>  
until here.

> - {
> - u32 tbl_ctl;
> -
> - tbl_ctl = 0;
> - /* select VMM table 0 */
> - if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
> - tbl_ctl |= BIT(0);
> - /* select VMM table 1 */
> - if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
> - tbl_ctl |= BIT(1);
> + tbl_ctl = 0;
> + /* select VMM table 0 */
> + if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
> + tbl_ctl |= BIT(0);
> + /* select VMM table 1 */
> + if ((val & SEL_VMM_TBL1) == 

Re: [PATCH 3/6] staging: wilc1000: fix line over 80 characters in spi_cmd_complete()

2018-02-16 Thread Claudiu Beznea


On 14.02.2018 13:10, Ajay Singh wrote:
> Refactor spi_cmd_complete() to fix the line over 80 char issues reported
> by checkpatch.pl script.
> 
> Signed-off-by: Ajay Singh 
> ---
>  drivers/staging/wilc1000/wilc_spi.c | 250 
> ++--
>  1 file changed, 124 insertions(+), 126 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_spi.c 
> b/drivers/staging/wilc1000/wilc_spi.c
> index 66b6aea..30a9a61 100644
> --- a/drivers/staging/wilc1000/wilc_spi.c
> +++ b/drivers/staging/wilc1000/wilc_spi.c
> @@ -287,17 +287,19 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   u8 rsp;
>   int len = 0;
>   int result = N_OK;
> + int retry;
> + u8 crc[2];
>  
>   wb[0] = cmd;
>   switch (cmd) {
> - case CMD_SINGLE_READ:   /* single word (4 
> bytes) read */
> + case CMD_SINGLE_READ: /* single word (4 bytes) read */
Ok with this but I think would be nicer to have them documented the place were
they are defined.
>   wb[1] = (u8)(adr >> 16);
>   wb[2] = (u8)(adr >> 8);
>   wb[3] = (u8)adr;
>   len = 5;
>   break;
>  
> - case CMD_INTERNAL_READ: /* internal register read */
> + case CMD_INTERNAL_READ: /* internal register read */
Ditto
>   wb[1] = (u8)(adr >> 8);
>   if (clockless == 1)
>   wb[1] |= BIT(7);
> @@ -306,29 +308,29 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   len = 5;
>   break;
>  
> - case CMD_TERMINATE: /* termination 
> */
> + case CMD_TERMINATE:
Ditto
>   wb[1] = 0x00;
>   wb[2] = 0x00;
>   wb[3] = 0x00;
>   len = 5;
>   break;
>  
> - case CMD_REPEAT:/* 
> repeat */
> + case CMD_REPEAT:
Ditto
>   wb[1] = 0x00;
>   wb[2] = 0x00;
>   wb[3] = 0x00;
>   len = 5;
>   break;
>  
> - case CMD_RESET: /* 
> reset */
> + case CMD_RESET:
Ditto
>   wb[1] = 0xff;
>   wb[2] = 0xff;
>   wb[3] = 0xff;
>   len = 5;
>   break;
>  
> - case CMD_DMA_WRITE: /* dma write */
> - case CMD_DMA_READ:  /* dma read */
> + case CMD_DMA_WRITE: /* dma write */
> + case CMD_DMA_READ:  /* dma read */
Ditto
>   wb[1] = (u8)(adr >> 16);
>   wb[2] = (u8)(adr >> 8);
>   wb[3] = (u8)adr;
> @@ -337,8 +339,8 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   len = 7;
>   break;
>  
> - case CMD_DMA_EXT_WRITE: /* dma extended write */
> - case CMD_DMA_EXT_READ:  /* dma extended read */
> + case CMD_DMA_EXT_WRITE: /* dma extended write */
> + case CMD_DMA_EXT_READ:  /* dma extended read */
Ditto
>   wb[1] = (u8)(adr >> 16);
>   wb[2] = (u8)(adr >> 8);
>   wb[3] = (u8)adr;
> @@ -348,7 +350,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   len = 8;
>   break;
>  
> - case CMD_INTERNAL_WRITE:/* internal register write */
> + case CMD_INTERNAL_WRITE: /* internal register write */
Ditto
>   wb[1] = (u8)(adr >> 8);
>   if (clockless == 1)
>   wb[1] |= BIT(7);
> @@ -360,7 +362,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   len = 8;
>   break;
>  
> - case CMD_SINGLE_WRITE:  /* single word write */
> + case CMD_SINGLE_WRITE: /* single word write */
Ditto
>   wb[1] = (u8)(adr >> 16);
>   wb[2] = (u8)(adr >> 8);
>   wb[3] = (u8)(adr);
> @@ -395,13 +397,12 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   cmd == CMD_REPEAT) {
>   len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES);
>   } else if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) {
> - if (!g_spi.crc_off) {
> - len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + 
> NUM_DATA_BYTES
> -   + NUM_CRC_BYTES + NUM_DUMMY_BYTES);
> - } else {
> - len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + 
> NUM_DATA_BYTES
> -   + NUM_DUMMY_BYTES);
> - }
> + int tmp = NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES
> + + NUM_DUMMY_BYTES;
> + if 

Re: [PATCH 1/6] staging: wilc1000: modified code comments as per linux coding style

2018-02-16 Thread Claudiu Beznea
Hi Ajay,

Even I cannot locate something in Documentation/CodingStyle related to single
line comment, I prefer to use:
/* comment */

instead of:
/*
 * comment
 */

Do as you wish!

Thank you,
Claudiu

On 14.02.2018 13:10, Ajay Singh wrote:
> diff --git a/drivers/staging/wilc1000/wilc_spi.c 
> b/drivers/staging/wilc1000/wilc_spi.c
> index 8f71a60..5d0de4e 100644
> --- a/drivers/staging/wilc1000/wilc_spi.c
> +++ b/drivers/staging/wilc1000/wilc_spi.c
> @@ -422,9 +422,9 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   return N_FAIL;
>   }
>  
> - /**
> + /*
>* Command/Control response
> -  **/
> +  */
>   if (cmd == CMD_RESET ||
>   cmd == CMD_TERMINATE ||
>   cmd == CMD_REPEAT) {
> @@ -443,9 +443,9 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   return N_FAIL;
>   }
>  
> - /**
> + /*
>* State response
> -  **/
> +  */
>   rsp = rb[rix++];
>   if (rsp != 0x00) {
>   dev_err(>dev, "Failed cmd state response state (%02x)\n",
> @@ -458,12 +458,15 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   int retry;
>   /* u16 crc1, crc2; */
>   u8 crc[2];
> - /**
> + /*
>* Data Respnose header
> -  **/
> +  */
>   retry = 100;
>   do {
> - /* ensure there is room in buffer later to read data 
> and crc */
> + /*
> +  * ensure there is room in buffer later
> +  * to read data and crc
> +  */
>   if (rix < len2) {
>   rsp = rb[rix++];
>   } else {
> @@ -481,9 +484,9 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   }
>  
>   if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) {
> - /**
> + /*
>* Read bytes
> -  **/
> +  */
>   if ((rix + 3) < len2) {
>   b[0] = rb[rix++];
>   b[1] = rb[rix++];
> @@ -496,9 +499,9 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   }
>  
>   if (!g_spi.crc_off) {
> - /**
> + /*
>* Read Crc
> -  **/
> +  */
>   if ((rix + 1) < len2) {
>   crc[0] = rb[rix++];
>   crc[1] = rb[rix++];
> @@ -524,18 +527,18 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   else
>   nbytes = DATA_PKT_SZ - ix;
>  
> - /**
> + /*
>* Read bytes
> -  **/
> +  */
>   if (wilc_spi_rx(wilc, [ix], nbytes)) {
>   dev_err(>dev, "Failed data block 
> read, bus error...\n");
>   result = N_FAIL;
>   goto _error_;
>   }
>  
> - /**
> + /*
>* Read Crc
> -  **/
> +  */
>   if (!g_spi.crc_off) {
>   if (wilc_spi_rx(wilc, crc, 2)) {
>   dev_err(>dev, "Failed data 
> block crc read, bus error...\n");
> @@ -548,7 +551,10 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   sz -= nbytes;
>   }
>  
> - /*  if any data in left unread, then read the rest 
> using normal DMA code.*/
> + /*
> +  * if any data in left unread,
> +  * then read the rest using normal DMA code.
> +  */
>   while (sz > 0) {
>   int nbytes;
>  
> @@ -557,14 +563,14 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, 
> u32 adr, u8 *b, u32 sz,
>   else
>   nbytes = DATA_PKT_SZ;
>  
> - /**
> + /*
>* read data response only on the next DMA 
> cycles 

Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
On Fri, 16 Feb 2018, Greg KH wrote:

> On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote:
> > Fix the dup_sg_table function to initialize the dma_address of the new
> > sg list entries instead of the source dma_address entries.
> > 
> > Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")
> 
> So this should be sent to the stable trees as well, right?
> 
> Please add that when you resend...

My understanding was that I should only send this to the stable branch if 
it fixes a real bug.

Both myself and Laura can't see any actual problems that result from this 
issue, the change is more to help future proof the code.

My commit message wasn't clear about this and could have mislead people 
into thinking there was a bug.
I will update the commit message to make it clear that this issue doesn't 
currently result in any problem.

Do you still want me to send it to the stable trees?

Thanks,
Liam

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
On Thu, 15 Feb 2018, Laura Abbott wrote:

> On 02/12/2018 01:25 PM, Liam Mark wrote:
> > 
> > On Mon, 12 Feb 2018, Dan Carpenter wrote:
> > 
> > > On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote:
> > > > Fix the dup_sg_table function to initialize the dma_address of the new
> > > > sg list entries instead of the source dma_address entries.
> > > > 
> > > > Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")
> > > > Signed-off-by: Liam Mark 
> > > 
> > > How did you find this bug?  What are the user visible effects of this
> > > bug?  I'm probably going to ask you to send a v2 patch with a new
> > > changelog depending on the answers to these questions.
> > 
> > I noticed the bug when reading through the code, I haven?t seen any
> > visible effects of this bug.
> > 
> >  From looking at the code I don?t see any obvious ways that this bug
> would
> > introduce any issues with the current code base.
> > 
> > Liam
> > 
> 
> Given the way we duplicate the sg_list this should be harmless but you
> are right it's cleaner if we initialize the new list. You can add my
> Ack when you update with a new change log clarifying this.
> 
> Thanks,
> Laura
> 

Will do.

Thanks,
Liam

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC patch] checkpatch: test identifier lengths

2018-02-16 Thread Joe Perches
On Fri, 2018-02-16 at 15:55 +0300, Dan Carpenter wrote:
> On Fri, Feb 16, 2018 at 05:06:34PM +0530, Yash Omer wrote:
> > This patch fix line should not end with open parenthesis found by 
> > checkpatch.plscript.
> > 
> > Signed-off-by: Yash Omer 
> > ---
> >  drivers/staging/nvec/nvec.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> > index 52054a528723..39fb737543b5 100644
> > --- a/drivers/staging/nvec/nvec.c
> > +++ b/drivers/staging/nvec/nvec.c
> > @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct 
> > *work)
> > msg = list_first_entry(>tx_data, struct nvec_msg, node);
> > spin_unlock_irqrestore(>tx_lock, flags);
> > nvec_gpio_set_value(nvec, 0);
> > -   err = wait_for_completion_interruptible_timeout(
> > -   >ec_transfer, msecs_to_jiffies(5000));
> > +   err = wait_for_completion_interruptible_timeout
> > +   (>ec_transfer, msecs_to_jiffies(5000));
> 
> The original code is basically fine...  It's OK to ignore checkpatch in
> this situation.

Right.

Please remember checkpatch is basically stupid as it is
a trivial pattern matcher.

It is very hard to use 80 column line lengths with very
long identifiers.

Any time identifiers are very long (here 40+ characters),
checkpatch long line and line format messages should be
taken with extremely large grains of salt.

Dan/Andrew, what do you think of adding some --strict only
'very_long_identifier' message to checkpatch?

Something like the below: (perhaps using 25 chars lengths?)

This also excludes any long identifier found in include/...
like the camelcase tests.

---
 scripts/checkpatch.pl | 102 +-
 1 file changed, 101 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3d4040322ae1..3659ed0988c4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -59,6 +59,7 @@ my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $color = "auto";
 my $allow_c99_comments = 1;
+my $long_identifier_len = 25;
 
 sub help {
my ($exitcode) = @_;
@@ -541,12 +542,13 @@ our @typeListWithAttr = (
qr{struct\s+$InitAttribute\s+$Ident},
qr{union\s+$InitAttribute\s+$Ident},
 );
-
 our @modifierList = (
qr{fastcall},
 );
 our @modifierListFile = ();
 
+our %long_identifiers = ();
+
 our @mode_permission_funcs = (
["module_param", 3],
["module_param_(?:array|named|string)", 4],
@@ -834,6 +836,29 @@ sub seed_camelcase_file {
}
 }
 
+sub seed_long_identifier_file {
+   my ($file) = @_;
+
+   return if (!(-f $file));
+
+   local $/;
+
+   open(my $include_file, '<', "$file")
+   or warn "$P: Can't read '$file' $!\n";
+   my $text = <$include_file>;
+   close($include_file);
+
+   my @lines = split('\n', $text);
+
+   foreach my $line (@lines) {
+   while ($line =~ /($Ident)/g) {
+   my $ident = $1;
+   next if (length($ident) <= $long_identifier_len);
+   $long_identifiers{$ident} = 1;
+   }
+   }
+}
+
 sub is_maintained_obsolete {
my ($filename) = @_;
 
@@ -902,6 +927,64 @@ sub seed_camelcase_includes {
}
 }
 
+my $long_identifiers_seeded = 0;
+sub seed_long_identifiers {
+   return if ($long_identifiers_seeded);
+
+   my $files;
+   my $long_identifier_cache = "";
+   my @include_files = ();
+
+   $long_identifiers_seeded = 1;
+
+   if (-e ".git") {
+   my $git_last_include_commit = `git log --no-merges 
--pretty=format:"%h%n" -1 -- include`;
+   chomp $git_last_include_commit;
+   $long_identifier_cache = 
".checkpatch-long_identifier.git.$git_last_include_commit";
+   } else {
+   my $last_mod_date = 0;
+   $files = `find $root/include -name "*.h"`;
+   @include_files = split('\n', $files);
+   foreach my $file (@include_files) {
+   my $date = POSIX::strftime("%Y%m%d%H%M",
+  localtime((stat $file)[9]));
+   $last_mod_date = $date if ($last_mod_date < $date);
+   }
+   $long_identifier_cache = 
".checkpatch-long_identifier.date.$last_mod_date";
+   }
+
+   if ($long_identifier_cache ne "" && -f $long_identifier_cache) {
+   open(my $long_identifier_file, '<', "$long_identifier_cache")
+   or warn "$P: Can't read '$long_identifier_cache' $!\n";
+   while (<$long_identifier_file>) {
+   chomp;
+   $long_identifiers{$_} = 1;
+   }
+   close($long_identifier_file);
+
+   return;
+   

Re: [PATCH] Staging: wlan-ng: Fix Alignment should match open paranthesis in prism2mgmt.c

2018-02-16 Thread Joe Perches
On Fri, 2018-02-16 at 15:36 +0100, Greg KH wrote:
> On Fri, Feb 16, 2018 at 12:18:36AM +0530, Yash Omer wrote:
> > This is patch fixes up a matching paranthesis alignment issue found by 
> > checkpatch.pl script.
[]
> > diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
> > b/drivers/staging/wlan-ng/prism2mgmt.c
[]
> > @@ -264,8 +264,8 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void 
> > *msgp)
> > goto exit;
> > }
> > /* ibss options */
> > -   result = hfa384x_drvr_setconfig16(hw,
> > -   HFA384x_RID_CREATEIBSS,
> > +   result = hfa384x_drvr_setconfig16
> > +   (hw, HFA384x_RID_CREATEIBSS,
> 
> The original code is just fine, why is checkpatch complaining about
> this?

lack of argument alignment to parentheses.

Maybe wlan-ng should be marked obsolete in MAINTAINERS.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/12] fix to remove line over 80 chars and few other

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 08:41:37PM +0530, Ajay Singh wrote:
> This patch series contains changes to fix line over 80 characters,
> too many leading tabs and few other issues reported by checkpatch.pl
> script.

Please put the proper prefix on your 00/XX patches, that are with your
other patches.  Otherwise it can get lost in my patch queues...

thanks,

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


Re: [PATCH v2 4/9] staging: android: ion: Avoid NULL point in error path

2018-02-16 Thread Greg KH
On Mon, Feb 12, 2018 at 06:43:09PM +0800, Yisheng Xie wrote:
> If we failed to create debugfs for ion at ion_device_create, the
> debug_root of ion_device will be NULL, and then when try to create debug
> file for shrinker of heap it will be create on the top of debugfs. If we
> also failed to create this the debug file, it call dentry_path to found
> the path of debug_root, then a NULL point will occur.
> 
> Fix this by avoiding call dentry_path, but show the debug name only when
> failed to create debug file for shrinker.
> 
> Acked-by: Laura Abbott 
> Signed-off-by: Yisheng Xie 
> ---
>  drivers/staging/android/ion/ion.c | 10 +++---
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c 
> b/drivers/staging/android/ion/ion.c
> index 57e0d80..4b69372 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -564,13 +564,9 @@ void ion_device_add_heap(struct ion_heap *heap)
>   debug_file = debugfs_create_file(debug_name,
>0644, dev->debug_root, heap,
>_shrink_fops);
> - if (!debug_file) {
> - char buf[256], *path;
> -
> - path = dentry_path(dev->debug_root, buf, 256);
> - pr_err("Failed to create heap shrinker debugfs at 
> %s/%s\n",
> -path, debug_name);
> - }
> + if (!debug_file)
> + pr_err("Failed to create ion heap shrinker debugfs at 
> %s\n",
> +debug_name);

Really we can just remove this, there's no need to check the return
value of this debugfs call at all, it doesn't matter.

thanks,

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


Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Greg KH
On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote:
> Fix the dup_sg_table function to initialize the dma_address of the new
> sg list entries instead of the source dma_address entries.
> 
> Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")

So this should be sent to the stable trees as well, right?

Please add that when you resend...

thanks,

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


[PATCH 01/12] staging: wilc1000: remove unnecessary comments to avoid line over 80 char issue

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue reported by checkpatch.pl script by
removing unnecessary comments.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index bb65b37..6ce9c94 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -405,7 +405,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 
data)
cmd.increment = 1;
cmd.count = 4;
cmd.buffer = (u8 *)
-   cmd.block_size = g_sdio.block_size; /* johnny : prevent it from 
setting unexpected value */
+   cmd.block_size = g_sdio.block_size;
ret = wilc_sdio_cmd53(wilc, );
if (ret) {
dev_err(>dev,
@@ -489,7 +489,7 @@ static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, 
u32 size)
cmd.count = nleft;
cmd.buffer = buf;
 
-   cmd.block_size = block_size; /* johnny : prevent it from 
setting unexpected value */
+   cmd.block_size = block_size;
 
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
@@ -543,7 +543,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 
*data)
cmd.count = 4;
cmd.buffer = (u8 *)data;
 
-   cmd.block_size = g_sdio.block_size; /* johnny : prevent it from 
setting unexpected value */
+   cmd.block_size = g_sdio.block_size;
ret = wilc_sdio_cmd53(wilc, );
if (ret) {
dev_err(>dev,
@@ -629,7 +629,7 @@ static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, 
u32 size)
cmd.count = nleft;
cmd.buffer = buf;
 
-   cmd.block_size = block_size; /* johnny : prevent it from 
setting unexpected value */
+   cmd.block_size = block_size;
 
if (addr > 0) {
if (!sdio_set_func0_csa_address(wilc, addr))
-- 
2.7.4

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


[PATCH 06/12] staging: wilc1000: remove blank line before close brace in wilc_wlan_cfg_get_wid_value()

2018-02-16 Thread Ajay Singh
Cleanup patch to remove "Blank lines aren't necessary before a close
brace '}'" issue reported by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_cfg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index c4b3d8d..752b292 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -497,7 +497,6 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 
buffer_size)
 
i += toggle;
toggle ^= 1;
-
}
memcpy(buffer,  _cfg_str[i].str[2],
   size);
-- 
2.7.4

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


[PATCH 11/12] staging: wilc1000: fix line over 80 chars in wilc_wlan_txq_filter_dup_tcp_ack()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue reported by checkpatch.pl.
Use temporary variable to avoid checkpatch.pl issue.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 391ecd5..98cd949 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -262,10 +262,20 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct 
net_device *dev)
 
spin_lock_irqsave(>txq_spinlock, wilc->txq_spinlock_flags);
for (i = pending_base; i < (pending_base + pending_acks); i++) {
-   if (i >= MAX_PENDING_ACKS ||
-   pending_acks_info[i].session_index >= 2 * MAX_TCP_SESSION)
+   u32 session_index;
+   u32 bigger_ack_num;
+
+   if (i >= MAX_PENDING_ACKS)
+   break;
+
+   session_index = pending_acks_info[i].session_index;
+
+   if (session_index >= 2 * MAX_TCP_SESSION)
break;
-   if (pending_acks_info[i].ack_num < 
ack_session_info[pending_acks_info[i].session_index].bigger_ack_num) {
+
+   bigger_ack_num = ack_session_info[session_index].bigger_ack_num;
+
+   if (pending_acks_info[i].ack_num < bigger_ack_num) {
struct txq_entry_t *tqe;
 
tqe = pending_acks_info[i].txqe;
-- 
2.7.4

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


[PATCH 10/12] staging: wilc1000: fix line over 80 characters in tcp_process()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index aedf84d..391ecd5 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -232,8 +232,10 @@ static inline void tcp_process(struct net_device *dev, 
struct txq_entry_t *tqe)
 (u32)tcp_hdr_ptr[11];
 
for (i = 0; i < tcp_session; i++) {
+   u32 j = ack_session_info[i].seq_num;
+
if (i < 2 * MAX_TCP_SESSION &&
-   ack_session_info[i].seq_num == 
seq_no) {
+   j == seq_no) {
update_tcp_session(i, ack_no);
break;
}
-- 
2.7.4

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


[PATCH 12/12] staging: wilc1000: fix line over 80 chars in wilc_wlan_handle_txq()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue reported by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.c | 38 +++-
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 98cd949..1a9ef1a 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -576,6 +576,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
u32 vmm_table[WILC_VMM_TBL_SIZE];
struct wilc_vif *vif;
struct wilc *wilc;
+   const struct wilc_hif_func *func;
 
vif = netdev_priv(dev);
wilc = vif->wilc;
@@ -629,10 +630,9 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
 
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
counter = 0;
+   func = wilc->hif_func;
do {
-   ret = wilc->hif_func->hif_read_reg(wilc,
-  WILC_HOST_TX_CTRL,
-  );
+   ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, );
if (!ret)
break;
 
@@ -642,7 +642,8 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
counter++;
if (counter > 200) {
counter = 0;
-   ret = wilc->hif_func->hif_write_reg(wilc, 
WILC_HOST_TX_CTRL, 0);
+   ret = func->hif_write_reg(wilc,
+ WILC_HOST_TX_CTRL, 0);
break;
}
} while (!wilc->quit);
@@ -652,18 +653,21 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
 
timeout = 200;
do {
-   ret = wilc->hif_func->hif_block_tx(wilc, 
WILC_VMM_TBL_RX_SHADOW_BASE, (u8 *)vmm_table, ((i + 1) * 4));
+   ret = func->hif_block_tx(wilc,
+WILC_VMM_TBL_RX_SHADOW_BASE,
+(u8 *)vmm_table,
+((i + 1) * 4));
if (!ret)
break;
 
-   ret = wilc->hif_func->hif_write_reg(wilc,
-   WILC_HOST_VMM_CTL,
-   0x2);
+   ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2);
if (!ret)
break;
 
do {
-   ret = wilc->hif_func->hif_read_reg(wilc, 
WILC_HOST_VMM_CTL, );
+   ret = func->hif_read_reg(wilc,
+WILC_HOST_VMM_CTL,
+);
if (!ret)
break;
if ((reg >> 2) & 0x1) {
@@ -673,7 +677,9 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
release_bus(wilc, RELEASE_ALLOW_SLEEP);
} while (--timeout);
if (timeout <= 0) {
-   ret = wilc->hif_func->hif_write_reg(wilc, 
WILC_HOST_VMM_CTL, 0x0);
+   ret = func->hif_write_reg(wilc,
+ WILC_HOST_VMM_CTL,
+ 0x0);
break;
}
 
@@ -681,11 +687,15 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
break;
 
if (entries == 0) {
-   ret = wilc->hif_func->hif_read_reg(wilc, 
WILC_HOST_TX_CTRL, );
+   ret = func->hif_read_reg(wilc,
+WILC_HOST_TX_CTRL,
+);
if (!ret)
break;
reg &= ~BIT(0);
-   ret = wilc->hif_func->hif_write_reg(wilc, 
WILC_HOST_TX_CTRL, reg);
+   ret = func->hif_write_reg(wilc,
+ WILC_HOST_TX_CTRL,
+ reg);
if (!ret)
break;

[PATCH 04/12] staging: wilc1000: fix open parenthesis alignment mismatch in wilc_parse_network_info()

2018-02-16 Thread Ajay Singh
Fix "Alignment should match open parenthesis" issue found by
checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index e98fc8e..2e2187b 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -320,8 +320,8 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
get_ssid(msa, network_info->ssid, _info->ssid_len);
get_BSSID(msa, network_info->bssid);
 
-   network_info->ch = get_current_channel_802_11n(msa,
-   rx_len + FCS_LEN);
+   network_info->ch = get_current_channel_802_11n(msa, rx_len
+  + FCS_LEN);
 
index = MAC_HDR_LEN + TIME_STAMP_LEN;
 
-- 
2.7.4

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


[PATCH 07/12] staging: wilc1000: fix line over 80 chars in wilc_wlan_cfg_indicate_rxi()

2018-02-16 Thread Ajay Singh
Cleanup patch to fix "line over 80 characters" issue reported by
checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_cfg.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index 752b292..ab69bac 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -523,9 +523,12 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 
*frame, int size,
frame += 4;
size -= 4;
 
-   /**
-*  The  valid types of response messages are 'R' (Response), 'I' 
(Information), and 'N' (Network Information)
-**/
+   /*
+* The valid types of response messages are
+* 'R' (Response),
+* 'I' (Information), and
+* 'N' (Network Information)
+*/
 
switch (msg_type) {
case 'R':
-- 
2.7.4

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


[PATCH 09/12] staging: wilc1000: fix line over 80 chars in add_tcp_pending_ack()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue reported by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index acaeafc..aedf84d 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -173,11 +173,13 @@ static inline int update_tcp_session(u32 index, u32 ack)
 static inline int add_tcp_pending_ack(u32 ack, u32 session_index,
  struct txq_entry_t *txqe)
 {
-   if (pending_base + pending_acks < MAX_PENDING_ACKS) {
-   pending_acks_info[pending_base + pending_acks].ack_num = ack;
-   pending_acks_info[pending_base + pending_acks].txqe = txqe;
-   pending_acks_info[pending_base + pending_acks].session_index = 
session_index;
-   txqe->tcp_pending_ack_idx = pending_base + pending_acks;
+   u32 i = pending_base + pending_acks;
+
+   if (i < MAX_PENDING_ACKS) {
+   pending_acks_info[i].ack_num = ack;
+   pending_acks_info[i].txqe = txqe;
+   pending_acks_info[i].session_index = session_index;
+   txqe->tcp_pending_ack_idx = i;
pending_acks++;
}
return 0;
-- 
2.7.4

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


[PATCH 08/12] staging: wilc1000: fix line over 80 chars in wilc_wlan_cfg_get_wid_value()

2018-02-16 Thread Ajay Singh
Fix "line over 80 character" issue found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_cfg.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index ab69bac..2b44f4c 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -484,15 +484,17 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 
buffer_size)
} while (1);
} else if (type == CFG_STR_CMD) {
do {
-   if (g_cfg_str[i].id == WID_NIL)
+   u32 id = g_cfg_str[i].id;
+
+   if (id == WID_NIL)
break;
 
-   if (g_cfg_str[i].id == wid) {
+   if (id == wid) {
u32 size = g_cfg_str[i].str[0] |
(g_cfg_str[i].str[1] << 8);
 
if (buffer_size >= size) {
-   if (g_cfg_str[i].id == 
WID_SITE_SURVEY_RESULTS) {
+   if (id == WID_SITE_SURVEY_RESULTS) {
static int toggle;
 
i += toggle;
-- 
2.7.4

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


[PATCH 05/12] staging: wilc1000: fix line over 80 char in wilc_wlan_cfg_set_str()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_cfg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c 
b/drivers/staging/wilc1000/wilc_wlan_cfg.c
index aeb5417..c4b3d8d 100644
--- a/drivers/staging/wilc1000/wilc_wlan_cfg.c
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -221,7 +221,8 @@ static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, 
u16 id, u32 val32)
return 8;
 }
 
-static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str, u32 
size)
+static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
+u32 size)
 {
u8 *buf;
 
-- 
2.7.4

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


[PATCH 02/12] staging: wilc1000: fix too many leading tabs warning in sdio_clear_int_ext()

2018-02-16 Thread Ajay Singh
Refactor sdio_clear_int_ext() function to remove "Too many leading tabs"
warning reported by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c | 134 +--
 1 file changed, 65 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index 6ce9c94..27ec90e 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -871,6 +871,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
 {
struct sdio_func *func = dev_to_sdio_func(wilc->dev);
int ret;
+   int vmm_ctl;
 
if (g_sdio.has_thrpt_enh3) {
u32 reg;
@@ -909,84 +910,79 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
goto _fail_;
}
}
-   } else {
-   if (g_sdio.irq_gpio) {
-   /* see below. has_thrpt_enh2 uses register 0xf8 to 
clear interrupts. */
-   /* Cannot clear multiple interrupts. Must clear each 
interrupt individually */
-   u32 flags;
-
-   flags = val & (BIT(MAX_NUM_INT) - 1);
-   if (flags) {
-   int i;
-
-   ret = 1;
-   for (i = 0; i < g_sdio.nint; i++) {
-   if (flags & 1) {
-   struct sdio_cmd52 cmd;
-
-   cmd.read_write = 1;
-   cmd.function = 0;
-   cmd.raw = 0;
-   cmd.address = 0xf8;
-   cmd.data = BIT(i);
-
-   ret = wilc_sdio_cmd52(wilc, 
);
-   if (ret) {
-   dev_err(>dev,
-   "Failed cmd52, 
set 0xf8 data (%d) ...\n",
-   __LINE__);
-   goto _fail_;
-   }
+   return 1;
+   }
+   if (g_sdio.irq_gpio) {
+   /* see below. has_thrpt_enh2 uses register 0xf8 to clear 
interrupts. */
+   /* Cannot clear multiple interrupts. Must clear each interrupt 
individually */
+   u32 flags;
+
+   flags = val & (BIT(MAX_NUM_INT) - 1);
+   if (flags) {
+   int i;
+
+   ret = 1;
+   for (i = 0; i < g_sdio.nint; i++) {
+   if (flags & 1) {
+   struct sdio_cmd52 cmd;
+
+   cmd.read_write = 1;
+   cmd.function = 0;
+   cmd.raw = 0;
+   cmd.address = 0xf8;
+   cmd.data = BIT(i);
+
+   ret = wilc_sdio_cmd52(wilc, );
+   if (ret) {
+   dev_err(>dev,
+   "Failed cmd52, set 0xf8 
data (%d) ...\n",
+   __LINE__);
+   goto _fail_;
}
-   if (!ret)
-   break;
-   flags >>= 1;
}
if (!ret)
-   goto _fail_;
-   for (i = g_sdio.nint; i < MAX_NUM_INT; i++) {
-   if (flags & 1)
-   dev_err(>dev,
-   "Unexpected interrupt 
cleared %d...\n",
-   i);
-   flags >>= 1;
-   }
+   break;
+   flags >>= 1;
}
-   }
-
-   {
-   u32 vmm_ctl;
-
-   vmm_ctl = 0;
-   /* select VMM table 0 */
-   if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
-   vmm_ctl |= BIT(0);
-   /* select VMM table 1 */
-   if ((val & 

[PATCH 00/12] fix to remove line over 80 chars and few other

2018-02-16 Thread Ajay Singh
This patch series contains changes to fix line over 80 characters,
too many leading tabs and few other issues reported by checkpatch.pl
script.

Ajay Singh (12):
  staging: wilc1000: remove unnecessary comments to avoid line over 80
char issue
  staging: wilc1000: fix too many leading tabs warning in
sdio_clear_int_ext()
  staging: wilc1000: fix line over 80 characters in sdio_clear_int_ext()
  staging: wilc1000: fix open parenthesis alignment mismatch in
wilc_parse_network_info()
  staging: wilc1000: fix line over 80 char in wilc_wlan_cfg_set_str()
  staging: wilc1000: remove blank line before close brace in
wilc_wlan_cfg_get_wid_value()
  staging: wilc1000: fix line over 80 chars in
wilc_wlan_cfg_indicate_rxi()
  staging: wilc1000: fix line over 80 chars in
wilc_wlan_cfg_get_wid_value()
  staging: wilc1000: fix line over 80 chars in add_tcp_pending_ack()
  staging: wilc1000: fix line over 80 characters in tcp_process()
  staging: wilc1000: fix line over 80 chars in
wilc_wlan_txq_filter_dup_tcp_ack()
  staging: wilc1000: fix line over 80 chars in wilc_wlan_handle_txq()

 drivers/staging/wilc1000/coreconfigurator.c |   4 +-
 drivers/staging/wilc1000/wilc_sdio.c| 145 ++--
 drivers/staging/wilc1000/wilc_wlan.c|  70 +-
 drivers/staging/wilc1000/wilc_wlan_cfg.c|  21 ++--
 4 files changed, 134 insertions(+), 106 deletions(-)

-- 
2.7.4

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


[PATCH 03/12] staging: wilc1000: fix line over 80 characters in sdio_clear_int_ext()

2018-02-16 Thread Ajay Singh
Fix "line over 80 characters" issue found by checkpatch.pl script by
modifying the comment description.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index 27ec90e..a088999 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -913,8 +913,11 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
return 1;
}
if (g_sdio.irq_gpio) {
-   /* see below. has_thrpt_enh2 uses register 0xf8 to clear 
interrupts. */
-   /* Cannot clear multiple interrupts. Must clear each interrupt 
individually */
+   /* has_thrpt_enh2 uses register 0xf8 to clear interrupts. */
+   /*
+* Cannot clear multiple interrupts.
+* Must clear each interrupt individually.
+*/
u32 flags;
 
flags = val & (BIT(MAX_NUM_INT) - 1);
-- 
2.7.4

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


Re: [PATCH 1/2] staging: rtl8712: make unsigned length for rtl8717_get{_wpa_,_wpa2_,_}ie

2018-02-16 Thread Greg KH
On Thu, Feb 01, 2018 at 08:14:52PM +0100, Stefano Manni wrote:
> Fixed r8712_get_ie, r8712_get_wpa_ie, r8712_get_wpa2_ie
> to have a length as unsigned int pointer instead of signed.



Can you rebase both of these patches on the staging-testing branch of
the staging.git tree so that I can apply them?  Right now they have too
many conflicts.

thanks,

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Greg KH
On Tue, Feb 13, 2018 at 12:33:53AM +0200, Alexey Skidanov wrote:
> Current ion kernel mapping implementation uses vmap() to map previously
> allocated buffers into kernel virtual address space.
> 
> On 32-bit platforms, vmap() might fail on large enough buffers due to the
> limited available vmalloc space. dma_buf_kmap() should guarantee that
> only one page is mapped at a time.
> 
> To fix this, kmap()/kmap_atomic() is used to implement the appropriate
> interfaces.
> 
> Signed-off-by: Alexey Skidanov 

Again, I said I required another intel.com signed-off-by on any of your
ion patches before I would take them.  Please get internal review first
before asking for review from the community.

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


Re: [PATCH] Staging: wlan-ng: Fix Alignment should match open paranthesis in prism2mgmt.c

2018-02-16 Thread Greg KH
On Fri, Feb 16, 2018 at 12:18:36AM +0530, Yash Omer wrote:
> This is patch fixes up a matching paranthesis alignment issue found by 
> checkpatch.pl script.
> 
> Signed-off-by: Yash Omer 
> ---
>  drivers/staging/wlan-ng/prism2mgmt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
> b/drivers/staging/wlan-ng/prism2mgmt.c
> index 5be1af20d2d4..974a7572fafc 100644
> --- a/drivers/staging/wlan-ng/prism2mgmt.c
> +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> @@ -264,8 +264,8 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void 
> *msgp)
>   goto exit;
>   }
>   /* ibss options */
> - result = hfa384x_drvr_setconfig16(hw,
> - HFA384x_RID_CREATEIBSS,
> + result = hfa384x_drvr_setconfig16
> + (hw, HFA384x_RID_CREATEIBSS,

The original code is just fine, why is checkpatch complaining about
this?

thanks,

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


Re: [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function

2018-02-16 Thread Greg KH
On Wed, Jan 17, 2018 at 02:10:47PM +0530, Naveen Panwar wrote:
> In staging/netlogic/platform.c Refactoring the identical code used
> in several places for calculating the physical address of
> memory-mapped objects on the device.Put that into an inline helper
> function and use it.
> 
> Adjust the types of arguments of xlr_resource_init() - 'offset' and 'irq'
> are actually unsigned.  The values passed to those fit into 0..2G range,
> so the behaviour is unchanged, but it's more consistent that way.
> 
> Signed-off-by: Naveen Panwar 
> ---
>  drivers/staging/netlogic/platform_net.c | 21 +++--
>  1 file changed, 11 insertions(+), 10 deletions(-)

This patch does not apply at all :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/6] staging: wilc1000: fix line over 80 characters in wilc_spi_init()

2018-02-16 Thread Greg KH
On Wed, Feb 14, 2018 at 04:40:13PM +0530, Ajay Singh wrote:
> Modified wilc_spi_init() to fix the line over 80 char issues reported
> by checkpatch.pl script.
> To overcome the checkpatch.pl reported issue modified debug logs and
> comments used in wilc_spi_init().
> 
> Signed-off-by: Ajay Singh 
> ---
>  drivers/staging/wilc1000/wilc_spi.c | 18 +++---
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_spi.c 
> b/drivers/staging/wilc1000/wilc_spi.c
> index 30a9a61..fddc0db 100644
> --- a/drivers/staging/wilc1000/wilc_spi.c
> +++ b/drivers/staging/wilc1000/wilc_spi.c
> @@ -835,7 +835,6 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
>   struct spi_device *spi = to_spi_device(wilc->dev);
>   u32 reg;
>   u32 chipid;
> -
>   static int isinit;

You also deleted this line :(


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


Re: [PATCH] staging: iio/meter: add name to function definition arguments

2018-02-16 Thread Daniel Baluta
Hi Rodrigo,

I think this is a nice finding. One comment inline:

On Vi, 2018-02-16 at 10:50 -0200, rodrigosiqueira wrote:
> This patch fixes the checkpatch.pl warning:
> 
> drivers/staging/iio/meter/ade7854.h:157: WARNING: function definition
> argument 'struct device *' should also have an identifier name...
> 
> + int (*read_reg_32)(struct device *dev, u16 reg_address, u32 *val);
> + int (*write_reg_8)(struct device *dev, u16 reg_address, u8 value);


Any particular reason for using val vs value? I get that one is a pointer
and another a plain type, but I think the name should be the same.

thanks,
Daniel.

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


Re: [PATCH] staging: iio/meter: add name to function definition arguments

2018-02-16 Thread Rodrigo Siqueira
Hi Daniel

> Hi Rodrigo,
> 
> I think this is a nice finding. One comment inline:
> 
> On Vi, 2018-02-16 at 10:50 -0200, rodrigosiqueira wrote:
> > This patch fixes the checkpatch.pl warning:
> > 
> > drivers/staging/iio/meter/ade7854.h:157: WARNING: function definition
> > argument 'struct device *' should also have an identifier name...
> > 
> > +   int (*read_reg_32)(struct device *dev, u16 reg_address, u32 *val);
> > +   int (*write_reg_8)(struct device *dev, u16 reg_address, u8 value);
> 
> 
> Any particular reason for using val vs value? I get that one is a pointer
> and another a plain type, but I think the name should be the same.

Before I selected the name, I figure out that read_reg_* and write_reg_*
was assigned inside the iio/meter/ade7754-(i2c|spi).c files by function
like ade7754_*_read_reg_* and ade7754_*_write_reg_* .

I considered to use 'value' name for both functions parameters, however,
I noticed that function ade7754_*_write_reg_* adopted the name 'value'
for the last argument and ade7754_*_read_reg_* named the last argument
as 'val'. So, for consistency sake between the header file and the c
code, I decided to use the same parameter name patterns.


> thanks,
> Daniel.
>

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


Re: [PATCH] Staging: nvec: fix line should not end with a open parenthesis.

2018-02-16 Thread Dan Carpenter
On Fri, Feb 16, 2018 at 05:06:34PM +0530, Yash Omer wrote:
> This patch fix line should not end with open parenthesis found by 
> checkpatch.plscript.
> 
> Signed-off-by: Yash Omer 
> ---
>  drivers/staging/nvec/nvec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 52054a528723..39fb737543b5 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct *work)
>   msg = list_first_entry(>tx_data, struct nvec_msg, node);
>   spin_unlock_irqrestore(>tx_lock, flags);
>   nvec_gpio_set_value(nvec, 0);
> - err = wait_for_completion_interruptible_timeout(
> - >ec_transfer, msecs_to_jiffies(5000));
> + err = wait_for_completion_interruptible_timeout
> + (>ec_transfer, msecs_to_jiffies(5000));

The original code is basically fine...  It's OK to ignore checkpatch in
this situation.

regards,
dan carpenter

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


[PATCH] staging: iio/meter: add name to function definition arguments

2018-02-16 Thread rodrigosiqueira
This patch fixes the checkpatch.pl warning:

drivers/staging/iio/meter/ade7854.h:157: WARNING: function definition
argument 'struct device *' should also have an identifier name...

Signed-off-by: Rodrigo Siqueira 
---
 drivers/staging/iio/meter/ade7854.h | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7854.h 
b/drivers/staging/iio/meter/ade7854.h
index c27247a7891a..2362a4a51ce3 100644
--- a/drivers/staging/iio/meter/ade7854.h
+++ b/drivers/staging/iio/meter/ade7854.h
@@ -152,20 +152,20 @@
  * @rx:receive buffer
  **/
 struct ade7854_state {
-   struct spi_device   *spi;
-   struct i2c_client   *i2c;
-   int (*read_reg_8)(struct device *, u16, u8 *);
-   int (*read_reg_16)(struct device *, u16, u16 *);
-   int (*read_reg_24)(struct device *, u16, u32 *);
-   int (*read_reg_32)(struct device *, u16, u32 *);
-   int (*write_reg_8)(struct device *, u16, u8);
-   int (*write_reg_16)(struct device *, u16, u16);
-   int (*write_reg_24)(struct device *, u16, u32);
-   int (*write_reg_32)(struct device *, u16, u32);
-   int irq;
-   struct mutexbuf_lock;
-   u8  tx[ADE7854_MAX_TX] cacheline_aligned;
-   u8  rx[ADE7854_MAX_RX];
+   struct spi_device *spi;
+   struct i2c_client *i2c;
+   int (*read_reg_8)(struct device *dev, u16 reg_address, u8 *val);
+   int (*read_reg_16)(struct device *dev, u16 reg_address, u16 *val);
+   int (*read_reg_24)(struct device *dev, u16 reg_address, u32 *val);
+   int (*read_reg_32)(struct device *dev, u16 reg_address, u32 *val);
+   int (*write_reg_8)(struct device *dev, u16 reg_address, u8 value);
+   int (*write_reg_16)(struct device *dev, u16 reg_address, u16 value);
+   int (*write_reg_24)(struct device *dev, u16 reg_address, u32 value);
+   int (*write_reg_32)(struct device *dev, u16 reg_address, u32 value);
+   int irq;
+   struct mutex buf_lock;
+   u8 tx[ADE7854_MAX_TX] cacheline_aligned;
+   u8 rx[ADE7854_MAX_RX];
 
 };
 
-- 
2.16.1

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


Re: [PATCH] staging: android: ion: Change dma_buf_kmap()/dma_buf_kmap_atomic() implementation

2018-02-16 Thread Alexey Skidanov


On 02/16/2018 01:48 AM, Laura Abbott wrote:
> On 02/12/2018 02:33 PM, Alexey Skidanov wrote:
>> Current ion kernel mapping implementation uses vmap() to map previously
>> allocated buffers into kernel virtual address space.
>>
>> On 32-bit platforms, vmap() might fail on large enough buffers due to the
>> limited available vmalloc space. dma_buf_kmap() should guarantee that
>> only one page is mapped at a time.
>>
>> To fix this, kmap()/kmap_atomic() is used to implement the appropriate
>> interfaces.
>>
>> Signed-off-by: Alexey Skidanov 
>> ---
>>   drivers/staging/android/ion/ion.c | 97
>> +++
>>   drivers/staging/android/ion/ion.h |  1 -
>>   2 files changed, 48 insertions(+), 50 deletions(-)
>>
>> diff --git a/drivers/staging/android/ion/ion.c
>> b/drivers/staging/android/ion/ion.c
>> index 57e0d80..75830e3 100644
>> --- a/drivers/staging/android/ion/ion.c
>> +++ b/drivers/staging/android/ion/ion.c
>> @@ -27,6 +27,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>     #include "ion.h"
>>   @@ -119,8 +120,6 @@ static struct ion_buffer
>> *ion_buffer_create(struct ion_heap *heap,
>>     void ion_buffer_destroy(struct ion_buffer *buffer)
>>   {
>> -    if (WARN_ON(buffer->kmap_cnt > 0))
>> -    buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
>>   buffer->heap->ops->free(buffer);
>>   kfree(buffer);
>>   }
>> @@ -140,34 +139,6 @@ static void _ion_buffer_destroy(struct ion_buffer
>> *buffer)
>>   ion_buffer_destroy(buffer);
>>   }
>>   -static void *ion_buffer_kmap_get(struct ion_buffer *buffer)
>> -{
>> -    void *vaddr;
>> -
>> -    if (buffer->kmap_cnt) {
>> -    buffer->kmap_cnt++;
>> -    return buffer->vaddr;
>> -    }
>> -    vaddr = buffer->heap->ops->map_kernel(buffer->heap, buffer);
>> -    if (WARN_ONCE(!vaddr,
>> -  "heap->ops->map_kernel should return ERR_PTR on error"))
>> -    return ERR_PTR(-EINVAL);
>> -    if (IS_ERR(vaddr))
>> -    return vaddr;
>> -    buffer->vaddr = vaddr;
>> -    buffer->kmap_cnt++;
>> -    return vaddr;
>> -}
>> -
>> -static void ion_buffer_kmap_put(struct ion_buffer *buffer)
>> -{
>> -    buffer->kmap_cnt--;
>> -    if (!buffer->kmap_cnt) {
>> -    buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
>> -    buffer->vaddr = NULL;
>> -    }
>> -}
>> -
>>   static struct sg_table *dup_sg_table(struct sg_table *table)
>>   {
>>   struct sg_table *new_table;
>> @@ -305,34 +276,68 @@ static void ion_dma_buf_release(struct dma_buf
>> *dmabuf)
>>   _ion_buffer_destroy(buffer);
>>   }
>>   +static inline int sg_page_count(struct scatterlist *sg)
>> +{
>> +    return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT;
>> +}
>> +
>> +static struct page *ion_dma_buf_get_page(struct sg_table *sg_table,
>> + unsigned long offset)
>> +{
>> +    struct page *page;
>> +    struct scatterlist *sg;
>> +    int i;
>> +    unsigned int nr_pages;
>> +
>> +    nr_pages = 0;
>> +    page = NULL;
>> +    /* Find the page with specified offset */
>> +    for_each_sg(sg_table->sgl, sg, sg_table->nents, i) {
>> +    if (nr_pages + sg_page_count(sg) > offset) {
>> +    page = nth_page(sg_page(sg), offset - nr_pages);
>> +    break;
>> +    }
>> +
>> +    nr_pages += sg_page_count(sg);
>> +    }
>> +
>> +    return page;
>> +}
>>   static void *ion_dma_buf_kmap(struct dma_buf *dmabuf, unsigned long
>> offset)
>>   {
>>   struct ion_buffer *buffer = dmabuf->priv;
>>   -    return buffer->vaddr + offset * PAGE_SIZE;
>> +    return kmap(ion_dma_buf_get_page(buffer->sg_table, offset));
>>   }
> 
> This unfortunately doesn't work for uncached buffers. We need to create
> an uncached alias otherwise we break what little coherency that guarantees.
> I'm still convinced that we can't actually do the uncached buffers
> correctly and they should be removed...
> 
> Thanks,
> Laura
> 
I assume that your concern is possible cache coherency issue as result
of the memory access with the different cache attributes. Especially, if
these accesses are from different context.

But dma-buf requires that the cpu access should be started with
dma_buf_start_cpu_access() and ended with dma_buf_end_cpu_access() (and
with appropriate ioctl calls from the user space) to ensure that there
is no IO coherency issues. That is, the appropriate cache lines are
invalidated before the access and are flushed after the access (in case
of read/write access).

So, it seems, that in the end of each CPU access, the most update copy
of the buffer is in the RAM.

Probably, I'm wrong but I don't see the issue.

>>     static void ion_dma_buf_kunmap(struct dma_buf *dmabuf, unsigned
>> long offset,
>>  void *ptr)
>>   {
>> +    kunmap(ptr);
>> +}
>> +
>> +static void *ion_dma_buf_kmap_atomic(struct dma_buf *dmabuf,
>> + unsigned long offset)
>> +{
>> +    struct ion_buffer *buffer = dmabuf->priv;
>> 

RE: [PATCH] Staging: nvec: fix line should not end with a open parenthesis.

2018-02-16 Thread David Laight
From: Yash Omer
> Sent: 16 February 2018 11:37
> This patch fix line should not end with open parenthesis found by 
> checkpatch.plscript.
> 
> Signed-off-by: Yash Omer 
> ---
>  drivers/staging/nvec/nvec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 52054a528723..39fb737543b5 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct *work)
>   msg = list_first_entry(>tx_data, struct nvec_msg, node);
>   spin_unlock_irqrestore(>tx_lock, flags);
>   nvec_gpio_set_value(nvec, 0);
> - err = wait_for_completion_interruptible_timeout(
> - >ec_transfer, msecs_to_jiffies(5000));
> + err = wait_for_completion_interruptible_timeout
> + (>ec_transfer, msecs_to_jiffies(5000));

Ugg...
Isn't the correct fix to reduce the length of the function name?

David

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


[PATCH] Staging: nvec: fix line should not end with a open parenthesis.

2018-02-16 Thread Yash Omer
This patch fix line should not end with open parenthesis found by 
checkpatch.plscript.

Signed-off-by: Yash Omer 
---
 drivers/staging/nvec/nvec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 52054a528723..39fb737543b5 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -383,8 +383,8 @@ static void nvec_request_master(struct work_struct *work)
msg = list_first_entry(>tx_data, struct nvec_msg, node);
spin_unlock_irqrestore(>tx_lock, flags);
nvec_gpio_set_value(nvec, 0);
-   err = wait_for_completion_interruptible_timeout(
-   >ec_transfer, msecs_to_jiffies(5000));
+   err = wait_for_completion_interruptible_timeout
+   (>ec_transfer, msecs_to_jiffies(5000));
 
if (err == 0) {
dev_warn(nvec->dev, "timeout waiting for ec 
transfer\n");
-- 
2.14.3

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


Re: [PATCH] comedi: fix comedi_nsamples_left.

2018-02-16 Thread Ian Abbott

On 15/02/18 20:13, Frank Mori Hess wrote:

A rounding error was causing comedi_nsamples_left to
return the wrong value when nsamples was not a multiple
of the scan length.

Cc:  # v4.4+
Signed-off-by: Frank Mori Hess 
---
  drivers/staging/comedi/drivers.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 0b43db6371c6..c11c22bd6d13 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -484,8 +484,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice 
*s,
struct comedi_cmd *cmd = >cmd;
  
  	if (cmd->stop_src == TRIG_COUNT) {

-   unsigned int nscans = nsamples / cmd->scan_end_arg;
-   unsigned int scans_left = __comedi_nscans_left(s, nscans);
+   unsigned int scans_left = __comedi_nscans_left(s, 
cmd->stop_arg);
unsigned int scan_pos =
comedi_bytes_to_samples(s, async->scan_progress);
unsigned long long samples_left = 0;



I think Hartley's original implementation of comedi_nsamples_left() in 
commit f615915ee5fa ("staging: comedi: drivers: introduce 
comedi_nsamples_left()") may have also avoided the problem by adding 1 
to nscans:


/* +1 to force comedi_nscans_left() to return the scans left */
unsigned int nscans = (nsamples / cmd->scan_end_arg) + 1;

except for an extreme case I attempted to fix in commit 92d354cbe95f 
("staging: comedi: fix extreme case of comedi_nsamples_left()") where I 
removed the "+ 1" amongst other changes.  So I may have broke it.


Your fix should work though.  Thanks!

Reviewed-by: Ian Abbott 

--
-=( 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] ANDROID: binder: synchronize_rcu() when using POLLFREE.

2018-02-16 Thread Martijn Coenen
Greg,

This is for 4.14 LTS and 4.16.

Thanks,
Martijn

On Fri, Feb 16, 2018 at 9:47 AM, Martijn Coenen  wrote:
> To prevent races with ep_remove_waitqueue() removing the
> waitqueue at the same time.
>
> Reported-by: syzbot+a2a3c4909716e2714...@syzkaller.appspotmail.com
> Signed-off-by: Martijn Coenen 
> ---
>  drivers/android/binder.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 15e3d3c2260d..359220f87e1d 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -4376,6 +4376,15 @@ static int binder_thread_release(struct binder_proc 
> *proc,
>
> binder_inner_proc_unlock(thread->proc);
>
> +   /*
> +* This is needed to avoid races between wake_up_poll() above and
> +* and ep_remove_waitqueue() called for other reasons (eg the epoll 
> file
> +* descriptor being closed); ep_remove_waitqueue() holds an RCU read
> +* lock, so we can be sure it's done after calling synchronize_rcu().
> +*/
> +   if (thread->looper & BINDER_LOOPER_STATE_POLL)
> +   synchronize_rcu();
> +
> if (send_reply)
> binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
> binder_release_work(proc, >todo);
> --
> 2.16.1.291.g4437f3f132-goog
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] ANDROID: binder: synchronize_rcu() when using POLLFREE.

2018-02-16 Thread Martijn Coenen
To prevent races with ep_remove_waitqueue() removing the
waitqueue at the same time.

Reported-by: syzbot+a2a3c4909716e2714...@syzkaller.appspotmail.com
Signed-off-by: Martijn Coenen 
---
 drivers/android/binder.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 15e3d3c2260d..359220f87e1d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4376,6 +4376,15 @@ static int binder_thread_release(struct binder_proc 
*proc,
 
binder_inner_proc_unlock(thread->proc);
 
+   /*
+* This is needed to avoid races between wake_up_poll() above and
+* and ep_remove_waitqueue() called for other reasons (eg the epoll file
+* descriptor being closed); ep_remove_waitqueue() holds an RCU read
+* lock, so we can be sure it's done after calling synchronize_rcu().
+*/
+   if (thread->looper & BINDER_LOOPER_STATE_POLL)
+   synchronize_rcu();
+
if (send_reply)
binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
binder_release_work(proc, >todo);
-- 
2.16.1.291.g4437f3f132-goog

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