summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasmin Jessich <jasmin@anw.at>2017-07-15 20:43:03 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-07-20 15:27:50 -0400
commit5d023252cbe4d5164ec812f179b8b2b7fe55f476 (patch)
tree25b2244ef25fd291209af63455f0fc1d904fa1a7
parenta004b70e70d3fca8ea021ad51ebf8e614049332c (diff)
media: dvb_ca_en50221: New function dvb_ca_en50221_poll_cam_gone
The CAM poll code for the budget-av is exactly the same on several places. Extracting the code to a new function improves maintainability. Signed-off-by: Jasmin Jessich <jasmin@anw.at> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/dvb-core/dvb_ca_en50221.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index e2f35b7c59dd..bb6aa0f86c07 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1064,6 +1064,37 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
}
/**
+ * Poll if the CAM is gone.
+ *
+ * @ca: CA instance.
+ * @slot: Slot to process.
+ * @return: 0 .. no change
+ * 1 .. CAM state changed
+ */
+
+static int dvb_ca_en50221_poll_cam_gone(struct dvb_ca_private *ca, int slot)
+{
+ int changed = 0;
+ int status;
+
+ /*
+ * 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;
+ dvb_ca_en50221_thread_update_delay(ca);
+ changed = 1;
+ }
+ }
+ return changed;
+}
+
+/**
* Thread state machine for one CA slot to perform the data transfer.
*
* @ca: CA instance.
@@ -1074,7 +1105,6 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
{
struct dvb_ca_slot *sl = &ca->slot_info[slot];
int flags;
- int status;
int pktcount;
void *rxbuf;
@@ -1124,21 +1154,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
case DVB_CA_SLOTSTATE_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 = DVB_CA_SLOTSTATE_NONE;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- }
+ if (dvb_ca_en50221_poll_cam_gone(ca, slot))
+ break;
pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
ca->dvbdev->adapter->num);
@@ -1187,21 +1204,8 @@ static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
case DVB_CA_SLOTSTATE_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 = DVB_CA_SLOTSTATE_NONE;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- }
+ if (dvb_ca_en50221_poll_cam_gone(ca, slot))
+ break;
pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
ca->dvbdev->adapter->num);