4 * Raw interface to the bus
6 * Copyright (C) 1999, 2000 Andreas E. Bombe
7 * 2001, 2002 Manfred Weihs <weihs@ict.tuwien.ac.at>
8 * 2002 Christian Toegel <christian.toegel@gmx.at>
10 * This code is licensed under the GPL. See the file COPYING in the root
11 * directory of the kernel sources for details.
16 * Manfred Weihs <weihs@ict.tuwien.ac.at>
17 * configuration ROM manipulation
18 * address range mapping
19 * adaptation for new (transparent) loopback mechanism
20 * sending of arbitrary async packets
21 * Christian Toegel <christian.toegel@gmx.at>
22 * address range mapping
24 * transmit physical packet
25 * busreset notification control (switch on/off)
26 * busreset with selection of type (short/long)
30 #include <linux/kernel.h>
31 #include <linux/list.h>
32 #include <linux/string.h>
33 #include <linux/slab.h>
35 #include <linux/poll.h>
36 #include <linux/module.h>
37 #include <linux/init.h>
38 #include <linux/interrupt.h>
39 #include <linux/vmalloc.h>
40 #include <linux/cdev.h>
41 #include <asm/uaccess.h>
42 #include <asm/atomic.h>
43 #include <linux/compat.h>
46 #include "highlevel.h"
49 #include "ieee1394_core.h"
50 #include "ieee1394_hotplug.h"
51 #include "ieee1394_transactions.h"
52 #include "ieee1394_types.h"
56 #include "raw1394-private.h"
58 #define int2ptr(x) ((void __user *)(unsigned long)x)
59 #define ptr2int(x) ((u64)(unsigned long)(void __user *)x)
61 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
66 #define DBGMSG(fmt, args...) \
67 printk(KERN_INFO "raw1394:" fmt "\n" , ## args)
69 #define DBGMSG(fmt, args...) do {} while (0)
72 static LIST_HEAD(host_info_list
);
73 static int host_count
;
74 static DEFINE_SPINLOCK(host_info_lock
);
75 static atomic_t internal_generation
= ATOMIC_INIT(0);
77 static atomic_t iso_buffer_size
;
78 static const int iso_buffer_max
= 4 * 1024 * 1024; /* 4 MB */
80 static struct hpsb_highlevel raw1394_highlevel
;
82 static int arm_read(struct hpsb_host
*host
, int nodeid
, quadlet_t
* buffer
,
83 u64 addr
, size_t length
, u16 flags
);
84 static int arm_write(struct hpsb_host
*host
, int nodeid
, int destid
,
85 quadlet_t
* data
, u64 addr
, size_t length
, u16 flags
);
86 static int arm_lock(struct hpsb_host
*host
, int nodeid
, quadlet_t
* store
,
87 u64 addr
, quadlet_t data
, quadlet_t arg
, int ext_tcode
,
89 static int arm_lock64(struct hpsb_host
*host
, int nodeid
, octlet_t
* store
,
90 u64 addr
, octlet_t data
, octlet_t arg
, int ext_tcode
,
92 static struct hpsb_address_ops arm_ops
= {
99 static void queue_complete_cb(struct pending_request
*req
);
101 static struct pending_request
*__alloc_pending_request(gfp_t flags
)
103 struct pending_request
*req
;
105 req
= kzalloc(sizeof(*req
), flags
);
107 INIT_LIST_HEAD(&req
->list
);
112 static inline struct pending_request
*alloc_pending_request(void)
114 return __alloc_pending_request(GFP_KERNEL
);
117 static void free_pending_request(struct pending_request
*req
)
120 if (atomic_dec_and_test(&req
->ibs
->refcount
)) {
121 atomic_sub(req
->ibs
->data_size
, &iso_buffer_size
);
124 } else if (req
->free_data
) {
127 hpsb_free_packet(req
->packet
);
131 /* fi->reqlists_lock must be taken */
132 static void __queue_complete_req(struct pending_request
*req
)
134 struct file_info
*fi
= req
->file_info
;
136 list_move_tail(&req
->list
, &fi
->req_complete
);
137 wake_up(&fi
->wait_complete
);
140 static void queue_complete_req(struct pending_request
*req
)
143 struct file_info
*fi
= req
->file_info
;
145 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
146 __queue_complete_req(req
);
147 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
150 static void queue_complete_cb(struct pending_request
*req
)
152 struct hpsb_packet
*packet
= req
->packet
;
153 int rcode
= (packet
->header
[1] >> 12) & 0xf;
155 switch (packet
->ack_code
) {
157 case ACKX_SEND_ERROR
:
158 req
->req
.error
= RAW1394_ERROR_SEND_ERROR
;
161 req
->req
.error
= RAW1394_ERROR_ABORTED
;
164 req
->req
.error
= RAW1394_ERROR_TIMEOUT
;
167 req
->req
.error
= (packet
->ack_code
<< 16) | rcode
;
171 if (!((packet
->ack_code
== ACK_PENDING
) && (rcode
== RCODE_COMPLETE
))) {
175 if ((req
->req
.type
== RAW1394_REQ_ASYNC_READ
) ||
176 (req
->req
.type
== RAW1394_REQ_ASYNC_WRITE
) ||
177 (req
->req
.type
== RAW1394_REQ_ASYNC_STREAM
) ||
178 (req
->req
.type
== RAW1394_REQ_LOCK
) ||
179 (req
->req
.type
== RAW1394_REQ_LOCK64
))
180 hpsb_free_tlabel(packet
);
182 queue_complete_req(req
);
185 static void add_host(struct hpsb_host
*host
)
187 struct host_info
*hi
;
190 hi
= kmalloc(sizeof(*hi
), GFP_KERNEL
);
193 INIT_LIST_HEAD(&hi
->list
);
195 INIT_LIST_HEAD(&hi
->file_info_list
);
197 spin_lock_irqsave(&host_info_lock
, flags
);
198 list_add_tail(&hi
->list
, &host_info_list
);
200 spin_unlock_irqrestore(&host_info_lock
, flags
);
203 atomic_inc(&internal_generation
);
206 static struct host_info
*find_host_info(struct hpsb_host
*host
)
208 struct host_info
*hi
;
210 list_for_each_entry(hi
, &host_info_list
, list
)
211 if (hi
->host
== host
)
217 static void remove_host(struct hpsb_host
*host
)
219 struct host_info
*hi
;
222 spin_lock_irqsave(&host_info_lock
, flags
);
223 hi
= find_host_info(host
);
229 FIXME: address ranges should be removed
230 and fileinfo states should be initialized
231 (including setting generation to
232 internal-generation ...)
235 spin_unlock_irqrestore(&host_info_lock
, flags
);
238 printk(KERN_ERR
"raw1394: attempt to remove unknown host "
245 atomic_inc(&internal_generation
);
248 static void host_reset(struct hpsb_host
*host
)
251 struct host_info
*hi
;
252 struct file_info
*fi
;
253 struct pending_request
*req
;
255 spin_lock_irqsave(&host_info_lock
, flags
);
256 hi
= find_host_info(host
);
259 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
260 if (fi
->notification
== RAW1394_NOTIFY_ON
) {
261 req
= __alloc_pending_request(GFP_ATOMIC
);
265 req
->req
.type
= RAW1394_REQ_BUS_RESET
;
266 req
->req
.generation
=
267 get_hpsb_generation(host
);
268 req
->req
.misc
= (host
->node_id
<< 16)
270 if (fi
->protocol_version
> 3) {
277 queue_complete_req(req
);
282 spin_unlock_irqrestore(&host_info_lock
, flags
);
285 static void fcp_request(struct hpsb_host
*host
, int nodeid
, int direction
,
286 int cts
, u8
* data
, size_t length
)
289 struct host_info
*hi
;
290 struct file_info
*fi
;
291 struct pending_request
*req
, *req_next
;
292 struct iso_block_store
*ibs
= NULL
;
295 if ((atomic_read(&iso_buffer_size
) + length
) > iso_buffer_max
) {
296 HPSB_INFO("dropped fcp request");
300 spin_lock_irqsave(&host_info_lock
, flags
);
301 hi
= find_host_info(host
);
304 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
308 req
= __alloc_pending_request(GFP_ATOMIC
);
313 ibs
= kmalloc(sizeof(*ibs
) + length
,
320 atomic_add(length
, &iso_buffer_size
);
321 atomic_set(&ibs
->refcount
, 0);
322 ibs
->data_size
= length
;
323 memcpy(ibs
->data
, data
, length
);
326 atomic_inc(&ibs
->refcount
);
330 req
->data
= ibs
->data
;
331 req
->req
.type
= RAW1394_REQ_FCP_REQUEST
;
332 req
->req
.generation
= get_hpsb_generation(host
);
333 req
->req
.misc
= nodeid
| (direction
<< 16);
334 req
->req
.recvb
= ptr2int(fi
->fcp_buffer
);
335 req
->req
.length
= length
;
337 list_add_tail(&req
->list
, &reqs
);
340 spin_unlock_irqrestore(&host_info_lock
, flags
);
342 list_for_each_entry_safe(req
, req_next
, &reqs
, list
)
343 queue_complete_req(req
);
347 struct compat_raw1394_req
{
362 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
363 __attribute__((packed
))
367 static const char __user
*raw1394_compat_write(const char __user
*buf
)
369 struct compat_raw1394_req __user
*cr
= (typeof(cr
)) buf
;
370 struct raw1394_request __user
*r
;
371 r
= compat_alloc_user_space(sizeof(struct raw1394_request
));
373 #define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x))
375 if (copy_in_user(r
, cr
, sizeof(struct compat_raw1394_req
)) ||
380 return ERR_PTR(-EFAULT
);
381 return (const char __user
*)r
;
385 #define P(x) __put_user(r->x, &cr->x)
388 raw1394_compat_read(const char __user
*buf
, struct raw1394_request
*r
)
390 struct compat_raw1394_req __user
*cr
= (typeof(cr
)) buf
;
391 if (!access_ok(VERIFY_WRITE
, cr
, sizeof(struct compat_raw1394_req
)) ||
402 return sizeof(struct compat_raw1394_req
);
408 /* get next completed request (caller must hold fi->reqlists_lock) */
409 static inline struct pending_request
*__next_complete_req(struct file_info
*fi
)
411 struct list_head
*lh
;
412 struct pending_request
*req
= NULL
;
414 if (!list_empty(&fi
->req_complete
)) {
415 lh
= fi
->req_complete
.next
;
417 req
= list_entry(lh
, struct pending_request
, list
);
422 /* atomically get next completed request */
423 static struct pending_request
*next_complete_req(struct file_info
*fi
)
426 struct pending_request
*req
;
428 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
429 req
= __next_complete_req(fi
);
430 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
434 static ssize_t
raw1394_read(struct file
*file
, char __user
* buffer
,
435 size_t count
, loff_t
* offset_is_ignored
)
437 struct file_info
*fi
= (struct file_info
*)file
->private_data
;
438 struct pending_request
*req
;
442 if (count
== sizeof(struct compat_raw1394_req
)) {
446 if (count
!= sizeof(struct raw1394_request
)) {
450 if (!access_ok(VERIFY_WRITE
, buffer
, count
)) {
454 if (file
->f_flags
& O_NONBLOCK
) {
455 if (!(req
= next_complete_req(fi
)))
459 * NB: We call the macro wait_event_interruptible() with a
460 * condition argument with side effect. This is only possible
461 * because the side effect does not occur until the condition
462 * became true, and wait_event_interruptible() won't evaluate
463 * the condition again after that.
465 if (wait_event_interruptible(fi
->wait_complete
,
466 (req
= next_complete_req(fi
))))
470 if (req
->req
.length
) {
471 if (copy_to_user(int2ptr(req
->req
.recvb
), req
->data
,
473 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
478 if (count
== sizeof(struct compat_raw1394_req
) &&
479 sizeof(struct compat_raw1394_req
) !=
480 sizeof(struct raw1394_request
)) {
481 ret
= raw1394_compat_read(buffer
, &req
->req
);
485 if (copy_to_user(buffer
, &req
->req
, sizeof(req
->req
))) {
489 ret
= (ssize_t
) sizeof(struct raw1394_request
);
492 free_pending_request(req
);
496 static int state_opened(struct file_info
*fi
, struct pending_request
*req
)
498 if (req
->req
.type
== RAW1394_REQ_INITIALIZE
) {
499 switch (req
->req
.misc
) {
500 case RAW1394_KERNELAPI_VERSION
:
502 fi
->state
= initialized
;
503 fi
->protocol_version
= req
->req
.misc
;
504 req
->req
.error
= RAW1394_ERROR_NONE
;
505 req
->req
.generation
= atomic_read(&internal_generation
);
509 req
->req
.error
= RAW1394_ERROR_COMPAT
;
510 req
->req
.misc
= RAW1394_KERNELAPI_VERSION
;
513 req
->req
.error
= RAW1394_ERROR_STATE_ORDER
;
517 queue_complete_req(req
);
521 static int state_initialized(struct file_info
*fi
, struct pending_request
*req
)
524 struct host_info
*hi
;
525 struct raw1394_khost_list
*khl
;
527 if (req
->req
.generation
!= atomic_read(&internal_generation
)) {
528 req
->req
.error
= RAW1394_ERROR_GENERATION
;
529 req
->req
.generation
= atomic_read(&internal_generation
);
531 queue_complete_req(req
);
535 switch (req
->req
.type
) {
536 case RAW1394_REQ_LIST_CARDS
:
537 spin_lock_irqsave(&host_info_lock
, flags
);
538 khl
= kmalloc(sizeof(*khl
) * host_count
, GFP_ATOMIC
);
541 req
->req
.misc
= host_count
;
542 req
->data
= (quadlet_t
*) khl
;
544 list_for_each_entry(hi
, &host_info_list
, list
) {
545 khl
->nodes
= hi
->host
->node_count
;
546 strcpy(khl
->name
, hi
->host
->driver
->name
);
550 spin_unlock_irqrestore(&host_info_lock
, flags
);
553 req
->req
.error
= RAW1394_ERROR_NONE
;
554 req
->req
.length
= min(req
->req
.length
,
556 (struct raw1394_khost_list
)
564 case RAW1394_REQ_SET_CARD
:
565 spin_lock_irqsave(&host_info_lock
, flags
);
566 if (req
->req
.misc
>= host_count
) {
567 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
570 list_for_each_entry(hi
, &host_info_list
, list
)
571 if (!req
->req
.misc
--)
573 get_device(&hi
->host
->device
); /* FIXME handle failure case */
574 list_add_tail(&fi
->list
, &hi
->file_info_list
);
576 /* prevent unloading of the host's low-level driver */
577 if (!try_module_get(hi
->host
->driver
->owner
)) {
578 req
->req
.error
= RAW1394_ERROR_ABORTED
;
583 fi
->state
= connected
;
585 req
->req
.error
= RAW1394_ERROR_NONE
;
586 req
->req
.generation
= get_hpsb_generation(fi
->host
);
587 req
->req
.misc
= (fi
->host
->node_id
<< 16)
588 | fi
->host
->node_count
;
589 if (fi
->protocol_version
> 3)
590 req
->req
.misc
|= NODEID_TO_NODE(fi
->host
->irm_id
) << 8;
592 spin_unlock_irqrestore(&host_info_lock
, flags
);
598 req
->req
.error
= RAW1394_ERROR_STATE_ORDER
;
603 queue_complete_req(req
);
607 static void handle_fcp_listen(struct file_info
*fi
, struct pending_request
*req
)
610 if (fi
->fcp_buffer
) {
611 req
->req
.error
= RAW1394_ERROR_ALREADY
;
613 fi
->fcp_buffer
= int2ptr(req
->req
.recvb
);
616 if (!fi
->fcp_buffer
) {
617 req
->req
.error
= RAW1394_ERROR_ALREADY
;
619 fi
->fcp_buffer
= NULL
;
624 queue_complete_req(req
);
627 static int handle_async_request(struct file_info
*fi
,
628 struct pending_request
*req
, int node
)
631 struct hpsb_packet
*packet
= NULL
;
632 u64 addr
= req
->req
.address
& 0xffffffffffffULL
;
634 switch (req
->req
.type
) {
635 case RAW1394_REQ_ASYNC_READ
:
636 DBGMSG("read_request called");
638 hpsb_make_readpacket(fi
->host
, node
, addr
, req
->req
.length
);
643 if (req
->req
.length
== 4)
644 req
->data
= &packet
->header
[3];
646 req
->data
= packet
->data
;
650 case RAW1394_REQ_ASYNC_WRITE
:
651 DBGMSG("write_request called");
653 packet
= hpsb_make_writepacket(fi
->host
, node
, addr
, NULL
,
658 if (req
->req
.length
== 4) {
660 (&packet
->header
[3], int2ptr(req
->req
.sendb
),
662 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
665 (packet
->data
, int2ptr(req
->req
.sendb
),
667 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
673 case RAW1394_REQ_ASYNC_STREAM
:
674 DBGMSG("stream_request called");
677 hpsb_make_streampacket(fi
->host
, NULL
, req
->req
.length
,
678 node
& 0x3f /*channel */ ,
679 (req
->req
.misc
>> 16) & 0x3,
680 req
->req
.misc
& 0xf);
684 if (copy_from_user(packet
->data
, int2ptr(req
->req
.sendb
),
686 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
691 case RAW1394_REQ_LOCK
:
692 DBGMSG("lock_request called");
693 if ((req
->req
.misc
== EXTCODE_FETCH_ADD
)
694 || (req
->req
.misc
== EXTCODE_LITTLE_ADD
)) {
695 if (req
->req
.length
!= 4) {
696 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
700 if (req
->req
.length
!= 8) {
701 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
706 packet
= hpsb_make_lockpacket(fi
->host
, node
, addr
,
707 req
->req
.misc
, NULL
, 0);
711 if (copy_from_user(packet
->data
, int2ptr(req
->req
.sendb
),
713 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
717 req
->data
= packet
->data
;
721 case RAW1394_REQ_LOCK64
:
722 DBGMSG("lock64_request called");
723 if ((req
->req
.misc
== EXTCODE_FETCH_ADD
)
724 || (req
->req
.misc
== EXTCODE_LITTLE_ADD
)) {
725 if (req
->req
.length
!= 8) {
726 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
730 if (req
->req
.length
!= 16) {
731 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
735 packet
= hpsb_make_lock64packet(fi
->host
, node
, addr
,
736 req
->req
.misc
, NULL
, 0);
740 if (copy_from_user(packet
->data
, int2ptr(req
->req
.sendb
),
742 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
746 req
->data
= packet
->data
;
751 req
->req
.error
= RAW1394_ERROR_STATE_ORDER
;
754 req
->packet
= packet
;
756 if (req
->req
.error
) {
758 queue_complete_req(req
);
762 hpsb_set_packet_complete_task(packet
,
763 (void (*)(void *))queue_complete_cb
, req
);
765 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
766 list_add_tail(&req
->list
, &fi
->req_pending
);
767 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
769 packet
->generation
= req
->req
.generation
;
771 if (hpsb_send_packet(packet
) < 0) {
772 req
->req
.error
= RAW1394_ERROR_SEND_ERROR
;
774 hpsb_free_tlabel(packet
);
775 queue_complete_req(req
);
780 static int handle_async_send(struct file_info
*fi
, struct pending_request
*req
)
783 struct hpsb_packet
*packet
;
784 int header_length
= req
->req
.misc
& 0xffff;
785 int expect_response
= req
->req
.misc
>> 16;
788 if (header_length
> req
->req
.length
|| header_length
< 12 ||
789 header_length
> FIELD_SIZEOF(struct hpsb_packet
, header
)) {
790 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
792 queue_complete_req(req
);
796 data_size
= req
->req
.length
- header_length
;
797 packet
= hpsb_alloc_packet(data_size
);
798 req
->packet
= packet
;
802 if (copy_from_user(packet
->header
, int2ptr(req
->req
.sendb
),
804 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
806 queue_complete_req(req
);
811 (packet
->data
, int2ptr(req
->req
.sendb
) + header_length
,
813 req
->req
.error
= RAW1394_ERROR_MEMFAULT
;
815 queue_complete_req(req
);
819 packet
->type
= hpsb_async
;
820 packet
->node_id
= packet
->header
[0] >> 16;
821 packet
->tcode
= (packet
->header
[0] >> 4) & 0xf;
822 packet
->tlabel
= (packet
->header
[0] >> 10) & 0x3f;
823 packet
->host
= fi
->host
;
824 packet
->expect_response
= expect_response
;
825 packet
->header_size
= header_length
;
826 packet
->data_size
= data_size
;
829 hpsb_set_packet_complete_task(packet
,
830 (void (*)(void *))queue_complete_cb
, req
);
832 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
833 list_add_tail(&req
->list
, &fi
->req_pending
);
834 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
836 /* Update the generation of the packet just before sending. */
837 packet
->generation
= req
->req
.generation
;
839 if (hpsb_send_packet(packet
) < 0) {
840 req
->req
.error
= RAW1394_ERROR_SEND_ERROR
;
841 queue_complete_req(req
);
847 static int arm_read(struct hpsb_host
*host
, int nodeid
, quadlet_t
* buffer
,
848 u64 addr
, size_t length
, u16 flags
)
850 unsigned long irqflags
;
851 struct pending_request
*req
;
852 struct host_info
*hi
;
853 struct file_info
*fi
= NULL
;
854 struct list_head
*entry
;
855 struct arm_addr
*arm_addr
= NULL
;
856 struct arm_request
*arm_req
= NULL
;
857 struct arm_response
*arm_resp
= NULL
;
858 int found
= 0, size
= 0, rcode
= -1;
859 struct arm_request_response
*arm_req_resp
= NULL
;
861 DBGMSG("arm_read called by node: %X "
862 "addr: %4.4x %8.8x length: %Zu", nodeid
,
863 (u16
) ((addr
>> 32) & 0xFFFF), (u32
) (addr
& 0xFFFFFFFF),
865 spin_lock_irqsave(&host_info_lock
, irqflags
);
866 hi
= find_host_info(host
); /* search address-entry */
868 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
869 entry
= fi
->addr_list
.next
;
870 while (entry
!= &(fi
->addr_list
)) {
872 list_entry(entry
, struct arm_addr
,
874 if (((arm_addr
->start
) <= (addr
))
875 && ((arm_addr
->end
) >= (addr
+ length
))) {
888 printk(KERN_ERR
"raw1394: arm_read FAILED addr_entry not found"
889 " -> rcode_address_error\n");
890 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
891 return (RCODE_ADDRESS_ERROR
);
893 DBGMSG("arm_read addr_entry FOUND");
895 if (arm_addr
->rec_length
< length
) {
896 DBGMSG("arm_read blocklength too big -> rcode_data_error");
897 rcode
= RCODE_DATA_ERROR
; /* hardware error, data is unavailable */
900 if (arm_addr
->access_rights
& ARM_READ
) {
901 if (!(arm_addr
->client_transactions
& ARM_READ
)) {
903 (arm_addr
->addr_space_buffer
) + (addr
-
907 DBGMSG("arm_read -> (rcode_complete)");
908 rcode
= RCODE_COMPLETE
;
911 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
912 DBGMSG("arm_read -> rcode_type_error (access denied)");
915 if (arm_addr
->notification_options
& ARM_READ
) {
916 DBGMSG("arm_read -> entering notification-section");
917 req
= __alloc_pending_request(GFP_ATOMIC
);
919 DBGMSG("arm_read -> rcode_conflict_error");
920 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
921 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
922 The request may be retried */
924 if (rcode
== RCODE_COMPLETE
) {
926 sizeof(struct arm_request
) +
927 sizeof(struct arm_response
) +
928 length
* sizeof(byte_t
) +
929 sizeof(struct arm_request_response
);
932 sizeof(struct arm_request
) +
933 sizeof(struct arm_response
) +
934 sizeof(struct arm_request_response
);
936 req
->data
= kmalloc(size
, GFP_ATOMIC
);
938 free_pending_request(req
);
939 DBGMSG("arm_read -> rcode_conflict_error");
940 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
941 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
942 The request may be retried */
946 req
->req
.type
= RAW1394_REQ_ARM
;
947 req
->req
.generation
= get_hpsb_generation(host
);
949 (((length
<< 16) & (0xFFFF0000)) | (ARM_READ
& 0xFF));
950 req
->req
.tag
= arm_addr
->arm_tag
;
951 req
->req
.recvb
= arm_addr
->recvb
;
952 req
->req
.length
= size
;
953 arm_req_resp
= (struct arm_request_response
*)(req
->data
);
954 arm_req
= (struct arm_request
*)((byte_t
*) (req
->data
) +
957 arm_request_response
)));
959 (struct arm_response
*)((byte_t
*) (arm_req
) +
960 (sizeof(struct arm_request
)));
961 arm_req
->buffer
= NULL
;
962 arm_resp
->buffer
= NULL
;
963 if (rcode
== RCODE_COMPLETE
) {
965 (byte_t
*) arm_resp
+ sizeof(struct arm_response
);
967 (arm_addr
->addr_space_buffer
) + (addr
-
972 int2ptr((arm_addr
->recvb
) +
973 sizeof(struct arm_request_response
) +
974 sizeof(struct arm_request
) +
975 sizeof(struct arm_response
));
977 arm_resp
->buffer_length
=
978 (rcode
== RCODE_COMPLETE
) ? length
: 0;
979 arm_resp
->response_code
= rcode
;
980 arm_req
->buffer_length
= 0;
981 arm_req
->generation
= req
->req
.generation
;
982 arm_req
->extended_transaction_code
= 0;
983 arm_req
->destination_offset
= addr
;
984 arm_req
->source_nodeid
= nodeid
;
985 arm_req
->destination_nodeid
= host
->node_id
;
986 arm_req
->tlabel
= (flags
>> 10) & 0x3f;
987 arm_req
->tcode
= (flags
>> 4) & 0x0f;
988 arm_req_resp
->request
= int2ptr((arm_addr
->recvb
) +
990 arm_request_response
));
991 arm_req_resp
->response
=
992 int2ptr((arm_addr
->recvb
) +
993 sizeof(struct arm_request_response
) +
994 sizeof(struct arm_request
));
995 queue_complete_req(req
);
997 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1001 static int arm_write(struct hpsb_host
*host
, int nodeid
, int destid
,
1002 quadlet_t
* data
, u64 addr
, size_t length
, u16 flags
)
1004 unsigned long irqflags
;
1005 struct pending_request
*req
;
1006 struct host_info
*hi
;
1007 struct file_info
*fi
= NULL
;
1008 struct list_head
*entry
;
1009 struct arm_addr
*arm_addr
= NULL
;
1010 struct arm_request
*arm_req
= NULL
;
1011 struct arm_response
*arm_resp
= NULL
;
1012 int found
= 0, size
= 0, rcode
= -1, length_conflict
= 0;
1013 struct arm_request_response
*arm_req_resp
= NULL
;
1015 DBGMSG("arm_write called by node: %X "
1016 "addr: %4.4x %8.8x length: %Zu", nodeid
,
1017 (u16
) ((addr
>> 32) & 0xFFFF), (u32
) (addr
& 0xFFFFFFFF),
1019 spin_lock_irqsave(&host_info_lock
, irqflags
);
1020 hi
= find_host_info(host
); /* search address-entry */
1022 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
1023 entry
= fi
->addr_list
.next
;
1024 while (entry
!= &(fi
->addr_list
)) {
1026 list_entry(entry
, struct arm_addr
,
1028 if (((arm_addr
->start
) <= (addr
))
1029 && ((arm_addr
->end
) >= (addr
+ length
))) {
1033 entry
= entry
->next
;
1042 printk(KERN_ERR
"raw1394: arm_write FAILED addr_entry not found"
1043 " -> rcode_address_error\n");
1044 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1045 return (RCODE_ADDRESS_ERROR
);
1047 DBGMSG("arm_write addr_entry FOUND");
1049 if (arm_addr
->rec_length
< length
) {
1050 DBGMSG("arm_write blocklength too big -> rcode_data_error");
1051 length_conflict
= 1;
1052 rcode
= RCODE_DATA_ERROR
; /* hardware error, data is unavailable */
1055 if (arm_addr
->access_rights
& ARM_WRITE
) {
1056 if (!(arm_addr
->client_transactions
& ARM_WRITE
)) {
1057 memcpy((arm_addr
->addr_space_buffer
) +
1058 (addr
- (arm_addr
->start
)), data
,
1060 DBGMSG("arm_write -> (rcode_complete)");
1061 rcode
= RCODE_COMPLETE
;
1064 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
1065 DBGMSG("arm_write -> rcode_type_error (access denied)");
1068 if (arm_addr
->notification_options
& ARM_WRITE
) {
1069 DBGMSG("arm_write -> entering notification-section");
1070 req
= __alloc_pending_request(GFP_ATOMIC
);
1072 DBGMSG("arm_write -> rcode_conflict_error");
1073 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1074 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1075 The request my be retried */
1078 sizeof(struct arm_request
) + sizeof(struct arm_response
) +
1079 (length
) * sizeof(byte_t
) +
1080 sizeof(struct arm_request_response
);
1081 req
->data
= kmalloc(size
, GFP_ATOMIC
);
1083 free_pending_request(req
);
1084 DBGMSG("arm_write -> rcode_conflict_error");
1085 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1086 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1087 The request may be retried */
1090 req
->file_info
= fi
;
1091 req
->req
.type
= RAW1394_REQ_ARM
;
1092 req
->req
.generation
= get_hpsb_generation(host
);
1094 (((length
<< 16) & (0xFFFF0000)) | (ARM_WRITE
& 0xFF));
1095 req
->req
.tag
= arm_addr
->arm_tag
;
1096 req
->req
.recvb
= arm_addr
->recvb
;
1097 req
->req
.length
= size
;
1098 arm_req_resp
= (struct arm_request_response
*)(req
->data
);
1099 arm_req
= (struct arm_request
*)((byte_t
*) (req
->data
) +
1102 arm_request_response
)));
1104 (struct arm_response
*)((byte_t
*) (arm_req
) +
1105 (sizeof(struct arm_request
)));
1106 arm_resp
->buffer
= NULL
;
1107 memcpy((byte_t
*) arm_resp
+ sizeof(struct arm_response
),
1109 arm_req
->buffer
= int2ptr((arm_addr
->recvb
) +
1110 sizeof(struct arm_request_response
) +
1111 sizeof(struct arm_request
) +
1112 sizeof(struct arm_response
));
1113 arm_req
->buffer_length
= length
;
1114 arm_req
->generation
= req
->req
.generation
;
1115 arm_req
->extended_transaction_code
= 0;
1116 arm_req
->destination_offset
= addr
;
1117 arm_req
->source_nodeid
= nodeid
;
1118 arm_req
->destination_nodeid
= destid
;
1119 arm_req
->tlabel
= (flags
>> 10) & 0x3f;
1120 arm_req
->tcode
= (flags
>> 4) & 0x0f;
1121 arm_resp
->buffer_length
= 0;
1122 arm_resp
->response_code
= rcode
;
1123 arm_req_resp
->request
= int2ptr((arm_addr
->recvb
) +
1125 arm_request_response
));
1126 arm_req_resp
->response
=
1127 int2ptr((arm_addr
->recvb
) +
1128 sizeof(struct arm_request_response
) +
1129 sizeof(struct arm_request
));
1130 queue_complete_req(req
);
1132 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1136 static int arm_lock(struct hpsb_host
*host
, int nodeid
, quadlet_t
* store
,
1137 u64 addr
, quadlet_t data
, quadlet_t arg
, int ext_tcode
,
1140 unsigned long irqflags
;
1141 struct pending_request
*req
;
1142 struct host_info
*hi
;
1143 struct file_info
*fi
= NULL
;
1144 struct list_head
*entry
;
1145 struct arm_addr
*arm_addr
= NULL
;
1146 struct arm_request
*arm_req
= NULL
;
1147 struct arm_response
*arm_resp
= NULL
;
1148 int found
= 0, size
= 0, rcode
= -1;
1150 struct arm_request_response
*arm_req_resp
= NULL
;
1152 if (((ext_tcode
& 0xFF) == EXTCODE_FETCH_ADD
) ||
1153 ((ext_tcode
& 0xFF) == EXTCODE_LITTLE_ADD
)) {
1154 DBGMSG("arm_lock called by node: %X "
1155 "addr: %4.4x %8.8x extcode: %2.2X data: %8.8X",
1156 nodeid
, (u16
) ((addr
>> 32) & 0xFFFF),
1157 (u32
) (addr
& 0xFFFFFFFF), ext_tcode
& 0xFF,
1160 DBGMSG("arm_lock called by node: %X "
1161 "addr: %4.4x %8.8x extcode: %2.2X data: %8.8X arg: %8.8X",
1162 nodeid
, (u16
) ((addr
>> 32) & 0xFFFF),
1163 (u32
) (addr
& 0xFFFFFFFF), ext_tcode
& 0xFF,
1164 be32_to_cpu(data
), be32_to_cpu(arg
));
1166 spin_lock_irqsave(&host_info_lock
, irqflags
);
1167 hi
= find_host_info(host
); /* search address-entry */
1169 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
1170 entry
= fi
->addr_list
.next
;
1171 while (entry
!= &(fi
->addr_list
)) {
1173 list_entry(entry
, struct arm_addr
,
1175 if (((arm_addr
->start
) <= (addr
))
1176 && ((arm_addr
->end
) >=
1177 (addr
+ sizeof(*store
)))) {
1181 entry
= entry
->next
;
1190 printk(KERN_ERR
"raw1394: arm_lock FAILED addr_entry not found"
1191 " -> rcode_address_error\n");
1192 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1193 return (RCODE_ADDRESS_ERROR
);
1195 DBGMSG("arm_lock addr_entry FOUND");
1198 if (arm_addr
->access_rights
& ARM_LOCK
) {
1199 if (!(arm_addr
->client_transactions
& ARM_LOCK
)) {
1201 (arm_addr
->addr_space_buffer
) + (addr
-
1205 switch (ext_tcode
) {
1206 case (EXTCODE_MASK_SWAP
):
1207 new = data
| (old
& ~arg
);
1209 case (EXTCODE_COMPARE_SWAP
):
1216 case (EXTCODE_FETCH_ADD
):
1218 cpu_to_be32(be32_to_cpu(data
) +
1221 case (EXTCODE_LITTLE_ADD
):
1223 cpu_to_le32(le32_to_cpu(data
) +
1226 case (EXTCODE_BOUNDED_ADD
):
1229 cpu_to_be32(be32_to_cpu
1237 case (EXTCODE_WRAP_ADD
):
1240 cpu_to_be32(be32_to_cpu
1249 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
1251 "raw1394: arm_lock FAILED "
1252 "ext_tcode not allowed -> rcode_type_error\n");
1256 DBGMSG("arm_lock -> (rcode_complete)");
1257 rcode
= RCODE_COMPLETE
;
1258 memcpy(store
, &old
, sizeof(*store
));
1259 memcpy((arm_addr
->addr_space_buffer
) +
1260 (addr
- (arm_addr
->start
)),
1261 &new, sizeof(*store
));
1265 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
1266 DBGMSG("arm_lock -> rcode_type_error (access denied)");
1269 if (arm_addr
->notification_options
& ARM_LOCK
) {
1270 byte_t
*buf1
, *buf2
;
1271 DBGMSG("arm_lock -> entering notification-section");
1272 req
= __alloc_pending_request(GFP_ATOMIC
);
1274 DBGMSG("arm_lock -> rcode_conflict_error");
1275 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1276 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1277 The request may be retried */
1279 size
= sizeof(struct arm_request
) + sizeof(struct arm_response
) + 3 * sizeof(*store
) + sizeof(struct arm_request_response
); /* maximum */
1280 req
->data
= kmalloc(size
, GFP_ATOMIC
);
1282 free_pending_request(req
);
1283 DBGMSG("arm_lock -> rcode_conflict_error");
1284 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1285 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1286 The request may be retried */
1289 arm_req_resp
= (struct arm_request_response
*)(req
->data
);
1290 arm_req
= (struct arm_request
*)((byte_t
*) (req
->data
) +
1293 arm_request_response
)));
1295 (struct arm_response
*)((byte_t
*) (arm_req
) +
1296 (sizeof(struct arm_request
)));
1297 buf1
= (byte_t
*) arm_resp
+ sizeof(struct arm_response
);
1298 buf2
= buf1
+ 2 * sizeof(*store
);
1299 if ((ext_tcode
== EXTCODE_FETCH_ADD
) ||
1300 (ext_tcode
== EXTCODE_LITTLE_ADD
)) {
1301 arm_req
->buffer_length
= sizeof(*store
);
1302 memcpy(buf1
, &data
, sizeof(*store
));
1305 arm_req
->buffer_length
= 2 * sizeof(*store
);
1306 memcpy(buf1
, &arg
, sizeof(*store
));
1307 memcpy(buf1
+ sizeof(*store
), &data
, sizeof(*store
));
1309 if (rcode
== RCODE_COMPLETE
) {
1310 arm_resp
->buffer_length
= sizeof(*store
);
1311 memcpy(buf2
, &old
, sizeof(*store
));
1313 arm_resp
->buffer_length
= 0;
1315 req
->file_info
= fi
;
1316 req
->req
.type
= RAW1394_REQ_ARM
;
1317 req
->req
.generation
= get_hpsb_generation(host
);
1318 req
->req
.misc
= ((((sizeof(*store
)) << 16) & (0xFFFF0000)) |
1320 req
->req
.tag
= arm_addr
->arm_tag
;
1321 req
->req
.recvb
= arm_addr
->recvb
;
1322 req
->req
.length
= size
;
1323 arm_req
->generation
= req
->req
.generation
;
1324 arm_req
->extended_transaction_code
= ext_tcode
;
1325 arm_req
->destination_offset
= addr
;
1326 arm_req
->source_nodeid
= nodeid
;
1327 arm_req
->destination_nodeid
= host
->node_id
;
1328 arm_req
->tlabel
= (flags
>> 10) & 0x3f;
1329 arm_req
->tcode
= (flags
>> 4) & 0x0f;
1330 arm_resp
->response_code
= rcode
;
1331 arm_req_resp
->request
= int2ptr((arm_addr
->recvb
) +
1333 arm_request_response
));
1334 arm_req_resp
->response
=
1335 int2ptr((arm_addr
->recvb
) +
1336 sizeof(struct arm_request_response
) +
1337 sizeof(struct arm_request
));
1339 int2ptr((arm_addr
->recvb
) +
1340 sizeof(struct arm_request_response
) +
1341 sizeof(struct arm_request
) +
1342 sizeof(struct arm_response
));
1344 int2ptr((arm_addr
->recvb
) +
1345 sizeof(struct arm_request_response
) +
1346 sizeof(struct arm_request
) +
1347 sizeof(struct arm_response
) + 2 * sizeof(*store
));
1348 queue_complete_req(req
);
1350 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1354 static int arm_lock64(struct hpsb_host
*host
, int nodeid
, octlet_t
* store
,
1355 u64 addr
, octlet_t data
, octlet_t arg
, int ext_tcode
,
1358 unsigned long irqflags
;
1359 struct pending_request
*req
;
1360 struct host_info
*hi
;
1361 struct file_info
*fi
= NULL
;
1362 struct list_head
*entry
;
1363 struct arm_addr
*arm_addr
= NULL
;
1364 struct arm_request
*arm_req
= NULL
;
1365 struct arm_response
*arm_resp
= NULL
;
1366 int found
= 0, size
= 0, rcode
= -1;
1368 struct arm_request_response
*arm_req_resp
= NULL
;
1370 if (((ext_tcode
& 0xFF) == EXTCODE_FETCH_ADD
) ||
1371 ((ext_tcode
& 0xFF) == EXTCODE_LITTLE_ADD
)) {
1372 DBGMSG("arm_lock64 called by node: %X "
1373 "addr: %4.4x %8.8x extcode: %2.2X data: %8.8X %8.8X ",
1374 nodeid
, (u16
) ((addr
>> 32) & 0xFFFF),
1375 (u32
) (addr
& 0xFFFFFFFF),
1377 (u32
) ((be64_to_cpu(data
) >> 32) & 0xFFFFFFFF),
1378 (u32
) (be64_to_cpu(data
) & 0xFFFFFFFF));
1380 DBGMSG("arm_lock64 called by node: %X "
1381 "addr: %4.4x %8.8x extcode: %2.2X data: %8.8X %8.8X arg: "
1383 nodeid
, (u16
) ((addr
>> 32) & 0xFFFF),
1384 (u32
) (addr
& 0xFFFFFFFF),
1386 (u32
) ((be64_to_cpu(data
) >> 32) & 0xFFFFFFFF),
1387 (u32
) (be64_to_cpu(data
) & 0xFFFFFFFF),
1388 (u32
) ((be64_to_cpu(arg
) >> 32) & 0xFFFFFFFF),
1389 (u32
) (be64_to_cpu(arg
) & 0xFFFFFFFF));
1391 spin_lock_irqsave(&host_info_lock
, irqflags
);
1392 hi
= find_host_info(host
); /* search addressentry in file_info's for host */
1394 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
1395 entry
= fi
->addr_list
.next
;
1396 while (entry
!= &(fi
->addr_list
)) {
1398 list_entry(entry
, struct arm_addr
,
1400 if (((arm_addr
->start
) <= (addr
))
1401 && ((arm_addr
->end
) >=
1402 (addr
+ sizeof(*store
)))) {
1406 entry
= entry
->next
;
1416 "raw1394: arm_lock64 FAILED addr_entry not found"
1417 " -> rcode_address_error\n");
1418 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1419 return (RCODE_ADDRESS_ERROR
);
1421 DBGMSG("arm_lock64 addr_entry FOUND");
1424 if (arm_addr
->access_rights
& ARM_LOCK
) {
1425 if (!(arm_addr
->client_transactions
& ARM_LOCK
)) {
1427 (arm_addr
->addr_space_buffer
) + (addr
-
1431 switch (ext_tcode
) {
1432 case (EXTCODE_MASK_SWAP
):
1433 new = data
| (old
& ~arg
);
1435 case (EXTCODE_COMPARE_SWAP
):
1442 case (EXTCODE_FETCH_ADD
):
1444 cpu_to_be64(be64_to_cpu(data
) +
1447 case (EXTCODE_LITTLE_ADD
):
1449 cpu_to_le64(le64_to_cpu(data
) +
1452 case (EXTCODE_BOUNDED_ADD
):
1455 cpu_to_be64(be64_to_cpu
1463 case (EXTCODE_WRAP_ADD
):
1466 cpu_to_be64(be64_to_cpu
1476 "raw1394: arm_lock64 FAILED "
1477 "ext_tcode not allowed -> rcode_type_error\n");
1478 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
1483 ("arm_lock64 -> (rcode_complete)");
1484 rcode
= RCODE_COMPLETE
;
1485 memcpy(store
, &old
, sizeof(*store
));
1486 memcpy((arm_addr
->addr_space_buffer
) +
1487 (addr
- (arm_addr
->start
)),
1488 &new, sizeof(*store
));
1492 rcode
= RCODE_TYPE_ERROR
; /* function not allowed */
1494 ("arm_lock64 -> rcode_type_error (access denied)");
1497 if (arm_addr
->notification_options
& ARM_LOCK
) {
1498 byte_t
*buf1
, *buf2
;
1499 DBGMSG("arm_lock64 -> entering notification-section");
1500 req
= __alloc_pending_request(GFP_ATOMIC
);
1502 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1503 DBGMSG("arm_lock64 -> rcode_conflict_error");
1504 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1505 The request may be retried */
1507 size
= sizeof(struct arm_request
) + sizeof(struct arm_response
) + 3 * sizeof(*store
) + sizeof(struct arm_request_response
); /* maximum */
1508 req
->data
= kmalloc(size
, GFP_ATOMIC
);
1510 free_pending_request(req
);
1511 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1512 DBGMSG("arm_lock64 -> rcode_conflict_error");
1513 return (RCODE_CONFLICT_ERROR
); /* A resource conflict was detected.
1514 The request may be retried */
1517 arm_req_resp
= (struct arm_request_response
*)(req
->data
);
1518 arm_req
= (struct arm_request
*)((byte_t
*) (req
->data
) +
1521 arm_request_response
)));
1523 (struct arm_response
*)((byte_t
*) (arm_req
) +
1524 (sizeof(struct arm_request
)));
1525 buf1
= (byte_t
*) arm_resp
+ sizeof(struct arm_response
);
1526 buf2
= buf1
+ 2 * sizeof(*store
);
1527 if ((ext_tcode
== EXTCODE_FETCH_ADD
) ||
1528 (ext_tcode
== EXTCODE_LITTLE_ADD
)) {
1529 arm_req
->buffer_length
= sizeof(*store
);
1530 memcpy(buf1
, &data
, sizeof(*store
));
1533 arm_req
->buffer_length
= 2 * sizeof(*store
);
1534 memcpy(buf1
, &arg
, sizeof(*store
));
1535 memcpy(buf1
+ sizeof(*store
), &data
, sizeof(*store
));
1537 if (rcode
== RCODE_COMPLETE
) {
1538 arm_resp
->buffer_length
= sizeof(*store
);
1539 memcpy(buf2
, &old
, sizeof(*store
));
1541 arm_resp
->buffer_length
= 0;
1543 req
->file_info
= fi
;
1544 req
->req
.type
= RAW1394_REQ_ARM
;
1545 req
->req
.generation
= get_hpsb_generation(host
);
1546 req
->req
.misc
= ((((sizeof(*store
)) << 16) & (0xFFFF0000)) |
1548 req
->req
.tag
= arm_addr
->arm_tag
;
1549 req
->req
.recvb
= arm_addr
->recvb
;
1550 req
->req
.length
= size
;
1551 arm_req
->generation
= req
->req
.generation
;
1552 arm_req
->extended_transaction_code
= ext_tcode
;
1553 arm_req
->destination_offset
= addr
;
1554 arm_req
->source_nodeid
= nodeid
;
1555 arm_req
->destination_nodeid
= host
->node_id
;
1556 arm_req
->tlabel
= (flags
>> 10) & 0x3f;
1557 arm_req
->tcode
= (flags
>> 4) & 0x0f;
1558 arm_resp
->response_code
= rcode
;
1559 arm_req_resp
->request
= int2ptr((arm_addr
->recvb
) +
1561 arm_request_response
));
1562 arm_req_resp
->response
=
1563 int2ptr((arm_addr
->recvb
) +
1564 sizeof(struct arm_request_response
) +
1565 sizeof(struct arm_request
));
1567 int2ptr((arm_addr
->recvb
) +
1568 sizeof(struct arm_request_response
) +
1569 sizeof(struct arm_request
) +
1570 sizeof(struct arm_response
));
1572 int2ptr((arm_addr
->recvb
) +
1573 sizeof(struct arm_request_response
) +
1574 sizeof(struct arm_request
) +
1575 sizeof(struct arm_response
) + 2 * sizeof(*store
));
1576 queue_complete_req(req
);
1578 spin_unlock_irqrestore(&host_info_lock
, irqflags
);
1582 static int arm_register(struct file_info
*fi
, struct pending_request
*req
)
1585 struct arm_addr
*addr
;
1586 struct host_info
*hi
;
1587 struct file_info
*fi_hlp
= NULL
;
1588 struct list_head
*entry
;
1589 struct arm_addr
*arm_addr
= NULL
;
1590 int same_host
, another_host
;
1591 unsigned long flags
;
1593 DBGMSG("arm_register called "
1594 "addr(Offset): %8.8x %8.8x length: %u "
1595 "rights: %2.2X notify: %2.2X "
1596 "max_blk_len: %4.4X",
1597 (u32
) ((req
->req
.address
>> 32) & 0xFFFF),
1598 (u32
) (req
->req
.address
& 0xFFFFFFFF),
1599 req
->req
.length
, ((req
->req
.misc
>> 8) & 0xFF),
1600 (req
->req
.misc
& 0xFF), ((req
->req
.misc
>> 16) & 0xFFFF));
1601 /* check addressrange */
1602 if ((((req
->req
.address
) & ~(0xFFFFFFFFFFFFULL
)) != 0) ||
1603 (((req
->req
.address
+ req
->req
.length
) & ~(0xFFFFFFFFFFFFULL
)) !=
1605 req
->req
.length
= 0;
1608 /* addr-list-entry for fileinfo */
1609 addr
= kmalloc(sizeof(*addr
), GFP_KERNEL
);
1611 req
->req
.length
= 0;
1614 /* allocation of addr_space_buffer */
1615 addr
->addr_space_buffer
= vmalloc(req
->req
.length
);
1616 if (!(addr
->addr_space_buffer
)) {
1618 req
->req
.length
= 0;
1621 /* initialization of addr_space_buffer */
1622 if ((req
->req
.sendb
) == (unsigned long)NULL
) {
1624 memset(addr
->addr_space_buffer
, 0, req
->req
.length
);
1626 /* init: user -> kernel */
1628 (addr
->addr_space_buffer
, int2ptr(req
->req
.sendb
),
1630 vfree(addr
->addr_space_buffer
);
1635 INIT_LIST_HEAD(&addr
->addr_list
);
1636 addr
->arm_tag
= req
->req
.tag
;
1637 addr
->start
= req
->req
.address
;
1638 addr
->end
= req
->req
.address
+ req
->req
.length
;
1639 addr
->access_rights
= (u8
) (req
->req
.misc
& 0x0F);
1640 addr
->notification_options
= (u8
) ((req
->req
.misc
>> 4) & 0x0F);
1641 addr
->client_transactions
= (u8
) ((req
->req
.misc
>> 8) & 0x0F);
1642 addr
->access_rights
|= addr
->client_transactions
;
1643 addr
->notification_options
|= addr
->client_transactions
;
1644 addr
->recvb
= req
->req
.recvb
;
1645 addr
->rec_length
= (u16
) ((req
->req
.misc
>> 16) & 0xFFFF);
1647 spin_lock_irqsave(&host_info_lock
, flags
);
1648 hi
= find_host_info(fi
->host
);
1651 /* same host with address-entry containing same addressrange ? */
1652 list_for_each_entry(fi_hlp
, &hi
->file_info_list
, list
) {
1653 entry
= fi_hlp
->addr_list
.next
;
1654 while (entry
!= &(fi_hlp
->addr_list
)) {
1656 list_entry(entry
, struct arm_addr
, addr_list
);
1657 if ((arm_addr
->start
== addr
->start
)
1658 && (arm_addr
->end
== addr
->end
)) {
1659 DBGMSG("same host ownes same "
1660 "addressrange -> EALREADY");
1664 entry
= entry
->next
;
1671 /* addressrange occupied by same host */
1672 spin_unlock_irqrestore(&host_info_lock
, flags
);
1673 vfree(addr
->addr_space_buffer
);
1677 /* another host with valid address-entry containing same addressrange */
1678 list_for_each_entry(hi
, &host_info_list
, list
) {
1679 if (hi
->host
!= fi
->host
) {
1680 list_for_each_entry(fi_hlp
, &hi
->file_info_list
, list
) {
1681 entry
= fi_hlp
->addr_list
.next
;
1682 while (entry
!= &(fi_hlp
->addr_list
)) {
1684 list_entry(entry
, struct arm_addr
,
1686 if ((arm_addr
->start
== addr
->start
)
1687 && (arm_addr
->end
== addr
->end
)) {
1689 ("another host ownes same "
1694 entry
= entry
->next
;
1702 spin_unlock_irqrestore(&host_info_lock
, flags
);
1705 DBGMSG("another hosts entry is valid -> SUCCESS");
1706 if (copy_to_user(int2ptr(req
->req
.recvb
),
1707 &addr
->start
, sizeof(u64
))) {
1708 printk(KERN_ERR
"raw1394: arm_register failed "
1709 " address-range-entry is invalid -> EFAULT !!!\n");
1710 vfree(addr
->addr_space_buffer
);
1714 free_pending_request(req
); /* immediate success or fail */
1716 spin_lock_irqsave(&host_info_lock
, flags
);
1717 list_add_tail(&addr
->addr_list
, &fi
->addr_list
);
1718 spin_unlock_irqrestore(&host_info_lock
, flags
);
1722 hpsb_register_addrspace(&raw1394_highlevel
, fi
->host
, &arm_ops
,
1724 req
->req
.address
+ req
->req
.length
);
1727 spin_lock_irqsave(&host_info_lock
, flags
);
1728 list_add_tail(&addr
->addr_list
, &fi
->addr_list
);
1729 spin_unlock_irqrestore(&host_info_lock
, flags
);
1731 DBGMSG("arm_register failed errno: %d \n", retval
);
1732 vfree(addr
->addr_space_buffer
);
1736 free_pending_request(req
); /* immediate success or fail */
1740 static int arm_unregister(struct file_info
*fi
, struct pending_request
*req
)
1744 struct list_head
*entry
;
1745 struct arm_addr
*addr
= NULL
;
1746 struct host_info
*hi
;
1747 struct file_info
*fi_hlp
= NULL
;
1748 struct arm_addr
*arm_addr
= NULL
;
1750 unsigned long flags
;
1752 DBGMSG("arm_Unregister called addr(Offset): "
1754 (u32
) ((req
->req
.address
>> 32) & 0xFFFF),
1755 (u32
) (req
->req
.address
& 0xFFFFFFFF));
1756 spin_lock_irqsave(&host_info_lock
, flags
);
1758 entry
= fi
->addr_list
.next
;
1759 while (entry
!= &(fi
->addr_list
)) {
1760 addr
= list_entry(entry
, struct arm_addr
, addr_list
);
1761 if (addr
->start
== req
->req
.address
) {
1765 entry
= entry
->next
;
1768 DBGMSG("arm_Unregister addr not found");
1769 spin_unlock_irqrestore(&host_info_lock
, flags
);
1772 DBGMSG("arm_Unregister addr found");
1774 /* another host with valid address-entry containing
1775 same addressrange */
1776 list_for_each_entry(hi
, &host_info_list
, list
) {
1777 if (hi
->host
!= fi
->host
) {
1778 list_for_each_entry(fi_hlp
, &hi
->file_info_list
, list
) {
1779 entry
= fi_hlp
->addr_list
.next
;
1780 while (entry
!= &(fi_hlp
->addr_list
)) {
1781 arm_addr
= list_entry(entry
,
1784 if (arm_addr
->start
== addr
->start
) {
1785 DBGMSG("another host ownes "
1786 "same addressrange");
1790 entry
= entry
->next
;
1799 DBGMSG("delete entry from list -> success");
1800 list_del(&addr
->addr_list
);
1801 spin_unlock_irqrestore(&host_info_lock
, flags
);
1802 vfree(addr
->addr_space_buffer
);
1804 free_pending_request(req
); /* immediate success or fail */
1808 hpsb_unregister_addrspace(&raw1394_highlevel
, fi
->host
,
1811 printk(KERN_ERR
"raw1394: arm_Unregister failed -> EINVAL\n");
1812 spin_unlock_irqrestore(&host_info_lock
, flags
);
1815 DBGMSG("delete entry from list -> success");
1816 list_del(&addr
->addr_list
);
1817 spin_unlock_irqrestore(&host_info_lock
, flags
);
1818 vfree(addr
->addr_space_buffer
);
1820 free_pending_request(req
); /* immediate success or fail */
1824 /* Copy data from ARM buffer(s) to user buffer. */
1825 static int arm_get_buf(struct file_info
*fi
, struct pending_request
*req
)
1827 struct arm_addr
*arm_addr
= NULL
;
1828 unsigned long flags
;
1829 unsigned long offset
;
1831 struct list_head
*entry
;
1833 DBGMSG("arm_get_buf "
1834 "addr(Offset): %04X %08X length: %u",
1835 (u32
) ((req
->req
.address
>> 32) & 0xFFFF),
1836 (u32
) (req
->req
.address
& 0xFFFFFFFF), (u32
) req
->req
.length
);
1838 spin_lock_irqsave(&host_info_lock
, flags
);
1839 entry
= fi
->addr_list
.next
;
1840 while (entry
!= &(fi
->addr_list
)) {
1841 arm_addr
= list_entry(entry
, struct arm_addr
, addr_list
);
1842 if ((arm_addr
->start
<= req
->req
.address
) &&
1843 (arm_addr
->end
> req
->req
.address
)) {
1844 if (req
->req
.address
+ req
->req
.length
<= arm_addr
->end
) {
1845 offset
= req
->req
.address
- arm_addr
->start
;
1846 spin_unlock_irqrestore(&host_info_lock
, flags
);
1849 ("arm_get_buf copy_to_user( %08X, %p, %u )",
1850 (u32
) req
->req
.recvb
,
1851 arm_addr
->addr_space_buffer
+ offset
,
1852 (u32
) req
->req
.length
);
1854 (int2ptr(req
->req
.recvb
),
1855 arm_addr
->addr_space_buffer
+ offset
,
1859 /* We have to free the request, because we
1860 * queue no response, and therefore nobody
1862 free_pending_request(req
);
1865 DBGMSG("arm_get_buf request exceeded mapping");
1866 spin_unlock_irqrestore(&host_info_lock
, flags
);
1870 entry
= entry
->next
;
1872 spin_unlock_irqrestore(&host_info_lock
, flags
);
1876 /* Copy data from user buffer to ARM buffer(s). */
1877 static int arm_set_buf(struct file_info
*fi
, struct pending_request
*req
)
1879 struct arm_addr
*arm_addr
= NULL
;
1880 unsigned long flags
;
1881 unsigned long offset
;
1883 struct list_head
*entry
;
1885 DBGMSG("arm_set_buf "
1886 "addr(Offset): %04X %08X length: %u",
1887 (u32
) ((req
->req
.address
>> 32) & 0xFFFF),
1888 (u32
) (req
->req
.address
& 0xFFFFFFFF), (u32
) req
->req
.length
);
1890 spin_lock_irqsave(&host_info_lock
, flags
);
1891 entry
= fi
->addr_list
.next
;
1892 while (entry
!= &(fi
->addr_list
)) {
1893 arm_addr
= list_entry(entry
, struct arm_addr
, addr_list
);
1894 if ((arm_addr
->start
<= req
->req
.address
) &&
1895 (arm_addr
->end
> req
->req
.address
)) {
1896 if (req
->req
.address
+ req
->req
.length
<= arm_addr
->end
) {
1897 offset
= req
->req
.address
- arm_addr
->start
;
1898 spin_unlock_irqrestore(&host_info_lock
, flags
);
1901 ("arm_set_buf copy_from_user( %p, %08X, %u )",
1902 arm_addr
->addr_space_buffer
+ offset
,
1903 (u32
) req
->req
.sendb
,
1904 (u32
) req
->req
.length
);
1906 (arm_addr
->addr_space_buffer
+ offset
,
1907 int2ptr(req
->req
.sendb
),
1911 /* We have to free the request, because we
1912 * queue no response, and therefore nobody
1914 free_pending_request(req
);
1917 DBGMSG("arm_set_buf request exceeded mapping");
1918 spin_unlock_irqrestore(&host_info_lock
, flags
);
1922 entry
= entry
->next
;
1924 spin_unlock_irqrestore(&host_info_lock
, flags
);
1928 static int reset_notification(struct file_info
*fi
, struct pending_request
*req
)
1930 DBGMSG("reset_notification called - switch %s ",
1931 (req
->req
.misc
== RAW1394_NOTIFY_OFF
) ? "OFF" : "ON");
1932 if ((req
->req
.misc
== RAW1394_NOTIFY_OFF
) ||
1933 (req
->req
.misc
== RAW1394_NOTIFY_ON
)) {
1934 fi
->notification
= (u8
) req
->req
.misc
;
1935 free_pending_request(req
); /* we have to free the request, because we queue no response, and therefore nobody will free it */
1938 /* error EINVAL (22) invalid argument */
1942 static int write_phypacket(struct file_info
*fi
, struct pending_request
*req
)
1944 struct hpsb_packet
*packet
= NULL
;
1947 unsigned long flags
;
1949 data
= be32_to_cpu((u32
) req
->req
.sendb
);
1950 DBGMSG("write_phypacket called - quadlet 0x%8.8x ", data
);
1951 packet
= hpsb_make_phypacket(fi
->host
, data
);
1954 req
->req
.length
= 0;
1955 req
->packet
= packet
;
1956 hpsb_set_packet_complete_task(packet
,
1957 (void (*)(void *))queue_complete_cb
, req
);
1958 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
1959 list_add_tail(&req
->list
, &fi
->req_pending
);
1960 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
1961 packet
->generation
= req
->req
.generation
;
1962 retval
= hpsb_send_packet(packet
);
1963 DBGMSG("write_phypacket send_packet called => retval: %d ", retval
);
1965 req
->req
.error
= RAW1394_ERROR_SEND_ERROR
;
1966 req
->req
.length
= 0;
1967 queue_complete_req(req
);
1972 static int get_config_rom(struct file_info
*fi
, struct pending_request
*req
)
1975 quadlet_t
*data
= kmalloc(req
->req
.length
, GFP_KERNEL
);
1982 csr1212_read(fi
->host
->csr
.rom
, CSR1212_CONFIG_ROM_SPACE_OFFSET
,
1983 data
, req
->req
.length
);
1984 if (copy_to_user(int2ptr(req
->req
.recvb
), data
, req
->req
.length
))
1987 (int2ptr(req
->req
.tag
), &fi
->host
->csr
.rom
->cache_head
->len
,
1988 sizeof(fi
->host
->csr
.rom
->cache_head
->len
)))
1990 if (copy_to_user(int2ptr(req
->req
.address
), &fi
->host
->csr
.generation
,
1991 sizeof(fi
->host
->csr
.generation
)))
1993 if (copy_to_user(int2ptr(req
->req
.sendb
), &status
, sizeof(status
)))
1997 free_pending_request(req
); /* we have to free the request, because we queue no response, and therefore nobody will free it */
2002 static int update_config_rom(struct file_info
*fi
, struct pending_request
*req
)
2005 quadlet_t
*data
= kmalloc(req
->req
.length
, GFP_KERNEL
);
2008 if (copy_from_user(data
, int2ptr(req
->req
.sendb
), req
->req
.length
)) {
2011 int status
= hpsb_update_config_rom(fi
->host
,
2012 data
, req
->req
.length
,
2013 (unsigned char)req
->req
.
2016 (int2ptr(req
->req
.recvb
), &status
, sizeof(status
)))
2021 free_pending_request(req
); /* we have to free the request, because we queue no response, and therefore nobody will free it */
2027 static int modify_config_rom(struct file_info
*fi
, struct pending_request
*req
)
2029 struct csr1212_keyval
*kv
;
2030 struct csr1212_csr_rom_cache
*cache
;
2031 struct csr1212_dentry
*dentry
;
2035 if (req
->req
.misc
== ~0) {
2036 if (req
->req
.length
== 0)
2039 /* Find an unused slot */
2041 dr
< RAW1394_MAX_USER_CSR_DIRS
&& fi
->csr1212_dirs
[dr
];
2044 if (dr
== RAW1394_MAX_USER_CSR_DIRS
)
2047 fi
->csr1212_dirs
[dr
] =
2048 csr1212_new_directory(CSR1212_KV_ID_VENDOR
);
2049 if (!fi
->csr1212_dirs
[dr
])
2053 if (!fi
->csr1212_dirs
[dr
])
2056 /* Delete old stuff */
2058 fi
->csr1212_dirs
[dr
]->value
.directory
.dentries_head
;
2059 dentry
; dentry
= dentry
->next
) {
2060 csr1212_detach_keyval_from_directory(fi
->host
->csr
.rom
->
2065 if (req
->req
.length
== 0) {
2066 csr1212_release_keyval(fi
->csr1212_dirs
[dr
]);
2067 fi
->csr1212_dirs
[dr
] = NULL
;
2069 hpsb_update_config_rom_image(fi
->host
);
2070 free_pending_request(req
);
2075 cache
= csr1212_rom_cache_malloc(0, req
->req
.length
);
2077 csr1212_release_keyval(fi
->csr1212_dirs
[dr
]);
2078 fi
->csr1212_dirs
[dr
] = NULL
;
2082 cache
->filled_head
= kmalloc(sizeof(*cache
->filled_head
), GFP_KERNEL
);
2083 if (!cache
->filled_head
) {
2084 csr1212_release_keyval(fi
->csr1212_dirs
[dr
]);
2085 fi
->csr1212_dirs
[dr
] = NULL
;
2086 CSR1212_FREE(cache
);
2089 cache
->filled_tail
= cache
->filled_head
;
2091 if (copy_from_user(cache
->data
, int2ptr(req
->req
.sendb
),
2093 csr1212_release_keyval(fi
->csr1212_dirs
[dr
]);
2094 fi
->csr1212_dirs
[dr
] = NULL
;
2097 cache
->len
= req
->req
.length
;
2098 cache
->filled_head
->offset_start
= 0;
2099 cache
->filled_head
->offset_end
= cache
->size
- 1;
2101 cache
->layout_head
= cache
->layout_tail
= fi
->csr1212_dirs
[dr
];
2103 ret
= CSR1212_SUCCESS
;
2104 /* parse all the items */
2105 for (kv
= cache
->layout_head
; ret
== CSR1212_SUCCESS
&& kv
;
2107 ret
= csr1212_parse_keyval(kv
, cache
);
2110 /* attach top level items to the root directory */
2112 fi
->csr1212_dirs
[dr
]->value
.directory
.dentries_head
;
2113 ret
== CSR1212_SUCCESS
&& dentry
; dentry
= dentry
->next
) {
2115 csr1212_attach_keyval_to_directory(fi
->host
->csr
.
2120 if (ret
== CSR1212_SUCCESS
) {
2121 ret
= hpsb_update_config_rom_image(fi
->host
);
2123 if (ret
>= 0 && copy_to_user(int2ptr(req
->req
.recvb
),
2129 kfree(cache
->filled_head
);
2130 CSR1212_FREE(cache
);
2133 /* we have to free the request, because we queue no response,
2134 * and therefore nobody will free it */
2135 free_pending_request(req
);
2139 fi
->csr1212_dirs
[dr
]->value
.directory
.dentries_head
;
2140 dentry
; dentry
= dentry
->next
) {
2141 csr1212_detach_keyval_from_directory(fi
->host
->csr
.rom
->
2145 csr1212_release_keyval(fi
->csr1212_dirs
[dr
]);
2146 fi
->csr1212_dirs
[dr
] = NULL
;
2151 static int state_connected(struct file_info
*fi
, struct pending_request
*req
)
2153 int node
= req
->req
.address
>> 48;
2155 req
->req
.error
= RAW1394_ERROR_NONE
;
2157 switch (req
->req
.type
) {
2159 case RAW1394_REQ_ECHO
:
2160 queue_complete_req(req
);
2163 case RAW1394_REQ_ARM_REGISTER
:
2164 return arm_register(fi
, req
);
2166 case RAW1394_REQ_ARM_UNREGISTER
:
2167 return arm_unregister(fi
, req
);
2169 case RAW1394_REQ_ARM_SET_BUF
:
2170 return arm_set_buf(fi
, req
);
2172 case RAW1394_REQ_ARM_GET_BUF
:
2173 return arm_get_buf(fi
, req
);
2175 case RAW1394_REQ_RESET_NOTIFY
:
2176 return reset_notification(fi
, req
);
2178 case RAW1394_REQ_ISO_SEND
:
2179 case RAW1394_REQ_ISO_LISTEN
:
2180 printk(KERN_DEBUG
"raw1394: old iso ABI has been removed\n");
2181 req
->req
.error
= RAW1394_ERROR_COMPAT
;
2182 req
->req
.misc
= RAW1394_KERNELAPI_VERSION
;
2183 queue_complete_req(req
);
2186 case RAW1394_REQ_FCP_LISTEN
:
2187 handle_fcp_listen(fi
, req
);
2190 case RAW1394_REQ_RESET_BUS
:
2191 if (req
->req
.misc
== RAW1394_LONG_RESET
) {
2192 DBGMSG("busreset called (type: LONG)");
2193 hpsb_reset_bus(fi
->host
, LONG_RESET
);
2194 free_pending_request(req
); /* we have to free the request, because we queue no response, and therefore nobody will free it */
2197 if (req
->req
.misc
== RAW1394_SHORT_RESET
) {
2198 DBGMSG("busreset called (type: SHORT)");
2199 hpsb_reset_bus(fi
->host
, SHORT_RESET
);
2200 free_pending_request(req
); /* we have to free the request, because we queue no response, and therefore nobody will free it */
2203 /* error EINVAL (22) invalid argument */
2205 case RAW1394_REQ_GET_ROM
:
2206 return get_config_rom(fi
, req
);
2208 case RAW1394_REQ_UPDATE_ROM
:
2209 return update_config_rom(fi
, req
);
2211 case RAW1394_REQ_MODIFY_ROM
:
2212 return modify_config_rom(fi
, req
);
2215 if (req
->req
.generation
!= get_hpsb_generation(fi
->host
)) {
2216 req
->req
.error
= RAW1394_ERROR_GENERATION
;
2217 req
->req
.generation
= get_hpsb_generation(fi
->host
);
2218 req
->req
.length
= 0;
2219 queue_complete_req(req
);
2223 switch (req
->req
.type
) {
2224 case RAW1394_REQ_PHYPACKET
:
2225 return write_phypacket(fi
, req
);
2226 case RAW1394_REQ_ASYNC_SEND
:
2227 return handle_async_send(fi
, req
);
2230 if (req
->req
.length
== 0) {
2231 req
->req
.error
= RAW1394_ERROR_INVALID_ARG
;
2232 queue_complete_req(req
);
2236 return handle_async_request(fi
, req
, node
);
2239 static ssize_t
raw1394_write(struct file
*file
, const char __user
* buffer
,
2240 size_t count
, loff_t
* offset_is_ignored
)
2242 struct file_info
*fi
= (struct file_info
*)file
->private_data
;
2243 struct pending_request
*req
;
2244 ssize_t retval
= -EBADFD
;
2246 #ifdef CONFIG_COMPAT
2247 if (count
== sizeof(struct compat_raw1394_req
) &&
2248 sizeof(struct compat_raw1394_req
) !=
2249 sizeof(struct raw1394_request
)) {
2250 buffer
= raw1394_compat_write(buffer
);
2252 return PTR_ERR(buffer
);
2255 if (count
!= sizeof(struct raw1394_request
)) {
2259 req
= alloc_pending_request();
2263 req
->file_info
= fi
;
2265 if (copy_from_user(&req
->req
, buffer
, sizeof(struct raw1394_request
))) {
2266 free_pending_request(req
);
2270 switch (fi
->state
) {
2272 retval
= state_opened(fi
, req
);
2276 retval
= state_initialized(fi
, req
);
2280 retval
= state_connected(fi
, req
);
2285 free_pending_request(req
);
2294 /* rawiso operations */
2296 /* check if any RAW1394_REQ_RAWISO_ACTIVITY event is already in the
2297 * completion queue (reqlists_lock must be taken) */
2298 static inline int __rawiso_event_in_queue(struct file_info
*fi
)
2300 struct pending_request
*req
;
2302 list_for_each_entry(req
, &fi
->req_complete
, list
)
2303 if (req
->req
.type
== RAW1394_REQ_RAWISO_ACTIVITY
)
2309 /* put a RAWISO_ACTIVITY event in the queue, if one isn't there already */
2310 static void queue_rawiso_event(struct file_info
*fi
)
2312 unsigned long flags
;
2314 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
2316 /* only one ISO activity event may be in the queue */
2317 if (!__rawiso_event_in_queue(fi
)) {
2318 struct pending_request
*req
=
2319 __alloc_pending_request(GFP_ATOMIC
);
2322 req
->file_info
= fi
;
2323 req
->req
.type
= RAW1394_REQ_RAWISO_ACTIVITY
;
2324 req
->req
.generation
= get_hpsb_generation(fi
->host
);
2325 __queue_complete_req(req
);
2327 /* on allocation failure, signal an overflow */
2328 if (fi
->iso_handle
) {
2329 atomic_inc(&fi
->iso_handle
->overflows
);
2333 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
2336 static void rawiso_activity_cb(struct hpsb_iso
*iso
)
2338 unsigned long flags
;
2339 struct host_info
*hi
;
2340 struct file_info
*fi
;
2342 spin_lock_irqsave(&host_info_lock
, flags
);
2343 hi
= find_host_info(iso
->host
);
2346 list_for_each_entry(fi
, &hi
->file_info_list
, list
) {
2347 if (fi
->iso_handle
== iso
)
2348 queue_rawiso_event(fi
);
2352 spin_unlock_irqrestore(&host_info_lock
, flags
);
2355 /* helper function - gather all the kernel iso status bits for returning to user-space */
2356 static void raw1394_iso_fill_status(struct hpsb_iso
*iso
,
2357 struct raw1394_iso_status
*stat
)
2359 int overflows
= atomic_read(&iso
->overflows
);
2360 int skips
= atomic_read(&iso
->skips
);
2362 stat
->config
.data_buf_size
= iso
->buf_size
;
2363 stat
->config
.buf_packets
= iso
->buf_packets
;
2364 stat
->config
.channel
= iso
->channel
;
2365 stat
->config
.speed
= iso
->speed
;
2366 stat
->config
.irq_interval
= iso
->irq_interval
;
2367 stat
->n_packets
= hpsb_iso_n_ready(iso
);
2368 stat
->overflows
= ((skips
& 0xFFFF) << 16) | ((overflows
& 0xFFFF));
2369 stat
->xmit_cycle
= iso
->xmit_cycle
;
2372 static int raw1394_iso_xmit_init(struct file_info
*fi
, void __user
* uaddr
)
2374 struct raw1394_iso_status stat
;
2379 if (copy_from_user(&stat
, uaddr
, sizeof(stat
)))
2382 fi
->iso_handle
= hpsb_iso_xmit_init(fi
->host
,
2383 stat
.config
.data_buf_size
,
2384 stat
.config
.buf_packets
,
2385 stat
.config
.channel
,
2387 stat
.config
.irq_interval
,
2388 rawiso_activity_cb
);
2389 if (!fi
->iso_handle
)
2392 fi
->iso_state
= RAW1394_ISO_XMIT
;
2394 raw1394_iso_fill_status(fi
->iso_handle
, &stat
);
2395 if (copy_to_user(uaddr
, &stat
, sizeof(stat
)))
2398 /* queue an event to get things started */
2399 rawiso_activity_cb(fi
->iso_handle
);
2404 static int raw1394_iso_recv_init(struct file_info
*fi
, void __user
* uaddr
)
2406 struct raw1394_iso_status stat
;
2411 if (copy_from_user(&stat
, uaddr
, sizeof(stat
)))
2414 fi
->iso_handle
= hpsb_iso_recv_init(fi
->host
,
2415 stat
.config
.data_buf_size
,
2416 stat
.config
.buf_packets
,
2417 stat
.config
.channel
,
2418 stat
.config
.dma_mode
,
2419 stat
.config
.irq_interval
,
2420 rawiso_activity_cb
);
2421 if (!fi
->iso_handle
)
2424 fi
->iso_state
= RAW1394_ISO_RECV
;
2426 raw1394_iso_fill_status(fi
->iso_handle
, &stat
);
2427 if (copy_to_user(uaddr
, &stat
, sizeof(stat
)))
2432 static int raw1394_iso_get_status(struct file_info
*fi
, void __user
* uaddr
)
2434 struct raw1394_iso_status stat
;
2435 struct hpsb_iso
*iso
= fi
->iso_handle
;
2437 raw1394_iso_fill_status(fi
->iso_handle
, &stat
);
2438 if (copy_to_user(uaddr
, &stat
, sizeof(stat
)))
2441 /* reset overflow counter */
2442 atomic_set(&iso
->overflows
, 0);
2443 /* reset skip counter */
2444 atomic_set(&iso
->skips
, 0);
2449 /* copy N packet_infos out of the ringbuffer into user-supplied array */
2450 static int raw1394_iso_recv_packets(struct file_info
*fi
, void __user
* uaddr
)
2452 struct raw1394_iso_packets upackets
;
2453 unsigned int packet
= fi
->iso_handle
->first_packet
;
2456 if (copy_from_user(&upackets
, uaddr
, sizeof(upackets
)))
2459 if (upackets
.n_packets
> hpsb_iso_n_ready(fi
->iso_handle
))
2462 /* ensure user-supplied buffer is accessible and big enough */
2463 if (!access_ok(VERIFY_WRITE
, upackets
.infos
,
2464 upackets
.n_packets
*
2465 sizeof(struct raw1394_iso_packet_info
)))
2468 /* copy the packet_infos out */
2469 for (i
= 0; i
< upackets
.n_packets
; i
++) {
2470 if (__copy_to_user(&upackets
.infos
[i
],
2471 &fi
->iso_handle
->infos
[packet
],
2472 sizeof(struct raw1394_iso_packet_info
)))
2475 packet
= (packet
+ 1) % fi
->iso_handle
->buf_packets
;
2481 /* copy N packet_infos from user to ringbuffer, and queue them for transmission */
2482 static int raw1394_iso_send_packets(struct file_info
*fi
, void __user
* uaddr
)
2484 struct raw1394_iso_packets upackets
;
2487 if (copy_from_user(&upackets
, uaddr
, sizeof(upackets
)))
2490 if (upackets
.n_packets
>= fi
->iso_handle
->buf_packets
)
2493 if (upackets
.n_packets
>= hpsb_iso_n_ready(fi
->iso_handle
))
2496 /* ensure user-supplied buffer is accessible and big enough */
2497 if (!access_ok(VERIFY_READ
, upackets
.infos
,
2498 upackets
.n_packets
*
2499 sizeof(struct raw1394_iso_packet_info
)))
2502 /* copy the infos structs in and queue the packets */
2503 for (i
= 0; i
< upackets
.n_packets
; i
++) {
2504 struct raw1394_iso_packet_info info
;
2506 if (__copy_from_user(&info
, &upackets
.infos
[i
],
2507 sizeof(struct raw1394_iso_packet_info
)))
2510 rv
= hpsb_iso_xmit_queue_packet(fi
->iso_handle
, info
.offset
,
2511 info
.len
, info
.tag
, info
.sy
);
2519 static void raw1394_iso_shutdown(struct file_info
*fi
)
2522 hpsb_iso_shutdown(fi
->iso_handle
);
2524 fi
->iso_handle
= NULL
;
2525 fi
->iso_state
= RAW1394_ISO_INACTIVE
;
2528 static int raw1394_read_cycle_timer(struct file_info
*fi
, void __user
* uaddr
)
2530 struct raw1394_cycle_timer ct
;
2533 err
= hpsb_read_cycle_timer(fi
->host
, &ct
.cycle_timer
, &ct
.local_time
);
2535 if (copy_to_user(uaddr
, &ct
, sizeof(ct
)))
2540 /* mmap the rawiso xmit/recv buffer */
2541 static int raw1394_mmap(struct file
*file
, struct vm_area_struct
*vma
)
2543 struct file_info
*fi
= file
->private_data
;
2545 if (fi
->iso_state
== RAW1394_ISO_INACTIVE
)
2548 return dma_region_mmap(&fi
->iso_handle
->data_buf
, file
, vma
);
2551 /* ioctl is only used for rawiso operations */
2552 static int raw1394_ioctl(struct inode
*inode
, struct file
*file
,
2553 unsigned int cmd
, unsigned long arg
)
2555 struct file_info
*fi
= file
->private_data
;
2556 void __user
*argp
= (void __user
*)arg
;
2558 switch (fi
->iso_state
) {
2559 case RAW1394_ISO_INACTIVE
:
2561 case RAW1394_IOC_ISO_XMIT_INIT
:
2562 return raw1394_iso_xmit_init(fi
, argp
);
2563 case RAW1394_IOC_ISO_RECV_INIT
:
2564 return raw1394_iso_recv_init(fi
, argp
);
2569 case RAW1394_ISO_RECV
:
2571 case RAW1394_IOC_ISO_RECV_START
:{
2572 /* copy args from user-space */
2575 (&args
[0], argp
, sizeof(args
)))
2577 return hpsb_iso_recv_start(fi
->iso_handle
,
2581 case RAW1394_IOC_ISO_XMIT_RECV_STOP
:
2582 hpsb_iso_stop(fi
->iso_handle
);
2584 case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL
:
2585 return hpsb_iso_recv_listen_channel(fi
->iso_handle
,
2587 case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL
:
2588 return hpsb_iso_recv_unlisten_channel(fi
->iso_handle
,
2590 case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK
:{
2591 /* copy the u64 from user-space */
2593 if (copy_from_user(&mask
, argp
, sizeof(mask
)))
2595 return hpsb_iso_recv_set_channel_mask(fi
->
2599 case RAW1394_IOC_ISO_GET_STATUS
:
2600 return raw1394_iso_get_status(fi
, argp
);
2601 case RAW1394_IOC_ISO_RECV_PACKETS
:
2602 return raw1394_iso_recv_packets(fi
, argp
);
2603 case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS
:
2604 return hpsb_iso_recv_release_packets(fi
->iso_handle
,
2606 case RAW1394_IOC_ISO_RECV_FLUSH
:
2607 return hpsb_iso_recv_flush(fi
->iso_handle
);
2608 case RAW1394_IOC_ISO_SHUTDOWN
:
2609 raw1394_iso_shutdown(fi
);
2611 case RAW1394_IOC_ISO_QUEUE_ACTIVITY
:
2612 queue_rawiso_event(fi
);
2616 case RAW1394_ISO_XMIT
:
2618 case RAW1394_IOC_ISO_XMIT_START
:{
2619 /* copy two ints from user-space */
2622 (&args
[0], argp
, sizeof(args
)))
2624 return hpsb_iso_xmit_start(fi
->iso_handle
,
2627 case RAW1394_IOC_ISO_XMIT_SYNC
:
2628 return hpsb_iso_xmit_sync(fi
->iso_handle
);
2629 case RAW1394_IOC_ISO_XMIT_RECV_STOP
:
2630 hpsb_iso_stop(fi
->iso_handle
);
2632 case RAW1394_IOC_ISO_GET_STATUS
:
2633 return raw1394_iso_get_status(fi
, argp
);
2634 case RAW1394_IOC_ISO_XMIT_PACKETS
:
2635 return raw1394_iso_send_packets(fi
, argp
);
2636 case RAW1394_IOC_ISO_SHUTDOWN
:
2637 raw1394_iso_shutdown(fi
);
2639 case RAW1394_IOC_ISO_QUEUE_ACTIVITY
:
2640 queue_rawiso_event(fi
);
2648 /* state-independent commands */
2650 case RAW1394_IOC_GET_CYCLE_TIMER
:
2651 return raw1394_read_cycle_timer(fi
, argp
);
2659 #ifdef CONFIG_COMPAT
2660 struct raw1394_iso_packets32
{
2662 compat_uptr_t infos
;
2663 } __attribute__((packed
));
2665 struct raw1394_cycle_timer32
{
2669 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
2670 __attribute__((packed
))
2674 #define RAW1394_IOC_ISO_RECV_PACKETS32 \
2675 _IOW ('#', 0x25, struct raw1394_iso_packets32)
2676 #define RAW1394_IOC_ISO_XMIT_PACKETS32 \
2677 _IOW ('#', 0x27, struct raw1394_iso_packets32)
2678 #define RAW1394_IOC_GET_CYCLE_TIMER32 \
2679 _IOR ('#', 0x30, struct raw1394_cycle_timer32)
2681 static long raw1394_iso_xmit_recv_packets32(struct file
*file
, unsigned int cmd
,
2682 struct raw1394_iso_packets32 __user
*arg
)
2684 compat_uptr_t infos32
;
2687 struct raw1394_iso_packets __user
*dst
= compat_alloc_user_space(sizeof(struct raw1394_iso_packets
));
2689 if (!copy_in_user(&dst
->n_packets
, &arg
->n_packets
, sizeof arg
->n_packets
) &&
2690 !copy_from_user(&infos32
, &arg
->infos
, sizeof infos32
)) {
2691 infos
= compat_ptr(infos32
);
2692 if (!copy_to_user(&dst
->infos
, &infos
, sizeof infos
))
2693 err
= raw1394_ioctl(NULL
, file
, cmd
, (unsigned long)dst
);
2698 static long raw1394_read_cycle_timer32(struct file_info
*fi
, void __user
* uaddr
)
2700 struct raw1394_cycle_timer32 ct
;
2703 err
= hpsb_read_cycle_timer(fi
->host
, &ct
.cycle_timer
, &ct
.local_time
);
2705 if (copy_to_user(uaddr
, &ct
, sizeof(ct
)))
2710 static long raw1394_compat_ioctl(struct file
*file
,
2711 unsigned int cmd
, unsigned long arg
)
2713 struct file_info
*fi
= file
->private_data
;
2714 void __user
*argp
= (void __user
*)arg
;
2719 /* These requests have same format as long as 'int' has same size. */
2720 case RAW1394_IOC_ISO_RECV_INIT
:
2721 case RAW1394_IOC_ISO_RECV_START
:
2722 case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL
:
2723 case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL
:
2724 case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK
:
2725 case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS
:
2726 case RAW1394_IOC_ISO_RECV_FLUSH
:
2727 case RAW1394_IOC_ISO_XMIT_RECV_STOP
:
2728 case RAW1394_IOC_ISO_XMIT_INIT
:
2729 case RAW1394_IOC_ISO_XMIT_START
:
2730 case RAW1394_IOC_ISO_XMIT_SYNC
:
2731 case RAW1394_IOC_ISO_GET_STATUS
:
2732 case RAW1394_IOC_ISO_SHUTDOWN
:
2733 case RAW1394_IOC_ISO_QUEUE_ACTIVITY
:
2734 err
= raw1394_ioctl(NULL
, file
, cmd
, arg
);
2736 /* These request have different format. */
2737 case RAW1394_IOC_ISO_RECV_PACKETS32
:
2738 err
= raw1394_iso_xmit_recv_packets32(file
, RAW1394_IOC_ISO_RECV_PACKETS
, argp
);
2740 case RAW1394_IOC_ISO_XMIT_PACKETS32
:
2741 err
= raw1394_iso_xmit_recv_packets32(file
, RAW1394_IOC_ISO_XMIT_PACKETS
, argp
);
2743 case RAW1394_IOC_GET_CYCLE_TIMER32
:
2744 err
= raw1394_read_cycle_timer32(fi
, argp
);
2756 static unsigned int raw1394_poll(struct file
*file
, poll_table
* pt
)
2758 struct file_info
*fi
= file
->private_data
;
2759 unsigned int mask
= POLLOUT
| POLLWRNORM
;
2760 unsigned long flags
;
2762 poll_wait(file
, &fi
->wait_complete
, pt
);
2764 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
2765 if (!list_empty(&fi
->req_complete
)) {
2766 mask
|= POLLIN
| POLLRDNORM
;
2768 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
2773 static int raw1394_open(struct inode
*inode
, struct file
*file
)
2775 struct file_info
*fi
;
2777 fi
= kzalloc(sizeof(*fi
), GFP_KERNEL
);
2781 fi
->notification
= (u8
) RAW1394_NOTIFY_ON
; /* busreset notification */
2783 INIT_LIST_HEAD(&fi
->list
);
2785 INIT_LIST_HEAD(&fi
->req_pending
);
2786 INIT_LIST_HEAD(&fi
->req_complete
);
2787 spin_lock_init(&fi
->reqlists_lock
);
2788 init_waitqueue_head(&fi
->wait_complete
);
2789 INIT_LIST_HEAD(&fi
->addr_list
);
2791 file
->private_data
= fi
;
2796 static int raw1394_release(struct inode
*inode
, struct file
*file
)
2798 struct file_info
*fi
= file
->private_data
;
2799 struct list_head
*lh
;
2800 struct pending_request
*req
;
2803 struct list_head
*entry
;
2804 struct arm_addr
*addr
= NULL
;
2805 struct host_info
*hi
;
2806 struct file_info
*fi_hlp
= NULL
;
2807 struct arm_addr
*arm_addr
= NULL
;
2810 unsigned long flags
;
2812 if (fi
->iso_state
!= RAW1394_ISO_INACTIVE
)
2813 raw1394_iso_shutdown(fi
);
2815 spin_lock_irqsave(&host_info_lock
, flags
);
2818 /* set address-entries invalid */
2820 while (!list_empty(&fi
->addr_list
)) {
2822 lh
= fi
->addr_list
.next
;
2823 addr
= list_entry(lh
, struct arm_addr
, addr_list
);
2824 /* another host with valid address-entry containing
2825 same addressrange? */
2826 list_for_each_entry(hi
, &host_info_list
, list
) {
2827 if (hi
->host
!= fi
->host
) {
2828 list_for_each_entry(fi_hlp
, &hi
->file_info_list
,
2830 entry
= fi_hlp
->addr_list
.next
;
2831 while (entry
!= &(fi_hlp
->addr_list
)) {
2832 arm_addr
= list_entry(entry
, struct
2835 if (arm_addr
->start
==
2838 ("raw1394_release: "
2839 "another host ownes "
2840 "same addressrange");
2844 entry
= entry
->next
;
2852 if (!another_host
) {
2853 DBGMSG("raw1394_release: call hpsb_arm_unregister");
2855 hpsb_unregister_addrspace(&raw1394_highlevel
,
2856 fi
->host
, addr
->start
);
2860 "raw1394_release arm_Unregister failed\n");
2863 DBGMSG("raw1394_release: delete addr_entry from list");
2864 list_del(&addr
->addr_list
);
2865 vfree(addr
->addr_space_buffer
);
2868 spin_unlock_irqrestore(&host_info_lock
, flags
);
2870 printk(KERN_ERR
"raw1394: during addr_list-release "
2871 "error(s) occurred \n");
2875 /* This locked section guarantees that neither
2876 * complete nor pending requests exist once i!=0 */
2877 spin_lock_irqsave(&fi
->reqlists_lock
, flags
);
2878 while ((req
= __next_complete_req(fi
)))
2879 free_pending_request(req
);
2881 i
= list_empty(&fi
->req_pending
);
2882 spin_unlock_irqrestore(&fi
->reqlists_lock
, flags
);
2887 * Sleep until more requests can be freed.
2889 * NB: We call the macro wait_event() with a condition argument
2890 * with side effect. This is only possible because the side
2891 * effect does not occur until the condition became true, and
2892 * wait_event() won't evaluate the condition again after that.
2894 wait_event(fi
->wait_complete
, (req
= next_complete_req(fi
)));
2895 free_pending_request(req
);
2898 /* Remove any sub-trees left by user space programs */
2899 for (i
= 0; i
< RAW1394_MAX_USER_CSR_DIRS
; i
++) {
2900 struct csr1212_dentry
*dentry
;
2901 if (!fi
->csr1212_dirs
[i
])
2904 fi
->csr1212_dirs
[i
]->value
.directory
.dentries_head
; dentry
;
2905 dentry
= dentry
->next
) {
2906 csr1212_detach_keyval_from_directory(fi
->host
->csr
.rom
->
2910 csr1212_release_keyval(fi
->csr1212_dirs
[i
]);
2911 fi
->csr1212_dirs
[i
] = NULL
;
2915 if ((csr_mod
|| fi
->cfgrom_upd
)
2916 && hpsb_update_config_rom_image(fi
->host
) < 0)
2918 ("Failed to generate Configuration ROM image for host %d",
2921 if (fi
->state
== connected
) {
2922 spin_lock_irqsave(&host_info_lock
, flags
);
2923 list_del(&fi
->list
);
2924 spin_unlock_irqrestore(&host_info_lock
, flags
);
2926 put_device(&fi
->host
->device
);
2929 spin_lock_irqsave(&host_info_lock
, flags
);
2931 module_put(fi
->host
->driver
->owner
);
2932 spin_unlock_irqrestore(&host_info_lock
, flags
);
2939 /*** HOTPLUG STUFF **********************************************************/
2941 * Export information about protocols/devices supported by this driver.
2944 static struct ieee1394_device_id raw1394_id_table
[] = {
2946 .match_flags
= IEEE1394_MATCH_SPECIFIER_ID
| IEEE1394_MATCH_VERSION
,
2947 .specifier_id
= AVC_UNIT_SPEC_ID_ENTRY
& 0xffffff,
2948 .version
= AVC_SW_VERSION_ENTRY
& 0xffffff},
2950 .match_flags
= IEEE1394_MATCH_SPECIFIER_ID
| IEEE1394_MATCH_VERSION
,
2951 .specifier_id
= CAMERA_UNIT_SPEC_ID_ENTRY
& 0xffffff,
2952 .version
= CAMERA_SW_VERSION_ENTRY
& 0xffffff},
2954 .match_flags
= IEEE1394_MATCH_SPECIFIER_ID
| IEEE1394_MATCH_VERSION
,
2955 .specifier_id
= CAMERA_UNIT_SPEC_ID_ENTRY
& 0xffffff,
2956 .version
= (CAMERA_SW_VERSION_ENTRY
+ 1) & 0xffffff},
2958 .match_flags
= IEEE1394_MATCH_SPECIFIER_ID
| IEEE1394_MATCH_VERSION
,
2959 .specifier_id
= CAMERA_UNIT_SPEC_ID_ENTRY
& 0xffffff,
2960 .version
= (CAMERA_SW_VERSION_ENTRY
+ 2) & 0xffffff},
2964 MODULE_DEVICE_TABLE(ieee1394
, raw1394_id_table
);
2967 static struct hpsb_protocol_driver raw1394_driver
= {
2971 /******************************************************************************/
2973 static struct hpsb_highlevel raw1394_highlevel
= {
2974 .name
= RAW1394_DEVICE_NAME
,
2975 .add_host
= add_host
,
2976 .remove_host
= remove_host
,
2977 .host_reset
= host_reset
,
2978 .fcp_request
= fcp_request
,
2981 static struct cdev raw1394_cdev
;
2982 static const struct file_operations raw1394_fops
= {
2983 .owner
= THIS_MODULE
,
2984 .read
= raw1394_read
,
2985 .write
= raw1394_write
,
2986 .mmap
= raw1394_mmap
,
2987 .ioctl
= raw1394_ioctl
,
2988 #ifdef CONFIG_COMPAT
2989 .compat_ioctl
= raw1394_compat_ioctl
,
2991 .poll
= raw1394_poll
,
2992 .open
= raw1394_open
,
2993 .release
= raw1394_release
,
2996 static int __init
init_raw1394(void)
3000 hpsb_register_highlevel(&raw1394_highlevel
);
3004 hpsb_protocol_class
, NULL
,
3005 MKDEV(IEEE1394_MAJOR
, IEEE1394_MINOR_BLOCK_RAW1394
* 16),
3006 RAW1394_DEVICE_NAME
))) {
3011 cdev_init(&raw1394_cdev
, &raw1394_fops
);
3012 raw1394_cdev
.owner
= THIS_MODULE
;
3013 ret
= cdev_add(&raw1394_cdev
, IEEE1394_RAW1394_DEV
, 1);
3015 HPSB_ERR("raw1394 failed to register minor device block");
3019 HPSB_INFO("raw1394: /dev/%s device initialized", RAW1394_DEVICE_NAME
);
3021 ret
= hpsb_register_protocol(&raw1394_driver
);
3023 HPSB_ERR("raw1394: failed to register protocol");
3024 cdev_del(&raw1394_cdev
);
3031 device_destroy(hpsb_protocol_class
,
3032 MKDEV(IEEE1394_MAJOR
,
3033 IEEE1394_MINOR_BLOCK_RAW1394
* 16));
3035 hpsb_unregister_highlevel(&raw1394_highlevel
);
3040 static void __exit
cleanup_raw1394(void)
3042 device_destroy(hpsb_protocol_class
,
3043 MKDEV(IEEE1394_MAJOR
,
3044 IEEE1394_MINOR_BLOCK_RAW1394
* 16));
3045 cdev_del(&raw1394_cdev
);
3046 hpsb_unregister_highlevel(&raw1394_highlevel
);
3047 hpsb_unregister_protocol(&raw1394_driver
);
3050 module_init(init_raw1394
);
3051 module_exit(cleanup_raw1394
);
3052 MODULE_LICENSE("GPL");