summaryrefslogtreecommitdiff
path: root/drivers/media/dvb/firesat/cmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/firesat/cmp.c')
-rw-r--r--drivers/media/dvb/firesat/cmp.c99
1 files changed, 28 insertions, 71 deletions
diff --git a/drivers/media/dvb/firesat/cmp.c b/drivers/media/dvb/firesat/cmp.c
index a1291caa0674..d1bafba615e4 100644
--- a/drivers/media/dvb/firesat/cmp.c
+++ b/drivers/media/dvb/firesat/cmp.c
@@ -1,8 +1,8 @@
/*
- * FireSAT DVB driver
+ * FireDTV driver (formerly known as FireSAT)
*
- * Copyright (c) ?
- * Copyright (c) 2008 Henrik Kurelid <henrik@kurelid.se>
+ * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
+ * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -10,15 +10,19 @@
* the License, or (at your option) any later version.
*/
-#include "cmp.h"
-#include <ieee1394.h>
-#include <nodemgr.h>
-#include <highlevel.h>
-#include <ohci1394.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+
#include <hosts.h>
+#include <ieee1394.h>
#include <ieee1394_core.h>
#include <ieee1394_transactions.h>
+#include <nodemgr.h>
+
#include "avc_api.h"
+#include "cmp.h"
+#include "firesat.h"
typedef struct _OPCR
{
@@ -38,63 +42,33 @@ typedef struct _OPCR
#define FIRESAT_SPEED IEEE1394_SPEED_400
-/* hpsb_lock is being removed from the kernel-source,
- * therefor we define our own 'firesat_hpsb_lock'*/
-
-int send_packet_and_wait(struct hpsb_packet *packet);
-
-int firesat_hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
- u64 addr, int extcode, quadlet_t * data, quadlet_t arg) {
-
- struct hpsb_packet *packet;
- int retval = 0;
-
- BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
-
- packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
- if (!packet)
- return -ENOMEM;
-
- packet->generation = generation;
- retval = send_packet_and_wait(packet);
- if (retval < 0)
- goto hpsb_lock_fail;
-
- retval = hpsb_packet_success(packet);
-
- if (retval == 0) {
- *data = packet->data[0];
- }
-
- hpsb_lock_fail:
- hpsb_free_tlabel(packet);
- hpsb_free_packet(packet);
-
- return retval;
-}
-
-
-static int cmp_read(struct firesat *firesat, void *buffer, u64 addr, size_t length) {
+static int cmp_read(struct firesat *firesat, void *buf, u64 addr, size_t len)
+{
int ret;
- if(down_interruptible(&firesat->avc_sem))
+
+ if (mutex_lock_interruptible(&firesat->avc_mutex))
return -EINTR;
- ret = hpsb_read(firesat->host, firesat->nodeentry->nodeid, firesat->nodeentry->generation,
- addr, buffer, length);
+ ret = hpsb_read(firesat->host, firesat->nodeentry->nodeid,
+ firesat->nodeentry->generation, addr, buf, len);
- up(&firesat->avc_sem);
+ mutex_unlock(&firesat->avc_mutex);
return ret;
}
-static int cmp_lock(struct firesat *firesat, quadlet_t *data, u64 addr, quadlet_t arg, int ext_tcode) {
+static int cmp_lock(struct firesat *firesat, quadlet_t *data, u64 addr,
+ quadlet_t arg, int ext_tcode)
+{
int ret;
- if(down_interruptible(&firesat->avc_sem))
+
+ if (mutex_lock_interruptible(&firesat->avc_mutex))
return -EINTR;
- ret = firesat_hpsb_lock(firesat->host, firesat->nodeentry->nodeid, firesat->nodeentry->generation,
- addr, ext_tcode, data, arg);
+ ret = hpsb_lock(firesat->host, firesat->nodeentry->nodeid,
+ firesat->nodeentry->generation,
+ addr, ext_tcode, data, arg);
- up(&firesat->avc_sem);
+ mutex_unlock(&firesat->avc_mutex);
return ret;
}
@@ -223,20 +197,3 @@ int try_CMPBreakPPconnection(struct firesat *firesat, int output_plug,int iso_ch
}
return 0;
}
-
-static void complete_packet(void *data) {
- complete((struct completion *) data);
-}
-
-int send_packet_and_wait(struct hpsb_packet *packet) {
- struct completion done;
- int retval;
-
- init_completion(&done);
- hpsb_set_packet_complete_task(packet, complete_packet, &done);
- retval = hpsb_send_packet(packet);
- if (retval == 0)
- wait_for_completion(&done);
-
- return retval;
-}