Skip to contentSkip to conversation

staging: octeon: fix line over 80 characters

PATCH Superseded [email protected] 3 participants 3 messages Jul 25, 2017 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: octeon: fix line over 80 characters

From: John Smith <[email protected]>

ethernet-rx.c:

fix WARNING: line over 80 characters

---
 drivers/staging/octeon/ethernet-rx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/octeon/ethernet-rx.c +2 -1
index 72baede..623c5e0 100644
@@ -323,7 +323,8 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 						segment_size = len;
 					/* Copy the data into the packet */
 					skb_put_data(skb,
-						     cvmx_phys_to_ptr(segment_ptr.s.addr),
+						     cvmx_phys_to_ptr(
+						     segment_ptr.s.addr),
 						     segment_size);
 					len -= segment_size;
 					segment_ptr = next_ptr;

--
2.7.4

#1 lore raw
Quoted 5 lines · On Tue, 2017-07-25 at 16:01 +0300, [email protected] wrote:

From: John Smith <[email protected]>

ethernet-rx.c:

fix WARNING: line over 80 characters

Instead of just shutting up checkpatch, how about restructuring the code a bit by adding a helper function to this very long cvm_oct_poll?

drivers/staging/octeon/ethernet-rx.c

Quoted 1 line
drivers/staging/octeon/ethernet-rx.c +0 -0

[]

drivers/staging/octeon/ethernet-rx.c static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget) · line 330

Quoted 10 lines
drivers/staging/octeon/ethernet-rx.c +2 -1
@@ -323,7 +323,8 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 						segment_size = len;
 					/* Copy the data into the packet */
 					skb_put_data(skb,
-						     cvmx_phys_to_ptr(segment_ptr.s.addr),
+						     cvmx_phys_to_ptr(
+						     segment_ptr.s.addr),
 						     segment_size);
 					len -= segment_size;
 					segment_ptr = next_ptr;

Something like (uncompiled, untested)
---
 drivers/staging/octeon/ethernet-rx.c | 78 ++++++++++++++++++------------------

 1 file changed, 40 insertions(+), 38 deletions(-)
drivers/staging/octeon/ethernet-rx.c +0 -0
index 72baedefa0f1..7315c8150dcb 100644
@@ -149,6 +149,45 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)

  return 0;
 }

+static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb) +{
+ int segments = work->word2.s.bufs;
+ union cvmx_buf_ptr segment_ptr = work->packet_ptr;
+ int len = work->word1.len;
+
+ while (segments--) {
+ union cvmx_buf_ptr next_ptr;
+
+ next_ptr = *(union cvmx_buf_ptr *)
+ cvmx_phys_to_ptr(segment_ptr.s.addr - 8);
+
+ /*
+  * Octeon Errata PKI-100: The segment size is wrong.
+  *
+  * Until it is fixed, calculate the segment size based on
+  * the packet pool buffer size.
+  * When it is fixed, the following line should be replaced
+  * with this one:
+  * int segment_size = segment_ptr.s.size;
+  */
+ int segment_size =
+ CVMX_FPA_PACKET_POOL_SIZE -
+ (segment_ptr.s.addr -
+  (((segment_ptr.s.addr >> 7) -
+    segment_ptr.s.back) << 7));
+
+ /* Don't copy more than what is left in the packet */
+ if (segment_size > len)
+ segment_size = len;
+
+ /* Copy the data into the packet */
+ skb_put_data(skb, cvmx_phys_to_ptr(segment_ptr.s.addr),
+      segment_size);
+ len -= segment_size;
+ segment_ptr = next_ptr;
+ }
+}
+
 static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 {
  const int coreid = cvmx_get_core_num();
@@ -290,44 +329,7 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget) skb_put_data(skb, ptr, work->word1.len); /* No packet buffers to free */
  } else {
- int segments = work->word2.s.bufs;
- union cvmx_buf_ptr segment_ptr =
-     work->packet_ptr;
- int len = work->word1.len;
-
- while (segments--) {
- union cvmx_buf_ptr next_ptr =
-     *(union cvmx_buf_ptr *)
-       cvmx_phys_to_ptr(
-       segment_ptr.s.addr - 8);
-
- /*
-  * Octeon Errata PKI-100: The segment size is
-  * wrong. Until it is fixed, calculate the
-  * segment size based on the packet pool
-  * buffer size. When it is fixed, the
-  * following line should be replaced with this
-  * one: int segment_size =
-  * segment_ptr.s.size;
-  */
- int segment_size =
-     CVMX_FPA_PACKET_POOL_SIZE -
-     (segment_ptr.s.addr -
-      (((segment_ptr.s.addr >> 7) -
-        segment_ptr.s.back) << 7));
- /*
-  * Don't copy more than what
-  * is left in the packet.
-  */
- if (segment_size > len)
- segment_size = len;
- /* Copy the data into the packet */
- skb_put_data(skb,
-      cvmx_phys_to_ptr(segment_ptr.s.addr),
-      segment_size);
- len -= segment_size;
- segment_ptr = next_ptr;
- }
+ copy_segments_to_skb(work, skb);
  }
  packet_not_copied = 0;
  }

#2 lore raw
In reply to [email protected]
Quoted 16 lines · On Tue, Jul 25, 2017 at 04:01:57PM +0300, [email protected] wrote:

From: John Smith <[email protected]>

ethernet-rx.c:

fix WARNING: line over 80 characters

---
 drivers/staging/octeon/ethernet-rx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/octeon/ethernet-rx.c +0 -0
index 72baede..623c5e0 100644

drivers/staging/octeon/ethernet-rx.c static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget) · line 327

Quoted 6 lines
drivers/staging/octeon/ethernet-rx.c +2 -1
@@ -323,7 +323,8 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 						segment_size = len;
 					/* Copy the data into the packet */
 					skb_put_data(skb,
-						     cvmx_phys_to_ptr(segment_ptr.s.addr),
+						     cvmx_phys_to_ptr(
+						     segment_ptr.s.addr),

The original looks better.

regards,
dan carpenter