Commit 11092356 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/gregkh/linux/pci-2.5

into home.osdl.org:/home/torvalds/v2.5/linux
parents 09189bd8 3891cd30
......@@ -499,6 +499,7 @@ config KCORE_AOUT
default y
config KCORE_ELF
bool
default y
source "fs/Kconfig.binfmt"
......
......@@ -162,28 +162,33 @@ void do_gettimeofday(struct timeval *tv)
tv->tv_usec = usec;
}
void do_settimeofday(struct timeval *tv)
int do_settimeofday(struct timespec *tv)
{
if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
write_seqlock_irq(&xtime_lock);
/* This is revolting. We need to set the xtime.tv_usec
/*
* This is revolting. We need to set the xtime.tv_usec
* correctly. However, the value in this location is
* is value at the last tick.
* Discover what correction gettimeofday
* would have done, and then undo it!
*/
if (mach_gettimeoffset)
tv->tv_usec -= mach_gettimeoffset();
tv->tv_nsec -= (mach_gettimeoffset() * 1000);
while (tv->tv_usec < 0) {
tv->tv_usec += 1000000;
while (tv->tv_nsec < 0) {
tv->tv_nsec += NSEC_PER_SEC;
tv->tv_sec--;
}
xtime.tv_sec = tv->tv_sec;
xtime.tv_nsec = (tv->tv_usec * 1000);
xtime.tv_nsec = tv->tv_nsec;
time_adjust = 0; /* stop active adjtime() */
time_status |= STA_UNSYNC;
time_maxerror = NTP_PHASE_LIMIT;
time_esterror = NTP_PHASE_LIMIT;
write_sequnlock_irq(&xtime_lock);
return 0;
}
......@@ -18,6 +18,9 @@ obj-$(CONFIG_IEEE1394_CMP) += cmp.o
clean-files := oui.c
quiet_cmd_oui2c = OUI2C $@
cmd_oui2c = $(CONFIG_SHELL) $(obj)/oui2c.sh < $(obj)/oui.db > $@
$(obj)/oui.o: $(obj)/oui.c
$(obj)/oui.c: $(obj)/oui.db $(obj)/oui2c.sh
$(CONFIG_SHELL) $(obj)/oui2c.sh < $(obj)/oui.db > $@
$(call if_changed,oui2c)
......@@ -732,7 +732,7 @@ static void fill_packet(struct stream *s, struct packet *packet, int nevents)
/* Fill IEEE1394 headers */
packet->db->header_desc.header[0] =
(SPEED_100 << 16) | (0x01 << 14) |
(IEEE1394_SPEED_100 << 16) | (0x01 << 14) |
(s->iso_channel << 8) | (TCODE_ISO_DATA << 4);
packet->db->header_desc.header[1] = size << 16;
......
......@@ -138,7 +138,7 @@ static void cmp_add_host(struct hpsb_host *host)
}
ch->host = host;
ch->u.ompr.rate = SPEED_100;
ch->u.ompr.rate = IEEE1394_SPEED_100;
ch->u.ompr.bcast_channel_base = 63;
ch->u.ompr.nplugs = 2;
......
......@@ -2,6 +2,10 @@
#ifndef _IEEE1394_CSR_H
#define _IEEE1394_CSR_H
#ifdef CONFIG_PREEMPT
#include <linux/sched.h>
#endif
#define CSR_REGISTER_BASE 0xfffff0000000ULL
/* register offsets relative to CSR_REGISTER_BASE */
......
......@@ -31,7 +31,7 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
prog->n_pages = n_bytes / PAGE_SIZE;
prog->kvirt = pci_alloc_consistent(dev, prog->n_pages * PAGE_SIZE, &prog->bus_addr);
if(!prog->kvirt) {
if (!prog->kvirt) {
printk(KERN_ERR "dma_prog_region_alloc: pci_alloc_consistent() failed\n");
dma_prog_region_free(prog);
return -ENOMEM;
......@@ -44,7 +44,7 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
void dma_prog_region_free(struct dma_prog_region *prog)
{
if(prog->kvirt) {
if (prog->kvirt) {
pci_free_consistent(prog->dev, prog->n_pages * PAGE_SIZE, prog->kvirt, prog->bus_addr);
}
......@@ -75,7 +75,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
n_pages = n_bytes / PAGE_SIZE;
dma->kvirt = vmalloc_32(n_pages * PAGE_SIZE);
if(!dma->kvirt) {
if (!dma->kvirt) {
printk(KERN_ERR "dma_region_alloc: vmalloc_32() failed\n");
goto err;
}
......@@ -87,7 +87,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
/* allocate scatter/gather list */
dma->sglist = kmalloc(dma->n_pages * sizeof(struct scatterlist), GFP_KERNEL);
if(!dma->sglist) {
if (!dma->sglist) {
printk(KERN_ERR "dma_region_alloc: kmalloc(sglist) failed\n");
goto err;
}
......@@ -96,7 +96,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
memset(dma->sglist, 0, dma->n_pages * sizeof(struct scatterlist));
/* fill scatter/gather list with pages */
for(i = 0; i < dma->n_pages; i++) {
for (i = 0; i < dma->n_pages; i++) {
unsigned long va = (unsigned long) dma->kvirt + i * PAGE_SIZE;
dma->sglist[i].page = vmalloc_to_page((void *)va);
......@@ -106,7 +106,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
/* map sglist to the IOMMU */
dma->n_dma_pages = pci_map_sg(dev, &dma->sglist[0], dma->n_pages, direction);
if(dma->n_dma_pages == 0) {
if (dma->n_dma_pages == 0) {
printk(KERN_ERR "dma_region_alloc: pci_map_sg() failed\n");
goto err;
}
......@@ -123,18 +123,18 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
void dma_region_free(struct dma_region *dma)
{
if(dma->n_dma_pages) {
if (dma->n_dma_pages) {
pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages, dma->direction);
dma->n_dma_pages = 0;
dma->dev = NULL;
}
if(dma->sglist) {
if (dma->sglist) {
kfree(dma->sglist);
dma->sglist = NULL;
}
if(dma->kvirt) {
if (dma->kvirt) {
vfree(dma->kvirt);
dma->kvirt = NULL;
dma->n_pages = 0;
......@@ -148,8 +148,8 @@ static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
int i;
unsigned long off = offset;
for(i = 0; i < dma->n_dma_pages; i++) {
if(off < sg_dma_len(&dma->sglist[i])) {
for (i = 0; i < dma->n_dma_pages; i++) {
if (off < sg_dma_len(&dma->sglist[i])) {
*rem = off;
return i;
}
......@@ -173,7 +173,7 @@ void dma_region_sync(struct dma_region *dma, unsigned long offset, unsigned long
int first, last;
unsigned long rem;
if(!len)
if (!len)
len = 1;
first = dma_region_find(dma, offset, &rem);
......@@ -193,10 +193,10 @@ dma_region_pagefault(struct vm_area_struct *area, unsigned long address, int wri
struct dma_region *dma = (struct dma_region*) area->vm_private_data;
if(!dma->kvirt)
if (!dma->kvirt)
goto out;
if( (address < (unsigned long) area->vm_start) ||
if ( (address < (unsigned long) area->vm_start) ||
(address > (unsigned long) area->vm_start + (PAGE_SIZE * dma->n_pages)) )
goto out;
......@@ -216,16 +216,16 @@ int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_st
{
unsigned long size;
if(!dma->kvirt)
if (!dma->kvirt)
return -EINVAL;
/* must be page-aligned */
if(vma->vm_pgoff != 0)
if (vma->vm_pgoff != 0)
return -EINVAL;
/* check the length */
size = vma->vm_end - vma->vm_start;
if(size > (PAGE_SIZE * dma->n_pages))
if (size > (PAGE_SIZE * dma->n_pages))
return -EINVAL;
vma->vm_ops = &dma_region_vm_ops;
......
......@@ -76,7 +76,7 @@ dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset
/* round up a number of bytes to be a multiple of the PAGE_SIZE */
static inline unsigned long round_up_to_page(unsigned long len)
{
if(len % PAGE_SIZE)
if (len % PAGE_SIZE)
len += PAGE_SIZE - (len % PAGE_SIZE);
return len;
}
......
......@@ -97,7 +97,7 @@ static inline void fill_output_more_immediate(struct output_more_immediate *omi,
omi->q[3] = 0;
/* IT packet header */
omi->q[4] = cpu_to_le32( (0x0 << 16) /* DMA_SPEED_100 */
omi->q[4] = cpu_to_le32( (0x0 << 16) /* IEEE1394_SPEED_100 */
| (tag << 14)
| (channel << 8)
| (TCODE_ISO_DATA << 4)
......@@ -129,10 +129,10 @@ static inline void fill_output_last(struct output_last *ol,
u32 temp = 0;
temp |= 1 << 28; /* OUTPUT_LAST */
if(want_timestamp) /* controller will update timestamp at DMA time */
if (want_timestamp) /* controller will update timestamp at DMA time */
temp |= 1 << 27;
if(want_interrupt)
if (want_interrupt)
temp |= 3 << 20;
temp |= 3 << 18; /* must take branch */
......
......@@ -201,14 +201,14 @@ static void frame_reset(struct frame *f)
static struct frame* frame_new(unsigned int frame_num, struct video_card *video)
{
struct frame *f = kmalloc(sizeof(*f), GFP_KERNEL);
if(!f)
if (!f)
return NULL;
f->video = video;
f->frame_num = frame_num;
f->header_pool = pci_alloc_consistent(f->video->ohci->dev, PAGE_SIZE, &f->header_pool_dma);
if(!f->header_pool) {
if (!f->header_pool) {
printk(KERN_ERR "dv1394: failed to allocate CIP header pool\n");
kfree(f);
return NULL;
......@@ -224,7 +224,7 @@ static struct frame* frame_new(unsigned int frame_num, struct video_card *video)
f->descriptor_pool = pci_alloc_consistent(f->video->ohci->dev,
f->descriptor_pool_size,
&f->descriptor_pool_dma);
if(!f->descriptor_pool) {
if (!f->descriptor_pool) {
pci_free_consistent(f->video->ohci->dev, PAGE_SIZE, f->header_pool, f->header_pool_dma);
kfree(f);
return NULL;
......@@ -284,12 +284,12 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
if(video->pal_or_ntsc == DV1394_PAL)
if (video->pal_or_ntsc == DV1394_PAL)
packets_per_frame = DV1394_PAL_PACKETS_PER_FRAME;
else
packets_per_frame = DV1394_NTSC_PACKETS_PER_FRAME;
while( full_packets < packets_per_frame ) {
while ( full_packets < packets_per_frame ) {
empty_packet = first_packet = last_packet = mid_packet = 0;
data_p = f->data + full_packets * 480;
......@@ -300,7 +300,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
/* note: these should NOT cross a page boundary (DMA restriction) */
if(f->n_packets >= MAX_PACKETS) {
if (f->n_packets >= MAX_PACKETS) {
printk(KERN_ERR "dv1394: FATAL ERROR: max packet count exceeded\n");
return;
}
......@@ -316,7 +316,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
/* the whole CIP pool fits on one page, so no worries about boundaries */
if( ((unsigned long) &(f->header_pool[f->n_packets]) - (unsigned long) f->header_pool)
if ( ((unsigned long) &(f->header_pool[f->n_packets]) - (unsigned long) f->header_pool)
> PAGE_SIZE) {
printk(KERN_ERR "dv1394: FATAL ERROR: no room to allocate CIP header\n");
return;
......@@ -331,7 +331,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
/* is this an empty packet? */
if(video->cip_accum > (video->cip_d - video->cip_n)) {
if (video->cip_accum > (video->cip_d - video->cip_n)) {
empty_packet = 1;
payload_size = 8;
video->cip_accum -= (video->cip_d - video->cip_n);
......@@ -364,7 +364,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
the timestamp before DMA starts on the next frame.
*/
if(f->n_packets == 0) {
if (f->n_packets == 0) {
first_packet = 1;
} else if ( full_packets == (packets_per_frame-1) ) {
last_packet = 1;
......@@ -383,12 +383,12 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
need a timestamp. */
/* first packet in the frame needs a timestamp */
if(first_packet) {
if (first_packet) {
f->cip_syt1 = cip;
if(empty_packet)
if (empty_packet)
first_packet_empty = 1;
} else if(first_packet_empty && (f->n_packets == 1) ) {
} else if (first_packet_empty && (f->n_packets == 1) ) {
/* if the first packet was empty, the second
packet's CIP header also needs a timestamp */
f->cip_syt2 = cip;
......@@ -402,7 +402,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
0xFFFF /* the timestamp is filled in later */);
/* advance counter, only for full packets */
if( ! empty_packet )
if ( ! empty_packet )
video->continuity_counter++;
/******************************/
......@@ -412,7 +412,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
/* first descriptor - OUTPUT_MORE_IMMEDIATE, for the controller's IT header */
fill_output_more_immediate( &(block->u.out.omi), 1, video->channel, 0, payload_size);
if(empty_packet) {
if (empty_packet) {
/* second descriptor - OUTPUT_LAST for CIP header */
fill_output_last( &(block->u.out.u.empty.ol),
......@@ -425,18 +425,18 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
sizeof(struct CIP_header), /* data size */
cip_dma);
if(first_packet)
if (first_packet)
f->frame_begin_timestamp = &(block->u.out.u.empty.ol.q[3]);
else if(mid_packet)
else if (mid_packet)
f->mid_frame_timestamp = &(block->u.out.u.empty.ol.q[3]);
else if(last_packet) {
else if (last_packet) {
f->frame_end_timestamp = &(block->u.out.u.empty.ol.q[3]);
f->frame_end_branch = &(block->u.out.u.empty.ol.q[2]);
}
branch_address = &(block->u.out.u.empty.ol.q[2]);
n_descriptors = 3;
if(first_packet)
if (first_packet)
f->first_n_descriptors = n_descriptors;
} else { /* full packet */
......@@ -452,7 +452,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
we need to split it into two DMA descriptors */
/* does the 480-byte data payload cross a page boundary? */
if( (PAGE_SIZE- ((unsigned long)data_p % PAGE_SIZE) ) < 480 ) {
if ( (PAGE_SIZE- ((unsigned long)data_p % PAGE_SIZE) ) < 480 ) {
/* page boundary crossed */
......@@ -479,11 +479,11 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
dma_region_offset_to_bus(&video->dv_buf,
data_p + PAGE_SIZE - (data_p % PAGE_SIZE) - (unsigned long) video->dv_buf.kvirt));
if(first_packet)
if (first_packet)
f->frame_begin_timestamp = &(block->u.out.u.full.u.cross.ol.q[3]);
else if(mid_packet)
else if (mid_packet)
f->mid_frame_timestamp = &(block->u.out.u.full.u.cross.ol.q[3]);
else if(last_packet) {
else if (last_packet) {
f->frame_end_timestamp = &(block->u.out.u.full.u.cross.ol.q[3]);
f->frame_end_branch = &(block->u.out.u.full.u.cross.ol.q[2]);
}
......@@ -491,7 +491,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
branch_address = &(block->u.out.u.full.u.cross.ol.q[2]);
n_descriptors = 5;
if(first_packet)
if (first_packet)
f->first_n_descriptors = n_descriptors;
full_packets++;
......@@ -514,11 +514,11 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
dma_region_offset_to_bus(&video->dv_buf,
data_p - (unsigned long) video->dv_buf.kvirt));
if(first_packet)
if (first_packet)
f->frame_begin_timestamp = &(block->u.out.u.full.u.nocross.ol.q[3]);
else if(mid_packet)
else if (mid_packet)
f->mid_frame_timestamp = &(block->u.out.u.full.u.nocross.ol.q[3]);
else if(last_packet) {
else if (last_packet) {
f->frame_end_timestamp = &(block->u.out.u.full.u.nocross.ol.q[3]);
f->frame_end_branch = &(block->u.out.u.full.u.nocross.ol.q[2]);
}
......@@ -526,7 +526,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
branch_address = &(block->u.out.u.full.u.nocross.ol.q[2]);
n_descriptors = 4;
if(first_packet)
if (first_packet)
f->first_n_descriptors = n_descriptors;
full_packets++;
......@@ -538,7 +538,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
/* note: we are not linked into the active DMA chain yet */
if(last_branch_address) {
if (last_branch_address) {
*(last_branch_address) = cpu_to_le32(block_dma | n_descriptors);
}
......@@ -564,7 +564,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
video->n_clear_frames--;
last_frame = video->first_clear_frame - 1;
if(last_frame == -1)
if (last_frame == -1)
last_frame = video->n_frames-1;
video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames;
......@@ -578,11 +578,11 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
(unsigned long) f->frame_end_timestamp,
(unsigned long) f->frame_end_branch);
if(video->active_frame != -1) {
if (video->active_frame != -1) {
/* if DMA is already active, we are almost done */
/* just link us onto the active DMA chain */
if(video->frames[last_frame]->frame_end_branch) {
if (video->frames[last_frame]->frame_end_branch) {
u32 temp;
/* point the previous frame's tail to this frame's head */
......@@ -650,11 +650,11 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
f->assigned_timestamp = (ts_cyc&0xF) << 12;
/* now actually write the timestamp into the appropriate CIP headers */
if(f->cip_syt1) {
if (f->cip_syt1) {
f->cip_syt1->b[6] = f->assigned_timestamp >> 8;
f->cip_syt1->b[7] = f->assigned_timestamp & 0xFF;
}
if(f->cip_syt2) {
if (f->cip_syt2) {
f->cip_syt2->b[6] = f->assigned_timestamp >> 8;
f->cip_syt2->b[7] = f->assigned_timestamp & 0xFF;
}
......@@ -706,10 +706,10 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
{
/* check if DMA is really running */
int i = 0;
while(i < 20) {
while (i < 20) {
mb();
mdelay(1);
if(reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) {
if (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) {
printk("DMA ACTIVE after %d msec\n", i);
break;
}
......@@ -721,7 +721,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)
);
if( ! (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) {
if ( ! (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) {
printk("DMA did NOT go active after 20ms, event = %x\n",
reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & 0x1F);
} else
......@@ -821,14 +821,14 @@ static void start_dma_receive(struct video_card *video)
{
int i;
for(i = 0; i < 1000; ++i) {
for (i = 0; i < 1000; ++i) {
mdelay(1);
if(reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) {
if (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) {
printk("DMA ACTIVE after %d msec\n", i);
break;
}
}
if( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
printk("DEAD, event = %x\n",
reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F);
} else
......@@ -836,7 +836,7 @@ static void start_dma_receive(struct video_card *video)
}
#endif
}
else if( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
else if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
debug_printk("DEAD, event = %x\n",
reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F);
......@@ -912,36 +912,36 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
int retval = -EINVAL;
debug_printk("dv1394: initialising %d\n", video->id);
if(init->api_version != DV1394_API_VERSION)
if (init->api_version != DV1394_API_VERSION)
return -EINVAL;
/* first sanitize all the parameters */
if( (init->n_frames < 2) || (init->n_frames > DV1394_MAX_FRAMES) )
if ( (init->n_frames < 2) || (init->n_frames > DV1394_MAX_FRAMES) )
return -EINVAL;
if( (init->format != DV1394_NTSC) && (init->format != DV1394_PAL) )
if ( (init->format != DV1394_NTSC) && (init->format != DV1394_PAL) )
return -EINVAL;
if( (init->syt_offset == 0) || (init->syt_offset > 50) )
if ( (init->syt_offset == 0) || (init->syt_offset > 50) )
/* default SYT offset is 3 cycles */
init->syt_offset = 3;
if( (init->channel > 63) || (init->channel < 0) )
if ( (init->channel > 63) || (init->channel < 0) )
init->channel = 63;
chan_mask = (u64)1 << init->channel;
/* calculate what size DMA buffer is needed */
if(init->format == DV1394_NTSC)
if (init->format == DV1394_NTSC)
new_buf_size = DV1394_NTSC_FRAME_SIZE * init->n_frames;
else
new_buf_size = DV1394_PAL_FRAME_SIZE * init->n_frames;
/* round up to PAGE_SIZE */
if(new_buf_size % PAGE_SIZE) new_buf_size += PAGE_SIZE - (new_buf_size % PAGE_SIZE);
if (new_buf_size % PAGE_SIZE) new_buf_size += PAGE_SIZE - (new_buf_size % PAGE_SIZE);
/* don't allow the user to allocate the DMA buffer more than once */
if(video->dv_buf.kvirt && video->dv_buf_size != new_buf_size) {
if (video->dv_buf.kvirt && video->dv_buf_size != new_buf_size) {
printk("dv1394: re-sizing the DMA buffer is not allowed\n");
return -EINVAL;
}
......@@ -953,7 +953,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
/* try to claim the ISO channel */
spin_lock_irqsave(&video->ohci->IR_channel_lock, flags);
if(video->ohci->ISO_channel_usage & chan_mask) {
if (video->ohci->ISO_channel_usage & chan_mask) {
spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags);
retval = -EBUSY;
goto err;
......@@ -981,7 +981,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
video->current_packet = -1;
video->first_frame = 0;
if(video->pal_or_ntsc == DV1394_NTSC) {
if (video->pal_or_ntsc == DV1394_NTSC) {
video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_NTSC;
video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_NTSC;
video->frame_size = DV1394_NTSC_FRAME_SIZE;
......@@ -995,7 +995,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
/* find and claim DMA contexts on the OHCI card */
if(video->ohci_it_ctx == -1) {
if (video->ohci_it_ctx == -1) {
ohci1394_init_iso_tasklet(&video->it_tasklet, OHCI_ISO_TRANSMIT,
it_tasklet_func, (unsigned long) video);
......@@ -1009,7 +1009,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
debug_printk("dv1394: claimed IT DMA context %d\n", video->ohci_it_ctx);
}
if(video->ohci_ir_ctx == -1) {
if (video->ohci_ir_ctx == -1) {
ohci1394_init_iso_tasklet(&video->ir_tasklet, OHCI_ISO_RECEIVE,
ir_tasklet_func, (unsigned long) video);
......@@ -1023,20 +1023,20 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
}
/* allocate struct frames */
for(i = 0; i < init->n_frames; i++) {
for (i = 0; i < init->n_frames; i++) {
video->frames[i] = frame_new(i, video);
if(!video->frames[i]) {
if (!video->frames[i]) {
printk(KERN_ERR "dv1394: Cannot allocate frame structs\n");
retval = -ENOMEM;
goto err;
}
}
if(!video->dv_buf.kvirt) {
if (!video->dv_buf.kvirt) {
/* allocate the ringbuffer */
retval = dma_region_alloc(&video->dv_buf, new_buf_size, video->ohci->dev, PCI_DMA_TODEVICE);
if(retval)
if (retval)
goto err;
video->dv_buf_size = new_buf_size;
......@@ -1047,10 +1047,10 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
}
/* set up the frame->data pointers */
for(i = 0; i < video->n_frames; i++)
for (i = 0; i < video->n_frames; i++)
video->frames[i]->data = (unsigned long) video->dv_buf.kvirt + i * video->frame_size;
if(!video->packet_buf.kvirt) {
if (!video->packet_buf.kvirt) {
/* allocate packet buffer */
video->packet_buf_size = sizeof(struct packet) * video->n_frames * MAX_PACKETS;
if (video->packet_buf_size % PAGE_SIZE)
......@@ -1058,7 +1058,7 @@ static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
retval = dma_region_alloc(&video->packet_buf, video->packet_buf_size,
video->ohci->dev, PCI_DMA_FROMDEVICE);
if(retval)
if (retval)
goto err;
debug_printk("dv1394: Allocated %d packets in buffer, total %u pages (%u DMA pages), %lu bytes\n",
......@@ -1124,11 +1124,11 @@ static void stop_dma(struct video_card *video)
video->dma_running = 0;
if( (video->ohci_it_ctx == -1) && (video->ohci_ir_ctx == -1) )
if ( (video->ohci_it_ctx == -1) && (video->ohci_ir_ctx == -1) )
goto out;
/* stop DMA if in progress */
if( (video->active_frame != -1) ||
if ( (video->active_frame != -1) ||
(reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
(reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) {
......@@ -1142,12 +1142,12 @@ static void stop_dma(struct video_card *video)
/* wait until DMA really stops */
i = 0;
while(i < 1000) {
while (i < 1000) {
/* wait 0.1 millisecond */
udelay(100);
if( (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
if ( (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
(reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) {
/* still active */
debug_printk("dv1394: stop_dma: DMA not stopped yet\n" );
......@@ -1160,7 +1160,7 @@ static void stop_dma(struct video_card *video)
i++;
}
if(i == 1000) {
if (i == 1000) {
printk(KERN_ERR "dv1394: stop_dma: DMA still going after %d ms!\n", i/10);
}
}
......@@ -1183,7 +1183,7 @@ static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
stop_dma(video);
/* release the DMA contexts */
if(video->ohci_it_ctx != -1) {
if (video->ohci_it_ctx != -1) {
video->ohci_IsoXmitContextControlSet = 0;
video->ohci_IsoXmitContextControlClear = 0;
video->ohci_IsoXmitCommandPtr = 0;
......@@ -1197,7 +1197,7 @@ static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
video->ohci_it_ctx = -1;
}
if(video->ohci_ir_ctx != -1) {
if (video->ohci_ir_ctx != -1) {
video->ohci_IsoRcvContextControlSet = 0;
video->ohci_IsoRcvContextControlClear = 0;
video->ohci_IsoRcvCommandPtr = 0;
......@@ -1213,7 +1213,7 @@ static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
}
/* release the ISO channel */
if(video->channel != -1) {
if (video->channel != -1) {
u64 chan_mask;
unsigned long flags;
......@@ -1227,8 +1227,8 @@ static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
}
/* free the frame structs */
for(i = 0; i < DV1394_MAX_FRAMES; i++) {
if(video->frames[i])
for (i = 0; i < DV1394_MAX_FRAMES; i++) {
if (video->frames[i])
frame_delete(video->frames[i]);
video->frames[i] = NULL;
}
......@@ -1238,7 +1238,7 @@ static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
/* we can't free the DMA buffer unless it is guaranteed that
no more user-space mappings exist */
if(free_dv_buf) {
if (free_dv_buf) {
dma_region_free(&video->dv_buf);
video->dv_buf_size = 0;
}
......@@ -1282,9 +1282,9 @@ int dv1394_mmap(struct file *file, struct vm_area_struct *vma)
/* serialize mmap */
down(&video->sem);
if( ! video_card_initialized(video) ) {
if ( ! video_card_initialized(video) ) {
retval = do_dv1394_init_default(video);
if(retval)
if (retval)
goto out;
}
......@@ -1306,14 +1306,14 @@ static unsigned int dv1394_poll(struct file *file, struct poll_table_struct *wai
poll_wait(file, &video->waitq, wait);
spin_lock_irqsave(&video->spinlock, flags);
if( video->n_frames == 0 ) {
if ( video->n_frames == 0 ) {
} else if( video->active_frame == -1 ) {
} else if ( video->active_frame == -1 ) {
/* nothing going on */
mask |= POLLOUT;
} else {
/* any clear/ready buffers? */
if(video->n_clear_frames >0)
if (video->n_clear_frames >0)
mask |= POLLOUT | POLLIN;
}
spin_unlock_irqrestore(&video->spinlock, flags);
......@@ -1345,17 +1345,17 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
int target_frame;
/* serialize this to prevent multi-threaded mayhem */
if(file->f_flags & O_NONBLOCK) {
if(down_trylock(&video->sem))
if (file->f_flags & O_NONBLOCK) {
if (down_trylock(&video->sem))
return -EAGAIN;
} else {
if(down_interruptible(&video->sem))
if (down_interruptible(&video->sem))
return -ERESTARTSYS;
}
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = do_dv1394_init_default(video);
if(ret) {
if (ret) {
up(&video->sem);
return ret;
}
......@@ -1364,7 +1364,7 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
ret = 0;
add_wait_queue(&video->waitq, &wait);
while(count > 0) {
while (count > 0) {
/* must set TASK_INTERRUPTIBLE *before* checking for free
buffers; otherwise we could miss a wakeup if the interrupt
......@@ -1378,7 +1378,7 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
spin_unlock_irqrestore(&video->spinlock, flags);
if(video->frames[target_frame]->state == FRAME_CLEAR) {
if (video->frames[target_frame]->state == FRAME_CLEAR) {
/* how much room is left in the target frame buffer */
cnt = video->frame_size - (video->write_off - target_frame * video->frame_size);
......@@ -1388,12 +1388,12 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
cnt = 0;
}
if(cnt > count)
if (cnt > count)
cnt = count;
if (cnt <= 0) {
/* no room left, gotta wait */
if(file->f_flags & O_NONBLOCK) {
if (file->f_flags & O_NONBLOCK) {
if (!ret)
ret = -EAGAIN;
break;
......@@ -1409,8 +1409,8 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
continue; /* start over from 'while(count > 0)...' */
}
if(copy_from_user(video->dv_buf.kvirt + video->write_off, buffer, cnt)) {
if(!ret)
if (copy_from_user(video->dv_buf.kvirt + video->write_off, buffer, cnt)) {
if (!ret)
ret = -EFAULT;
break;
}
......@@ -1421,7 +1421,7 @@ static ssize_t dv1394_write(struct file *file, const char *buffer, size_t count,
buffer += cnt;
ret += cnt;
if(video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames))
if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames))
frame_prepare(video, target_frame);
}
......@@ -1442,17 +1442,17 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
int target_frame;
/* serialize this to prevent multi-threaded mayhem */
if(file->f_flags & O_NONBLOCK) {
if(down_trylock(&video->sem))
if (file->f_flags & O_NONBLOCK) {
if (down_trylock(&video->sem))
return -EAGAIN;
} else {
if(down_interruptible(&video->sem))
if (down_interruptible(&video->sem))
return -ERESTARTSYS;
}
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = do_dv1394_init_default(video);
if(ret) {
if (ret) {
up(&video->sem);
return ret;
}
......@@ -1466,7 +1466,7 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
ret = 0;
add_wait_queue(&video->waitq, &wait);
while(count > 0) {
while (count > 0) {
/* must set TASK_INTERRUPTIBLE *before* checking for free
buffers; otherwise we could miss a wakeup if the interrupt
......@@ -1480,7 +1480,7 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
spin_unlock_irqrestore(&video->spinlock, flags);
if(target_frame >= 0 &&
if (target_frame >= 0 &&
video->n_clear_frames > 0 &&
video->frames[target_frame]->state == FRAME_CLEAR) {
......@@ -1492,12 +1492,12 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
cnt = 0;
}
if(cnt > count)
if (cnt > count)
cnt = count;
if (cnt <= 0) {
/* no room left, gotta wait */
if(file->f_flags & O_NONBLOCK) {
if (file->f_flags & O_NONBLOCK) {
if (!ret)
ret = -EAGAIN;
break;
......@@ -1513,8 +1513,8 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
continue; /* start over from 'while(count > 0)...' */
}
if(copy_to_user(buffer, video->dv_buf.kvirt + video->write_off, cnt)) {
if(!ret)
if (copy_to_user(buffer, video->dv_buf.kvirt + video->write_off, cnt)) {
if (!ret)
ret = -EFAULT;
break;
}
......@@ -1525,7 +1525,7 @@ static ssize_t dv1394_read(struct file *file, char *buffer, size_t count, loff_
buffer += cnt;
ret += cnt;
if(video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames)) {
if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames)) {
spin_lock_irqsave(&video->spinlock, flags);
video->n_clear_frames--;
video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames;
......@@ -1555,11 +1555,11 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
DECLARE_WAITQUEUE(wait, current);
/* serialize this to prevent multi-threaded mayhem */
if(file->f_flags & O_NONBLOCK) {
if(down_trylock(&video->sem))
if (file->f_flags & O_NONBLOCK) {
if (down_trylock(&video->sem))
return -EAGAIN;
} else {
if(down_interruptible(&video->sem))
if (down_interruptible(&video->sem))
return -ERESTARTSYS;
}
......@@ -1568,20 +1568,20 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
case DV1394_IOC_SUBMIT_FRAMES: {
unsigned int n_submit;
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = do_dv1394_init_default(video);
if(ret)
if (ret)
goto out;
}
n_submit = (unsigned int) arg;
if(n_submit > video->n_frames) {
if (n_submit > video->n_frames) {
ret = -EINVAL;
goto out;
}
while(n_submit > 0) {
while (n_submit > 0) {
add_wait_queue(&video->waitq, &wait);
set_current_state(TASK_INTERRUPTIBLE);
......@@ -1589,11 +1589,11 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
spin_lock_irqsave(&video->spinlock, flags);
/* wait until video->first_clear_frame is really CLEAR */
while(video->frames[video->first_clear_frame]->state != FRAME_CLEAR) {
while (video->frames[video->first_clear_frame]->state != FRAME_CLEAR) {
spin_unlock_irqrestore(&video->spinlock, flags);
if(signal_pending(current)) {
if (signal_pending(current)) {
remove_wait_queue(&video->waitq, &wait);
set_current_state(TASK_RUNNING);
ret = -EINTR;
......@@ -1622,7 +1622,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
case DV1394_IOC_WAIT_FRAMES: {
unsigned int n_wait;
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = -EINVAL;
goto out;
}
......@@ -1633,7 +1633,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
never actually have n_frames clear frames; at most only
n_frames - 1 */
if(n_wait > (video->n_frames-1) ) {
if (n_wait > (video->n_frames-1) ) {
ret = -EINVAL;
goto out;
}
......@@ -1643,11 +1643,11 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
spin_lock_irqsave(&video->spinlock, flags);
while(video->n_clear_frames < n_wait) {
while (video->n_clear_frames < n_wait) {
spin_unlock_irqrestore(&video->spinlock, flags);
if(signal_pending(current)) {
if (signal_pending(current)) {
remove_wait_queue(&video->waitq, &wait);
set_current_state(TASK_RUNNING);
ret = -EINTR;
......@@ -1671,7 +1671,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
case DV1394_IOC_RECEIVE_FRAMES: {
unsigned int n_recv;
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = -EINVAL;
goto out;
}
......@@ -1679,7 +1679,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
n_recv = (unsigned int) arg;
/* at least one frame must be active */
if(n_recv > (video->n_frames-1) ) {
if (n_recv > (video->n_frames-1) ) {
ret = -EINVAL;
goto out;
}
......@@ -1702,9 +1702,9 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
}
case DV1394_IOC_START_RECEIVE: {
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = do_dv1394_init_default(video);
if(ret)
if (ret)
goto out;
}
......@@ -1720,10 +1720,10 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
case DV1394_IOC_INIT: {
struct dv1394_init init;
if(arg == (unsigned long) NULL) {
if (arg == (unsigned long) NULL) {
ret = do_dv1394_init_default(video);
} else {
if(copy_from_user(&init, (void*)arg, sizeof(init))) {
if (copy_from_user(&init, (void*)arg, sizeof(init))) {
ret = -EFAULT;
goto out;
}
......@@ -1741,7 +1741,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
case DV1394_IOC_GET_STATUS: {
struct dv1394_status status;
if( !video_card_initialized(video) ) {
if ( !video_card_initialized(video) ) {
ret = -EINVAL;
goto out;
}
......@@ -1769,7 +1769,7 @@ static int dv1394_ioctl(struct inode *inode, struct file *file,
spin_unlock_irqrestore(&video->spinlock, flags);
if(copy_to_user((void*)arg, &status, sizeof(status))) {
if (copy_to_user((void*)arg, &status, sizeof(status))) {
ret = -EFAULT;
goto out;
}
......@@ -1797,7 +1797,7 @@ static int dv1394_open(struct inode *inode, struct file *file)
/* if the device was opened through devfs, then file->private_data
has already been set to video by devfs */
if(file->private_data) {
if (file->private_data) {
video = (struct video_card*) file->private_data;
} else {
......@@ -1807,11 +1807,11 @@ static int dv1394_open(struct inode *inode, struct file *file)
unsigned long flags;
spin_lock_irqsave(&dv1394_cards_lock, flags);
if(!list_empty(&dv1394_cards)) {
if (!list_empty(&dv1394_cards)) {
struct video_card *p;
list_for_each(lh, &dv1394_cards) {
p = list_entry(lh, struct video_card, list);
if((p->id) == ieee1394_file_to_instance(file)) {
if ((p->id) == ieee1394_file_to_instance(file)) {
video = p;
break;
}
......@@ -1819,7 +1819,7 @@ static int dv1394_open(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
if(!video) {
if (!video) {
debug_printk("dv1394: OHCI card %d not found", ieee1394_file_to_instance(file));
return -ENODEV;
}
......@@ -1829,7 +1829,7 @@ static int dv1394_open(struct inode *inode, struct file *file)
#ifndef DV1394_ALLOW_MORE_THAN_ONE_OPEN
if( test_and_set_bit(0, &video->open) ) {
if ( test_and_set_bit(0, &video->open) ) {
/* video is already open by someone else */
return -EBUSY;
}
......@@ -1971,10 +1971,10 @@ dv1394_procfs_find( char *name)
struct dv1394_procfs_entry *p;
spin_lock( &dv1394_procfs_lock);
if(!list_empty(&dv1394_procfs)) {
if (!list_empty(&dv1394_procfs)) {
list_for_each(lh, &dv1394_procfs) {
p = list_entry(lh, struct dv1394_procfs_entry, list);
if(!strncmp(p->name, name, sizeof(p->name))) {
if (!strncmp(p->name, name, sizeof(p->name))) {
spin_unlock( &dv1394_procfs_lock);
return p;
}
......@@ -1991,7 +1991,7 @@ static int dv1394_procfs_add_entry(struct video_card *video)
struct dv1394_procfs_entry *parent;
p = kmalloc(sizeof(struct dv1394_procfs_entry), GFP_KERNEL);
if(!p) {
if (!p) {
printk(KERN_ERR "dv1394: cannot allocate dv1394_procfs_entry\n");
goto err;
}
......@@ -2043,7 +2043,7 @@ dv1394_procfs_add_dir( char *name,
struct dv1394_procfs_entry *p;
p = kmalloc(sizeof(struct dv1394_procfs_entry), GFP_KERNEL);
if(!p) {
if (!p) {
printk(KERN_ERR "dv1394: cannot allocate dv1394_procfs_entry\n");
goto err;
}
......@@ -2104,7 +2104,7 @@ static void it_tasklet_func(unsigned long data)
spin_lock(&video->spinlock);
if(!video->dma_running)
if (!video->dma_running)
goto out;
irq_printk("ContextControl = %08x, CommandPtr = %08x\n",
......@@ -2113,24 +2113,24 @@ static void it_tasklet_func(unsigned long data)
);
if( (video->ohci_it_ctx != -1) &&
if ( (video->ohci_it_ctx != -1) &&
(reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) {
struct frame *f;
unsigned int frame, i;
if(video->active_frame == -1)
if (video->active_frame == -1)
frame = 0;
else
frame = video->active_frame;
/* check all the DMA-able frames */
for(i = 0; i < video->n_frames; i++, frame = (frame+1) % video->n_frames) {
for (i = 0; i < video->n_frames; i++, frame = (frame+1) % video->n_frames) {
irq_printk("IRQ checking frame %d...", frame);
f = video->frames[frame];
if(f->state != FRAME_READY) {
if (f->state != FRAME_READY) {
irq_printk("clear, skipping\n");
/* we don't own this frame */
continue;
......@@ -2139,7 +2139,7 @@ static void it_tasklet_func(unsigned long data)
irq_printk("DMA\n");
/* check the frame begin semaphore to see if we can free the previous frame */
if( *(f->frame_begin_timestamp) ) {
if ( *(f->frame_begin_timestamp) ) {
int prev_frame;
struct frame *prev_f;
......@@ -2149,13 +2149,13 @@ static void it_tasklet_func(unsigned long data)
irq_printk(" BEGIN\n");
prev_frame = frame - 1;
if(prev_frame == -1)
if (prev_frame == -1)
prev_frame += video->n_frames;
prev_f = video->frames[prev_frame];
/* make sure we can actually garbage collect
this frame */
if( (prev_f->state == FRAME_READY) &&
if ( (prev_f->state == FRAME_READY) &&
prev_f->done && (!f->done) )
{
frame_reset(prev_f);
......@@ -2173,7 +2173,7 @@ static void it_tasklet_func(unsigned long data)
/* see if we need to set the timestamp for the next frame */
if( *(f->mid_frame_timestamp) ) {
if ( *(f->mid_frame_timestamp) ) {
struct frame *next_frame;
u32 begin_ts, ts_cyc, ts_off;
......@@ -2188,7 +2188,7 @@ static void it_tasklet_func(unsigned long data)
/* prepare next frame and assign timestamp */
next_frame = video->frames[ (frame+1) % video->n_frames ];
if(next_frame->state == FRAME_READY) {
if (next_frame->state == FRAME_READY) {
irq_printk(" MIDDLE - next frame is ready, good\n");
} else {
debug_printk("dv1394: Underflow! At least one frame has been dropped.\n");
......@@ -2207,11 +2207,11 @@ static void it_tasklet_func(unsigned long data)
ts_off %= 3072;
next_frame->assigned_timestamp = ((ts_cyc&0xF) << 12) + ts_off;
if(next_frame->cip_syt1) {
if (next_frame->cip_syt1) {
next_frame->cip_syt1->b[6] = next_frame->assigned_timestamp >> 8;
next_frame->cip_syt1->b[7] = next_frame->assigned_timestamp & 0xFF;
}
if(next_frame->cip_syt2) {
if (next_frame->cip_syt2) {
next_frame->cip_syt2->b[6] = next_frame->assigned_timestamp >> 8;
next_frame->cip_syt2->b[7] = next_frame->assigned_timestamp & 0xFF;
}
......@@ -2219,7 +2219,7 @@ static void it_tasklet_func(unsigned long data)
}
/* see if the frame looped */
if( *(f->frame_end_timestamp) ) {
if ( *(f->frame_end_timestamp) ) {
*(f->frame_end_timestamp) = 0;
......@@ -2230,10 +2230,10 @@ static void it_tasklet_func(unsigned long data)
} /* for(each frame) */
} /* for (each frame) */
}
if(wake) {
if (wake) {
kill_fasync(&video->fasync, SIGIO, POLL_OUT);
/* wake readers/writers/ioctl'ers */
......@@ -2251,10 +2251,10 @@ static void ir_tasklet_func(unsigned long data)
spin_lock(&video->spinlock);
if(!video->dma_running)
if (!video->dma_running)
goto out;
if( (video->ohci_ir_ctx != -1) &&
if ( (video->ohci_ir_ctx != -1) &&
(reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) )
{
......@@ -2374,7 +2374,7 @@ static void ir_tasklet_func(unsigned long data)
prev_i = (next_i == 0) ? (MAX_PACKETS * video->n_frames - 1) : (next_i - 1);
f = video->frames[prev_i / MAX_PACKETS];
prev = &(f->descriptor_pool[prev_i % MAX_PACKETS]);
if(prev_i % (MAX_PACKETS/2)) {
if (prev_i % (MAX_PACKETS/2)) {
prev->u.in.il.q[0] &= ~(3 << 20); /* no interrupt */
} else {
prev->u.in.il.q[0] |= 3 << 20; /* enable interrupt */
......@@ -2394,7 +2394,7 @@ static void ir_tasklet_func(unsigned long data)
} /* receive interrupt */
if(wake) {
if (wake) {
kill_fasync(&video->fasync, SIGIO, POLL_IN);
/* wake readers/writers/ioctl'ers */
......@@ -2453,7 +2453,7 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
int i;
video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
if(!video) {
if (!video) {
printk(KERN_ERR "dv1394: cannot allocate video_card\n");
goto err;
}
......@@ -2497,7 +2497,7 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
goto err_free;
#endif
for(i = 0; i < DV1394_MAX_FRAMES; i++)
for (i = 0; i < DV1394_MAX_FRAMES; i++)
video->frames[i] = NULL;
dma_region_init(&video->dv_buf);
......@@ -2574,10 +2574,10 @@ static void dv1394_remove_host (struct hpsb_host *host)
/* find the corresponding video_cards */
spin_lock_irqsave(&dv1394_cards_lock, flags);
if(!list_empty(&dv1394_cards)) {
if (!list_empty(&dv1394_cards)) {
list_for_each_safe(lh, templh, &dv1394_cards) {
video = list_entry(lh, struct video_card, list);
if((video->id >> 2) == ohci->id)
if ((video->id >> 2) == ohci->id)
dv1394_un_init(video);
}
}
......@@ -2655,32 +2655,32 @@ static void dv1394_host_reset(struct hpsb_host *host)
/* find the corresponding video_cards */
spin_lock_irqsave(&dv1394_cards_lock, flags);
if(!list_empty(&dv1394_cards)) {
if (!list_empty(&dv1394_cards)) {
list_for_each(lh, &dv1394_cards) {
video = list_entry(lh, struct video_card, list);
if((video->id >> 2) == ohci->id)
if ((video->id >> 2) == ohci->id)
break;
}
}
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
if(!video)
if (!video)
return;
spin_lock_irqsave(&video->spinlock, flags);
if(!video->dma_running)
if (!video->dma_running)
goto out;
/* check IT context */
if(video->ohci_it_ctx != -1) {
if (video->ohci_it_ctx != -1) {
u32 ctx;
ctx = reg_read(video->ohci, video->ohci_IsoXmitContextControlSet);
/* if(RUN but not ACTIVE) */
if( (ctx & (1<<15)) &&
/* if (RUN but not ACTIVE) */
if ( (ctx & (1<<15)) &&
!(ctx & (1<<10)) ) {
debug_printk("dv1394: IT context stopped due to bus reset; waking it up\n");
......@@ -2710,13 +2710,13 @@ static void dv1394_host_reset(struct hpsb_host *host)
}
/* check IR context */
if(video->ohci_ir_ctx != -1) {
if (video->ohci_ir_ctx != -1) {
u32 ctx;
ctx = reg_read(video->ohci, video->ohci_IsoRcvContextControlSet);
/* if(RUN but not ACTIVE) */
if( (ctx & (1<<15)) &&
/* if (RUN but not ACTIVE) */
if ( (ctx & (1<<15)) &&
!(ctx & (1<<10)) ) {
debug_printk("dv1394: IR context stopped due to bus reset; waking it up\n");
......
......@@ -64,7 +64,7 @@
ioctl(fd, DV1394_INIT, &init);
while(1) {
while (1) {
read( <a raw DV file>, buf, DV1394_NTSC_FRAME_SIZE );
write( <the dv1394 FD>, buf, DV1394_NTSC_FRAME_SIZE );
}
......@@ -145,7 +145,7 @@
(checks of system call return values omitted for brevity; always
check return values in your code!)
while( frames left ) {
while ( frames left ) {
struct pollfd *pfd = ...;
......@@ -157,15 +157,15 @@
poll(pfd, 1, -1); (or select(); add a timeout if you want)
if(pfd->revents) {
if (pfd->revents) {
struct dv1394_status status;
ioctl(dv1394_fd, DV1394_GET_STATUS, &status);
if(status.dropped_frames > 0) {
if (status.dropped_frames > 0) {
reset_dv1394();
} else {
for(int i = 0; i < status.n_clear_frames; i++) {
for (int i = 0; i < status.n_clear_frames; i++) {
copy_DV_frame();
}
}
......
......@@ -30,7 +30,7 @@
* TODO:
* RFC 2734 related:
* - Add Config ROM entry
* - Add MCAP and multicast
* - Add MCAP. Limited Multicast exists only to 224.0.0.1 and 224.0.0.2.
*
* Non-RFC 2734 related:
* - Fix bug related to fragmented broadcast datagrams
......@@ -59,9 +59,12 @@
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/tcp.h>
#include <linux/skbuff.h>
#include <linux/bitops.h>
#include <linux/ethtool.h>
#include <asm/uaccess.h>
#include <asm/delay.h>
#include <asm/semaphore.h>
#include <net/arp.h>
......@@ -76,17 +79,17 @@
#include "eth1394.h"
#define ETH1394_PRINT_G(level, fmt, args...) \
printk(level ETHER1394_DRIVER_NAME": "fmt, ## args)
printk(level "%s: " fmt, driver_name, ## args)
#define ETH1394_PRINT(level, dev_name, fmt, args...) \
printk(level ETHER1394_DRIVER_NAME": %s: " fmt, dev_name, ## args)
printk(level "%s: %s: " fmt, driver_name, dev_name, ## args)
#define DEBUG(fmt, args...) \
printk(KERN_ERR "eth1394:%s[%d]: "fmt"\n", __FUNCTION__, __LINE__, ## args)
#define TRACE() printk(KERN_ERR "eth1394:%s[%d] ---- TRACE\n", __FUNCTION__, __LINE__)
printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args)
#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
static char version[] __devinitdata =
"$Rev: 951 $ Ben Collins <bcollins@debian.org>";
"$Rev: 971 $ Ben Collins <bcollins@debian.org>";
struct fragment_info {
struct list_head list;
......@@ -105,7 +108,7 @@ struct partial_datagram {
};
/* Our ieee1394 highlevel driver */
#define ETHER1394_DRIVER_NAME "ether1394"
static const char driver_name[] = "eth1394";
static kmem_cache_t *packet_task_cache;
......@@ -156,15 +159,26 @@ static inline void purge_partial_datagram(struct list_head *old);
static int ether1394_tx(struct sk_buff *skb, struct net_device *dev);
static void ether1394_iso(struct hpsb_iso *iso);
static int ether1394_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr);
static void eth1394_iso_shutdown(struct eth1394_priv *priv)
{
priv->bc_state = ETHER1394_BC_CLOSED;
if (priv->iso != NULL) {
hpsb_iso_shutdown(priv->iso);
priv->iso = NULL;
}
}
static int ether1394_init_bc(struct net_device *dev)
{
int ret = 0;
struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
/* First time sending? Need a broadcast channel for ARP and for
* listening on */
if(priv->bc_state == ETHER1394_BC_CHECK) {
if (priv->bc_state == ETHER1394_BC_CHECK) {
quadlet_t bc;
/* Get the local copy of the broadcast channel and check its
......@@ -172,30 +186,26 @@ static int ether1394_init_bc(struct net_device *dev)
bc = priv->host->csr.broadcast_channel;
if((bc & 0xc0000000) != 0xc0000000) {
if ((bc & 0xc0000000) != 0xc0000000) {
/* broadcast channel not validated yet */
ETH1394_PRINT(KERN_WARNING, dev->name,
"Error BROADCAST_CHANNEL register valid "
"bit not set, can't send IP traffic\n");
if(!in_interrupt()) {
hpsb_iso_shutdown(priv->iso);
priv->bc_state = ETHER1394_BC_CLOSED;
}
ret = -EAGAIN;
goto fail;
if (!in_interrupt())
eth1394_iso_shutdown(priv);
return -EAGAIN;
}
if(priv->broadcast_channel != (bc & 0x3f)) {
if (priv->broadcast_channel != (bc & 0x3f)) {
/* This really shouldn't be possible, but just in case
* the IEEE 1394 spec changes regarding broadcast
* channels in the future. */
if(in_interrupt()) {
ret = -EAGAIN;
goto fail;
if (in_interrupt())
return -EAGAIN;
}
hpsb_iso_shutdown(priv->iso);
eth1394_iso_shutdown(priv);
priv->broadcast_channel = bc & 0x3f;
ETH1394_PRINT(KERN_INFO, dev->name,
......@@ -205,29 +215,26 @@ static int ether1394_init_bc(struct net_device *dev)
priv->iso = hpsb_iso_recv_init(priv->host, 16 * 4096,
16, priv->broadcast_channel,
1, ether1394_iso);
if(priv->iso == NULL) {
if (priv->iso == NULL) {
ETH1394_PRINT(KERN_ERR, dev->name,
"failed to change broadcast "
"channel\n");
ret = -EAGAIN;
goto fail;
return -EAGAIN;
}
}
if(hpsb_iso_recv_start(priv->iso, -1, (1 << 3), -1) < 0) {
if (hpsb_iso_recv_start(priv->iso, -1, (1 << 3), -1) < 0) {
ETH1394_PRINT(KERN_ERR, dev->name,
"Could not start data stream reception\n");
if(!in_interrupt()) {
hpsb_iso_shutdown(priv->iso);
priv->bc_state = ETHER1394_BC_CLOSED;
}
ret = -EAGAIN;
goto fail;
if (!in_interrupt())
eth1394_iso_shutdown(priv);
return -EAGAIN;
}
priv->bc_state = ETHER1394_BC_OPENED;
}
fail:
return ret;
return 0;
}
/* This is called after an "ifup" */
......@@ -243,7 +250,7 @@ static int ether1394_open (struct net_device *dev)
ret = ether1394_init_bc(dev);
spin_unlock_irqrestore(&priv->lock, flags);
if(ret)
if (ret)
return ret;
netif_start_queue (dev);
......@@ -280,9 +287,9 @@ static int ether1394_change_mtu(struct net_device *dev, int new_mtu)
struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
int phy_id = NODEID_TO_NODE(priv->host->node_id);
if ((new_mtu < 68) || (new_mtu > (priv->maxpayload[phy_id] -
if ((new_mtu < 68) || (new_mtu > MIN(ETH_DATA_LEN, (priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) +
ETHER1394_GASP_OVERHEAD))))
ETHER1394_GASP_OVERHEAD)))))
return -EINVAL;
dev->mtu = new_mtu;
return 0;
......@@ -315,7 +322,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
struct hpsb_host *host = priv->host;
int phy_id = NODEID_TO_NODE(host->node_id);
u64 guid = *((u64*)&(host->csr.rom[3]));
u64 guid = (u64)(((u64)be32_to_cpu(host->csr.rom[3]) << 32) |
be32_to_cpu(host->csr.rom[4]));
u16 maxpayload = 1 << (((be32_to_cpu(host->csr.rom[2]) >> 12) & 0xf) + 1);
spin_lock_irqsave (&priv->lock, flags);
......@@ -325,14 +333,14 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
memset (priv->sspd, 0, sizeof (priv->sspd));
memset (priv->fifo, 0, sizeof (priv->fifo));
#if 0
#if 1
/* Compile this out to make testing of fragmented broadcast datagrams
* easier. */
priv->sspd[ALL_NODES] = SPEED_MAX;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[SPEED_MAX];
priv->sspd[ALL_NODES] = IEEE1394_SPEED_MAX;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[IEEE1394_SPEED_MAX];
#else
priv->sspd[ALL_NODES] = SPEED_100;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[SPEED_100];
priv->sspd[ALL_NODES] = IEEE1394_SPEED_100;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[IEEE1394_SPEED_100];
#endif
priv->bc_state = ETHER1394_BC_CHECK;
......@@ -344,8 +352,9 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
/* We'll use our maxpayload as the default mtu */
if (set_mtu) {
dev->mtu = priv->maxpayload[phy_id] - (sizeof(union eth1394_hdr) +
ETHER1394_GASP_OVERHEAD);
dev->mtu = MIN(ETH_DATA_LEN, priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) +
ETHER1394_GASP_OVERHEAD));
/* Set our hardware address while we're at it */
*(u64*)dev->dev_addr = guid;
......@@ -354,11 +363,11 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
spin_unlock_irqrestore (&priv->lock, flags);
for(i = 0; i < ALL_NODES; i++) {
for (i = 0; i < ALL_NODES; i++) {
struct list_head *lh, *n;
spin_lock_irqsave(&priv->pdg[i].lock, flags);
if(!set_mtu) {
if (!set_mtu) {
list_for_each_safe(lh, n, &priv->pdg[i].list) {
purge_partial_datagram(lh);
}
......@@ -386,11 +395,14 @@ static int ether1394_init_dev (struct net_device *dev)
dev->header_cache_update= ether1394_header_cache_update;
dev->hard_header_parse = ether1394_header_parse;
dev->set_mac_address = ether1394_mac_addr;
dev->do_ioctl = ether1394_do_ioctl;
/* Some constants */
dev->watchdog_timeo = ETHER1394_TIMEOUT;
dev->flags = IFF_BROADCAST; /* | IFF_MULTICAST someday */
dev->features = NETIF_F_NO_CSUM|NETIF_F_SG|NETIF_F_HIGHDMA|NETIF_F_FRAGLIST;
dev->flags = IFF_BROADCAST | IFF_MULTICAST;
/* !! If data corruption or untrackable kernel panics occur, try
* removing NETIF_F_FRAGLIST !! */
dev->features = NETIF_F_HIGHDMA | NETIF_F_FRAGLIST;
dev->addr_len = ETH1394_ALEN;
dev->hard_header_len = ETH1394_HLEN;
dev->type = ARPHRD_IEEE1394;
......@@ -421,8 +433,12 @@ static void ether1394_add_host (struct hpsb_host *host)
* it for ourselves. That way we'd be a real networking device. */
dev = alloc_etherdev(sizeof (struct eth1394_priv));
if (dev == NULL)
if (dev == NULL) {
ETH1394_PRINT_G (KERN_ERR, "Out of memory trying to allocate "
"etherdevice for IEEE 1394 device %s-%d\n",
host->driver->name, host->id);
goto out;
}
SET_MODULE_OWNER(dev);
......@@ -433,7 +449,7 @@ static void ether1394_add_host (struct hpsb_host *host)
priv->host = host;
spin_lock_init(&priv->lock);
for(i = 0; i < ALL_NODES; i++) {
for (i = 0; i < ALL_NODES; i++) {
spin_lock_init(&priv->pdg[i].lock);
INIT_LIST_HEAD(&priv->pdg[i].list);
priv->pdg[i].sz = 0;
......@@ -441,8 +457,12 @@ static void ether1394_add_host (struct hpsb_host *host)
hi = hpsb_create_hostinfo(&eth1394_highlevel, host, sizeof(*hi));
if (hi == NULL)
if (hi == NULL) {
ETH1394_PRINT_G (KERN_ERR, "Out of memory trying to create "
"hostinfo for IEEE 1394 device %s-%d\n",
host->driver->name, host->id);
goto out;
}
if (register_netdev (dev)) {
ETH1394_PRINT (KERN_ERR, dev->name, "Error registering network driver\n");
......@@ -472,8 +492,6 @@ static void ether1394_add_host (struct hpsb_host *host)
if (hi)
hpsb_destroy_hostinfo(&eth1394_highlevel, host);
ETH1394_PRINT_G (KERN_ERR, "Out of memory\n");
return;
}
......@@ -486,11 +504,13 @@ static void ether1394_remove_host (struct hpsb_host *host)
struct eth1394_priv *priv = (struct eth1394_priv *)hi->dev->priv;
priv->bc_state = ETHER1394_BC_CLOSED;
unregister_netdev (hi->dev);
hpsb_iso_shutdown(priv->iso);
eth1394_iso_shutdown(priv);
if (hi->dev) {
unregister_netdev (hi->dev);
kfree(hi->dev);
}
}
return;
}
......@@ -536,7 +556,7 @@ static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
return(dev->hard_header_len);
}
if(daddr)
if (daddr)
{
memcpy(eth->h_dest,daddr,dev->addr_len);
return dev->hard_header_len;
......@@ -579,7 +599,7 @@ static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr)
{
struct net_device *dev = skb->dev;
memcpy(haddr, dev->dev_addr, ETH1394_ALEN);
return ETH_ALEN;
return ETH1394_ALEN;
}
......@@ -635,15 +655,15 @@ static inline u16 ether1394_type_trans(struct sk_buff *skb,
skb_pull (skb, ETH1394_HLEN);
eth = (struct eth1394hdr*)skb->mac.raw;
if(*eth->h_dest & 1) {
if(memcmp(eth->h_dest, dev->broadcast, dev->addr_len)==0)
if (*eth->h_dest & 1) {
if (memcmp(eth->h_dest, dev->broadcast, dev->addr_len)==0)
skb->pkt_type = PACKET_BROADCAST;
#if 0
else
skb->pkt_type = PACKET_MULTICAST;
#endif
} else {
if(memcmp(eth->h_dest, dev->dev_addr, dev->addr_len))
if (memcmp(eth->h_dest, dev->dev_addr, dev->addr_len))
skb->pkt_type = PACKET_OTHERHOST;
}
......@@ -671,7 +691,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
/* Setup our hw addresses. We use these to build the
* ethernet header. */
if(destid == (LOCAL_BUS | ALL_NODES))
if (destid == (LOCAL_BUS | ALL_NODES))
dest_hw = ~0ULL; /* broadcast */
else
dest_hw = priv->eui[NODEID_TO_NODE(destid)];
......@@ -716,7 +736,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
*(u32*)arp_ptr = arp1394->sip; /* move sender IP addr */
arp_ptr += arp->ar_pln; /* skip over sender IP addr */
if(arp->ar_op == 1)
if (arp->ar_op == 1)
/* just set ARP req target unique ID to 0 */
memset(arp_ptr, 0, ETH1394_ALEN);
else
......@@ -739,7 +759,7 @@ static inline int fragment_overlap(struct list_head *frag_list, int offset, int
list_for_each(lh, frag_list) {
fi = list_entry(lh, struct fragment_info, list);
if( ! ((offset > (fi->offset + fi->len - 1)) ||
if ( ! ((offset > (fi->offset + fi->len - 1)) ||
((offset + len - 1) < fi->offset)))
return 1;
}
......@@ -753,7 +773,7 @@ static inline struct list_head *find_partial_datagram(struct list_head *pdgl, in
list_for_each(lh, pdgl) {
pd = list_entry(lh, struct partial_datagram, list);
if(pd->dgl == dgl)
if (pd->dgl == dgl)
return lh;
}
return NULL;
......@@ -767,32 +787,32 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len)
list_for_each(lh, frag_info) {
fi = list_entry(lh, struct fragment_info, list);
if((fi->offset + fi->len) == offset) {
if ((fi->offset + fi->len) == offset) {
/* The new fragment can be tacked on to the end */
fi->len += len;
/* Did the new fragment plug a hole? */
fi2 = list_entry(lh->next, struct fragment_info, list);
if((fi->offset + fi->len) == fi2->offset) {
if ((fi->offset + fi->len) == fi2->offset) {
/* glue fragments together */
fi->len += fi2->len;
list_del(lh->next);
kfree(fi2);
}
return 0;
} else if((offset + len) == fi->offset) {
} else if ((offset + len) == fi->offset) {
/* The new fragment can be tacked on to the beginning */
fi->offset = offset;
fi->len += len;
/* Did the new fragment plug a hole? */
fi2 = list_entry(lh->prev, struct fragment_info, list);
if((fi2->offset + fi2->len) == fi->offset) {
if ((fi2->offset + fi2->len) == fi->offset) {
/* glue fragments together */
fi2->len += fi->len;
list_del(lh);
kfree(fi);
}
return 0;
} else if(offset > (fi->offset + fi->len)) {
} else if (offset > (fi->offset + fi->len)) {
break;
} else if ((offset + len) < fi->offset) {
lh = lh->prev;
......@@ -801,7 +821,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len)
}
new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC);
if(!new)
if (!new)
return -ENOMEM;
new->offset = offset;
......@@ -820,12 +840,12 @@ static inline int new_partial_datagram(struct net_device *dev,
struct partial_datagram *new;
new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC);
if(!new)
if (!new)
return -ENOMEM;
INIT_LIST_HEAD(&new->frag_info);
if(new_fragment(&new->frag_info, frag_off, frag_len) < 0) {
if (new_fragment(&new->frag_info, frag_off, frag_len) < 0) {
kfree(new);
return -ENOMEM;
}
......@@ -834,7 +854,7 @@ static inline int new_partial_datagram(struct net_device *dev,
new->dg_size = dg_size;
new->skb = dev_alloc_skb(dg_size + dev->hard_header_len + 15);
if(!new->skb) {
if (!new->skb) {
struct fragment_info *fi = list_entry(new->frag_info.next,
struct fragment_info,
list);
......@@ -857,7 +877,7 @@ static inline int update_partial_datagram(struct list_head *pdgl, struct list_he
{
struct partial_datagram *pd = list_entry(lh, struct partial_datagram, list);
if(new_fragment(&pd->frag_info, frag_off, frag_len) < 0) {
if (new_fragment(&pd->frag_info, frag_off, frag_len) < 0) {
return -ENOMEM;
}
......@@ -915,7 +935,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
hdr_len = hdr_type_len[hdr->common.lf];
if(hdr->common.lf == ETH1394_HDR_LF_UF) {
if (hdr->common.lf == ETH1394_HDR_LF_UF) {
/* An unfragmented datagram has been received by the ieee1394
* bus. Build an skbuff around it so we can pass it to the
* high level network layer. */
......@@ -945,15 +965,15 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
hdr->words.word3 = ntohs(hdr->words.word3);
/* The 4th header word is reserved so no need to do ntohs() */
if(hdr->common.lf == ETH1394_HDR_LF_FF) {
if (hdr->common.lf == ETH1394_HDR_LF_FF) {
ether_type = hdr->ff.ether_type;
dgl = hdr->ff.dgl;
dg_size = hdr->ff.dg_size;
dg_size = hdr->ff.dg_size + 1;
fg_off = 0;
} else {
hdr->words.word2 = ntohs(hdr->words.word2);
dgl = hdr->sf.dgl;
dg_size = hdr->sf.dg_size;
dg_size = hdr->sf.dg_size + 1;
fg_off = hdr->sf.fg_off;
}
spin_lock_irqsave(&pdg->lock, flags);
......@@ -961,8 +981,8 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
pdgl = &(pdg->list);
lh = find_partial_datagram(pdgl, dgl);
if(lh == NULL) {
if(pdg->sz == max_partial_datagrams) {
if (lh == NULL) {
if (pdg->sz == max_partial_datagrams) {
/* remove the oldest */
purge_partial_datagram(pdgl->prev);
pdg->sz--;
......@@ -971,7 +991,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
retval = new_partial_datagram(dev, pdgl, dgl, dg_size,
buf + hdr_len, fg_off,
fg_len);
if(retval < 0) {
if (retval < 0) {
spin_unlock_irqrestore(&pdg->lock, flags);
goto bad_proto;
}
......@@ -982,7 +1002,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
pd = list_entry(lh, struct partial_datagram, list);
if(fragment_overlap(&pd->frag_info, fg_off, fg_len)) {
if (fragment_overlap(&pd->frag_info, fg_off, fg_len)) {
/* Overlapping fragments, obliterate old
* datagram and start new one. */
purge_partial_datagram(lh);
......@@ -990,7 +1010,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
dg_size,
buf + hdr_len,
fg_off, fg_len);
if(retval < 0) {
if (retval < 0) {
pdg->sz--;
spin_unlock_irqrestore(&pdg->lock, flags);
goto bad_proto;
......@@ -999,7 +1019,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
retval = update_partial_datagram(pdgl, lh,
buf + hdr_len,
fg_off, fg_len);
if(retval < 0) {
if (retval < 0) {
/* Couldn't save off fragment anyway
* so might as well obliterate the
* datagram now. */
......@@ -1013,11 +1033,11 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
pd = list_entry(lh, struct partial_datagram, list);
if(hdr->common.lf == ETH1394_HDR_LF_FF) {
if (hdr->common.lf == ETH1394_HDR_LF_FF) {
pd->ether_type = ether_type;
}
if(is_datagram_complete(lh, dg_size)) {
if (is_datagram_complete(lh, dg_size)) {
ether_type = pd->ether_type;
pdg->sz--;
skb = skb_get(pd->skb);
......@@ -1044,14 +1064,14 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
spin_lock_irqsave(&priv->lock, flags);
if(!skb->protocol) {
if (!skb->protocol) {
priv->stats.rx_errors++;
priv->stats.rx_dropped++;
dev_kfree_skb_any(skb);
goto bad_proto;
}
if(netif_rx(skb) == NET_RX_DROP) {
if (netif_rx(skb) == NET_RX_DROP) {
priv->stats.rx_errors++;
priv->stats.rx_dropped++;
goto bad_proto;
......@@ -1062,7 +1082,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
priv->stats.rx_bytes += skb->len;
bad_proto:
if(netif_queue_stopped(dev))
if (netif_queue_stopped(dev))
netif_wake_queue(dev);
spin_unlock_irqrestore(&priv->lock, flags);
......@@ -1076,13 +1096,13 @@ static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
{
struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
if(hi == NULL) {
if (hi == NULL) {
ETH1394_PRINT_G(KERN_ERR, "Could not find net device for host %s\n",
host->driver->name);
return RCODE_ADDRESS_ERROR;
}
if(ether1394_data_handler(hi->dev, srcid, destid, (char*)data, len))
if (ether1394_data_handler(hi->dev, srcid, destid, (char*)data, len))
return RCODE_ADDRESS_ERROR;
else
return RCODE_COMPLETE;
......@@ -1101,7 +1121,7 @@ static void ether1394_iso(struct hpsb_iso *iso)
int i;
int nready;
if(hi == NULL) {
if (hi == NULL) {
ETH1394_PRINT_G(KERN_ERR, "Could not find net device for host %s\n",
iso->host->driver->name);
return;
......@@ -1110,7 +1130,7 @@ static void ether1394_iso(struct hpsb_iso *iso)
dev = hi->dev;
nready = hpsb_iso_n_ready(iso);
for(i = 0; i < nready; i++) {
for (i = 0; i < nready; i++) {
struct hpsb_iso_packet_info *info = &iso->infos[iso->first_packet + i];
data = (quadlet_t*) (iso->data_buf.kvirt + info->offset);
......@@ -1124,7 +1144,7 @@ static void ether1394_iso(struct hpsb_iso *iso)
priv = (struct eth1394_priv *)dev->priv;
if(info->channel != (iso->host->csr.broadcast_channel & 0x3f) ||
if (info->channel != (iso->host->csr.broadcast_channel & 0x3f) ||
specifier_id != ETHER1394_GASP_SPECIFIER_ID) {
/* This packet is not for us */
continue;
......@@ -1185,13 +1205,13 @@ static inline unsigned int ether1394_encapsulate_prep(unsigned int max_payload,
unsigned int adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_UF];
/* Does it all fit in one packet? */
if(dg_size <= adj_max_payload) {
if (dg_size <= adj_max_payload) {
hdr->uf.lf = ETH1394_HDR_LF_UF;
hdr->uf.ether_type = proto;
} else {
hdr->ff.lf = ETH1394_HDR_LF_FF;
hdr->ff.ether_type = proto;
hdr->ff.dg_size = dg_size;
hdr->ff.dg_size = dg_size - 1;
hdr->ff.dgl = dgl;
adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF];
}
......@@ -1229,7 +1249,7 @@ static inline unsigned int ether1394_encapsulate(struct sk_buff *skb,
default:
hdr->sf.fg_off += adj_max_payload;
bufhdr = (union eth1394_hdr *)skb_pull(skb, adj_max_payload);
if(max_payload >= skb->len)
if (max_payload >= skb->len)
hdr->common.lf = ETH1394_HDR_LF_LF;
bufhdr->words.word1 = htons(hdr->words.word1);
bufhdr->words.word2 = htons(hdr->words.word2);
......@@ -1245,7 +1265,7 @@ static inline struct hpsb_packet *ether1394_alloc_common_packet(struct hpsb_host
struct hpsb_packet *p;
p = alloc_hpsb_packet(0);
if(p) {
if (p) {
p->host = host;
p->data = NULL;
p->generation = get_hpsb_generation(host);
......@@ -1269,8 +1289,9 @@ static inline int ether1394_prep_write_packet(struct hpsb_packet *p,
p->header_size = 16;
p->expect_response = 1;
if(hpsb_get_tlabel(p, !in_interrupt())) {
ETH1394_PRINT_G(KERN_ERR, "No more tlabels left");
if (hpsb_get_tlabel(p, !in_interrupt())) {
ETH1394_PRINT_G(KERN_ERR, "No more tlabels left while sending "
"to node " NODE_BUS_FMT "\n", NODE_BUS_ARGS(node));
return -1;
}
p->header[0] = (p->node_id << 16) | (p->tlabel << 10)
......@@ -1309,30 +1330,31 @@ static inline void ether1394_prep_gasp_packet(struct hpsb_packet *p,
static inline void ether1394_free_packet(struct hpsb_packet *packet)
{
if (packet->tcode != TCODE_STREAM_DATA)
hpsb_free_tlabel(packet);
packet->data = NULL;
free_hpsb_packet(packet);
}
static void ether1394_complete_cb(void *__ptask);
static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
{
struct eth1394_priv *priv = ptask->priv;
struct hpsb_packet *packet;
struct hpsb_packet *packet = NULL;
packet = ether1394_alloc_common_packet(priv->host);
if(!packet)
if (!packet)
return -1;
if(ptask->tx_type == ETH1394_GASP) {
if (ptask->tx_type == ETH1394_GASP) {
int length = tx_len + (2 * sizeof(quadlet_t));
ether1394_prep_gasp_packet(packet, priv, ptask->skb, length);
} else {
if(ether1394_prep_write_packet(packet, priv->host,
} else if (ether1394_prep_write_packet(packet, priv->host,
ptask->dest_node,
ptask->addr, ptask->skb->data,
tx_len))
tx_len)) {
goto fail;
}
......@@ -1340,10 +1362,13 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
hpsb_set_packet_complete_task(ptask->packet, ether1394_complete_cb,
ptask);
if(hpsb_send_packet(packet)) {
if (hpsb_send_packet(packet))
return 0;
}
fail:
if (packet)
ether1394_free_packet(packet);
return -1;
}
......@@ -1357,7 +1382,7 @@ static inline void ether1394_dg_complete(struct packet_task *ptask, int fail)
unsigned long flags;
/* Statistics */
if(fail) {
if (fail) {
spin_lock_irqsave(&priv->lock, flags);
priv->stats.tx_dropped++;
priv->stats.tx_errors++;
......@@ -1382,22 +1407,20 @@ static void ether1394_complete_cb(void *__ptask)
struct hpsb_packet *packet = ptask->packet;
int fail = 0;
if(packet->tcode != TCODE_STREAM_DATA) {
if (packet->tcode != TCODE_STREAM_DATA)
fail = hpsb_packet_success(packet);
hpsb_free_tlabel(packet);
}
ether1394_free_packet(packet);
ptask->outstanding_pkts--;
if(ptask->outstanding_pkts > 0 && !fail)
if (ptask->outstanding_pkts > 0 && !fail)
{
int tx_len;
/* Add the encapsulation header to the fragment */
tx_len = ether1394_encapsulate(ptask->skb, ptask->max_payload,
&ptask->hdr);
if(ether1394_send_packet(ptask, tx_len))
if (ether1394_send_packet(ptask, tx_len))
ether1394_dg_complete(ptask, 1);
} else {
ether1394_dg_complete(ptask, fail);
......@@ -1424,14 +1447,8 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
struct packet_task *ptask;
struct node_entry *ne;
if (skb_is_nonlinear(skb)) {
ret = skb_linearize(skb, kmflags);
if(ret)
goto fail;
}
ptask = kmem_cache_alloc(packet_task_cache, kmflags);
if(ptask == NULL) {
if (ptask == NULL) {
ret = -ENOMEM;
goto fail;
}
......@@ -1446,7 +1463,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
}
if (priv->bc_state == ETHER1394_BC_CHECK) {
if(ether1394_init_bc(dev)) {
if (ether1394_init_bc(dev)) {
spin_unlock_irqrestore (&priv->lock, flags);
goto fail;
}
......@@ -1464,7 +1481,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
skb_pull(skb, ETH1394_HLEN);
ne = hpsb_guid_get_entry(be64_to_cpu(*(u64*)eth->h_dest));
if(!ne)
if (!ne)
dest_node = LOCAL_BUS | ALL_NODES;
else
dest_node = ne->nodeid;
......@@ -1479,7 +1496,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
/* This check should be unnecessary, but we'll keep it for safety for
* a while longer. */
if(max_payload < 512) {
if (max_payload < 512) {
ETH1394_PRINT(KERN_WARNING, dev->name,
"max_payload too small: %d (setting to 512)\n",
max_payload);
......@@ -1487,13 +1504,11 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
}
/* Set the transmission type for the packet. ARP packets and IP
* broadcast packets are sent via GASP, however, we cheat a little bit
* when detecting IP broadcast packets. This will need to change when
* we switch from using node id for the hardware address to the EUI
* which we should be using instead. IP multicast is not yet
* supported. */
if((memcmp(eth->h_dest, dev->broadcast, ETH1394_ALEN) == 0) ||
(proto == __constant_htons(ETH_P_ARP))) {
* broadcast packets are sent via GASP. */
if (memcmp(eth->h_dest, dev->broadcast, ETH1394_ALEN) == 0 ||
proto == __constant_htons(ETH_P_ARP) ||
(proto == __constant_htons(ETH_P_IP) &&
IN_MULTICAST(__constant_ntohl(skb->nh.iph->daddr)))) {
tx_type = ETH1394_GASP;
max_payload -= ETHER1394_GASP_OVERHEAD;
} else {
......@@ -1504,7 +1519,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
spin_lock_irqsave (&priv->lock, flags);
dgl = priv->dgl[NODEID_TO_NODE(dest_node)];
if(max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
priv->dgl[NODEID_TO_NODE(dest_node)]++;
spin_unlock_irqrestore (&priv->lock, flags);
......@@ -1516,14 +1531,14 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
ptask->priv = priv;
ptask->tx_type = tx_type;
if(tx_type != ETH1394_GASP) {
if (tx_type != ETH1394_GASP) {
u64 addr;
/* This test is just temporary until ConfigROM support has
* been added to eth1394. Until then, we need an ARP packet
* after a bus reset from the current destination node so that
* we can get FIFO information. */
if(priv->fifo[NODEID_TO_NODE(dest_node)] == 0ULL) {
if (priv->fifo[NODEID_TO_NODE(dest_node)] == 0ULL) {
ret = -EAGAIN;
goto fail;
}
......@@ -1545,19 +1560,17 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
/* Add the encapsulation header to the fragment */
tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr);
dev->trans_start = jiffies;
if(ether1394_send_packet(ptask, tx_len))
if (ether1394_send_packet(ptask, tx_len))
goto fail;
netif_wake_queue(dev);
return 0;
fail:
if(ptask->packet)
ether1394_free_packet(ptask->packet);
if(ptask)
if (ptask)
kmem_cache_free(packet_task_cache, ptask);
if(skb != NULL) {
if (skb != NULL)
dev_kfree_skb(skb);
}
spin_lock_irqsave (&priv->lock, flags);
priv->stats.tx_dropped++;
......@@ -1570,6 +1583,53 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
return 0; /* returning non-zero causes serious problems */
}
static int ether1394_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
switch(cmd) {
case SIOCETHTOOL:
return ether1394_ethtool_ioctl(dev, (void *) ifr->ifr_data);
case SIOCGMIIPHY: /* Get address of MII PHY in use. */
case SIOCGMIIREG: /* Read MII PHY register. */
case SIOCSMIIREG: /* Write MII PHY register. */
default:
return -EOPNOTSUPP;
}
return 0;
}
static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr)
{
u32 ethcmd;
if (get_user(ethcmd, (u32 *)useraddr))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, driver_name);
strcpy (info.version, "$Rev: 971 $");
/* FIXME XXX provide sane businfo */
strcpy (info.bus_info, "ieee1394");
if (copy_to_user (useraddr, &info, sizeof (info)))
return -EFAULT;
break;
}
case ETHTOOL_GSET:
case ETHTOOL_SSET:
case ETHTOOL_NWAY_RST:
case ETHTOOL_GLINK:
case ETHTOOL_GMSGLVL:
case ETHTOOL_SMSGLVL:
default:
return -EOPNOTSUPP;
}
return 0;
}
/* Function for incoming 1394 packets */
static struct hpsb_address_ops addr_ops = {
.write = ether1394_write,
......@@ -1577,7 +1637,7 @@ static struct hpsb_address_ops addr_ops = {
/* Ieee1394 highlevel driver functions */
static struct hpsb_highlevel eth1394_highlevel = {
.name = ETHER1394_DRIVER_NAME,
.name = driver_name,
.add_host = ether1394_add_host,
.remove_host = ether1394_remove_host,
.host_reset = ether1394_host_reset,
......
......@@ -46,14 +46,14 @@
#define ACKX_TIMEOUT (-4)
#define SPEED_100 0x00
#define SPEED_200 0x01
#define SPEED_400 0x02
#define SPEED_800 0x03
#define SPEED_1600 0x04
#define SPEED_3200 0x05
#define IEEE1394_SPEED_100 0x00
#define IEEE1394_SPEED_200 0x01
#define IEEE1394_SPEED_400 0x02
#define IEEE1394_SPEED_800 0x03
#define IEEE1394_SPEED_1600 0x04
#define IEEE1394_SPEED_3200 0x05
/* The current highest tested speed supported by the subsystem */
#define SPEED_MAX SPEED_800
#define IEEE1394_SPEED_MAX IEEE1394_SPEED_800
/* Maps speed values above to a string representation */
extern const char *hpsb_speedto_str[];
......
......@@ -289,7 +289,7 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
for (i = 0; i < (nodecount * 64); i += 64) {
for (j = 0; j < nodecount; j++) {
map[i+j] = SPEED_MAX;
map[i+j] = IEEE1394_SPEED_MAX;
}
}
......@@ -458,7 +458,7 @@ int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
struct hpsb_packet *packet;
int retval = 0;
if(rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
(rootid == -1 && gapcnt == -1)) {
HPSB_DEBUG("Invalid Parameter: rootid = %d gapcnt = %d",
rootid, gapcnt);
......@@ -470,22 +470,21 @@ int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
return -ENOMEM;
packet->host = host;
packet->header_size = 16;
packet->header_size = 8;
packet->data_size = 0;
packet->expect_response = 0;
packet->no_waiter = 0;
packet->type = hpsb_raw;
packet->header[0] = 0;
if(rootid != -1)
if (rootid != -1)
packet->header[0] |= rootid << 24 | 1 << 23;
if(gapcnt != -1)
if (gapcnt != -1)
packet->header[0] |= gapcnt << 16 | 1 << 22;
packet->header[1] = ~packet->header[0];
packet->generation = get_hpsb_generation(host);
HPSB_DEBUG("Sending PHY configuration packet (I hope)...");
if (!hpsb_send_packet(packet)) {
retval = -EINVAL;
goto fail;
......@@ -1030,12 +1029,12 @@ int ieee1394_register_chardev(int blocknum,
{
int retval;
if( (blocknum < 0) || (blocknum > 15) )
if ( (blocknum < 0) || (blocknum > 15) )
return -EINVAL;
write_lock(&ieee1394_chardevs_lock);
if(ieee1394_chardevs[blocknum].file_ops == NULL) {
if (ieee1394_chardevs[blocknum].file_ops == NULL) {
/* grab the minor block */
ieee1394_chardevs[blocknum].file_ops = file_ops;
ieee1394_chardevs[blocknum].module = module;
......@@ -1054,12 +1053,12 @@ int ieee1394_register_chardev(int blocknum,
/* release a block of minor numbers */
void ieee1394_unregister_chardev(int blocknum)
{
if( (blocknum < 0) || (blocknum > 15) )
if ( (blocknum < 0) || (blocknum > 15) )
return;
write_lock(&ieee1394_chardevs_lock);
if(ieee1394_chardevs[blocknum].file_ops) {
if (ieee1394_chardevs[blocknum].file_ops) {
ieee1394_chardevs[blocknum].file_ops = NULL;
ieee1394_chardevs[blocknum].module = NULL;
}
......@@ -1139,7 +1138,7 @@ static int ieee1394_dispatch_open(struct inode *inode, struct file *file)
/* look up the driver */
if(ieee1394_get_chardev(blocknum, &module, &file_ops) == 0)
if (ieee1394_get_chardev(blocknum, &module, &file_ops) == 0)
return -ENODEV;
/* redirect all subsequent requests to the driver's
......
......@@ -34,7 +34,7 @@ struct hpsb_packet {
} __attribute__((packed)) state;
/* These are core internal. */
char tlabel;
signed char tlabel;
char ack_code;
char tcode;
......
......@@ -95,7 +95,7 @@ static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data)
packet->data_size = 0;
packet->expect_response = 0;
packet->type = hpsb_raw; /* No CRC added */
packet->speed_code = SPEED_100; /* Force speed to be 100Mbps */
packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */
}
static void fill_async_stream_packet(struct hpsb_packet *packet, int length,
......@@ -147,7 +147,7 @@ int hpsb_get_tlabel(struct hpsb_packet *packet, int wait)
spin_lock_irqsave(&tp->lock, flags);
packet->tlabel = find_next_zero_bit(tp->pool, 64, tp->next);
if(packet->tlabel > 63)
if (packet->tlabel > 63)
packet->tlabel = find_first_zero_bit(tp->pool, 64);
tp->next = (packet->tlabel + 1) % 64;
/* Should _never_ happen */
......
......@@ -40,7 +40,7 @@ do { \
(_tp)->next = 0; \
(_tp)->allocations = 0; \
sema_init(&(_tp)->count, 63); \
} while(0)
} while (0)
typedef u32 quadlet_t;
......
......@@ -25,7 +25,7 @@ void hpsb_iso_stop(struct hpsb_iso *iso)
void hpsb_iso_shutdown(struct hpsb_iso *iso)
{
if(iso->flags & HPSB_ISO_DRIVER_INIT) {
if (iso->flags & HPSB_ISO_DRIVER_INIT) {
hpsb_iso_stop(iso);
iso->host->driver->isoctl(iso, iso->type == HPSB_ISO_XMIT ?
XMIT_SHUTDOWN : RECV_SHUTDOWN, 0);
......@@ -47,7 +47,7 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
int dma_direction;
/* make sure driver supports the ISO API */
if(!host->driver->isoctl) {
if (!host->driver->isoctl) {
printk(KERN_INFO "ieee1394: host driver '%s' does not support the rawiso API\n",
host->driver->name);
return NULL;
......@@ -55,23 +55,23 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
/* sanitize parameters */
if(buf_packets < 2)
if (buf_packets < 2)
buf_packets = 2;
if(irq_interval < 1 || irq_interval > buf_packets / 2)
if (irq_interval < 1 || irq_interval > buf_packets / 2)
irq_interval = buf_packets / 2;
if(channel < -1 || channel >= 64)
if (channel < -1 || channel >= 64)
return NULL;
/* channel = -1 is OK for multi-channel recv but not for xmit */
if(type == HPSB_ISO_XMIT && channel < 0)
if (type == HPSB_ISO_XMIT && channel < 0)
return NULL;
/* allocate and write the struct hpsb_iso */
iso = kmalloc(sizeof(*iso) + buf_packets * sizeof(struct hpsb_iso_packet_info), GFP_KERNEL);
if(!iso)
if (!iso)
return NULL;
iso->infos = (struct hpsb_iso_packet_info *)(iso + 1);
......@@ -90,7 +90,7 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
iso->first_packet = 0;
spin_lock_init(&iso->lock);
if(iso->type == HPSB_ISO_XMIT) {
if (iso->type == HPSB_ISO_XMIT) {
iso->n_ready_packets = iso->buf_packets;
dma_direction = PCI_DMA_TODEVICE;
} else {
......@@ -103,7 +103,7 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
iso->prebuffer = 0;
/* allocate the packet buffer */
if(dma_region_alloc(&iso->data_buf, iso->buf_size, host->pdev, dma_direction))
if (dma_region_alloc(&iso->data_buf, iso->buf_size, host->pdev, dma_direction))
goto err;
return iso;
......@@ -137,13 +137,13 @@ struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_XMIT,
data_buf_size, buf_packets,
channel, irq_interval, callback);
if(!iso)
if (!iso)
return NULL;
iso->speed = speed;
/* tell the driver to start working */
if(host->driver->isoctl(iso, XMIT_INIT, 0))
if (host->driver->isoctl(iso, XMIT_INIT, 0))
goto err;
iso->flags |= HPSB_ISO_DRIVER_INIT;
......@@ -164,11 +164,11 @@ struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_RECV,
data_buf_size, buf_packets,
channel, irq_interval, callback);
if(!iso)
if (!iso)
return NULL;
/* tell the driver to start working */
if(host->driver->isoctl(iso, RECV_INIT, 0))
if (host->driver->isoctl(iso, RECV_INIT, 0))
goto err;
iso->flags |= HPSB_ISO_DRIVER_INIT;
......@@ -181,21 +181,21 @@ struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel)
{
if(iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64)
if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64)
return -EINVAL;
return iso->host->driver->isoctl(iso, RECV_LISTEN_CHANNEL, channel);
}
int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel)
{
if(iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64)
if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64)
return -EINVAL;
return iso->host->driver->isoctl(iso, RECV_UNLISTEN_CHANNEL, channel);
}
int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask)
{
if(iso->type != HPSB_ISO_RECV || iso->channel != -1)
if (iso->type != HPSB_ISO_RECV || iso->channel != -1)
return -EINVAL;
return iso->host->driver->isoctl(iso, RECV_SET_CHANNEL_MASK, (unsigned long) &mask);
}
......@@ -203,7 +203,7 @@ int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask)
static int do_iso_xmit_start(struct hpsb_iso *iso, int cycle)
{
int retval = iso->host->driver->isoctl(iso, XMIT_START, cycle);
if(retval)
if (retval)
return retval;
iso->flags |= HPSB_ISO_DRIVER_STARTED;
......@@ -212,25 +212,25 @@ static int do_iso_xmit_start(struct hpsb_iso *iso, int cycle)
int hpsb_iso_xmit_start(struct hpsb_iso *iso, int cycle, int prebuffer)
{
if(iso->type != HPSB_ISO_XMIT)
if (iso->type != HPSB_ISO_XMIT)
return -1;
if(iso->flags & HPSB_ISO_DRIVER_STARTED)
if (iso->flags & HPSB_ISO_DRIVER_STARTED)
return 0;
if(cycle < -1)
if (cycle < -1)
cycle = -1;
else if(cycle >= 8000)
else if (cycle >= 8000)
cycle %= 8000;
iso->xmit_cycle = cycle;
if(prebuffer < 0)
if (prebuffer < 0)
prebuffer = iso->buf_packets;
else if(prebuffer == 0)
else if (prebuffer == 0)
prebuffer = 1;
if(prebuffer > iso->buf_packets)
if (prebuffer > iso->buf_packets)
prebuffer = iso->buf_packets;
iso->prebuffer = prebuffer;
......@@ -247,20 +247,20 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync)
int retval = 0;
int isoctl_args[3];
if(iso->type != HPSB_ISO_RECV)
if (iso->type != HPSB_ISO_RECV)
return -1;
if(iso->flags & HPSB_ISO_DRIVER_STARTED)
if (iso->flags & HPSB_ISO_DRIVER_STARTED)
return 0;
if(cycle < -1)
if (cycle < -1)
cycle = -1;
else if(cycle >= 8000)
else if (cycle >= 8000)
cycle %= 8000;
isoctl_args[0] = cycle;
if(tag_mask < 0)
if (tag_mask < 0)
/* match all tags */
tag_mask = 0xF;
isoctl_args[1] = tag_mask;
......@@ -268,7 +268,7 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync)
isoctl_args[2] = sync;
retval = iso->host->driver->isoctl(iso, RECV_START, (unsigned long) &isoctl_args[0]);
if(retval)
if (retval)
return retval;
iso->flags |= HPSB_ISO_DRIVER_STARTED;
......@@ -282,15 +282,15 @@ static int hpsb_iso_check_offset_len(struct hpsb_iso *iso,
unsigned int offset, unsigned short len,
unsigned int *out_offset, unsigned short *out_len)
{
if(offset >= iso->buf_size)
if (offset >= iso->buf_size)
return -EFAULT;
/* make sure the packet does not go beyond the end of the buffer */
if(offset + len > iso->buf_size)
if (offset + len > iso->buf_size)
return -EFAULT;
/* check for wrap-around */
if(offset + len < offset)
if (offset + len < offset)
return -EFAULT;
/* now we can trust 'offset' and 'length' */
......@@ -307,18 +307,18 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
unsigned long flags;
int rv;
if(iso->type != HPSB_ISO_XMIT)
if (iso->type != HPSB_ISO_XMIT)
return -EINVAL;
/* is there space in the buffer? */
if(iso->n_ready_packets <= 0) {
if (iso->n_ready_packets <= 0) {
return -EBUSY;
}
info = &iso->infos[iso->first_packet];
/* check for bogus offset/length */
if(hpsb_iso_check_offset_len(iso, offset, len, &info->offset, &info->len))
if (hpsb_iso_check_offset_len(iso, offset, len, &info->offset, &info->len))
return -EFAULT;
info->tag = tag;
......@@ -327,7 +327,7 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
spin_lock_irqsave(&iso->lock, flags);
rv = iso->host->driver->isoctl(iso, XMIT_QUEUE, (unsigned long) info);
if(rv)
if (rv)
goto out;
/* increment cursors */
......@@ -335,9 +335,9 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
iso->xmit_cycle = (iso->xmit_cycle+1) % 8000;
iso->n_ready_packets--;
if(iso->prebuffer != 0) {
if (iso->prebuffer != 0) {
iso->prebuffer--;
if(iso->prebuffer <= 0) {
if (iso->prebuffer <= 0) {
iso->prebuffer = 0;
rv = do_iso_xmit_start(iso, iso->start_cycle);
}
......@@ -350,7 +350,7 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
int hpsb_iso_xmit_sync(struct hpsb_iso *iso)
{
if(iso->type != HPSB_ISO_XMIT)
if (iso->type != HPSB_ISO_XMIT)
return -EINVAL;
return wait_event_interruptible(iso->waitq, hpsb_iso_n_ready(iso) == iso->buf_packets);
......@@ -371,7 +371,7 @@ void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error)
iso->n_ready_packets++;
iso->pkt_dma = (iso->pkt_dma + 1) % iso->buf_packets;
if(iso->n_ready_packets == iso->buf_packets || error != 0) {
if (iso->n_ready_packets == iso->buf_packets || error != 0) {
/* the buffer has run empty! */
atomic_inc(&iso->overflows);
}
......@@ -385,7 +385,7 @@ void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
unsigned long flags;
spin_lock_irqsave(&iso->lock, flags);
if(iso->n_ready_packets == iso->buf_packets) {
if (iso->n_ready_packets == iso->buf_packets) {
/* overflow! */
atomic_inc(&iso->overflows);
} else {
......@@ -410,14 +410,14 @@ int hpsb_iso_recv_release_packets(struct hpsb_iso *iso, unsigned int n_packets)
unsigned int i;
int rv = 0;
if(iso->type != HPSB_ISO_RECV)
if (iso->type != HPSB_ISO_RECV)
return -1;
spin_lock_irqsave(&iso->lock, flags);
for(i = 0; i < n_packets; i++) {
for (i = 0; i < n_packets; i++) {
rv = iso->host->driver->isoctl(iso, RECV_RELEASE,
(unsigned long) &iso->infos[iso->first_packet]);
if(rv)
if (rv)
break;
iso->first_packet = (iso->first_packet+1) % iso->buf_packets;
......@@ -431,6 +431,6 @@ void hpsb_iso_wake(struct hpsb_iso *iso)
{
wake_up_interruptible(&iso->waitq);
if(iso->callback)
if (iso->callback)
iso->callback(iso);
}
......@@ -66,7 +66,7 @@ struct hpsb_iso {
/* wait for buffer space */
wait_queue_head_t waitq;
int speed; /* SPEED_100, 200, or 400 */
int speed; /* IEEE1394_SPEED_100, 200, or 400 */
int channel; /* -1 if multichannel */
/* greatest # of packets between interrupts - controls
......
......@@ -1167,7 +1167,7 @@ do { \
return -ENOMEM; \
++length; \
scratch = buffer + length; \
} while(0)
} while (0)
PUT_ENVP("VENDOR_ID=%06x", ud->vendor_id);
PUT_ENVP("MODEL_ID=%06x", ud->model_id);
......@@ -1547,12 +1547,12 @@ static void nodemgr_do_irm_duties(struct hpsb_host *host)
/* If there is no bus manager then we should set the root node's
* force_root bit to promote bus stability per the 1394
* spec. (8.4.2.6) */
if (host->busmgr_id == 0x3f && host->node_count > 1)
if (host->busmgr_id == 0xffff && host->node_count > 1)
{
u16 root_node = host->node_count - 1;
struct node_entry *ne = hpsb_nodeid_get_entry(host, root_node);
struct node_entry *ne = find_entry_by_nodeid(host, root_node | LOCAL_BUS);
if (ne->busopt.cmc)
if (ne && ne->busopt.cmc)
hpsb_send_phy_config(host, root_node, -1);
else {
HPSB_DEBUG("The root node is not cycle master capable; "
......
......@@ -164,7 +164,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
static char version[] __devinitdata =
"$Rev: 948 $ Ben Collins <bcollins@debian.org>";
"$Rev: 952 $ Ben Collins <bcollins@debian.org>";
/* Module Parameters */
static int phys_dma = 1;
......@@ -428,7 +428,7 @@ static void initialize_dma_rcv_ctx(struct dma_rcv_ctx *d, int generate_irq)
d->buf_ind = 0;
d->buf_offset = 0;
if(d->type == DMA_CTX_ISO) {
if (d->type == DMA_CTX_ISO) {
/* Clear contextControl */
reg_write(ohci, d->ctrlClear, 0xffffffff);
......@@ -470,7 +470,7 @@ static void initialize_dma_trm_ctx(struct dma_trm_ctx *d)
INIT_LIST_HEAD(&d->fifo_list);
INIT_LIST_HEAD(&d->pending_list);
if(d->type == DMA_CTX_ISO) {
if (d->type == DMA_CTX_ISO) {
/* enable interrupts */
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << d->ctx);
}
......@@ -490,8 +490,8 @@ static int get_nb_iso_ctx(struct ti_ohci *ohci, int reg)
DBGMSG(ohci->id,"Iso contexts reg: %08x implemented: %08x", reg, tmp);
/* Count the number of contexts */
for(i=0; i<32; i++) {
if(tmp & 1) ctx++;
for (i=0; i<32; i++) {
if (tmp & 1) ctx++;
tmp >>= 1;
}
return ctx;
......@@ -856,8 +856,8 @@ static int ohci_transmit(struct hpsb_host *host, struct hpsb_packet *packet)
* case. I don't see anyone sending ISO packets from
* interrupt context anyway... */
if(ohci->it_legacy_context.ohci == NULL) {
if(in_interrupt()) {
if (ohci->it_legacy_context.ohci == NULL) {
if (in_interrupt()) {
PRINT(KERN_ERR, ohci->id,
"legacy IT context cannot be initialized during interrupt");
return 0;
......@@ -1074,7 +1074,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
DBGMSG(ohci->id, "Listening disabled on channel %d", arg);
if(ohci->ir_legacy_channels == 0) {
if (ohci->ir_legacy_channels == 0) {
free_dma_rcv_ctx(&ohci->ir_legacy_context);
DBGMSG(ohci->id, "ISO receive legacy context deactivated");
}
......@@ -1162,7 +1162,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
int ret = -ENOMEM;
recv = kmalloc(sizeof(*recv), SLAB_KERNEL);
if(!recv)
if (!recv)
return -ENOMEM;
iso->hostdata = recv;
......@@ -1174,7 +1174,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
/* use buffer-fill mode, unless irq_interval is 1
(note: multichannel requires buffer-fill) */
if(iso->irq_interval == 1 && iso->channel != -1) {
if (iso->irq_interval == 1 && iso->channel != -1) {
recv->dma_mode = PACKET_PER_BUFFER_MODE;
} else {
recv->dma_mode = BUFFER_FILL_MODE;
......@@ -1182,12 +1182,12 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
/* set nblocks, buf_stride, block_irq_interval */
if(recv->dma_mode == BUFFER_FILL_MODE) {
if (recv->dma_mode == BUFFER_FILL_MODE) {
recv->buf_stride = PAGE_SIZE;
/* one block per page of data in the DMA buffer, minus the final guard page */
recv->nblocks = iso->buf_size/PAGE_SIZE - 1;
if(recv->nblocks < 3) {
if (recv->nblocks < 3) {
DBGMSG(ohci->id, "ohci_iso_recv_init: DMA buffer too small");
goto err;
}
......@@ -1195,9 +1195,9 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
/* iso->irq_interval is in packets - translate that to blocks */
/* (err, sort of... 1 is always the safest value) */
recv->block_irq_interval = iso->irq_interval / recv->nblocks;
if(recv->block_irq_interval*4 > recv->nblocks)
if (recv->block_irq_interval*4 > recv->nblocks)
recv->block_irq_interval = recv->nblocks/4;
if(recv->block_irq_interval < 1)
if (recv->block_irq_interval < 1)
recv->block_irq_interval = 1;
} else {
......@@ -1211,10 +1211,10 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
max_packet_size = iso->buf_size / iso->buf_packets;
for(recv->buf_stride = 8; recv->buf_stride < max_packet_size;
for (recv->buf_stride = 8; recv->buf_stride < max_packet_size;
recv->buf_stride *= 2);
if(recv->buf_stride*iso->buf_packets > iso->buf_size ||
if (recv->buf_stride*iso->buf_packets > iso->buf_size ||
recv->buf_stride > PAGE_SIZE) {
/* this shouldn't happen, but anyway... */
DBGMSG(ohci->id, "ohci_iso_recv_init: problem choosing a buffer stride");
......@@ -1243,7 +1243,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
ohci_iso_recv_packetperbuf_task,
(unsigned long) iso);
if(ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0)
if (ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0)
goto err;
recv->task_active = 1;
......@@ -1255,7 +1255,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
recv->CommandPtr = OHCI1394_IsoRcvCommandPtr + 32 * ctx;
recv->ContextMatch = OHCI1394_IsoRcvContextMatch + 32 * ctx;
if(iso->channel == -1) {
if (iso->channel == -1) {
/* clear multi-channel selection mask */
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskHiClear, 0xFFFFFFFF);
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskLoClear, 0xFFFFFFFF);
......@@ -1293,7 +1293,7 @@ static void ohci_iso_recv_shutdown(struct hpsb_iso *iso)
{
struct ohci_iso_recv *recv = iso->hostdata;
if(recv->task_active) {
if (recv->task_active) {
ohci_iso_recv_stop(iso);
ohci1394_unregister_iso_tasklet(recv->ohci, &recv->task);
recv->task_active = 0;
......@@ -1363,7 +1363,7 @@ static void ohci_iso_recv_change_channel(struct hpsb_iso *iso, unsigned char cha
struct ohci_iso_recv *recv = iso->hostdata;
int reg, i;
if(channel < 32) {
if (channel < 32) {
reg = listen ? OHCI1394_IRMultiChanMaskLoSet : OHCI1394_IRMultiChanMaskLoClear;
i = channel;
} else {
......@@ -1383,14 +1383,14 @@ static void ohci_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask)
struct ohci_iso_recv *recv = iso->hostdata;
int i;
for(i = 0; i < 64; i++) {
if(mask & (1ULL << i)) {
if(i < 32)
for (i = 0; i < 64; i++) {
if (mask & (1ULL << i)) {
if (i < 32)
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskLoSet, (1 << i));
else
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskHiSet, (1 << (i-32)));
} else {
if(i < 32)
if (i < 32)
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskLoClear, (1 << i));
else
reg_write(recv->ohci, OHCI1394_IRMultiChanMaskHiClear, (1 << (i-32)));
......@@ -1413,7 +1413,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
/* always keep ISO headers */
command = (1 << 30);
if(recv->dma_mode == BUFFER_FILL_MODE)
if (recv->dma_mode == BUFFER_FILL_MODE)
command |= (1 << 31);
reg_write(recv->ohci, recv->ContextControlSet, command);
......@@ -1421,7 +1421,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
/* match on specified tags */
contextMatch = tag_mask << 28;
if(iso->channel == -1) {
if (iso->channel == -1) {
/* enable multichannel reception */
reg_write(recv->ohci, recv->ContextControlSet, (1 << 28));
} else {
......@@ -1429,7 +1429,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
contextMatch |= iso->channel;
}
if(cycle != -1) {
if (cycle != -1) {
u32 seconds;
/* enable cycleMatch */
......@@ -1450,7 +1450,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
contextMatch |= cycle << 12;
}
if(sync != -1) {
if (sync != -1) {
/* set sync flag on first DMA descriptor */
struct dma_cmd *cmd = &recv->block[recv->block_dma];
cmd->control |= DMA_CTL_WAIT;
......@@ -1482,7 +1482,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
reg_read(recv->ohci, OHCI1394_IsochronousCycleTimer);
/* check RUN */
if(!(reg_read(recv->ohci, recv->ContextControlSet) & 0x8000)) {
if (!(reg_read(recv->ohci, recv->ContextControlSet) & 0x8000)) {
PRINT(KERN_ERR, recv->ohci->id,
"Error starting IR DMA (ContextControl 0x%08x)\n",
reg_read(recv->ohci, recv->ContextControlSet));
......@@ -1515,7 +1515,7 @@ static void ohci_iso_recv_release_block(struct ohci_iso_recv *recv, int block)
| 1); /* Z=1 */
/* disable interrupt on previous DMA descriptor, except at intervals */
if((prev_i % recv->block_irq_interval) == 0) {
if ((prev_i % recv->block_irq_interval) == 0) {
prev->control |= cpu_to_le32(3 << 20); /* enable interrupt */
} else {
prev->control &= cpu_to_le32(~(3<<20)); /* disable interrupt */
......@@ -1535,7 +1535,7 @@ static void ohci_iso_recv_bufferfill_release(struct ohci_iso_recv *recv,
len = info->len;
/* add the wasted space for padding to 4 bytes */
if(len % 4)
if (len % 4)
len += 4 - (len % 4);
/* add 8 bytes for the OHCI DMA data format overhead */
......@@ -1544,7 +1544,7 @@ static void ohci_iso_recv_bufferfill_release(struct ohci_iso_recv *recv,
recv->released_bytes += len;
/* have we released enough memory for one block? */
while(recv->released_bytes > recv->buf_stride) {
while (recv->released_bytes > recv->buf_stride) {
ohci_iso_recv_release_block(recv, recv->block_reader);
recv->block_reader = (recv->block_reader + 1) % recv->nblocks;
recv->released_bytes -= recv->buf_stride;
......@@ -1554,7 +1554,7 @@ static void ohci_iso_recv_bufferfill_release(struct ohci_iso_recv *recv,
static inline void ohci_iso_recv_release(struct hpsb_iso *iso, struct hpsb_iso_packet_info *info)
{
struct ohci_iso_recv *recv = iso->hostdata;
if(recv->dma_mode == BUFFER_FILL_MODE) {
if (recv->dma_mode == BUFFER_FILL_MODE) {
ohci_iso_recv_bufferfill_release(recv, info);
} else {
ohci_iso_recv_release_block(recv, info - iso->infos);
......@@ -1567,7 +1567,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
int wake = 0;
int runaway = 0;
while(1) {
while (1) {
/* we expect the next parsable packet to begin at recv->dma_offset */
/* note: packet layout is as shown in section 10.6.1.1 of the OHCI spec */
......@@ -1580,7 +1580,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
unsigned int this_block = recv->dma_offset/recv->buf_stride;
/* don't loop indefinitely */
if(runaway++ > 100000) {
if (runaway++ > 100000) {
atomic_inc(&iso->overflows);
PRINT(KERN_ERR, recv->ohci->id,
"IR DMA error - Runaway during buffer parsing!\n");
......@@ -1588,7 +1588,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
}
/* stop parsing once we arrive at block_dma (i.e. don't get ahead of DMA) */
if(this_block == recv->block_dma)
if (this_block == recv->block_dma)
break;
wake = 1;
......@@ -1600,7 +1600,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
len = p[recv->dma_offset+2] | (p[recv->dma_offset+3] << 8);
if(len > 4096) {
if (len > 4096) {
PRINT(KERN_ERR, recv->ohci->id,
"IR DMA error - bogus 'len' value %u\n", len);
}
......@@ -1613,7 +1613,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
recv->dma_offset += 4;
/* check for wrap-around */
if(recv->dma_offset >= recv->buf_stride*recv->nblocks) {
if (recv->dma_offset >= recv->buf_stride*recv->nblocks) {
recv->dma_offset -= recv->buf_stride*recv->nblocks;
}
......@@ -1624,12 +1624,12 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
recv->dma_offset += len;
/* payload is padded to 4 bytes */
if(len % 4) {
if (len % 4) {
recv->dma_offset += 4 - (len%4);
}
/* check for wrap-around */
if(recv->dma_offset >= recv->buf_stride*recv->nblocks) {
if (recv->dma_offset >= recv->buf_stride*recv->nblocks) {
/* uh oh, the packet data wraps from the last
to the first DMA block - make the packet
contiguous by copying its "tail" into the
......@@ -1638,7 +1638,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
int guard_off = recv->buf_stride*recv->nblocks;
int tail_len = len - (guard_off - offset);
if(tail_len > 0 && tail_len < recv->buf_stride) {
if (tail_len > 0 && tail_len < recv->buf_stride) {
memcpy(iso->data_buf.kvirt + guard_off,
iso->data_buf.kvirt,
tail_len);
......@@ -1655,14 +1655,14 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
recv->dma_offset += 4;
/* check for wrap-around */
if(recv->dma_offset >= recv->buf_stride*recv->nblocks) {
if (recv->dma_offset >= recv->buf_stride*recv->nblocks) {
recv->dma_offset -= recv->buf_stride*recv->nblocks;
}
hpsb_iso_packet_received(iso, offset, len, cycle, channel, tag, sy);
}
if(wake)
if (wake)
hpsb_iso_wake(iso);
}
......@@ -1674,7 +1674,7 @@ static void ohci_iso_recv_bufferfill_task(unsigned long data)
int loop;
/* loop over all blocks */
for(loop = 0; loop < recv->nblocks; loop++) {
for (loop = 0; loop < recv->nblocks; loop++) {
/* check block_dma to see if it's done */
......@@ -1688,18 +1688,18 @@ static void ohci_iso_recv_bufferfill_task(unsigned long data)
unsigned char event = xferstatus & 0x1F;
if(!event) {
if (!event) {
/* nothing has happened to this block yet */
break;
}
if(event != 0x11) {
if (event != 0x11) {
atomic_inc(&iso->overflows);
PRINT(KERN_ERR, recv->ohci->id,
"IR DMA error - OHCI error code 0x%02x\n", event);
}
if(rescount != 0) {
if (rescount != 0) {
/* the card is still writing to this block;
we can't touch it until it's done */
break;
......@@ -1716,7 +1716,7 @@ static void ohci_iso_recv_bufferfill_task(unsigned long data)
/* advance block_dma */
recv->block_dma = (recv->block_dma + 1) % recv->nblocks;
if((recv->block_dma+1) % recv->nblocks == recv->block_reader) {
if ((recv->block_dma+1) % recv->nblocks == recv->block_reader) {
atomic_inc(&iso->overflows);
DBGMSG(recv->ohci->id, "ISO reception overflow - "
"ran out of DMA blocks");
......@@ -1735,7 +1735,7 @@ static void ohci_iso_recv_packetperbuf_task(unsigned long data)
int wake = 0;
/* loop over the entire buffer */
for(count = 0; count < recv->nblocks; count++) {
for (count = 0; count < recv->nblocks; count++) {
u32 packet_len = 0;
/* pointer to the DMA descriptor */
......@@ -1747,21 +1747,21 @@ static void ohci_iso_recv_packetperbuf_task(unsigned long data)
unsigned char event = xferstatus & 0x1F;
if(!event) {
if (!event) {
/* this packet hasn't come in yet; we are done for now */
goto out;
}
if(event == 0x11) {
if (event == 0x11) {
/* packet received successfully! */
/* rescount is the number of bytes *remaining* in the packet buffer,
after the packet was written */
packet_len = recv->buf_stride - rescount;
} else if(event == 0x02) {
} else if (event == 0x02) {
PRINT(KERN_ERR, recv->ohci->id, "IR DMA error - packet too long for buffer\n");
} else if(event) {
} else if (event) {
PRINT(KERN_ERR, recv->ohci->id, "IR DMA error - OHCI error code 0x%02x\n", event);
}
......@@ -1800,7 +1800,7 @@ static void ohci_iso_recv_packetperbuf_task(unsigned long data)
}
out:
if(wake)
if (wake)
hpsb_iso_wake(iso);
}
......@@ -1844,7 +1844,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
int ret = -ENOMEM;
xmit = kmalloc(sizeof(*xmit), SLAB_KERNEL);
if(!xmit)
if (!xmit)
return -ENOMEM;
iso->hostdata = xmit;
......@@ -1855,13 +1855,13 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
prog_size = sizeof(struct iso_xmit_cmd) * iso->buf_packets;
if(dma_prog_region_alloc(&xmit->prog, prog_size, xmit->ohci->dev))
if (dma_prog_region_alloc(&xmit->prog, prog_size, xmit->ohci->dev))
goto err;
ohci1394_init_iso_tasklet(&xmit->task, OHCI_ISO_TRANSMIT,
ohci_iso_xmit_task, (unsigned long) iso);
if(ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0)
if (ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0)
goto err;
xmit->task_active = 1;
......@@ -1887,7 +1887,7 @@ static void ohci_iso_xmit_stop(struct hpsb_iso *iso)
reg_write(xmit->ohci, OHCI1394_IsoXmitIntMaskClear, 1 << xmit->task.context);
/* halt DMA */
if(ohci1394_stop_context(xmit->ohci, xmit->ContextControlClear, NULL)) {
if (ohci1394_stop_context(xmit->ohci, xmit->ContextControlClear, NULL)) {
/* XXX the DMA context will lock up if you try to send too much data! */
PRINT(KERN_ERR, xmit->ohci->id,
"you probably exceeded the OHCI card's bandwidth limit - "
......@@ -1899,7 +1899,7 @@ static void ohci_iso_xmit_shutdown(struct hpsb_iso *iso)
{
struct ohci_iso_xmit *xmit = iso->hostdata;
if(xmit->task_active) {
if (xmit->task_active) {
ohci_iso_xmit_stop(iso);
ohci1394_unregister_iso_tasklet(xmit->ohci, &xmit->task);
xmit->task_active = 0;
......@@ -1918,7 +1918,7 @@ static void ohci_iso_xmit_task(unsigned long data)
int count;
/* check the whole buffer if necessary, starting at pkt_dma */
for(count = 0; count < iso->buf_packets; count++) {
for (count = 0; count < iso->buf_packets; count++) {
int cycle;
/* DMA descriptor */
......@@ -1928,12 +1928,12 @@ static void ohci_iso_xmit_task(unsigned long data)
u16 xferstatus = le32_to_cpu(cmd->output_last.status) >> 16;
u8 event = xferstatus & 0x1F;
if(!event) {
if (!event) {
/* packet hasn't been sent yet; we are done for now */
break;
}
if(event != 0x11)
if (event != 0x11)
PRINT(KERN_ERR, xmit->ohci->id,
"IT DMA error - OHCI error code 0x%02x\n", event);
......@@ -1950,7 +1950,7 @@ static void ohci_iso_xmit_task(unsigned long data)
cmd->output_last.status = 0;
}
if(wake)
if (wake)
hpsb_iso_wake(iso);
}
......@@ -1967,7 +1967,7 @@ static int ohci_iso_xmit_queue(struct hpsb_iso *iso, struct hpsb_iso_packet_info
/* check that the packet doesn't cross a page boundary
(we could allow this if we added OUTPUT_MORE descriptor support) */
if(cross_bound(info->offset, info->len)) {
if (cross_bound(info->offset, info->len)) {
PRINT(KERN_ERR, xmit->ohci->id,
"rawiso xmit: packet %u crosses a page boundary",
iso->first_packet);
......@@ -2030,7 +2030,7 @@ static int ohci_iso_xmit_queue(struct hpsb_iso *iso, struct hpsb_iso_packet_info
dma_prog_region_offset_to_bus(&xmit->prog, sizeof(struct iso_xmit_cmd) * next_i) | 3);
/* disable interrupt, unless required by the IRQ interval */
if(prev_i % iso->irq_interval) {
if (prev_i % iso->irq_interval) {
prev->output_last.control &= cpu_to_le32(~(3 << 20)); /* no interrupt */
} else {
prev->output_last.control |= cpu_to_le32(3 << 20); /* enable interrupt */
......@@ -2062,7 +2062,7 @@ static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle)
dma_prog_region_offset_to_bus(&xmit->prog, iso->pkt_dma * sizeof(struct iso_xmit_cmd)) | 3);
/* cycle match */
if(cycle != -1) {
if (cycle != -1) {
u32 start = cycle & 0x1FFF;
/* 'cycle' is only mod 8000, but we also need two 'seconds' bits -
......@@ -2088,7 +2088,7 @@ static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle)
udelay(100);
/* check the RUN bit */
if(!(reg_read(xmit->ohci, xmit->ContextControlSet) & 0x8000)) {
if (!(reg_read(xmit->ohci, xmit->ContextControlSet) & 0x8000)) {
PRINT(KERN_ERR, xmit->ohci->id, "Error starting IT DMA (ContextControl 0x%08x)\n",
reg_read(xmit->ohci, xmit->ContextControlSet));
return -1;
......@@ -2694,7 +2694,7 @@ static void dma_trm_tasklet (unsigned long data)
#ifdef OHCI1394_DEBUG
if (datasize)
if(((le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf) == 0xa)
if (((le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf) == 0xa)
DBGMSG(ohci->id,
"Stream packet sent to channel %d tcode=0x%X "
"ack=0x%X spd=%d dataLength=%d ctx=%d",
......@@ -2807,7 +2807,7 @@ static void free_dma_rcv_ctx(struct dma_rcv_ctx *d)
DBGMSG(d->ohci->id, "Freeing dma_rcv_ctx %d", d->ctx);
if(d->ctrlClear) {
if (d->ctrlClear) {
ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
if (d->type == DMA_CTX_ISO) {
......@@ -2969,7 +2969,7 @@ static void free_dma_trm_ctx(struct dma_trm_ctx *d)
DBGMSG(d->ohci->id, "Freeing dma_trm_ctx %d", d->ctx);
if(d->ctrlClear) {
if (d->ctrlClear) {
ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
if (d->type == DMA_CTX_ISO) {
......@@ -3261,7 +3261,7 @@ do { \
PRINT_G(KERN_ERR, fmt , ## args); \
ohci1394_pci_remove(dev); \
return err; \
} while(0)
} while (0)
static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
......@@ -3624,8 +3624,8 @@ int ohci1394_register_iso_tasklet(struct ti_ohci *ohci,
usage = &ohci->ir_ctx_usage;
/* only one receive context can be multichannel (OHCI sec 10.4.1) */
if(tasklet->type == OHCI_ISO_MULTICHANNEL_RECEIVE) {
if(test_and_set_bit(0, &ohci->ir_multichannel_used)) {
if (tasklet->type == OHCI_ISO_MULTICHANNEL_RECEIVE) {
if (test_and_set_bit(0, &ohci->ir_multichannel_used)) {
return r;
}
}
......@@ -3660,7 +3660,7 @@ void ohci1394_unregister_iso_tasklet(struct ti_ohci *ohci,
else {
clear_bit(tasklet->context, &ohci->ir_ctx_usage);
if(tasklet->type == OHCI_ISO_MULTICHANNEL_RECEIVE) {
if (tasklet->type == OHCI_ISO_MULTICHANNEL_RECEIVE) {
clear_bit(0, &ohci->ir_multichannel_used);
}
}
......
......@@ -601,7 +601,7 @@ static void handle_iso_listen(struct file_info *fi, struct pending_request *req)
if (fi->listen_channels & (1ULL << channel)) {
req->req.error = RAW1394_ERROR_ALREADY;
} else {
if(hpsb_listen_channel(&raw1394_highlevel, fi->host, channel)) {
if (hpsb_listen_channel(&raw1394_highlevel, fi->host, channel)) {
req->req.error = RAW1394_ERROR_ALREADY;
} else {
fi->listen_channels |= 1ULL << channel;
......@@ -2008,7 +2008,7 @@ static inline int __rawiso_event_in_queue(struct file_info *fi)
list_for_each(lh, &fi->req_complete) {
req = list_entry(lh, struct pending_request, list);
if(req->req.type == RAW1394_REQ_RAWISO_ACTIVITY) {
if (req->req.type == RAW1394_REQ_RAWISO_ACTIVITY) {
return 1;
}
}
......@@ -2024,17 +2024,17 @@ static void queue_rawiso_event(struct file_info *fi)
spin_lock_irqsave(&fi->reqlists_lock, flags);
/* only one ISO activity event may be in the queue */
if(!__rawiso_event_in_queue(fi)) {
if (!__rawiso_event_in_queue(fi)) {
struct pending_request *req = __alloc_pending_request(SLAB_ATOMIC);
if(req) {
if (req) {
req->file_info = fi;
req->req.type = RAW1394_REQ_RAWISO_ACTIVITY;
req->req.generation = get_hpsb_generation(fi->host);
__queue_complete_req(req);
} else {
/* on allocation failure, signal an overflow */
if(fi->iso_handle) {
if (fi->iso_handle) {
atomic_inc(&fi->iso_handle->overflows);
}
}
......@@ -2054,7 +2054,7 @@ static void rawiso_activity_cb(struct hpsb_iso *iso)
if (hi != NULL) {
list_for_each(lh, &hi->file_info_list) {
struct file_info *fi = list_entry(lh, struct file_info, list);
if(fi->iso_handle == iso)
if (fi->iso_handle == iso)
queue_rawiso_event(fi);
}
}
......@@ -2079,7 +2079,7 @@ static int raw1394_iso_xmit_init(struct file_info *fi, void *uaddr)
{
struct raw1394_iso_status stat;
if(copy_from_user(&stat, uaddr, sizeof(stat)))
if (copy_from_user(&stat, uaddr, sizeof(stat)))
return -EFAULT;
fi->iso_handle = hpsb_iso_xmit_init(fi->host,
......@@ -2089,13 +2089,13 @@ static int raw1394_iso_xmit_init(struct file_info *fi, void *uaddr)
stat.config.speed,
stat.config.irq_interval,
rawiso_activity_cb);
if(!fi->iso_handle)
if (!fi->iso_handle)
return -ENOMEM;
fi->iso_state = RAW1394_ISO_XMIT;
raw1394_iso_fill_status(fi->iso_handle, &stat);
if(copy_to_user(uaddr, &stat, sizeof(stat)))
if (copy_to_user(uaddr, &stat, sizeof(stat)))
return -EFAULT;
/* queue an event to get things started */
......@@ -2108,7 +2108,7 @@ static int raw1394_iso_recv_init(struct file_info *fi, void *uaddr)
{
struct raw1394_iso_status stat;
if(copy_from_user(&stat, uaddr, sizeof(stat)))
if (copy_from_user(&stat, uaddr, sizeof(stat)))
return -EFAULT;
fi->iso_handle = hpsb_iso_recv_init(fi->host,
......@@ -2117,13 +2117,13 @@ static int raw1394_iso_recv_init(struct file_info *fi, void *uaddr)
stat.config.channel,
stat.config.irq_interval,
rawiso_activity_cb);
if(!fi->iso_handle)
if (!fi->iso_handle)
return -ENOMEM;
fi->iso_state = RAW1394_ISO_RECV;
raw1394_iso_fill_status(fi->iso_handle, &stat);
if(copy_to_user(uaddr, &stat, sizeof(stat)))
if (copy_to_user(uaddr, &stat, sizeof(stat)))
return -EFAULT;
return 0;
}
......@@ -2134,7 +2134,7 @@ static int raw1394_iso_get_status(struct file_info *fi, void *uaddr)
struct hpsb_iso *iso = fi->iso_handle;
raw1394_iso_fill_status(fi->iso_handle, &stat);
if(copy_to_user(uaddr, &stat, sizeof(stat)))
if (copy_to_user(uaddr, &stat, sizeof(stat)))
return -EFAULT;
/* reset overflow counter */
......@@ -2150,20 +2150,20 @@ static int raw1394_iso_recv_packets(struct file_info *fi, void *uaddr)
unsigned int packet = fi->iso_handle->first_packet;
int i;
if(copy_from_user(&upackets, uaddr, sizeof(upackets)))
if (copy_from_user(&upackets, uaddr, sizeof(upackets)))
return -EFAULT;
if(upackets.n_packets > hpsb_iso_n_ready(fi->iso_handle))
if (upackets.n_packets > hpsb_iso_n_ready(fi->iso_handle))
return -EINVAL;
/* ensure user-supplied buffer is accessible and big enough */
if(verify_area(VERIFY_WRITE, upackets.infos,
if (verify_area(VERIFY_WRITE, upackets.infos,
upackets.n_packets * sizeof(struct raw1394_iso_packet_info)))
return -EFAULT;
/* copy the packet_infos out */
for(i = 0; i < upackets.n_packets; i++) {
if(__copy_to_user(&upackets.infos[i],
for (i = 0; i < upackets.n_packets; i++) {
if (__copy_to_user(&upackets.infos[i],
&fi->iso_handle->infos[packet],
sizeof(struct raw1394_iso_packet_info)))
return -EFAULT;
......@@ -2180,28 +2180,28 @@ static int raw1394_iso_send_packets(struct file_info *fi, void *uaddr)
struct raw1394_iso_packets upackets;
int i, rv;
if(copy_from_user(&upackets, uaddr, sizeof(upackets)))
if (copy_from_user(&upackets, uaddr, sizeof(upackets)))
return -EFAULT;
if(upackets.n_packets > hpsb_iso_n_ready(fi->iso_handle))
if (upackets.n_packets > hpsb_iso_n_ready(fi->iso_handle))
return -EINVAL;
/* ensure user-supplied buffer is accessible and big enough */
if(verify_area(VERIFY_READ, upackets.infos,
if (verify_area(VERIFY_READ, upackets.infos,
upackets.n_packets * sizeof(struct raw1394_iso_packet_info)))
return -EFAULT;
/* copy the infos structs in and queue the packets */
for(i = 0; i < upackets.n_packets; i++) {
for (i = 0; i < upackets.n_packets; i++) {
struct raw1394_iso_packet_info info;
if(__copy_from_user(&info, &upackets.infos[i],
if (__copy_from_user(&info, &upackets.infos[i],
sizeof(struct raw1394_iso_packet_info)))
return -EFAULT;
rv = hpsb_iso_xmit_queue_packet(fi->iso_handle, info.offset,
info.len, info.tag, info.sy);
if(rv)
if (rv)
return rv;
}
......@@ -2210,7 +2210,7 @@ static int raw1394_iso_send_packets(struct file_info *fi, void *uaddr)
static void raw1394_iso_shutdown(struct file_info *fi)
{
if(fi->iso_handle)
if (fi->iso_handle)
hpsb_iso_shutdown(fi->iso_handle);
fi->iso_handle = NULL;
......@@ -2222,7 +2222,7 @@ static int raw1394_mmap(struct file *file, struct vm_area_struct *vma)
{
struct file_info *fi = file->private_data;
if(fi->iso_state == RAW1394_ISO_INACTIVE)
if (fi->iso_state == RAW1394_ISO_INACTIVE)
return -EINVAL;
return dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
......@@ -2249,7 +2249,7 @@ static int raw1394_ioctl(struct inode *inode, struct file *file, unsigned int cm
case RAW1394_IOC_ISO_RECV_START: {
/* copy args from user-space */
int args[3];
if(copy_from_user(&args[0], (void*) arg, sizeof(args)))
if (copy_from_user(&args[0], (void*) arg, sizeof(args)))
return -EFAULT;
return hpsb_iso_recv_start(fi->iso_handle, args[0], args[1], args[2]);
}
......@@ -2263,7 +2263,7 @@ static int raw1394_ioctl(struct inode *inode, struct file *file, unsigned int cm
case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK: {
/* copy the u64 from user-space */
u64 mask;
if(copy_from_user(&mask, (void*) arg, sizeof(mask)))
if (copy_from_user(&mask, (void*) arg, sizeof(mask)))
return -EFAULT;
return hpsb_iso_recv_set_channel_mask(fi->iso_handle, mask);
}
......@@ -2286,7 +2286,7 @@ static int raw1394_ioctl(struct inode *inode, struct file *file, unsigned int cm
case RAW1394_IOC_ISO_XMIT_START: {
/* copy two ints from user-space */
int args[2];
if(copy_from_user(&args[0], (void*) arg, sizeof(args)))
if (copy_from_user(&args[0], (void*) arg, sizeof(args)))
return -EFAULT;
return hpsb_iso_xmit_start(fi->iso_handle, args[0], args[1]);
}
......@@ -2374,7 +2374,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
struct arm_addr *arm_addr = NULL;
int another_host;
if(fi->iso_state != RAW1394_ISO_INACTIVE)
if (fi->iso_state != RAW1394_ISO_INACTIVE)
raw1394_iso_shutdown(fi);
for (i = 0; i < 64; i++) {
......
......@@ -79,7 +79,7 @@
#include "sbp2.h"
static char version[] __devinitdata =
"$Rev: 942 $ Ben Collins <bcollins@debian.org>";
"$Rev: 967 $ Ben Collins <bcollins@debian.org>";
/*
* Module load parameter definitions
......@@ -93,7 +93,7 @@ static char version[] __devinitdata =
* (probably due to PCI latency/throughput issues with the part). You can
* bump down the speed if you are running into problems.
*/
static int max_speed = SPEED_MAX;
static int max_speed = IEEE1394_SPEED_MAX;
module_param(max_speed, int, 0644);
MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb default, 1 = 200mb, 0 = 100mb)");
......@@ -780,8 +780,8 @@ static int sbp2_start_ud(struct sbp2scsi_host_info *hi, struct unit_directory *u
scsi_id->ne = ud->ne;
scsi_id->hi = hi;
scsi_id->speed_code = SPEED_100;
scsi_id->max_payload_size = sbp2_speedto_max_payload[SPEED_100];
scsi_id->speed_code = IEEE1394_SPEED_100;
scsi_id->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100];
atomic_set(&scsi_id->sbp2_login_complete, 0);
INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_inuse);
INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
......
......@@ -589,7 +589,7 @@ static void initialize_dma_it_prg(struct dma_iso_ctx *d, int n, int sync_tag)
it_prg[i].begin.status = 0;
it_prg[i].data[0] = cpu_to_le32(
(SPEED_100 << 16)
(IEEE1394_SPEED_100 << 16)
| (/* tag */ 1 << 14)
| (d->channel << 8)
| (TCODE_ISO_DATA << 4));
......@@ -705,7 +705,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
struct dma_iso_ctx *d;
int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
/* if channel < 0, find lowest available one */
......@@ -802,7 +802,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
v.channel);
}
if(copy_to_user((void *)arg, &v, sizeof(v)))
if (copy_to_user((void *)arg, &v, sizeof(v)))
return -EFAULT;
return 0;
......@@ -814,7 +814,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
u64 mask;
struct dma_iso_ctx *d;
if(copy_from_user(&channel, (void *)arg, sizeof(int)))
if (copy_from_user(&channel, (void *)arg, sizeof(int)))
return -EFAULT;
if (channel<0 || channel>(ISO_CHANNELS-1)) {
......@@ -849,7 +849,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
struct video1394_wait v;
struct dma_iso_ctx *d;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
......@@ -911,7 +911,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
struct dma_iso_ctx *d;
int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
......@@ -939,12 +939,12 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
}
#if 1
while(d->buffer_status[v.buffer]!=
while (d->buffer_status[v.buffer]!=
VIDEO1394_BUFFER_READY) {
spin_unlock_irqrestore(&d->lock, flags);
interruptible_sleep_on(&d->waitq);
spin_lock_irqsave(&d->lock, flags);
if(signal_pending(current)) {
if (signal_pending(current)) {
spin_unlock_irqrestore(&d->lock,flags);
return -EINTR;
}
......@@ -981,7 +981,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
spin_unlock_irqrestore(&d->lock, flags);
v.buffer=i;
if(copy_to_user((void *)arg, &v, sizeof(v)))
if (copy_to_user((void *)arg, &v, sizeof(v)))
return -EFAULT;
return 0;
......@@ -994,7 +994,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
qv.packet_sizes = NULL;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
......@@ -1097,7 +1097,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
struct video1394_wait v;
struct dma_iso_ctx *d;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
......@@ -1114,10 +1114,10 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
return 0;
case VIDEO1394_BUFFER_QUEUED:
#if 1
while(d->buffer_status[v.buffer]!=
while (d->buffer_status[v.buffer]!=
VIDEO1394_BUFFER_READY) {
interruptible_sleep_on(&d->waitq);
if(signal_pending(current)) return -EINTR;
if (signal_pending(current)) return -EINTR;
}
#else
if (wait_event_interruptible(d->waitq,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment