All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Fix coding style in en50221 CAM functions
@ 2017-05-07 21:23 Jasmin J.
  2017-05-07 21:23 ` [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_?? Jasmin J.
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

These patch series is a follow up to the series "Add block read/write to
en50221 CAM functions". It fixed nearly all the style issues reported by
checkpatch.pl in dvb-core/dvb_ca_en50221.c
Please note, that there are 7 Warnings left, which I won't fix.

Two of them are "WARNING: memory barrier without comment". I have really
no clue why there is a call to "mb()" in that file, so I can't fill in a
good comment.

Four warnings are "WARNING: line over 80 characters" which are strings for
debugging, which shouldn't be split in several lines (will give other
warning).

And finally one "WARNING: Prefer [subsystem eg: netdev]_dbg", complaining
about the "dprintk" macro. In my opinion it is correctly used and it is
normally disabled anyway.

The main problem of the original code was the size of the lines and the
structural complexity of some functions. Beside shortening the names and
refactoring of the thread state machine, I used in nearly every function
a helper pointer "sl" (for "slot" structure) instead the whole structure
path. This saved also a lot of characters in long lines.

I split the patch set is small pieces for easier review, compiled each
step and tested the resulting driver on my hardware with the DD DuoFlex CI
(single) card.


Jasmin Jessich (11):
  [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  [media] dvb-core/dvb_ca_en50221.c: Rename DVB_CA_SLOTSTATE_???
  [media] dvb-core/dvb_ca_en50221.c: Used a helper variable
  [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 1
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 2
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 3
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 4
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 5
  [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 6
  [media] dvb-core/dvb_ca_en50221.c: Fixed wrong EXPORT_SYMBOL order

 drivers/media/dvb-core/dvb_ca_en50221.c | 916 ++++++++++++++++++--------------
 1 file changed, 527 insertions(+), 389 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-08  9:55   ` Mauro Carvalho Chehab
  2017-05-07 21:23 ` [PATCH 02/11] [media] dvb-core/dvb_ca_en50221.c: Rename DVB_CA_SLOTSTATE_??? Jasmin J.
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Rename STATUSREG_?? -> STATREG_?? to reduce the line length.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 34 ++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index cc709c9..b978246 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -72,11 +72,11 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
 #define CMDREG_DAIE   0x80	/* Enable DA interrupt */
 #define IRQEN (CMDREG_DAIE)
 
-#define STATUSREG_RE     1	/* read error */
-#define STATUSREG_WE     2	/* write error */
-#define STATUSREG_FR  0x40	/* module free */
-#define STATUSREG_DA  0x80	/* data available */
-#define STATUSREG_TXERR (STATUSREG_RE|STATUSREG_WE)	/* general transfer error */
+#define STATREG_RE     1	/* read error */
+#define STATREG_WE     2	/* write error */
+#define STATREG_FR  0x40	/* module free */
+#define STATREG_DA  0x80	/* data available */
+#define STATREG_TXERR (STATREG_RE|STATREG_WE)	/* general transfer error */
 
 
 #define DVB_CA_SLOTSTATE_NONE           0
@@ -347,7 +347,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	/* read the buffer size from the CAM */
 	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ)) != 0)
+	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_DA, HZ)) != 0)
 		return ret;
 	if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
 		return -EIO;
@@ -366,7 +366,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	/* write the buffer size to the CAM */
 	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0)
+	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_FR, HZ / 10)) != 0)
 		return ret;
 	if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
 		return -EIO;
@@ -661,7 +661,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 		/* check if there is data available */
 		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 			goto exit;
-		if (!(status & STATUSREG_DA)) {
+		if (!(status & STATREG_DA)) {
 			/* no data */
 			status = 0;
 			goto exit;
@@ -713,7 +713,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 		/* check for read error (RE should now be 0) */
 		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 			goto exit;
-		if (status & STATUSREG_RE) {
+		if (status & STATREG_RE) {
 			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
 			status = -EIO;
 			goto exit;
@@ -778,8 +778,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	   process the data if necessary. */
 	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 		goto exitnowrite;
-	if (status & (STATUSREG_DA | STATUSREG_RE)) {
-		if (status & STATUSREG_DA)
+	if (status & (STATREG_DA | STATREG_RE)) {
+		if (status & STATREG_DA)
 			dvb_ca_en50221_thread_wakeup(ca);
 
 		status = -EAGAIN;
@@ -794,7 +794,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	/* check if interface is still free */
 	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 		goto exit;
-	if (!(status & STATUSREG_FR)) {
+	if (!(status & STATREG_FR)) {
 		/* it wasn't free => try again later */
 		status = -EAGAIN;
 		goto exit;
@@ -815,8 +815,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	if (status < 0)
 		goto exit;
 
-	if (status & (STATUSREG_DA | STATUSREG_RE)) {
-		if (status & STATUSREG_DA)
+	if (status & (STATREG_DA | STATREG_RE)) {
+		if (status & STATREG_DA)
 			dvb_ca_en50221_thread_wakeup(ca);
 
 		status = -EAGAIN;
@@ -839,7 +839,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	/* check for write error (WE should now be 0) */
 	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 		goto exit;
-	if (status & STATUSREG_WE) {
+	if (status & STATREG_WE) {
 		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
 		status = -EIO;
 		goto exit;
@@ -952,7 +952,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 	switch (ca->slot_info[slot].slot_state) {
 	case DVB_CA_SLOTSTATE_LINKINIT:
 		flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
-		if (flags & STATUSREG_DA) {
+		if (flags & STATREG_DA) {
 			dprintk("CAM supports DA IRQ\n");
 			ca->slot_info[slot].da_irq_supported = 1;
 		}
@@ -1166,7 +1166,7 @@ static int dvb_ca_en50221_thread(void *data)
 				}
 
 				flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
-				if (flags & STATUSREG_FR) {
+				if (flags & STATREG_FR) {
 					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
 					ca->wakeup = 1;
 				}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/11] [media] dvb-core/dvb_ca_en50221.c: Rename DVB_CA_SLOTSTATE_???
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
  2017-05-07 21:23 ` [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_?? Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 03/11] [media] dvb-core/dvb_ca_en50221.c: Used a helper variable Jasmin J.
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Rename DVB_CA_SLOTSTATE_??? -> SLOT_STAT_??? to reduce the line length.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 124 ++++++++++++++++----------------
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index b978246..750989c 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -79,14 +79,14 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
 #define STATREG_TXERR (STATREG_RE|STATREG_WE)	/* general transfer error */
 
 
-#define DVB_CA_SLOTSTATE_NONE           0
-#define DVB_CA_SLOTSTATE_UNINITIALISED  1
-#define DVB_CA_SLOTSTATE_RUNNING        2
-#define DVB_CA_SLOTSTATE_INVALID        3
-#define DVB_CA_SLOTSTATE_WAITREADY      4
-#define DVB_CA_SLOTSTATE_VALIDATE       5
-#define DVB_CA_SLOTSTATE_WAITFR         6
-#define DVB_CA_SLOTSTATE_LINKINIT       7
+#define SLOT_STAT_NONE       0
+#define SLOT_STAT_UNINIT     1
+#define SLOT_STAT_RUNNING    2
+#define SLOT_STAT_INVALID    3
+#define SLOT_STAT_WAITREADY  4
+#define SLOT_STAT_VALIDATE   5
+#define SLOT_STAT_WAITFR     6
+#define SLOT_STAT_LINKINIT   7
 
 
 /* Information on a CA slot */
@@ -247,7 +247,7 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
 	cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
 	if (!cam_changed) {
-		int cam_present_old = (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE);
+		int cam_present_old = (ca->slot_info[slot].slot_state != SLOT_STAT_NONE);
 		cam_changed = (cam_present_now != cam_present_old);
 	}
 
@@ -259,10 +259,10 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 		}
 		atomic_set(&ca->slot_info[slot].camchange_count, 1);
 	} else {
-		if ((ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) &&
+		if ((ca->slot_info[slot].slot_state == SLOT_STAT_WAITREADY) &&
 		    (slot_status & DVB_CA_EN50221_POLL_CAM_READY)) {
 			// move to validate state if reset is completed
-			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE;
+			ca->slot_info[slot].slot_state = SLOT_STAT_VALIDATE;
 		}
 	}
 
@@ -646,7 +646,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 		}
 	}
 
-	if (ca->pub->read_data && (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT)) {
+	if (ca->pub->read_data && (ca->slot_info[slot].slot_state != SLOT_STAT_LINKINIT)) {
 		if (ebuf == NULL)
 			status = ca->pub->read_data(ca->pub, slot, buf, sizeof(buf));
 		else
@@ -680,14 +680,14 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 			if (bytes_read > ca->slot_info[slot].link_buf_size) {
 				pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
 				       ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size);
-				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
+				ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
 				status = -EIO;
 				goto exit;
 			}
 			if (bytes_read < 2) {
 				pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
 				       ca->dvbdev->adapter->num);
-				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
+				ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
 				status = -EIO;
 				goto exit;
 			}
@@ -714,7 +714,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 			goto exit;
 		if (status & STATREG_RE) {
-			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
+			ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
 			status = -EIO;
 			goto exit;
 		}
@@ -769,7 +769,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	if (bytes_write > ca->slot_info[slot].link_buf_size)
 		return -EINVAL;
 
-	if (ca->pub->write_data && (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT))
+	if (ca->pub->write_data && (ca->slot_info[slot].slot_state != SLOT_STAT_LINKINIT))
 		return ca->pub->write_data(ca->pub, slot, buf, bytes_write);
 
 	/* it is possible we are dealing with a single buffer implementation,
@@ -840,7 +840,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 		goto exit;
 	if (status & STATREG_WE) {
-		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
+		ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
 		status = -EIO;
 		goto exit;
 	}
@@ -874,7 +874,7 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
 	dprintk("%s\n", __func__);
 
 	ca->pub->slot_shutdown(ca->pub, slot);
-	ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
+	ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
 
 	/* need to wake up all processes to check if they're now
 	   trying to write to a defunct CAM */
@@ -929,8 +929,8 @@ void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
 
 	dprintk("CAMREADY IRQ slot:%i\n", slot);
 
-	if (ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) {
-		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE;
+	if (ca->slot_info[slot].slot_state == SLOT_STAT_WAITREADY) {
+		ca->slot_info[slot].slot_state = SLOT_STAT_VALIDATE;
 		dvb_ca_en50221_thread_wakeup(ca);
 	}
 }
@@ -950,7 +950,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 	dprintk("FR/DA IRQ slot:%i\n", slot);
 
 	switch (ca->slot_info[slot].slot_state) {
-	case DVB_CA_SLOTSTATE_LINKINIT:
+	case SLOT_STAT_LINKINIT:
 		flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
 		if (flags & STATREG_DA) {
 			dprintk("CAM supports DA IRQ\n");
@@ -958,7 +958,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 		}
 		break;
 
-	case DVB_CA_SLOTSTATE_RUNNING:
+	case SLOT_STAT_RUNNING:
 		if (ca->open)
 			dvb_ca_en50221_thread_wakeup(ca);
 		break;
@@ -1002,26 +1002,26 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
 	for (slot = 0; slot < ca->slot_count; slot++) {
 		switch (ca->slot_info[slot].slot_state) {
 		default:
-		case DVB_CA_SLOTSTATE_NONE:
+		case SLOT_STAT_NONE:
 			delay = HZ * 60;  /* 60s */
 			if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
 				delay = HZ * 5;  /* 5s */
 			break;
-		case DVB_CA_SLOTSTATE_INVALID:
+		case SLOT_STAT_INVALID:
 			delay = HZ * 60;  /* 60s */
 			if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
 				delay = HZ / 10;  /* 100ms */
 			break;
 
-		case DVB_CA_SLOTSTATE_UNINITIALISED:
-		case DVB_CA_SLOTSTATE_WAITREADY:
-		case DVB_CA_SLOTSTATE_VALIDATE:
-		case DVB_CA_SLOTSTATE_WAITFR:
-		case DVB_CA_SLOTSTATE_LINKINIT:
+		case SLOT_STAT_UNINIT:
+		case SLOT_STAT_WAITREADY:
+		case SLOT_STAT_VALIDATE:
+		case SLOT_STAT_WAITFR:
+		case SLOT_STAT_LINKINIT:
 			delay = HZ / 10;  /* 100ms */
 			break;
 
-		case DVB_CA_SLOTSTATE_RUNNING:
+		case SLOT_STAT_RUNNING:
 			delay = HZ * 60;  /* 60s */
 			if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
 				delay = HZ / 10;  /* 100ms */
@@ -1078,12 +1078,12 @@ static int dvb_ca_en50221_thread(void *data)
 			// check the cam status + deal with CAMCHANGEs
 			while (dvb_ca_en50221_check_camstatus(ca, slot)) {
 				/* clear down an old CI slot if necessary */
-				if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE)
+				if (ca->slot_info[slot].slot_state != SLOT_STAT_NONE)
 					dvb_ca_en50221_slot_shutdown(ca, slot);
 
 				/* if a CAM is NOW present, initialise it */
 				if (ca->slot_info[slot].camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_UNINITIALISED;
+					ca->slot_info[slot].slot_state = SLOT_STAT_UNINIT;
 				}
 
 				/* we've handled one CAMCHANGE */
@@ -1093,36 +1093,36 @@ static int dvb_ca_en50221_thread(void *data)
 
 			// CAM state machine
 			switch (ca->slot_info[slot].slot_state) {
-			case DVB_CA_SLOTSTATE_NONE:
-			case DVB_CA_SLOTSTATE_INVALID:
+			case SLOT_STAT_NONE:
+			case SLOT_STAT_INVALID:
 				// no action needed
 				break;
 
-			case DVB_CA_SLOTSTATE_UNINITIALISED:
-				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITREADY;
+			case SLOT_STAT_UNINIT:
+				ca->slot_info[slot].slot_state = SLOT_STAT_WAITREADY;
 				ca->pub->slot_reset(ca->pub, slot);
 				ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
 				break;
 
-			case DVB_CA_SLOTSTATE_WAITREADY:
+			case SLOT_STAT_WAITREADY:
 				if (time_after(jiffies, ca->slot_info[slot].timeout)) {
 					pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 				// no other action needed; will automatically change state when ready
 				break;
 
-			case DVB_CA_SLOTSTATE_VALIDATE:
+			case SLOT_STAT_VALIDATE:
 				if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
 					/* we need this extra check for annoying interfaces like the budget-av */
 					if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
 					    (ca->pub->poll_slot_status)) {
 						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
 						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
+							ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
 							dvb_ca_en50221_thread_update_delay(ca);
 							break;
 						}
@@ -1130,14 +1130,14 @@ static int dvb_ca_en50221_thread(void *data)
 
 					pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 				if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
 					pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
@@ -1145,41 +1145,41 @@ static int dvb_ca_en50221_thread(void *data)
 							       CTRLIF_COMMAND, CMDREG_RS) != 0) {
 					pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 				dprintk("DVB CAM validated successfully\n");
 
 				ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
-				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITFR;
+				ca->slot_info[slot].slot_state = SLOT_STAT_WAITFR;
 				ca->wakeup = 1;
 				break;
 
-			case DVB_CA_SLOTSTATE_WAITFR:
+			case SLOT_STAT_WAITFR:
 				if (time_after(jiffies, ca->slot_info[slot].timeout)) {
 					pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 
 				flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
 				if (flags & STATREG_FR) {
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
+					ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
 					ca->wakeup = 1;
 				}
 				break;
 
-			case DVB_CA_SLOTSTATE_LINKINIT:
+			case SLOT_STAT_LINKINIT:
 				if (dvb_ca_en50221_link_init(ca, slot) != 0) {
 					/* we need this extra check for annoying interfaces like the budget-av */
 					if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
 					    (ca->pub->poll_slot_status)) {
 						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
 						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
+							ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
 							dvb_ca_en50221_thread_update_delay(ca);
 							break;
 						}
@@ -1187,7 +1187,7 @@ static int dvb_ca_en50221_thread(void *data)
 
 					pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_UNINITIALISED;
+					ca->slot_info[slot].slot_state = SLOT_STAT_UNINIT;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
@@ -1197,7 +1197,7 @@ static int dvb_ca_en50221_thread(void *data)
 					if (rxbuf == NULL) {
 						pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
 						       ca->dvbdev->adapter->num);
-						ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+						ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
 						dvb_ca_en50221_thread_update_delay(ca);
 						break;
 					}
@@ -1205,13 +1205,13 @@ static int dvb_ca_en50221_thread(void *data)
 				}
 
 				ca->pub->slot_ts_enable(ca->pub, slot);
-				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
+				ca->slot_info[slot].slot_state = SLOT_STAT_RUNNING;
 				dvb_ca_en50221_thread_update_delay(ca);
 				pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
 				       ca->dvbdev->adapter->num);
 				break;
 
-			case DVB_CA_SLOTSTATE_RUNNING:
+			case SLOT_STAT_RUNNING:
 				if (!ca->open)
 					break;
 
@@ -1278,7 +1278,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 	case CA_RESET:
 		for (slot = 0; slot < ca->slot_count; slot++) {
 			mutex_lock(&ca->slot_info[slot].slot_lock);
-			if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) {
+			if (ca->slot_info[slot].slot_state != SLOT_STAT_NONE) {
 				dvb_ca_en50221_slot_shutdown(ca, slot);
 				if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
 					dvb_ca_en50221_camchange_irq(ca->pub,
@@ -1311,11 +1311,11 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 
 		info->type = CA_CI_LINK;
 		info->flags = 0;
-		if ((ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_NONE)
-			&& (ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_INVALID)) {
+		if ((ca->slot_info[info->num].slot_state != SLOT_STAT_NONE)
+			&& (ca->slot_info[info->num].slot_state != SLOT_STAT_INVALID)) {
 			info->flags = CA_CI_MODULE_PRESENT;
 		}
-		if (ca->slot_info[info->num].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
+		if (ca->slot_info[info->num].slot_state == SLOT_STAT_RUNNING) {
 			info->flags |= CA_CI_MODULE_READY;
 		}
 		break;
@@ -1387,7 +1387,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 	count -= 2;
 
 	/* check if the slot is actually running */
-	if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
+	if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING)
 		return -EINVAL;
 
 	/* fragment the packets & store in the buffer */
@@ -1412,7 +1412,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 		written = 0;
 		while (!time_after(jiffies, timeout)) {
 			/* check the CAM hasn't been removed/reset in the meantime */
-			if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) {
+			if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING) {
 				status = -EIO;
 				goto exit;
 			}
@@ -1459,7 +1459,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
 
 	slot = ca->next_read_slot;
 	while ((slot_count < ca->slot_count) && (!found)) {
-		if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
+		if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING)
 			goto nextslot;
 
 		if (ca->slot_info[slot].rx_buffer.data == NULL) {
@@ -1622,7 +1622,7 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
 
 	for (i = 0; i < ca->slot_count; i++) {
 
-		if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
+		if (ca->slot_info[i].slot_state == SLOT_STAT_RUNNING) {
 			if (ca->slot_info[i].rx_buffer.data != NULL) {
 				/* it is safe to call this here without locks because
 				 * ca->open == 0. Data is not read in this case */
@@ -1784,7 +1784,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	/* now initialise each slot */
 	for (i = 0; i < slot_count; i++) {
 		memset(&ca->slot_info[i], 0, sizeof(struct dvb_ca_slot));
-		ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
+		ca->slot_info[i].slot_state = SLOT_STAT_NONE;
 		atomic_set(&ca->slot_info[i].camchange_count, 0);
 		ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
 		mutex_init(&ca->slot_info[i].slot_lock);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/11] [media] dvb-core/dvb_ca_en50221.c: Used a helper variable
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
  2017-05-07 21:23 ` [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_?? Jasmin J.
  2017-05-07 21:23 ` [PATCH 02/11] [media] dvb-core/dvb_ca_en50221.c: Rename DVB_CA_SLOTSTATE_??? Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread Jasmin J.
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Used a helper variable "struct dvb_ca_slot *sl" instead of
"ca->slot_info[slot]". This reduces the line lenght and simplifies
code reading.
Renamed "i" to "slot" in some functions to make the code more readable.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 221 ++++++++++++++++++--------------
 1 file changed, 123 insertions(+), 98 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 750989c..ba30bcf4 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -232,13 +232,14 @@ static char *findstr(char * haystack, int hlen, char * needle, int nlen)
  */
 static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 {
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int slot_status;
 	int cam_present_now;
 	int cam_changed;
 
 	/* IRQ mode */
 	if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) {
-		return (atomic_read(&ca->slot_info[slot].camchange_count) != 0);
+		return (atomic_read(&sl->camchange_count) != 0);
 	}
 
 	/* poll mode */
@@ -247,22 +248,22 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
 	cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
 	if (!cam_changed) {
-		int cam_present_old = (ca->slot_info[slot].slot_state != SLOT_STAT_NONE);
+		int cam_present_old = (sl->slot_state != SLOT_STAT_NONE);
 		cam_changed = (cam_present_now != cam_present_old);
 	}
 
 	if (cam_changed) {
 		if (!cam_present_now) {
-			ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
+			sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
 		} else {
-			ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED;
+			sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED;
 		}
-		atomic_set(&ca->slot_info[slot].camchange_count, 1);
+		atomic_set(&sl->camchange_count, 1);
 	} else {
-		if ((ca->slot_info[slot].slot_state == SLOT_STAT_WAITREADY) &&
+		if ((sl->slot_state == SLOT_STAT_WAITREADY) &&
 		    (slot_status & DVB_CA_EN50221_POLL_CAM_READY)) {
 			// move to validate state if reset is completed
-			ca->slot_info[slot].slot_state = SLOT_STAT_VALIDATE;
+			sl->slot_state = SLOT_STAT_VALIDATE;
 		}
 	}
 
@@ -331,6 +332,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
  */
 static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 {
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int ret;
 	int buf_size;
 	u8 buf[2];
@@ -338,11 +340,11 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	dprintk("%s\n", __func__);
 
 	/* we'll be determining these during this function */
-	ca->slot_info[slot].da_irq_supported = 0;
+	sl->da_irq_supported = 0;
 
 	/* set the host link buffer size temporarily. it will be overwritten with the
 	 * real negotiated size later. */
-	ca->slot_info[slot].link_buf_size = 2;
+	sl->link_buf_size = 2;
 
 	/* read the buffer size from the CAM */
 	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
@@ -358,7 +360,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	buf_size = (buf[0] << 8) | buf[1];
 	if (buf_size > HOST_LINK_BUF_SIZE)
 		buf_size = HOST_LINK_BUF_SIZE;
-	ca->slot_info[slot].link_buf_size = buf_size;
+	sl->link_buf_size = buf_size;
 	buf[0] = buf_size >> 8;
 	buf[1] = buf_size & 0xff;
 	dprintk("Chosen link buffer size of %i\n", buf_size);
@@ -441,6 +443,7 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
  */
 static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 {
+	struct dvb_ca_slot *sl;
 	int address = 0;
 	int tupleLength;
 	int tupleType;
@@ -508,9 +511,11 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 	rasz = tuple[0] & 3;
 	if (tupleLength < (3 + rasz + 14))
 		return -EINVAL;
-	ca->slot_info[slot].config_base = 0;
+
+	sl = &ca->slot_info[slot];
+	sl->config_base = 0;
 	for (i = 0; i < rasz + 1; i++) {
-		ca->slot_info[slot].config_base |= (tuple[2 + i] << (8 * i));
+		sl->config_base |= (tuple[2 + i] << (8 * i));
 	}
 
 	/* check it contains the correct DVB string */
@@ -543,7 +548,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 				break;
 
 			/* get the config option */
-			ca->slot_info[slot].config_option = tuple[0] & 0x3f;
+			sl->config_option = tuple[0] & 0x3f;
 
 			/* OK, check it contains the correct strings */
 			if ((findstr((char *)tuple, tupleLength, "DVB_HOST", 8) == NULL) ||
@@ -571,8 +576,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 		return -EINVAL;
 
 	dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n",
-		manfid, devid, ca->slot_info[slot].config_base,
-		ca->slot_info[slot].config_option);
+		manfid, devid, sl->config_base, sl->config_option);
 
 	// success!
 	return 0;
@@ -587,19 +591,20 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
  */
 static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
 {
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int configoption;
 
 	dprintk("%s\n", __func__);
 
 	/* set the config option */
-	ca->pub->write_attribute_mem(ca->pub, slot,
-				     ca->slot_info[slot].config_base,
-				     ca->slot_info[slot].config_option);
+	ca->pub->write_attribute_mem(ca->pub, slot, sl->config_base,
+				     sl->config_option);
 
 	/* check it */
-	configoption = ca->pub->read_attribute_mem(ca->pub, slot, ca->slot_info[slot].config_base);
+	configoption = ca->pub->read_attribute_mem(ca->pub, slot,
+						   sl->config_base);
 	dprintk("Set configoption 0x%x, read configoption 0x%x\n",
-		ca->slot_info[slot].config_option, configoption & 0x3f);
+		sl->config_option, configoption & 0x3f);
 
 	/* fine! */
 	return 0;
@@ -623,6 +628,7 @@ static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
  */
 static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount)
 {
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int bytes_read;
 	int status;
 	u8 buf[HOST_LINK_BUF_SIZE];
@@ -634,19 +640,19 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 	if (ebuf == NULL) {
 		int buf_free;
 
-		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+		if (sl->rx_buffer.data == NULL) {
 			status = -EIO;
 			goto exit;
 		}
-		buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
+		buf_free = dvb_ringbuffer_free(&sl->rx_buffer);
 
-		if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
+		if (buf_free < (sl->link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
 			status = -EAGAIN;
 			goto exit;
 		}
 	}
 
-	if (ca->pub->read_data && (ca->slot_info[slot].slot_state != SLOT_STAT_LINKINIT)) {
+	if (ca->pub->read_data && (sl->slot_state != SLOT_STAT_LINKINIT)) {
 		if (ebuf == NULL)
 			status = ca->pub->read_data(ca->pub, slot, buf, sizeof(buf));
 		else
@@ -677,17 +683,17 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 
 		/* check it will fit */
 		if (ebuf == NULL) {
-			if (bytes_read > ca->slot_info[slot].link_buf_size) {
+			if (bytes_read > sl->link_buf_size) {
 				pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
-				       ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size);
-				ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
+				       ca->dvbdev->adapter->num, bytes_read, sl->link_buf_size);
+				sl->slot_state = SLOT_STAT_LINKINIT;
 				status = -EIO;
 				goto exit;
 			}
 			if (bytes_read < 2) {
 				pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
 				       ca->dvbdev->adapter->num);
-				ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
+				sl->slot_state = SLOT_STAT_LINKINIT;
 				status = -EIO;
 				goto exit;
 			}
@@ -714,7 +720,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 			goto exit;
 		if (status & STATREG_RE) {
-			ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
+			sl->slot_state = SLOT_STAT_LINKINIT;
 			status = -EIO;
 			goto exit;
 		}
@@ -722,11 +728,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
 
 	/* OK, add it to the receive buffer, or copy into external buffer if supplied */
 	if (ebuf == NULL) {
-		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+		if (sl->rx_buffer.data == NULL) {
 			status = -EIO;
 			goto exit;
 		}
-		dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
+		dvb_ringbuffer_pkt_write(&sl->rx_buffer, buf, bytes_read);
 	} else {
 		memcpy(ebuf, buf, bytes_read);
 	}
@@ -759,6 +765,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
  */
 static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * buf, int bytes_write)
 {
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int status;
 	int i;
 
@@ -766,10 +773,10 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 
 
 	/* sanity check */
-	if (bytes_write > ca->slot_info[slot].link_buf_size)
+	if (bytes_write > sl->link_buf_size)
 		return -EINVAL;
 
-	if (ca->pub->write_data && (ca->slot_info[slot].slot_state != SLOT_STAT_LINKINIT))
+	if (ca->pub->write_data && (sl->slot_state != SLOT_STAT_LINKINIT))
 		return ca->pub->write_data(ca->pub, slot, buf, bytes_write);
 
 	/* it is possible we are dealing with a single buffer implementation,
@@ -840,7 +847,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
 	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
 		goto exit;
 	if (status & STATREG_WE) {
-		ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
+		sl->slot_state = SLOT_STAT_LINKINIT;
 		status = -EIO;
 		goto exit;
 	}
@@ -898,6 +905,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
 void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type)
 {
 	struct dvb_ca_private *ca = pubca->private;
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 
 	dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type);
 
@@ -910,8 +918,8 @@ void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int ch
 		return;
 	}
 
-	ca->slot_info[slot].camchange_type = change_type;
-	atomic_inc(&ca->slot_info[slot].camchange_count);
+	sl->camchange_type = change_type;
+	atomic_inc(&sl->camchange_count);
 	dvb_ca_en50221_thread_wakeup(ca);
 }
 EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
@@ -926,11 +934,12 @@ EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
 void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
 {
 	struct dvb_ca_private *ca = pubca->private;
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 
 	dprintk("CAMREADY IRQ slot:%i\n", slot);
 
-	if (ca->slot_info[slot].slot_state == SLOT_STAT_WAITREADY) {
-		ca->slot_info[slot].slot_state = SLOT_STAT_VALIDATE;
+	if (sl->slot_state == SLOT_STAT_WAITREADY) {
+		sl->slot_state = SLOT_STAT_VALIDATE;
 		dvb_ca_en50221_thread_wakeup(ca);
 	}
 }
@@ -945,16 +954,17 @@ void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
 void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 {
 	struct dvb_ca_private *ca = pubca->private;
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int flags;
 
 	dprintk("FR/DA IRQ slot:%i\n", slot);
 
-	switch (ca->slot_info[slot].slot_state) {
+	switch (sl->slot_state) {
 	case SLOT_STAT_LINKINIT:
 		flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
 		if (flags & STATREG_DA) {
 			dprintk("CAM supports DA IRQ\n");
-			ca->slot_info[slot].da_irq_supported = 1;
+			sl->da_irq_supported = 1;
 		}
 		break;
 
@@ -1000,7 +1010,9 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
 	 * call might take several hundred milliseconds until timeout!
 	 */
 	for (slot = 0; slot < ca->slot_count; slot++) {
-		switch (ca->slot_info[slot].slot_state) {
+		struct dvb_ca_slot *sl = &ca->slot_info[slot];
+
+		switch (sl->slot_state) {
 		default:
 		case SLOT_STAT_NONE:
 			delay = HZ * 60;  /* 60s */
@@ -1026,7 +1038,7 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
 			if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
 				delay = HZ / 10;  /* 100ms */
 			if (ca->open) {
-				if ((!ca->slot_info[slot].da_irq_supported) ||
+				if ((!sl->da_irq_supported) ||
 				    (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA)))
 					delay = HZ / 10;  /* 100ms */
 			}
@@ -1072,43 +1084,44 @@ static int dvb_ca_en50221_thread(void *data)
 
 		/* go through all the slots processing them */
 		for (slot = 0; slot < ca->slot_count; slot++) {
+			struct dvb_ca_slot *sl = &ca->slot_info[slot];
 
-			mutex_lock(&ca->slot_info[slot].slot_lock);
+			mutex_lock(&sl->slot_lock);
 
 			// check the cam status + deal with CAMCHANGEs
 			while (dvb_ca_en50221_check_camstatus(ca, slot)) {
 				/* clear down an old CI slot if necessary */
-				if (ca->slot_info[slot].slot_state != SLOT_STAT_NONE)
+				if (sl->slot_state != SLOT_STAT_NONE)
 					dvb_ca_en50221_slot_shutdown(ca, slot);
 
 				/* if a CAM is NOW present, initialise it */
-				if (ca->slot_info[slot].camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
-					ca->slot_info[slot].slot_state = SLOT_STAT_UNINIT;
+				if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
+					sl->slot_state = SLOT_STAT_UNINIT;
 				}
 
 				/* we've handled one CAMCHANGE */
 				dvb_ca_en50221_thread_update_delay(ca);
-				atomic_dec(&ca->slot_info[slot].camchange_count);
+				atomic_dec(&sl->camchange_count);
 			}
 
 			// CAM state machine
-			switch (ca->slot_info[slot].slot_state) {
+			switch (sl->slot_state) {
 			case SLOT_STAT_NONE:
 			case SLOT_STAT_INVALID:
 				// no action needed
 				break;
 
 			case SLOT_STAT_UNINIT:
-				ca->slot_info[slot].slot_state = SLOT_STAT_WAITREADY;
+				sl->slot_state = SLOT_STAT_WAITREADY;
 				ca->pub->slot_reset(ca->pub, slot);
-				ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
+				sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
 				break;
 
 			case SLOT_STAT_WAITREADY:
-				if (time_after(jiffies, ca->slot_info[slot].timeout)) {
+				if (time_after(jiffies, sl->timeout)) {
 					pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+					sl->slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
@@ -1122,7 +1135,7 @@ static int dvb_ca_en50221_thread(void *data)
 					    (ca->pub->poll_slot_status)) {
 						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
 						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
+							sl->slot_state = SLOT_STAT_NONE;
 							dvb_ca_en50221_thread_update_delay(ca);
 							break;
 						}
@@ -1130,14 +1143,14 @@ static int dvb_ca_en50221_thread(void *data)
 
 					pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+					sl->slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 				if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
 					pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+					sl->slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
@@ -1145,29 +1158,29 @@ static int dvb_ca_en50221_thread(void *data)
 							       CTRLIF_COMMAND, CMDREG_RS) != 0) {
 					pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+					sl->slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 				dprintk("DVB CAM validated successfully\n");
 
-				ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
-				ca->slot_info[slot].slot_state = SLOT_STAT_WAITFR;
+				sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
+				sl->slot_state = SLOT_STAT_WAITFR;
 				ca->wakeup = 1;
 				break;
 
 			case SLOT_STAT_WAITFR:
-				if (time_after(jiffies, ca->slot_info[slot].timeout)) {
+				if (time_after(jiffies, sl->timeout)) {
 					pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+					sl->slot_state = SLOT_STAT_INVALID;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 
 				flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
 				if (flags & STATREG_FR) {
-					ca->slot_info[slot].slot_state = SLOT_STAT_LINKINIT;
+					sl->slot_state = SLOT_STAT_LINKINIT;
 					ca->wakeup = 1;
 				}
 				break;
@@ -1179,7 +1192,7 @@ static int dvb_ca_en50221_thread(void *data)
 					    (ca->pub->poll_slot_status)) {
 						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
 						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
+							sl->slot_state = SLOT_STAT_NONE;
 							dvb_ca_en50221_thread_update_delay(ca);
 							break;
 						}
@@ -1187,25 +1200,25 @@ static int dvb_ca_en50221_thread(void *data)
 
 					pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
 					       ca->dvbdev->adapter->num);
-					ca->slot_info[slot].slot_state = SLOT_STAT_UNINIT;
+					sl->slot_state = SLOT_STAT_UNINIT;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
 
-				if (ca->slot_info[slot].rx_buffer.data == NULL) {
+				if (sl->rx_buffer.data == NULL) {
 					rxbuf = vmalloc(RX_BUFFER_SIZE);
 					if (rxbuf == NULL) {
 						pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
 						       ca->dvbdev->adapter->num);
-						ca->slot_info[slot].slot_state = SLOT_STAT_INVALID;
+						sl->slot_state = SLOT_STAT_INVALID;
 						dvb_ca_en50221_thread_update_delay(ca);
 						break;
 					}
-					dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
+					dvb_ringbuffer_init(&sl->rx_buffer, rxbuf, RX_BUFFER_SIZE);
 				}
 
 				ca->pub->slot_ts_enable(ca->pub, slot);
-				ca->slot_info[slot].slot_state = SLOT_STAT_RUNNING;
+				sl->slot_state = SLOT_STAT_RUNNING;
 				dvb_ca_en50221_thread_update_delay(ca);
 				pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
 				       ca->dvbdev->adapter->num);
@@ -1238,7 +1251,7 @@ static int dvb_ca_en50221_thread(void *data)
 				break;
 			}
 
-			mutex_unlock(&ca->slot_info[slot].slot_lock);
+			mutex_unlock(&sl->slot_lock);
 		}
 	}
 
@@ -1277,15 +1290,16 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 	switch (cmd) {
 	case CA_RESET:
 		for (slot = 0; slot < ca->slot_count; slot++) {
-			mutex_lock(&ca->slot_info[slot].slot_lock);
-			if (ca->slot_info[slot].slot_state != SLOT_STAT_NONE) {
+			struct dvb_ca_slot *sl = &ca->slot_info[slot];
+			mutex_lock(&sl->slot_lock);
+			if (sl->slot_state != SLOT_STAT_NONE) {
 				dvb_ca_en50221_slot_shutdown(ca, slot);
 				if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
 					dvb_ca_en50221_camchange_irq(ca->pub,
 								     slot,
 								     DVB_CA_EN50221_CAMCHANGE_INSERTED);
 			}
-			mutex_unlock(&ca->slot_info[slot].slot_lock);
+			mutex_unlock(&sl->slot_lock);
 		}
 		ca->next_read_slot = 0;
 		dvb_ca_en50221_thread_wakeup(ca);
@@ -1303,19 +1317,22 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 
 	case CA_GET_SLOT_INFO: {
 		struct ca_slot_info *info = parg;
+		struct dvb_ca_slot *sl;
 
-		if ((info->num > ca->slot_count) || (info->num < 0)) {
+		slot = info->num;
+		if ((slot > ca->slot_count) || (slot < 0)) {
 			err = -EINVAL;
 			goto out_unlock;
 		}
 
 		info->type = CA_CI_LINK;
 		info->flags = 0;
-		if ((ca->slot_info[info->num].slot_state != SLOT_STAT_NONE)
-			&& (ca->slot_info[info->num].slot_state != SLOT_STAT_INVALID)) {
+		sl = &ca->slot_info[slot];
+		if ((sl->slot_state != SLOT_STAT_NONE)
+			&& (sl->slot_state != SLOT_STAT_INVALID)) {
 			info->flags = CA_CI_MODULE_PRESENT;
 		}
-		if (ca->slot_info[info->num].slot_state == SLOT_STAT_RUNNING) {
+		if (sl->slot_state == SLOT_STAT_RUNNING) {
 			info->flags |= CA_CI_MODULE_READY;
 		}
 		break;
@@ -1364,6 +1381,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
+	struct dvb_ca_slot *sl;
 	u8 slot, connection_id;
 	int status;
 	u8 fragbuf[HOST_LINK_BUF_SIZE];
@@ -1385,14 +1403,15 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 		return -EFAULT;
 	buf += 2;
 	count -= 2;
+	sl = &ca->slot_info[slot];
 
 	/* check if the slot is actually running */
-	if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING)
+	if (sl->slot_state != SLOT_STAT_RUNNING)
 		return -EINVAL;
 
 	/* fragment the packets & store in the buffer */
 	while (fragpos < count) {
-		fraglen = ca->slot_info[slot].link_buf_size - 2;
+		fraglen = sl->link_buf_size - 2;
 		if (fraglen < 0)
 			break;
 		if (fraglen > HOST_LINK_BUF_SIZE - 2)
@@ -1412,14 +1431,14 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 		written = 0;
 		while (!time_after(jiffies, timeout)) {
 			/* check the CAM hasn't been removed/reset in the meantime */
-			if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING) {
+			if (sl->slot_state != SLOT_STAT_RUNNING) {
 				status = -EIO;
 				goto exit;
 			}
 
-			mutex_lock(&ca->slot_info[slot].slot_lock);
+			mutex_lock(&sl->slot_lock);
 			status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2);
-			mutex_unlock(&ca->slot_info[slot].slot_lock);
+			mutex_unlock(&sl->slot_lock);
 			if (status == (fraglen + 2)) {
 				written = 1;
 				break;
@@ -1459,16 +1478,18 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
 
 	slot = ca->next_read_slot;
 	while ((slot_count < ca->slot_count) && (!found)) {
-		if (ca->slot_info[slot].slot_state != SLOT_STAT_RUNNING)
+		struct dvb_ca_slot *sl = &ca->slot_info[slot];
+
+		if (sl->slot_state != SLOT_STAT_RUNNING)
 			goto nextslot;
 
-		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+		if (sl->rx_buffer.data == NULL) {
 			return 0;
 		}
 
-		idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen);
+		idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, -1, &fraglen);
 		while (idx != -1) {
-			dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2);
+			dvb_ringbuffer_pkt_read(&sl->rx_buffer, idx, 0, hdr, 2);
 			if (connection_id == -1)
 				connection_id = hdr[0];
 			if ((hdr[0] == connection_id) && ((hdr[1] & 0x80) == 0)) {
@@ -1477,7 +1498,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
 				break;
 			}
 
-			idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
+			idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx, &fraglen);
 		}
 
 nextslot:
@@ -1505,6 +1526,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
+	struct dvb_ca_slot *sl;
 	int status;
 	int result = 0;
 	u8 hdr[2];
@@ -1540,7 +1562,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
 		return status;
 	}
 
-	idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen);
+	sl = &ca->slot_info[slot];
+	idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, -1, &fraglen);
 	pktlen = 2;
 	do {
 		if (idx == -1) {
@@ -1550,7 +1573,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
 			goto exit;
 		}
 
-		dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2);
+		dvb_ringbuffer_pkt_read(&sl->rx_buffer, idx, 0, hdr, 2);
 		if (connection_id == -1)
 			connection_id = hdr[0];
 		if (hdr[0] == connection_id) {
@@ -1561,7 +1584,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
 					fraglen -= 2;
 				}
 
-				if ((status = dvb_ringbuffer_pkt_read_user(&ca->slot_info[slot].rx_buffer, idx, 2,
+				if ((status = dvb_ringbuffer_pkt_read_user(&sl->rx_buffer, idx, 2,
 								      buf + pktlen, fraglen)) < 0) {
 					goto exit;
 				}
@@ -1573,9 +1596,9 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
 			dispose = 1;
 		}
 
-		idx2 = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
+		idx2 = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx, &fraglen);
 		if (dispose)
-			dvb_ringbuffer_pkt_dispose(&ca->slot_info[slot].rx_buffer, idx);
+			dvb_ringbuffer_pkt_dispose(&sl->rx_buffer, idx);
 		idx = idx2;
 		dispose = 0;
 	} while (!last_fragment);
@@ -1621,12 +1644,13 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
 	}
 
 	for (i = 0; i < ca->slot_count; i++) {
+		struct dvb_ca_slot *sl = &ca->slot_info[i];
 
-		if (ca->slot_info[i].slot_state == SLOT_STAT_RUNNING) {
-			if (ca->slot_info[i].rx_buffer.data != NULL) {
+		if (sl->slot_state == SLOT_STAT_RUNNING) {
+			if (sl->rx_buffer.data != NULL) {
 				/* it is safe to call this here without locks because
 				 * ca->open == 0. Data is not read in this case */
-				dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
+				dvb_ringbuffer_flush(&sl->rx_buffer);
 			}
 		}
 	}
@@ -1783,11 +1807,12 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 
 	/* now initialise each slot */
 	for (i = 0; i < slot_count; i++) {
-		memset(&ca->slot_info[i], 0, sizeof(struct dvb_ca_slot));
-		ca->slot_info[i].slot_state = SLOT_STAT_NONE;
-		atomic_set(&ca->slot_info[i].camchange_count, 0);
-		ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
-		mutex_init(&ca->slot_info[i].slot_lock);
+		struct dvb_ca_slot *sl = &ca->slot_info[i];
+		memset(sl, 0, sizeof(struct dvb_ca_slot));
+		sl->slot_state = SLOT_STAT_NONE;
+		atomic_set(&sl->camchange_count, 0);
+		sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
+		mutex_init(&sl->slot_lock);
 	}
 
 	mutex_init(&ca->ioctl_mutex);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (2 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 03/11] [media] dvb-core/dvb_ca_en50221.c: Used a helper variable Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 05/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 1 Jasmin J.
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Refactored "dvb_ca_en50221_thread" by moving the state machine into the
new function "dvb_ca_en50221_thread_state_machine". This reduces the
thread function size and reduces the structural complexity and of course
gives us more space to meet the line length goal in the new function.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 338 +++++++++++++++++---------------
 1 file changed, 176 insertions(+), 162 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index ba30bcf4..cc1d1d1 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1055,204 +1055,218 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
 
 
 /**
- * Kernel thread which monitors CA slots for CAM changes, and performs data transfers.
+ * Thread state machine for one CA slot to perform the data transfer.
+ *
+ * @ca: CA instance.
+ * @slot: Slot to process.
  */
-static int dvb_ca_en50221_thread(void *data)
+static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
+						int slot)
 {
-	struct dvb_ca_private *ca = data;
-	int slot;
 	int flags;
 	int status;
 	int pktcount;
 	void *rxbuf;
 
-	dprintk("%s\n", __func__);
-
-	/* choose the correct initial delay */
-	dvb_ca_en50221_thread_update_delay(ca);
-
-	/* main loop */
-	while (!kthread_should_stop()) {
-		/* sleep for a bit */
-		if (!ca->wakeup) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(ca->delay);
-			if (kthread_should_stop())
-				return 0;
-		}
-		ca->wakeup = 0;
+	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 
-		/* go through all the slots processing them */
-		for (slot = 0; slot < ca->slot_count; slot++) {
-			struct dvb_ca_slot *sl = &ca->slot_info[slot];
+	mutex_lock(&sl->slot_lock);
 
-			mutex_lock(&sl->slot_lock);
+	// check the CAM status + deal with CAMCHANGEs
+	while (dvb_ca_en50221_check_camstatus(ca, slot)) {
+		/* clear down an old CI slot if necessary */
+		if (sl->slot_state != SLOT_STAT_NONE)
+			dvb_ca_en50221_slot_shutdown(ca, slot);
 
-			// check the cam status + deal with CAMCHANGEs
-			while (dvb_ca_en50221_check_camstatus(ca, slot)) {
-				/* clear down an old CI slot if necessary */
-				if (sl->slot_state != SLOT_STAT_NONE)
-					dvb_ca_en50221_slot_shutdown(ca, slot);
+		/* if a CAM is NOW present, initialise it */
+		if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
+			sl->slot_state = SLOT_STAT_UNINIT;
+		}
 
-				/* if a CAM is NOW present, initialise it */
-				if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
-					sl->slot_state = SLOT_STAT_UNINIT;
-				}
+		/* we've handled one CAMCHANGE */
+		dvb_ca_en50221_thread_update_delay(ca);
+		atomic_dec(&sl->camchange_count);
+	}
 
-				/* we've handled one CAMCHANGE */
-				dvb_ca_en50221_thread_update_delay(ca);
-				atomic_dec(&sl->camchange_count);
-			}
+	// CAM state machine
+	switch (sl->slot_state) {
+	case SLOT_STAT_NONE:
+	case SLOT_STAT_INVALID:
+		// no action needed
+		break;
 
-			// CAM state machine
-			switch (sl->slot_state) {
-			case SLOT_STAT_NONE:
-			case SLOT_STAT_INVALID:
-				// no action needed
-				break;
+	case SLOT_STAT_UNINIT:
+		sl->slot_state = SLOT_STAT_WAITREADY;
+		ca->pub->slot_reset(ca->pub, slot);
+		sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
+		break;
 
-			case SLOT_STAT_UNINIT:
-				sl->slot_state = SLOT_STAT_WAITREADY;
-				ca->pub->slot_reset(ca->pub, slot);
-				sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
-				break;
+	case SLOT_STAT_WAITREADY:
+		if (time_after(jiffies, sl->timeout)) {
+			pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_INVALID;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
+		// no other action needed; will automatically change state when ready
+		break;
 
-			case SLOT_STAT_WAITREADY:
-				if (time_after(jiffies, sl->timeout)) {
-					pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_INVALID;
+	case SLOT_STAT_VALIDATE:
+		if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
+			/* we need this extra check for annoying interfaces like the budget-av */
+			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
+			    (ca->pub->poll_slot_status)) {
+				status = ca->pub->poll_slot_status(ca->pub, slot, 0);
+				if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
+					sl->slot_state = SLOT_STAT_NONE;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
-				// no other action needed; will automatically change state when ready
-				break;
+			}
 
-			case SLOT_STAT_VALIDATE:
-				if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
-					/* we need this extra check for annoying interfaces like the budget-av */
-					if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
-					    (ca->pub->poll_slot_status)) {
-						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
-						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							sl->slot_state = SLOT_STAT_NONE;
-							dvb_ca_en50221_thread_update_delay(ca);
-							break;
-						}
-					}
-
-					pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_INVALID;
-					dvb_ca_en50221_thread_update_delay(ca);
-					break;
-				}
-				if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
-					pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_INVALID;
-					dvb_ca_en50221_thread_update_delay(ca);
-					break;
-				}
-				if (ca->pub->write_cam_control(ca->pub, slot,
-							       CTRLIF_COMMAND, CMDREG_RS) != 0) {
-					pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_INVALID;
-					dvb_ca_en50221_thread_update_delay(ca);
-					break;
-				}
-				dprintk("DVB CAM validated successfully\n");
+			pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_INVALID;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
+		if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
+			pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_INVALID;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
+		if (ca->pub->write_cam_control(ca->pub, slot,
+					       CTRLIF_COMMAND, CMDREG_RS) != 0) {
+			pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_INVALID;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
+		dprintk("DVB CAM validated successfully\n");
 
-				sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
-				sl->slot_state = SLOT_STAT_WAITFR;
-				ca->wakeup = 1;
-				break;
+		sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
+		sl->slot_state = SLOT_STAT_WAITFR;
+		ca->wakeup = 1;
+		break;
 
-			case SLOT_STAT_WAITFR:
-				if (time_after(jiffies, sl->timeout)) {
-					pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_INVALID;
-					dvb_ca_en50221_thread_update_delay(ca);
-					break;
-				}
+	case SLOT_STAT_WAITFR:
+		if (time_after(jiffies, sl->timeout)) {
+			pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_INVALID;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
 
-				flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
-				if (flags & STATREG_FR) {
-					sl->slot_state = SLOT_STAT_LINKINIT;
-					ca->wakeup = 1;
-				}
-				break;
+		flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
+		if (flags & STATREG_FR) {
+			sl->slot_state = SLOT_STAT_LINKINIT;
+			ca->wakeup = 1;
+		}
+		break;
 
-			case SLOT_STAT_LINKINIT:
-				if (dvb_ca_en50221_link_init(ca, slot) != 0) {
-					/* we need this extra check for annoying interfaces like the budget-av */
-					if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
-					    (ca->pub->poll_slot_status)) {
-						status = ca->pub->poll_slot_status(ca->pub, slot, 0);
-						if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
-							sl->slot_state = SLOT_STAT_NONE;
-							dvb_ca_en50221_thread_update_delay(ca);
-							break;
-						}
-					}
-
-					pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
-					       ca->dvbdev->adapter->num);
-					sl->slot_state = SLOT_STAT_UNINIT;
+	case SLOT_STAT_LINKINIT:
+		if (dvb_ca_en50221_link_init(ca, slot) != 0) {
+			/* we need this extra check for annoying interfaces like the budget-av */
+			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
+			    (ca->pub->poll_slot_status)) {
+				status = ca->pub->poll_slot_status(ca->pub, slot, 0);
+				if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
+					sl->slot_state = SLOT_STAT_NONE;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
 				}
+			}
 
-				if (sl->rx_buffer.data == NULL) {
-					rxbuf = vmalloc(RX_BUFFER_SIZE);
-					if (rxbuf == NULL) {
-						pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
-						       ca->dvbdev->adapter->num);
-						sl->slot_state = SLOT_STAT_INVALID;
-						dvb_ca_en50221_thread_update_delay(ca);
-						break;
-					}
-					dvb_ringbuffer_init(&sl->rx_buffer, rxbuf, RX_BUFFER_SIZE);
-				}
+			pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
+			       ca->dvbdev->adapter->num);
+			sl->slot_state = SLOT_STAT_UNINIT;
+			dvb_ca_en50221_thread_update_delay(ca);
+			break;
+		}
 
-				ca->pub->slot_ts_enable(ca->pub, slot);
-				sl->slot_state = SLOT_STAT_RUNNING;
-				dvb_ca_en50221_thread_update_delay(ca);
-				pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
+		if (sl->rx_buffer.data == NULL) {
+			rxbuf = vmalloc(RX_BUFFER_SIZE);
+			if (rxbuf == NULL) {
+				pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
 				       ca->dvbdev->adapter->num);
+				sl->slot_state = SLOT_STAT_INVALID;
+				dvb_ca_en50221_thread_update_delay(ca);
 				break;
+			}
+			dvb_ringbuffer_init(&sl->rx_buffer, rxbuf, RX_BUFFER_SIZE);
+		}
 
-			case SLOT_STAT_RUNNING:
-				if (!ca->open)
-					break;
+		ca->pub->slot_ts_enable(ca->pub, slot);
+		sl->slot_state = SLOT_STAT_RUNNING;
+		dvb_ca_en50221_thread_update_delay(ca);
+		pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
+		       ca->dvbdev->adapter->num);
+		break;
 
-				// poll slots for data
-				pktcount = 0;
-				while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
-					if (!ca->open)
-						break;
-
-					/* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
-					if (dvb_ca_en50221_check_camstatus(ca, slot)) {
-						// we dont want to sleep on the next iteration so we can handle the cam change
-						ca->wakeup = 1;
-						break;
-					}
-
-					/* check if we've hit our limit this time */
-					if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
-						// dont sleep; there is likely to be more data to read
-						ca->wakeup = 1;
-						break;
-					}
-				}
+	case SLOT_STAT_RUNNING:
+		if (!ca->open)
+			break;
+
+		// poll slots for data
+		pktcount = 0;
+		while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
+			if (!ca->open)
+				break;
+
+			/* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
+			if (dvb_ca_en50221_check_camstatus(ca, slot)) {
+				// we dont want to sleep on the next iteration so we can handle the cam change
+				ca->wakeup = 1;
 				break;
 			}
 
-			mutex_unlock(&sl->slot_lock);
+			/* check if we've hit our limit this time */
+			if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
+				// dont sleep; there is likely to be more data to read
+				ca->wakeup = 1;
+				break;
+			}
 		}
+		break;
+	}
+
+	mutex_unlock(&sl->slot_lock);
+}
+
+
+
+/**
+ * Kernel thread which monitors CA slots for CAM changes, and performs data transfers.
+ */
+static int dvb_ca_en50221_thread(void *data)
+{
+	struct dvb_ca_private *ca = data;
+	int slot;
+
+	dprintk("%s\n", __func__);
+
+	/* choose the correct initial delay */
+	dvb_ca_en50221_thread_update_delay(ca);
+
+	/* main loop */
+	while (!kthread_should_stop()) {
+		/* sleep for a bit */
+		if (!ca->wakeup) {
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(ca->delay);
+			if (kthread_should_stop())
+				return 0;
+		}
+		ca->wakeup = 0;
+
+		/* go through all the slots processing them */
+		for (slot = 0; slot < ca->slot_count; slot++)
+			dvb_ca_en50221_thread_state_machine(ca, slot);
 	}
 
 	return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 1
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (3 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 06/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 2 Jasmin J.
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed all:
  ERROR: "foo * bar" should be "foo *bar"

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index cc1d1d1..48b652b 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -193,8 +193,10 @@ static void dvb_ca_private_put(struct dvb_ca_private *ca)
 }
 
 static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca);
-static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount);
-static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount);
+static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
+				    u8 *ebuf, int ecount);
+static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
+				     u8 *ebuf, int ecount);
 
 
 /**
@@ -206,7 +208,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * e
  * @nlen: Number of bytes in needle.
  * @return Pointer into haystack needle was found at, or NULL if not found.
  */
-static char *findstr(char * haystack, int hlen, char * needle, int nlen)
+static char *findstr(char *haystack, int hlen, char *needle, int nlen)
 {
 	int i;
 
@@ -392,7 +394,8 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
  * @return 0 on success, nonzero on error.
  */
 static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
-				     int *address, int *tupleType, int *tupleLength, u8 * tuple)
+				     int *address, int *tupleType,
+				     int *tupleLength, u8 *tuple)
 {
 	int i;
 	int _tupleType;
@@ -626,7 +629,8 @@ static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
  *
  * @return Number of bytes read, or < 0 on error
  */
-static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount)
+static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
+				    u8 *ebuf, int ecount)
 {
 	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int bytes_read;
@@ -763,7 +767,8 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
  *
  * @return Number of bytes written, or < 0 on error.
  */
-static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * buf, int bytes_write)
+static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
+				     u8 *buf, int bytes_write)
 {
 	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int status;
@@ -1391,7 +1396,8 @@ static long dvb_ca_en50221_io_ioctl(struct file *file,
  * @return Number of bytes read, or <0 on error.
  */
 static ssize_t dvb_ca_en50221_io_write(struct file *file,
-				       const char __user * buf, size_t count, loff_t * ppos)
+				       const char __user *buf, size_t count,
+				       loff_t *ppos)
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
@@ -1535,8 +1541,8 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
  *
  * @return Number of bytes read, or <0 on error.
  */
-static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
-				      size_t count, loff_t * ppos)
+static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
+				      size_t count, loff_t *ppos)
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
@@ -1717,7 +1723,7 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
  *
  * @return Standard poll mask.
  */
-static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
+static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 2
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (4 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 05/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 1 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 07/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 3 Jasmin J.
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed all:
  ERROR: do not use assignment in if condition

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 130 +++++++++++++++++++++-----------
 1 file changed, 88 insertions(+), 42 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 48b652b..6d405b5 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -349,13 +349,18 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	sl->link_buf_size = 2;
 
 	/* read the buffer size from the CAM */
-	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
+	ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
+					 IRQEN | CMDREG_SR);
+	if (ret != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_DA, HZ)) != 0)
+	ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_DA, HZ);
+	if (ret != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
+	ret = dvb_ca_en50221_read_data(ca, slot, buf, 2);
+	if (ret != 2)
 		return -EIO;
-	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
+	ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
+	if (ret != 0)
 		return ret;
 
 	/* store it, and choose the minimum of our buffer and the CAM's buffer size */
@@ -368,13 +373,18 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	dprintk("Chosen link buffer size of %i\n", buf_size);
 
 	/* write the buffer size to the CAM */
-	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
+	ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
+					 IRQEN | CMDREG_SW);
+	if (ret != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_FR, HZ / 10)) != 0)
+	ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_FR, HZ / 10);
+	if (ret != 0)
 		return ret;
-	if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
+	ret = dvb_ca_en50221_write_data(ca, slot, buf, 2);
+	if (ret != 2)
 		return -EIO;
-	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
+	ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
+	if (ret != 0)
 		return ret;
 
 	/* success */
@@ -403,7 +413,8 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
 	int _address = *address;
 
 	/* grab the next tuple length and type */
-	if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0)
+	_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address);
+	if (_tupleType < 0)
 		return _tupleType;
 	if (_tupleType == 0xff) {
 		dprintk("END OF CHAIN TUPLE type:0x%x\n", _tupleType);
@@ -412,7 +423,8 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
 		*tupleLength = 0;
 		return 0;
 	}
-	if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2)) < 0)
+	_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2);
+	if (_tupleLength < 0)
 		return _tupleLength;
 	_address += 4;
 
@@ -462,8 +474,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 
 	// CISTPL_DEVICE_0A
-	if ((status =
-	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+	status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+					   &tupleLength, tuple);
+	if (status < 0)
 		return status;
 	if (tupleType != 0x1D)
 		return -EINVAL;
@@ -471,8 +484,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 
 	// CISTPL_DEVICE_0C
-	if ((status =
-	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+	status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+					   &tupleLength, tuple);
+	if (status < 0)
 		return status;
 	if (tupleType != 0x1C)
 		return -EINVAL;
@@ -480,8 +494,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 
 	// CISTPL_VERS_1
-	if ((status =
-	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+	status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+					   &tupleLength, tuple);
+	if (status < 0)
 		return status;
 	if (tupleType != 0x15)
 		return -EINVAL;
@@ -489,8 +504,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 
 	// CISTPL_MANFID
-	if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
-						&tupleLength, tuple)) < 0)
+	status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+					   &tupleLength, tuple);
+	if (status < 0)
 		return status;
 	if (tupleType != 0x20)
 		return -EINVAL;
@@ -502,8 +518,9 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 
 	// CISTPL_CONFIG
-	if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
-						&tupleLength, tuple)) < 0)
+	status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+					   &tupleLength, tuple);
+	if (status < 0)
 		return status;
 	if (tupleType != 0x1A)
 		return -EINVAL;
@@ -538,8 +555,10 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 	/* process the CFTABLE_ENTRY tuples, and any after those */
 	while ((!end_chain) && (address < 0x1000)) {
-		if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
-							&tupleLength, tuple)) < 0)
+		status = dvb_ca_en50221_read_tuple(ca, slot, &address,
+						   &tupleType, &tupleLength,
+						   tuple);
+		if (status < 0)
 			return status;
 		switch (tupleType) {
 		case 0x1B:	// CISTPL_CFTABLE_ENTRY
@@ -669,7 +688,9 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 	} else {
 
 		/* check if there is data available */
-		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		status = ca->pub->read_cam_control(ca->pub, slot,
+						   CTRLIF_STATUS);
+		if (status < 0)
 			goto exit;
 		if (!(status & STATREG_DA)) {
 			/* no data */
@@ -678,10 +699,14 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		}
 
 		/* read the amount of data */
-		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0)
+		status = ca->pub->read_cam_control(ca->pub, slot,
+						   CTRLIF_SIZE_HIGH);
+		if (status < 0)
 			goto exit;
 		bytes_read = status << 8;
-		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0)
+		status = ca->pub->read_cam_control(ca->pub, slot,
+						   CTRLIF_SIZE_LOW);
+		if (status < 0)
 			goto exit;
 		bytes_read |= status;
 
@@ -713,7 +738,9 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		/* fill the buffer */
 		for (i = 0; i < bytes_read; i++) {
 			/* read byte and check */
-			if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0)
+			status = ca->pub->read_cam_control(ca->pub, slot,
+							   CTRLIF_DATA);
+			if (status < 0)
 				goto exit;
 
 			/* OK, store it in the buffer */
@@ -721,7 +748,9 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		}
 
 		/* check for read error (RE should now be 0) */
-		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		status = ca->pub->read_cam_control(ca->pub, slot,
+						   CTRLIF_STATUS);
+		if (status < 0)
 			goto exit;
 		if (status & STATREG_RE) {
 			sl->slot_state = SLOT_STAT_LINKINIT;
@@ -788,7 +817,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
 	   thus if there is data available for read or if there is even a read
 	   already in progress, we do nothing but awake the kernel thread to
 	   process the data if necessary. */
-	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+	status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
+	if (status < 0)
 		goto exitnowrite;
 	if (status & (STATREG_DA | STATREG_RE)) {
 		if (status & STATREG_DA)
@@ -799,12 +829,14 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
 	}
 
 	/* OK, set HC bit */
-	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
-						 IRQEN | CMDREG_HC)) != 0)
+	status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
+					    IRQEN | CMDREG_HC);
+	if (status != 0)
 		goto exit;
 
 	/* check if interface is still free */
-	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+	status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
+	if (status < 0)
 		goto exit;
 	if (!(status & STATREG_FR)) {
 		/* it wasn't free => try again later */
@@ -836,20 +868,26 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
 	}
 
 	/* send the amount of data */
-	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0)
+	status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH,
+					    bytes_write >> 8);
+	if (status != 0)
 		goto exit;
-	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
-						 bytes_write & 0xff)) != 0)
+	status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
+					    bytes_write & 0xff);
+	if (status != 0)
 		goto exit;
 
 	/* send the buffer */
 	for (i = 0; i < bytes_write; i++) {
-		if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0)
+		status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA,
+						    buf[i]);
+		if (status != 0)
 			goto exit;
 	}
 
 	/* check for write error (WE should now be 0) */
-	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+	status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
+	if (status < 0)
 		goto exit;
 	if (status & STATREG_WE) {
 		sl->slot_state = SLOT_STAT_LINKINIT;
@@ -1565,7 +1603,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 		return -EINVAL;
 
 	/* wait for some data */
-	if ((status = dvb_ca_en50221_io_read_condition(ca, &result, &slot)) == 0) {
+	status = dvb_ca_en50221_io_read_condition(ca, &result, &slot);
+	if (status == 0) {
 
 		/* if we're in nonblocking mode, exit immediately */
 		if (file->f_flags & O_NONBLOCK)
@@ -1604,8 +1643,12 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 					fraglen -= 2;
 				}
 
-				if ((status = dvb_ringbuffer_pkt_read_user(&sl->rx_buffer, idx, 2,
-								      buf + pktlen, fraglen)) < 0) {
+				status =
+				   dvb_ringbuffer_pkt_read_user(&sl->rx_buffer,
+								idx, 2,
+								buf + pktlen,
+								fraglen);
+				if (status < 0) {
 					goto exit;
 				}
 				pktlen += fraglen;
@@ -1801,8 +1844,9 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	if (slot_count < 1)
 		return -EINVAL;
 
-	/* initialise the system data */
-	if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
+	/* initialize the system data */
+	ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL);
+	if (ca == NULL) {
 		ret = -ENOMEM;
 		goto exit;
 	}
@@ -1810,7 +1854,9 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	ca->pub = pubca;
 	ca->flags = flags;
 	ca->slot_count = slot_count;
-	if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
+	ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot),
+				GFP_KERNEL);
+	if (ca->slot_info == NULL) {
 		ret = -ENOMEM;
 		goto free_ca;
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 3
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (5 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 06/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 2 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 08/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 4 Jasmin J.
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed all:
  WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 48 +++++++++++++--------------------
 1 file changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 6d405b5..af66c83 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -240,9 +240,8 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	int cam_changed;
 
 	/* IRQ mode */
-	if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) {
+	if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
 		return (atomic_read(&sl->camchange_count) != 0);
-	}
 
 	/* poll mode */
 	slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open);
@@ -255,11 +254,9 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	}
 
 	if (cam_changed) {
-		if (!cam_present_now) {
-			sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
-		} else {
-			sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED;
-		}
+		sl->camchange_type = cam_present_now ?
+				     DVB_CA_EN50221_CAMCHANGE_INSERTED :
+				     DVB_CA_EN50221_CAMCHANGE_REMOVED;
 		atomic_set(&sl->camchange_count, 1);
 	} else {
 		if ((sl->slot_state == SLOT_STAT_WAITREADY) &&
@@ -309,9 +306,8 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
 		}
 
 		/* check for timeout */
-		if (time_after(jiffies, timeout)) {
+		if (time_after(jiffies, timeout))
 			break;
-		}
 
 		/* wait for a bit */
 		msleep(1);
@@ -534,9 +530,8 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 
 	sl = &ca->slot_info[slot];
 	sl->config_base = 0;
-	for (i = 0; i < rasz + 1; i++) {
+	for (i = 0; i < rasz + 1; i++)
 		sl->config_base |= (tuple[2 + i] << (8 * i));
-	}
 
 	/* check it contains the correct DVB string */
 	dvb_str = findstr((char *)tuple, tupleLength, "DVB_CI_V", 8);
@@ -774,9 +769,9 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		buf[0], (buf[1] & 0x80) == 0, bytes_read);
 
 	/* wake up readers when a last_fragment is received */
-	if ((buf[1] & 0x80) == 0x00) {
+	if ((buf[1] & 0x80) == 0x00)
 		wake_up_interruptible(&ca->wait_queue);
-	}
+
 	status = bytes_read;
 
 exit:
@@ -1122,9 +1117,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 			dvb_ca_en50221_slot_shutdown(ca, slot);
 
 		/* if a CAM is NOW present, initialise it */
-		if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
+		if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED)
 			sl->slot_state = SLOT_STAT_UNINIT;
-		}
 
 		/* we've handled one CAMCHANGE */
 		dvb_ca_en50221_thread_update_delay(ca);
@@ -1389,9 +1383,8 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 			&& (sl->slot_state != SLOT_STAT_INVALID)) {
 			info->flags = CA_CI_MODULE_PRESENT;
 		}
-		if (sl->slot_state == SLOT_STAT_RUNNING) {
+		if (sl->slot_state == SLOT_STAT_RUNNING)
 			info->flags |= CA_CI_MODULE_READY;
-		}
 		break;
 	}
 
@@ -1541,9 +1534,8 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
 		if (sl->slot_state != SLOT_STAT_RUNNING)
 			goto nextslot;
 
-		if (sl->rx_buffer.data == NULL) {
+		if (sl->rx_buffer.data == NULL)
 			return 0;
-		}
 
 		idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, -1, &fraglen);
 		while (idx != -1) {
@@ -1637,20 +1629,18 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 			connection_id = hdr[0];
 		if (hdr[0] == connection_id) {
 			if (pktlen < count) {
-				if ((pktlen + fraglen - 2) > count) {
+				if ((pktlen + fraglen - 2) > count)
 					fraglen = count - pktlen;
-				} else {
+				else
 					fraglen -= 2;
-				}
 
 				status =
 				   dvb_ringbuffer_pkt_read_user(&sl->rx_buffer,
 								idx, 2,
 								buf + pktlen,
 								fraglen);
-				if (status < 0) {
+				if (status < 0)
 					goto exit;
-				}
 				pktlen += fraglen;
 			}
 
@@ -1776,9 +1766,8 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
 
 	dprintk("%s\n", __func__);
 
-	if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
+	if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1)
 		mask |= POLLIN;
-	}
 
 	/* if there is something, return now */
 	if (mask)
@@ -1787,9 +1776,8 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
 	/* wait for something to happen */
 	poll_wait(file, &ca->wait_queue, wait);
 
-	if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
+	if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1)
 		mask |= POLLIN;
-	}
 
 	return mask;
 }
@@ -1930,9 +1918,9 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
 	/* shutdown the thread if there was one */
 	kthread_stop(ca->thread);
 
-	for (i = 0; i < ca->slot_count; i++) {
+	for (i = 0; i < ca->slot_count; i++)
 		dvb_ca_en50221_slot_shutdown(ca, i);
-	}
+
 	dvb_remove_device(ca->dvbdev);
 	dvb_ca_private_put(ca);
 	pubca->private = NULL;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 4
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (6 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 07/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 3 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 09/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 5 Jasmin J.
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed all:
  WARNING: Missing a blank line after declarations
  WARNING: Block comments use * on subsequent lines

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index af66c83..090f343 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -178,7 +178,9 @@ static void dvb_ca_private_free(struct dvb_ca_private *ca)
 
 static void dvb_ca_private_release(struct kref *ref)
 {
-	struct dvb_ca_private *ca = container_of(ref, struct dvb_ca_private, refcount);
+	struct dvb_ca_private *ca;
+
+	ca = container_of(ref, struct dvb_ca_private, refcount);
 	dvb_ca_private_free(ca);
 }
 
@@ -237,6 +239,7 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	struct dvb_ca_slot *sl = &ca->slot_info[slot];
 	int slot_status;
 	int cam_present_now;
+	int cam_present_old;
 	int cam_changed;
 
 	/* IRQ mode */
@@ -249,7 +252,7 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
 	cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
 	if (!cam_changed) {
-		int cam_present_old = (sl->slot_state != SLOT_STAT_NONE);
+		cam_present_old = (sl->slot_state != SLOT_STAT_NONE);
 		cam_changed = (cam_present_now != cam_present_old);
 	}
 
@@ -294,7 +297,8 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
 	timeout = jiffies + timeout_hz;
 	while (1) {
 		/* read the status and check for error */
-		int res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
+		int res = ca->pub->read_cam_control(ca->pub, slot,
+						    CTRLIF_STATUS);
 		if (res < 0)
 			return -EIO;
 
@@ -809,9 +813,10 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
 		return ca->pub->write_data(ca->pub, slot, buf, bytes_write);
 
 	/* it is possible we are dealing with a single buffer implementation,
-	   thus if there is data available for read or if there is even a read
-	   already in progress, we do nothing but awake the kernel thread to
-	   process the data if necessary. */
+	 * thus if there is data available for read or if there is even a read
+	 * already in progress, we do nothing but awake the kernel thread to
+	 * process the data if necessary.
+	 */
 	status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
 	if (status < 0)
 		goto exitnowrite;
@@ -921,8 +926,9 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
 	ca->pub->slot_shutdown(ca->pub, slot);
 	ca->slot_info[slot].slot_state = SLOT_STAT_NONE;
 
-	/* need to wake up all processes to check if they're now
-	   trying to write to a defunct CAM */
+	/* need to wake up all processes to check if they're now trying to
+	 * write to a defunct CAM
+	 */
 	wake_up_interruptible(&ca->wait_queue);
 
 	dprintk("Slot %i shutdown\n", slot);
@@ -1342,6 +1348,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 	case CA_RESET:
 		for (slot = 0; slot < ca->slot_count; slot++) {
 			struct dvb_ca_slot *sl = &ca->slot_info[slot];
+
 			mutex_lock(&sl->slot_lock);
 			if (sl->slot_state != SLOT_STAT_NONE) {
 				dvb_ca_en50221_slot_shutdown(ca, slot);
@@ -1862,6 +1869,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	/* now initialise each slot */
 	for (i = 0; i < slot_count; i++) {
 		struct dvb_ca_slot *sl = &ca->slot_info[i];
+
 		memset(sl, 0, sizeof(struct dvb_ca_slot));
 		sl->slot_state = SLOT_STAT_NONE;
 		atomic_set(&sl->camchange_count, 0);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 5
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (7 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 08/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 4 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 10/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 6 Jasmin J.
  2017-05-07 21:23 ` [PATCH 11/11] [media] dvb-core/dvb_ca_en50221.c: Fixed wrong EXPORT_SYMBOL order Jasmin J.
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed all:
  WARNING: msleep < 20ms can sleep for up to 20ms
by using usleep_range.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 090f343..724fb34 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -314,7 +314,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
 			break;
 
 		/* wait for a bit */
-		msleep(1);
+		usleep_range(1000, 1100);
 	}
 
 	dprintk("%s failed timeout:%lu\n", __func__, jiffies - start);
@@ -1504,7 +1504,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 			if (status != -EAGAIN)
 				goto exit;
 
-			msleep(1);
+			usleep_range(1000, 1100);
 		}
 		if (!written) {
 			status = -EIO;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 6
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (8 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 09/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 5 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  2017-05-07 21:23 ` [PATCH 11/11] [media] dvb-core/dvb_ca_en50221.c: Fixed wrong EXPORT_SYMBOL order Jasmin J.
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Fixed most of
  WARNING: line over 80 characters
The remaining lines are printk strings, which should not be split.

The
  WARNING: memory barrier without comment
  WARNING: Prefer [subsystem eg: netdev]_dbg
will not be fixed.

checkpatch result:
  total: 0 errors, 7 warnings, 1987 lines checked

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 158 +++++++++++++++++++++-----------
 1 file changed, 105 insertions(+), 53 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 724fb34..ec9d63e 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -157,7 +157,9 @@ struct dvb_ca_private {
 	/* Delay the main thread should use */
 	unsigned long delay;
 
-	/* Slot to start looking for data to read from in the next user-space read operation */
+	/* Slot to start looking for data to read from in the next user-space
+	 * read operation
+	 */
 	int next_read_slot;
 
 	/* mutex serializing ioctls */
@@ -227,7 +229,7 @@ static char *findstr(char *haystack, int hlen, char *needle, int nlen)
 
 
 
-/* ******************************************************************************** */
+/* ************************************************************************** */
 /* EN50221 physical interface functions */
 
 
@@ -249,7 +251,8 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
 	/* poll mode */
 	slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open);
 
-	cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
+	cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ?
+			  1 : 0;
 	cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
 	if (!cam_changed) {
 		cam_present_old = (sl->slot_state != SLOT_STAT_NONE);
@@ -344,8 +347,9 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	/* we'll be determining these during this function */
 	sl->da_irq_supported = 0;
 
-	/* set the host link buffer size temporarily. it will be overwritten with the
-	 * real negotiated size later. */
+	/* set the host link buffer size temporarily. it will be overwritten
+	 * with the real negotiated size later.
+	 */
 	sl->link_buf_size = 2;
 
 	/* read the buffer size from the CAM */
@@ -363,7 +367,9 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
 	if (ret != 0)
 		return ret;
 
-	/* store it, and choose the minimum of our buffer and the CAM's buffer size */
+	/* store it, and choose the minimum of our buffer and the CAM's buffer
+	 * size
+	 */
 	buf_size = (buf[0] << 8) | buf[1];
 	if (buf_size > HOST_LINK_BUF_SIZE)
 		buf_size = HOST_LINK_BUF_SIZE;
@@ -432,7 +438,8 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
 
 	/* read in the whole tuple */
 	for (i = 0; i < _tupleLength; i++) {
-		tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i * 2));
+		tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot,
+						       _address + (i * 2));
 		dprintk("  0x%02x: 0x%02x %c\n",
 			i, tuple[i] & 0xff,
 			((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
@@ -572,8 +579,10 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 			sl->config_option = tuple[0] & 0x3f;
 
 			/* OK, check it contains the correct strings */
-			if ((findstr((char *)tuple, tupleLength, "DVB_HOST", 8) == NULL) ||
-			    (findstr((char *)tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL))
+			if ((findstr((char *)tuple, tupleLength,
+				     "DVB_HOST", 8) == NULL) ||
+			    (findstr((char *)tuple, tupleLength,
+				     "DVB_CI_MODULE", 13) == NULL))
 				break;
 
 			got_cftableentry = 1;
@@ -586,7 +595,10 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
 			end_chain = 1;
 			break;
 
-		default:	/* Unknown tuple type - just skip this tuple and move to the next one */
+		/* Unknown tuple type - just skip this tuple and move to the
+		 * next one
+		 */
+		default:
 			dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n",
 				tupleType, tupleLength);
 			break;
@@ -668,7 +680,8 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		}
 		buf_free = dvb_ringbuffer_free(&sl->rx_buffer);
 
-		if (buf_free < (sl->link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
+		if (buf_free < (sl->link_buf_size +
+				DVB_RINGBUFFER_PKTHDRSIZE)) {
 			status = -EAGAIN;
 			goto exit;
 		}
@@ -676,7 +689,8 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 
 	if (ca->pub->read_data && (sl->slot_state != SLOT_STAT_LINKINIT)) {
 		if (ebuf == NULL)
-			status = ca->pub->read_data(ca->pub, slot, buf, sizeof(buf));
+			status = ca->pub->read_data(ca->pub, slot, buf,
+						    sizeof(buf));
 		else
 			status = ca->pub->read_data(ca->pub, slot, buf, ecount);
 		if (status < 0)
@@ -713,7 +727,8 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		if (ebuf == NULL) {
 			if (bytes_read > sl->link_buf_size) {
 				pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
-				       ca->dvbdev->adapter->num, bytes_read, sl->link_buf_size);
+				       ca->dvbdev->adapter->num, bytes_read,
+				       sl->link_buf_size);
 				sl->slot_state = SLOT_STAT_LINKINIT;
 				status = -EIO;
 				goto exit;
@@ -758,7 +773,9 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
 		}
 	}
 
-	/* OK, add it to the receive buffer, or copy into external buffer if supplied */
+	/* OK, add it to the receive buffer, or copy into external buffer if
+	 * supplied
+	 */
 	if (ebuf == NULL) {
 		if (sl->rx_buffer.data == NULL) {
 			status = -EIO;
@@ -909,7 +926,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
 
 
 
-/* ******************************************************************************** */
+/* ************************************************************************** */
 /* EN50221 higher level functions */
 
 
@@ -946,7 +963,8 @@ EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
  * @slot: Slot concerned.
  * @change_type: One of the DVB_CA_CAMCHANGE_* values.
  */
-void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type)
+void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
+				  int change_type)
 {
 	struct dvb_ca_private *ca = pubca->private;
 	struct dvb_ca_slot *sl = &ca->slot_info[slot];
@@ -1021,7 +1039,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 
 
 
-/* ******************************************************************************** */
+/* ************************************************************************** */
 /* EN50221 thread functions */
 
 /**
@@ -1152,16 +1170,22 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 			dvb_ca_en50221_thread_update_delay(ca);
 			break;
 		}
-		// no other action needed; will automatically change state when ready
+		/* no other action needed; will automatically change state when
+		 * ready
+		 */
 		break;
 
 	case SLOT_STAT_VALIDATE:
 		if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
-			/* we need this extra check for annoying interfaces like the budget-av */
-			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
-			    (ca->pub->poll_slot_status)) {
-				status = ca->pub->poll_slot_status(ca->pub, slot, 0);
-				if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
+			/* we need this extra check for annoying interfaces like
+			 * the budget-av
+			 */
+			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
+			    && (ca->pub->poll_slot_status)) {
+				status = ca->pub->poll_slot_status(ca->pub,
+								   slot, 0);
+				if (!(status &
+				      DVB_CA_EN50221_POLL_CAM_PRESENT)) {
 					sl->slot_state = SLOT_STAT_NONE;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
@@ -1182,7 +1206,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 			break;
 		}
 		if (ca->pub->write_cam_control(ca->pub, slot,
-					       CTRLIF_COMMAND, CMDREG_RS) != 0) {
+					       CTRLIF_COMMAND,
+					       CMDREG_RS) != 0) {
 			pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
 			       ca->dvbdev->adapter->num);
 			sl->slot_state = SLOT_STAT_INVALID;
@@ -1214,11 +1239,15 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 
 	case SLOT_STAT_LINKINIT:
 		if (dvb_ca_en50221_link_init(ca, slot) != 0) {
-			/* we need this extra check for annoying interfaces like the budget-av */
-			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
-			    (ca->pub->poll_slot_status)) {
-				status = ca->pub->poll_slot_status(ca->pub, slot, 0);
-				if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
+			/* we need this extra check for annoying interfaces like
+			 * the budget-av
+			 */
+			if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
+			    && (ca->pub->poll_slot_status)) {
+				status = ca->pub->poll_slot_status(ca->pub,
+								   slot, 0);
+				if (!(status &
+				      DVB_CA_EN50221_POLL_CAM_PRESENT)) {
 					sl->slot_state = SLOT_STAT_NONE;
 					dvb_ca_en50221_thread_update_delay(ca);
 					break;
@@ -1241,7 +1270,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 				dvb_ca_en50221_thread_update_delay(ca);
 				break;
 			}
-			dvb_ringbuffer_init(&sl->rx_buffer, rxbuf, RX_BUFFER_SIZE);
+			dvb_ringbuffer_init(&sl->rx_buffer, rxbuf,
+					    RX_BUFFER_SIZE);
 		}
 
 		ca->pub->slot_ts_enable(ca->pub, slot);
@@ -1257,20 +1287,27 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 
 		// poll slots for data
 		pktcount = 0;
-		while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
+		while ((status = dvb_ca_en50221_read_data(ca, slot, NULL,
+							  0)) > 0) {
 			if (!ca->open)
 				break;
 
-			/* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
+			/* if a CAMCHANGE occurred at some point, do not do any
+			 * more processing of this slot
+			 */
 			if (dvb_ca_en50221_check_camstatus(ca, slot)) {
-				// we dont want to sleep on the next iteration so we can handle the cam change
+				/* we don't want to sleep on the next iteration
+				 * so we can handle the CAM change
+				 */
 				ca->wakeup = 1;
 				break;
 			}
 
 			/* check if we've hit our limit this time */
 			if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
-				// dont sleep; there is likely to be more data to read
+				/* don't sleep; there is likely to be more data
+				 * to read
+				 */
 				ca->wakeup = 1;
 				break;
 			}
@@ -1284,7 +1321,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
 
 
 /**
- * Kernel thread which monitors CA slots for CAM changes, and performs data transfers.
+ * Kernel thread which monitors CA slots for CAM changes, and performs data
+ * transfers.
  */
 static int dvb_ca_en50221_thread(void *data)
 {
@@ -1317,7 +1355,7 @@ static int dvb_ca_en50221_thread(void *data)
 
 
 
-/* ******************************************************************************** */
+/* ************************************************************************** */
 /* EN50221 IO interface functions */
 
 /**
@@ -1352,10 +1390,11 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 			mutex_lock(&sl->slot_lock);
 			if (sl->slot_state != SLOT_STAT_NONE) {
 				dvb_ca_en50221_slot_shutdown(ca, slot);
-				if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
-					dvb_ca_en50221_camchange_irq(ca->pub,
-								     slot,
-								     DVB_CA_EN50221_CAMCHANGE_INSERTED);
+				if (ca->flags &
+				    DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
+					dvb_ca_en50221_camchange_irq(
+					    ca->pub, slot,
+					    DVB_CA_EN50221_CAMCHANGE_INSERTED);
 			}
 			mutex_unlock(&sl->slot_lock);
 		}
@@ -1450,7 +1489,9 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 
 	dprintk("%s\n", __func__);
 
-	/* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
+	/* Incoming packet has a 2 byte header. hdr[0] = slot_id,
+	 * hdr[1] = connection_id
+	 */
 	if (count < 2)
 		return -EINVAL;
 
@@ -1488,14 +1529,17 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 		timeout = jiffies + HZ / 2;
 		written = 0;
 		while (!time_after(jiffies, timeout)) {
-			/* check the CAM hasn't been removed/reset in the meantime */
+			/* check the CAM hasn't been removed/reset in the
+			 * meantime
+			 */
 			if (sl->slot_state != SLOT_STAT_RUNNING) {
 				status = -EIO;
 				goto exit;
 			}
 
 			mutex_lock(&sl->slot_lock);
-			status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2);
+			status = dvb_ca_en50221_write_data(ca, slot, fragbuf,
+							   fraglen + 2);
 			mutex_unlock(&sl->slot_lock);
 			if (status == (fraglen + 2)) {
 				written = 1;
@@ -1549,13 +1593,15 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
 			dvb_ringbuffer_pkt_read(&sl->rx_buffer, idx, 0, hdr, 2);
 			if (connection_id == -1)
 				connection_id = hdr[0];
-			if ((hdr[0] == connection_id) && ((hdr[1] & 0x80) == 0)) {
+			if ((hdr[0] == connection_id) &&
+			    ((hdr[1] & 0x80) == 0)) {
 				*_slot = slot;
 				found = 1;
 				break;
 			}
 
-			idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx, &fraglen);
+			idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx,
+						      &fraglen);
 		}
 
 nextslot:
@@ -1597,7 +1643,9 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 
 	dprintk("%s\n", __func__);
 
-	/* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
+	/* Outgoing packet has a 2 byte header. hdr[0] = slot_id,
+	 * hdr[1] = connection_id
+	 */
 	if (count < 2)
 		return -EINVAL;
 
@@ -1610,9 +1658,10 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 			return -EWOULDBLOCK;
 
 		/* wait for some data */
-		status = wait_event_interruptible(ca->wait_queue,
-						  dvb_ca_en50221_io_read_condition
-						  (ca, &result, &slot));
+		status =
+		   wait_event_interruptible(ca->wait_queue,
+					    dvb_ca_en50221_io_read_condition
+					       (ca, &result, &slot));
 	}
 	if ((status < 0) || (result < 0)) {
 		if (result)
@@ -1708,8 +1757,10 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
 
 		if (sl->slot_state == SLOT_STAT_RUNNING) {
 			if (sl->rx_buffer.data != NULL) {
-				/* it is safe to call this here without locks because
-				 * ca->open == 0. Data is not read in this case */
+				/* it is safe to call this here without locks
+				 * because ca->open == 0. Data is not read in
+				 * this case
+				 */
 				dvb_ringbuffer_flush(&sl->rx_buffer);
 			}
 		}
@@ -1813,7 +1864,7 @@ static const struct dvb_device dvbdev_ca = {
 	.fops = &dvb_ca_fops,
 };
 
-/* ******************************************************************************** */
+/* ************************************************************************** */
 /* Initialisation/shutdown functions */
 
 
@@ -1862,7 +1913,8 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	pubca->private = ca;
 
 	/* register the DVB device */
-	ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA, 0);
+	ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,
+				  DVB_DEVICE_CA, 0);
 	if (ret)
 		goto free_slot_info;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/11] [media] dvb-core/dvb_ca_en50221.c: Fixed wrong EXPORT_SYMBOL order
  2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
                   ` (9 preceding siblings ...)
  2017-05-07 21:23 ` [PATCH 10/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 6 Jasmin J.
@ 2017-05-07 21:23 ` Jasmin J.
  10 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-05-07 21:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, max.kellermann, jasmin

From: Jasmin Jessich <jasmin@anw.at>

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index ec9d63e..f4b87a0 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -922,7 +922,6 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
 exitnowrite:
 	return status;
 }
-EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
 
 
 
@@ -931,7 +930,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
 
 
 /**
- * dvb_ca_en50221_camready_irq - A CAM has been removed => shut it down.
+ * dvb_ca_en50221_slot_shutdown - A CAM has been removed => shut it down.
  *
  * @ca: CA instance.
  * @slot: Slot to shut down.
@@ -953,11 +952,10 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
 	/* success */
 	return 0;
 }
-EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
 
 
 /**
- * dvb_ca_en50221_camready_irq - A CAMCHANGE IRQ has occurred.
+ * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred.
  *
  * @ca: CA instance.
  * @slot: Slot concerned.
@@ -984,7 +982,7 @@ void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
 	atomic_inc(&sl->camchange_count);
 	dvb_ca_en50221_thread_wakeup(ca);
 }
-EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
+EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
 
 
 /**
@@ -1005,10 +1003,11 @@ void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
 		dvb_ca_en50221_thread_wakeup(ca);
 	}
 }
+EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
 
 
 /**
- * An FR or DA IRQ has occurred.
+ * dvb_ca_en50221_frda_irq - An FR or DA IRQ has occurred.
  *
  * @ca: CA instance.
  * @slot: Slot concerned.
@@ -1036,7 +1035,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
 		break;
 	}
 }
-
+EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
 
 
 /* ************************************************************************** */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-05-07 21:23 ` [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_?? Jasmin J.
@ 2017-05-08  9:55   ` Mauro Carvalho Chehab
  2017-05-08 17:28     ` Jasmin J.
  0 siblings, 1 reply; 18+ messages in thread
From: Mauro Carvalho Chehab @ 2017-05-08  9:55 UTC (permalink / raw)
  To: Jasmin J.; +Cc: linux-media, max.kellermann

Em Sun,  7 May 2017 23:23:24 +0200
"Jasmin J." <jasmin@anw.at> escreveu:

> From: Jasmin Jessich <jasmin@anw.at>
> 
> Rename STATUSREG_?? -> STATREG_?? to reduce the line length.

That sounds a bad idea. We use "stat" on the DVB subsystem as an
alias for statistics.

> 
> Signed-off-by: Jasmin Jessich <jasmin@anw.at>
> ---
>  drivers/media/dvb-core/dvb_ca_en50221.c | 34 ++++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
> index cc709c9..b978246 100644
> --- a/drivers/media/dvb-core/dvb_ca_en50221.c
> +++ b/drivers/media/dvb-core/dvb_ca_en50221.c
> @@ -72,11 +72,11 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
>  #define CMDREG_DAIE   0x80	/* Enable DA interrupt */
>  #define IRQEN (CMDREG_DAIE)
>  
> -#define STATUSREG_RE     1	/* read error */
> -#define STATUSREG_WE     2	/* write error */
> -#define STATUSREG_FR  0x40	/* module free */
> -#define STATUSREG_DA  0x80	/* data available */
> -#define STATUSREG_TXERR (STATUSREG_RE|STATUSREG_WE)	/* general transfer error */
> +#define STATREG_RE     1	/* read error */
> +#define STATREG_WE     2	/* write error */
> +#define STATREG_FR  0x40	/* module free */
> +#define STATREG_DA  0x80	/* data available */
> +#define STATREG_TXERR (STATREG_RE|STATREG_WE)	/* general transfer error */
>  
>  
>  #define DVB_CA_SLOTSTATE_NONE           0
> @@ -347,7 +347,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
>  	/* read the buffer size from the CAM */
>  	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
>  		return ret;
> -	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ)) != 0)
> +	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_DA, HZ)) != 0)
>  		return ret;
>  	if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
>  		return -EIO;
> @@ -366,7 +366,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
>  	/* write the buffer size to the CAM */
>  	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
>  		return ret;
> -	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0)
> +	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATREG_FR, HZ / 10)) != 0)
>  		return ret;
>  	if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
>  		return -EIO;
> @@ -661,7 +661,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
>  		/* check if there is data available */
>  		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  			goto exit;
> -		if (!(status & STATUSREG_DA)) {
> +		if (!(status & STATREG_DA)) {
>  			/* no data */
>  			status = 0;
>  			goto exit;
> @@ -713,7 +713,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
>  		/* check for read error (RE should now be 0) */
>  		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  			goto exit;
> -		if (status & STATUSREG_RE) {
> +		if (status & STATREG_RE) {
>  			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
>  			status = -EIO;
>  			goto exit;
> @@ -778,8 +778,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
>  	   process the data if necessary. */
>  	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  		goto exitnowrite;
> -	if (status & (STATUSREG_DA | STATUSREG_RE)) {
> -		if (status & STATUSREG_DA)
> +	if (status & (STATREG_DA | STATREG_RE)) {
> +		if (status & STATREG_DA)
>  			dvb_ca_en50221_thread_wakeup(ca);
>  
>  		status = -EAGAIN;
> @@ -794,7 +794,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
>  	/* check if interface is still free */
>  	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  		goto exit;
> -	if (!(status & STATUSREG_FR)) {
> +	if (!(status & STATREG_FR)) {
>  		/* it wasn't free => try again later */
>  		status = -EAGAIN;
>  		goto exit;
> @@ -815,8 +815,8 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
>  	if (status < 0)
>  		goto exit;
>  
> -	if (status & (STATUSREG_DA | STATUSREG_RE)) {
> -		if (status & STATUSREG_DA)
> +	if (status & (STATREG_DA | STATREG_RE)) {
> +		if (status & STATREG_DA)
>  			dvb_ca_en50221_thread_wakeup(ca);
>  
>  		status = -EAGAIN;
> @@ -839,7 +839,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
>  	/* check for write error (WE should now be 0) */
>  	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  		goto exit;
> -	if (status & STATUSREG_WE) {
> +	if (status & STATREG_WE) {
>  		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
>  		status = -EIO;
>  		goto exit;
> @@ -952,7 +952,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
>  	switch (ca->slot_info[slot].slot_state) {
>  	case DVB_CA_SLOTSTATE_LINKINIT:
>  		flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
> -		if (flags & STATUSREG_DA) {
> +		if (flags & STATREG_DA) {
>  			dprintk("CAM supports DA IRQ\n");
>  			ca->slot_info[slot].da_irq_supported = 1;
>  		}
> @@ -1166,7 +1166,7 @@ static int dvb_ca_en50221_thread(void *data)
>  				}
>  
>  				flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
> -				if (flags & STATUSREG_FR) {
> +				if (flags & STATREG_FR) {
>  					ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
>  					ca->wakeup = 1;
>  				}



Thanks,
Mauro

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-05-08  9:55   ` Mauro Carvalho Chehab
@ 2017-05-08 17:28     ` Jasmin J.
  2017-06-07 16:43       ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 18+ messages in thread
From: Jasmin J. @ 2017-05-08 17:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, max.kellermann

Hello Mauro!

 >> Rename STATUSREG_?? -> STATREG_?? to reduce the line length.
 > That sounds a bad idea. We use "stat" on the DVB subsystem as an
 > alias for statistics.
At the beginning of the style fixes, I thought it is a good idea to reduce
as much as possible to get more characters, but at the end this patch
doesn't save so much, so we can omit it.

What is then the right procedure now?
When I omit it in the first place, I can redo the whole work again and
this were a lot of hours. Would it be acceptable to make a patch no. 12 at
the end of the sequence, which renames it back?

BR,
    Jasmin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-05-08 17:28     ` Jasmin J.
@ 2017-06-07 16:43       ` Mauro Carvalho Chehab
  2017-06-07 19:37         ` Jasmin J.
  0 siblings, 1 reply; 18+ messages in thread
From: Mauro Carvalho Chehab @ 2017-06-07 16:43 UTC (permalink / raw)
  To: Jasmin J.; +Cc: linux-media, max.kellermann

Em Mon, 8 May 2017 19:28:48 +0200
"Jasmin J." <jasmin@anw.at> escreveu:

> Hello Mauro!
> 
>  >> Rename STATUSREG_?? -> STATREG_?? to reduce the line length.  
>  > That sounds a bad idea. We use "stat" on the DVB subsystem as an
>  > alias for statistics.  
> At the beginning of the style fixes, I thought it is a good idea to reduce
> as much as possible to get more characters, but at the end this patch
> doesn't save so much, so we can omit it.

Renaming things is usually not a good idea, specially at core level,
as it makes a way harder to apply patches from other sources.

Also, if you're doing that just because of the 80cols warning, that's
the wrong way of doing it ;)

The hole idea when the 80cols warning was introduced is to point places at 
the code were there are potentially too much indentation or code complexity,
possibly indicating complex functions that could otherwise be split.
This is useful when new code gets added, but it usually doesn't make
much sense to fix it on existing code, except when some function has to 
be re-implemented.

So, I please drop patches 1 and 2 from this series.

> What is then the right procedure now?
> When I omit it in the first place, I can redo the whole work again and
> this were a lot of hours. Would it be acceptable to make a patch no. 12 at
> the end of the sequence, which renames it back?

If you want it applied, this is needed anyway, as the patch doesn't apply 
cleanly:

patching file drivers/media/dvb-core/dvb_ca_en50221.c
Hunk #2 FAILED at 347.
Hunk #4 succeeded at 649 (offset -12 lines).
Hunk #5 succeeded at 702 (offset -11 lines).
Hunk #6 succeeded at 763 (offset -15 lines).
Hunk #7 succeeded at 779 (offset -15 lines).
Hunk #8 succeeded at 800 (offset -15 lines).
Hunk #9 succeeded at 824 (offset -15 lines).
Hunk #10 succeeded at 937 (offset -15 lines).
Hunk #11 succeeded at 1151 (offset -15 lines).
1 out of 11 hunks FAILED -- rejects in file drivers/media/dvb-core/dvb_ca_en50221.c
Patch patches/lmml_41185_01_11_media_dvb_core_dvb_ca_en50221_c_rename_statusreg.patch does not apply (enforce with -f)
Patch didn't apply. Aborting

>From this patch series, I was able to apply 2 patches.

Btw, don't spend time fixing issues pointed by checkpatch on existing
code, except if you're rewriting most of the code. We don't want to handle
merge conflicts due to checkpatch-only changes.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-06-07 16:43       ` Mauro Carvalho Chehab
@ 2017-06-07 19:37         ` Jasmin J.
  2017-06-07 22:59           ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 18+ messages in thread
From: Jasmin J. @ 2017-06-07 19:37 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, max.kellermann

Hello Mauro!

> If you want it applied, this is needed anyway, as the patch doesn't apply 
> cleanly:
Because you didn't apply the first series!
In the first series
   [PATCH 0/7] Add block read/write to en50221 CAM functions
I wrote:
 There is another patch series coming soon "Fix coding style in en50221 CAM
 functions" which fixes nearly all the style issues in
 dvb-core/dvb_ca_en50221.c/.h, based on this patch series. So please be
 patient, if any of the dvb_ca_en50221.c/.h might be not 100% checkpatch.pl
 compliant.

It was NOT intended to apply the second series with the code style changes
before the first series! And now, that you accepted two out of this series
the first series might not apply also and I need to rework it.
Sorry for my feelings about this issue, but this is a bit frustrating!

In the preamble of the style fix series I wrote:
 These patch series is a follow up to the series "Add block read/write to
 en50221 CAM functions". It fixed nearly all the style issues reported by
 checkpatch.pl in dvb-core/dvb_ca_en50221.c

I can't do more as writing what is the right order!

> Btw, don't spend time fixing issues pointed by checkpatch on existing
> code, except if you're rewriting most of the code. We don't want to handle
> merge conflicts due to checkpatch-only changes.
I think you are talking about
 [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread
This function is a mess and breaking it into smaller pieces helps for the 80cols
limit and for the complexity. You just wrote:
 > The hole idea when the 80cols warning was introduced is to point places at 
 > the code were there are potentially too much indentation or code complexity,
 > possibly indicating complex functions that could otherwise be split.

But you wrote also:
 > This is useful when new code gets added, but it usually doesn't make
 > much sense to fix it on existing code, except when some function has to 
 > be re-implemented.
I would like to split the thread to make it more readable, but if you say you won't
apply it it makes no sense to put effort on this subject.

So what is your decision about this patch?

BR,
   Jasmin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-06-07 19:37         ` Jasmin J.
@ 2017-06-07 22:59           ` Mauro Carvalho Chehab
  2017-06-08 18:55             ` Jasmin J.
  0 siblings, 1 reply; 18+ messages in thread
From: Mauro Carvalho Chehab @ 2017-06-07 22:59 UTC (permalink / raw)
  To: Jasmin J.; +Cc: linux-media, max.kellermann

Em Wed, 7 Jun 2017 21:37:02 +0200
"Jasmin J." <jasmin@anw.at> escreveu:

> Hello Mauro!
> 
> > If you want it applied, this is needed anyway, as the patch doesn't apply 
> > cleanly:  
> Because you didn't apply the first series!
> In the first series
>    [PATCH 0/7] Add block read/write to en50221 CAM functions
> I wrote:
>  There is another patch series coming soon "Fix coding style in en50221 CAM
>  functions" which fixes nearly all the style issues in
>  dvb-core/dvb_ca_en50221.c/.h, based on this patch series. So please be
>  patient, if any of the dvb_ca_en50221.c/.h might be not 100% checkpatch.pl
>  compliant.
> 
> It was NOT intended to apply the second series with the code style changes
> before the first series! And now, that you accepted two out of this series
> the first series might not apply also and I need to rework it.
> Sorry for my feelings about this issue, but this is a bit frustrating!
> 
> In the preamble of the style fix series I wrote:
>  These patch series is a follow up to the series "Add block read/write to
>  en50221 CAM functions". It fixed nearly all the style issues reported by
>  checkpatch.pl in dvb-core/dvb_ca_en50221.c
> 
> I can't do more as writing what is the right order!

Sorry, I missed it. Unfortunately, patchwork doesn't retrieve patch 00/xx.
So, sometimes I end by not noticing that a patch series has a cover letter.

> > Btw, don't spend time fixing issues pointed by checkpatch on existing
> > code, except if you're rewriting most of the code. We don't want to handle
> > merge conflicts due to checkpatch-only changes.  
> I think you are talking about
>  [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread
> This function is a mess and breaking it into smaller pieces helps for the 80cols
> limit and for the complexity. You just wrote:

No, I'm actually talking about patches 1 and 2 of this series. Renaming
macros just due to 80 cols is usually a bad idea, as it causes conflict
with other stuff.

The idea behind patch 04/11 makes sense to me. I'll review it carefully
after having everything applied.

Please re-send the first series, making sure that the authorship is
preserved.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_??
  2017-06-07 22:59           ` Mauro Carvalho Chehab
@ 2017-06-08 18:55             ` Jasmin J.
  0 siblings, 0 replies; 18+ messages in thread
From: Jasmin J. @ 2017-06-08 18:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, max.kellermann

Hello Mauro!

 > The idea behind patch 04/11 makes sense to me. I'll review it carefully
 > after having everything applied.
Please don't do that now!
The first series will then not be easily changed, because it changes the state
machine. I will provide the first series and when it is applied the second
series again, now that I know what you like.

BR,
    Jasmin

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-06-08 18:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-07 21:23 [PATCH 00/11] Fix coding style in en50221 CAM functions Jasmin J.
2017-05-07 21:23 ` [PATCH 01/11] [media] dvb-core/dvb_ca_en50221.c: Rename STATUSREG_?? Jasmin J.
2017-05-08  9:55   ` Mauro Carvalho Chehab
2017-05-08 17:28     ` Jasmin J.
2017-06-07 16:43       ` Mauro Carvalho Chehab
2017-06-07 19:37         ` Jasmin J.
2017-06-07 22:59           ` Mauro Carvalho Chehab
2017-06-08 18:55             ` Jasmin J.
2017-05-07 21:23 ` [PATCH 02/11] [media] dvb-core/dvb_ca_en50221.c: Rename DVB_CA_SLOTSTATE_??? Jasmin J.
2017-05-07 21:23 ` [PATCH 03/11] [media] dvb-core/dvb_ca_en50221.c: Used a helper variable Jasmin J.
2017-05-07 21:23 ` [PATCH 04/11] [media] dvb-core/dvb_ca_en50221.c: Refactored dvb_ca_en50221_thread Jasmin J.
2017-05-07 21:23 ` [PATCH 05/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 1 Jasmin J.
2017-05-07 21:23 ` [PATCH 06/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 2 Jasmin J.
2017-05-07 21:23 ` [PATCH 07/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 3 Jasmin J.
2017-05-07 21:23 ` [PATCH 08/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 4 Jasmin J.
2017-05-07 21:23 ` [PATCH 09/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 5 Jasmin J.
2017-05-07 21:23 ` [PATCH 10/11] [media] dvb-core/dvb_ca_en50221.c: Make checkpatch happy 6 Jasmin J.
2017-05-07 21:23 ` [PATCH 11/11] [media] dvb-core/dvb_ca_en50221.c: Fixed wrong EXPORT_SYMBOL order Jasmin J.

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.