*
*/
+#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/kdev_t.h>
#include <linux/skbuff.h>
#include <linux/suspend.h>
-#include <linux/kthread.h>
#include <asm/byteorder.h>
#include <asm/semaphore.h>
static void build_speed_map(struct hpsb_host *host, int nodecount)
{
+ u8 speedcap[nodecount];
u8 cldcnt[nodecount];
u8 *map = host->speed_map;
- u8 *speedcap = host->speed;
struct selfid *sid;
struct ext_selfid *esid;
int i, j, n;
}
}
}
-
- /* assume maximum speed for 1394b PHYs, nodemgr will correct it */
- for (n = 0; n < nodecount; n++)
- if (speedcap[n] == 3)
- speedcap[n] = IEEE1394_SPEED_MAX;
}
return 0;
}
- if (packet->type == hpsb_async &&
- NODEID_TO_NODE(packet->node_id) != ALL_NODES)
+ if (packet->type == hpsb_async && packet->node_id != ALL_NODES) {
packet->speed_code =
- host->speed[NODEID_TO_NODE(packet->node_id)];
+ host->speed_map[NODEID_TO_NODE(host->node_id) * 64
+ + NODEID_TO_NODE(packet->node_id)];
+ }
dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
* packets that have a "complete" function are sent here. This way, the
* completion is run out of kernel context, and doesn't block the rest of
* the stack. */
-static struct task_struct *khpsbpkt_thread;
+static int khpsbpkt_pid = -1, khpsbpkt_kill;
+static DECLARE_COMPLETION(khpsbpkt_complete);
static struct sk_buff_head hpsbpkt_queue;
+static DECLARE_MUTEX_LOCKED(khpsbpkt_sig);
+
static void queue_packet_complete(struct hpsb_packet *packet)
{
}
if (packet->complete_routine != NULL) {
skb_queue_tail(&hpsbpkt_queue, packet->skb);
- wake_up_process(khpsbpkt_thread);
+
+ /* Signal the kernel thread to handle this */
+ up(&khpsbpkt_sig);
}
return;
}
void (*complete_routine)(void*);
void *complete_data;
+ daemonize("khpsbpkt");
+
current->flags |= PF_NOFREEZE;
- while (!kthread_should_stop()) {
+ while (1) {
+ if (down_interruptible(&khpsbpkt_sig)) {
+ printk("khpsbpkt: received unexpected signal?!\n" );
+ break;
+ }
+
+ if (khpsbpkt_kill)
+ break;
+
while ((skb = skb_dequeue(&hpsbpkt_queue)) != NULL) {
packet = (struct hpsb_packet *)skb->data;
complete_routine(complete_data);
}
-
- set_current_state(TASK_INTERRUPTIBLE);
- if (!skb_peek(&hpsbpkt_queue))
- schedule();
- __set_current_state(TASK_RUNNING);
}
- return 0;
+
+ complete_and_exit(&khpsbpkt_complete, 0);
}
static int __init ieee1394_init(void)
HPSB_ERR("Some features may not be available\n");
}
- khpsbpkt_thread = kthread_run(hpsbpkt_thread, NULL, "khpsbpkt");
- if (IS_ERR(khpsbpkt_thread)) {
+ khpsbpkt_pid = kernel_thread(hpsbpkt_thread, NULL, CLONE_KERNEL);
+ if (khpsbpkt_pid < 0) {
HPSB_ERR("Failed to start hpsbpkt thread!\n");
- ret = PTR_ERR(khpsbpkt_thread);
+ ret = -ENOMEM;
goto exit_cleanup_config_roms;
}
release_chrdev:
unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
exit_release_kernel_thread:
- kthread_stop(khpsbpkt_thread);
+ if (khpsbpkt_pid >= 0) {
+ kill_proc(khpsbpkt_pid, SIGTERM, 1);
+ wait_for_completion(&khpsbpkt_complete);
+ }
exit_cleanup_config_roms:
hpsb_cleanup_config_roms();
return ret;
bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
bus_unregister(&ieee1394_bus_type);
- kthread_stop(khpsbpkt_thread);
+ if (khpsbpkt_pid >= 0) {
+ khpsbpkt_kill = 1;
+ mb();
+ up(&khpsbpkt_sig);
+ wait_for_completion(&khpsbpkt_complete);
+ }
hpsb_cleanup_config_roms();