Commit f8012106 authored by David S. Miller's avatar David S. Miller

Merge Ben's and my fixes.

parents e17427d4 11092356
......@@ -201,54 +201,84 @@ static int __devinit pci_sanity_check(struct pci_raw_ops *o)
return 0;
}
static int __init pci_direct_init(void)
static int __init pci_check_type1(void)
{
unsigned int tmp;
unsigned long flags;
unsigned int tmp;
int works = 0;
local_irq_save(flags);
/*
* Check if configuration type 1 works.
*/
if (pci_probe & PCI_PROBE_CONF1) {
outb (0x01, 0xCFB);
tmp = inl (0xCF8);
outl (0x80000000, 0xCF8);
if (inl (0xCF8) == 0x80000000 &&
pci_sanity_check(&pci_direct_conf1)) {
outl (tmp, 0xCF8);
local_irq_restore(flags);
printk(KERN_INFO "PCI: Using configuration type 1\n");
if (!request_region(0xCF8, 8, "PCI conf1"))
raw_pci_ops = NULL;
else
raw_pci_ops = &pci_direct_conf1;
return 0;
}
outl (tmp, 0xCF8);
outb(0x01, 0xCFB);
tmp = inl(0xCF8);
outl(0x80000000, 0xCF8);
if (inl(0xCF8) == 0x80000000 && pci_sanity_check(&pci_direct_conf1)) {
works = 1;
}
outl(tmp, 0xCF8);
local_irq_restore(flags);
return works;
}
static int __init pci_check_type2(void)
{
unsigned long flags;
int works = 0;
local_irq_save(flags);
/*
* Check if configuration type 2 works.
*/
if (pci_probe & PCI_PROBE_CONF2) {
outb (0x00, 0xCFB);
outb (0x00, 0xCF8);
outb (0x00, 0xCFA);
if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
pci_sanity_check(&pci_direct_conf2)) {
local_irq_restore(flags);
printk(KERN_INFO "PCI: Using configuration type 2\n");
if (!request_region(0xCF8, 4, "PCI conf2"))
raw_pci_ops = NULL;
else
raw_pci_ops = &pci_direct_conf2;
return 0;
}
outb(0x00, 0xCFB);
outb(0x00, 0xCF8);
outb(0x00, 0xCFA);
if (inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00 &&
pci_sanity_check(&pci_direct_conf2)) {
works = 1;
}
local_irq_restore(flags);
return works;
}
static int __init pci_direct_init(void)
{
struct resource *region, *region2;
if ((pci_probe & PCI_PROBE_CONF1) == 0)
goto type2;
region = request_region(0xCF8, 8, "PCI conf1");
if (!region)
goto type2;
if (pci_check_type1()) {
printk(KERN_INFO "PCI: Using configuration type 1\n");
raw_pci_ops = &pci_direct_conf1;
return 0;
}
release_resource(region);
type2:
if ((!pci_probe & PCI_PROBE_CONF2) == 0)
goto out;
region = request_region(0xCF8, 4, "PCI conf2");
if (!region)
goto out;
region2 = request_region(0xC000, 0x1000, "PCI conf2");
if (!region2)
goto fail2;
if (pci_check_type2()) {
printk(KERN_INFO "PCI: Using configuration type 2\n");
raw_pci_ops = &pci_direct_conf2;
return 0;
}
release_resource(region2);
fail2:
release_resource(region);
out:
return 0;
}
......
......@@ -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 */
......
This diff is collapsed.
......@@ -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();
}
}
......
This diff is collapsed.
......@@ -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; "
......
This diff is collapsed.
......@@ -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,
......
......@@ -379,6 +379,25 @@ static void make_slot_name (struct slot *slot)
slot->acpi_slot->sun);
}
/**
* release_slot - free up the memory used by a slot
* @hotplug_slot: slot to free
*/
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
if (slot == NULL)
return;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
/**
* init_slots - initialize 'struct slot' structures for each slot
*
......@@ -422,6 +441,7 @@ static int init_slots (void)
slot->number = i;
slot->hotplug_slot->private = slot;
slot->hotplug_slot->release = &release_slot;
slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
slot->acpi_slot = get_slot_from_id(i);
......@@ -435,10 +455,7 @@ static int init_slots (void)
retval = pci_hp_register(slot->hotplug_slot);
if (retval) {
err("pci_hp_register failed with error %d\n", retval);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
release_slot(slot->hotplug_slot);
return retval;
}
......@@ -457,13 +474,10 @@ static void cleanup_slots (void)
struct slot *slot;
list_for_each_safe (tmp, n, &slot_list) {
/* memory will be freed in release_slot callback */
slot = list_entry(tmp, struct slot, slot_list);
list_del(&slot->slot_list);
pci_hp_deregister(slot->hotplug_slot);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
return;
......
......@@ -278,6 +278,19 @@ get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
return 0;
}
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
if(slot == NULL)
return;
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
#define SLOT_NAME_SIZE 6
static void
make_slot_name(struct slot *slot)
......@@ -346,6 +359,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
slot->devfn = PCI_DEVFN(i, 0);
hotplug_slot->private = slot;
hotplug_slot->release = &release_slot;
make_slot_name(slot);
hotplug_slot->ops = &cpci_hotplug_slot_ops;
......@@ -382,6 +396,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
{
struct slot *slot;
struct list_head *tmp;
struct list_head *next;
int status;
if(!bus) {
......@@ -393,7 +408,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
spin_unlock(&list_lock);
return -1;
}
list_for_each(tmp, &slot_list) {
list_for_each_safe(tmp, next, &slot_list) {
slot = list_entry(tmp, struct slot, slot_list);
if(slot->bus == bus) {
dbg("deregistering slot %s", slot->hotplug_slot->name);
......@@ -405,11 +420,6 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
}
list_del(&slot->slot_list);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
slots--;
}
}
......
......@@ -312,6 +312,20 @@ static void *get_SMBIOS_entry (void *smbios_start, void *smbios_table, u8 type,
return previous;
}
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
if (slot == NULL)
return;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *smbios_table)
{
......@@ -401,6 +415,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
/* register this slot with the hotplug pci core */
new_slot->hotplug_slot->release = &release_slot;
new_slot->hotplug_slot->private = new_slot;
make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
......@@ -415,10 +430,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
result = pci_hp_register (new_slot->hotplug_slot);
if (result) {
err ("pci_hp_register failed with error %d\n", result);
kfree (new_slot->hotplug_slot->info);
kfree (new_slot->hotplug_slot->name);
kfree (new_slot->hotplug_slot);
kfree (new_slot);
release_slot(new_slot->hotplug_slot);
return result;
}
......@@ -430,10 +442,9 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
slot_number++;
}
return(0);
return 0;
}
static int ctrl_slot_cleanup (struct controller * ctrl)
{
struct slot *old_slot, *next_slot;
......@@ -442,12 +453,9 @@ static int ctrl_slot_cleanup (struct controller * ctrl)
ctrl->slot = NULL;
while (old_slot) {
/* memory will be freed by the release_slot callback */
next_slot = old_slot->next;
pci_hp_deregister (old_slot->hotplug_slot);
kfree(old_slot->hotplug_slot->info);
kfree(old_slot->hotplug_slot->name);
kfree(old_slot->hotplug_slot);
kfree(old_slot);
old_slot = next_slot;
}
......@@ -498,7 +506,7 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
// Make sure I got at least one entry
if (len == 0) {
if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
kfree(PCIIRQRoutingInfoLength);
return -1;
}
......@@ -509,9 +517,7 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
if ((tbus == bus_num) && (tdevice == dev_num)) {
*slot = tslot;
if (PCIIRQRoutingInfoLength != NULL)
kfree(PCIIRQRoutingInfoLength);
kfree(PCIIRQRoutingInfoLength);
return 0;
} else {
// Didn't get a match on the target PCI device. Check if the
......@@ -540,10 +546,10 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
// slot number for the bridge.
if (bridgeSlot != 0xFF) {
*slot = bridgeSlot;
if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
kfree(PCIIRQRoutingInfoLength);
return 0;
}
if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
kfree(PCIIRQRoutingInfoLength);
// Couldn't find an entry in the routing table for this PCI device
return -1;
}
......
......@@ -7,7 +7,7 @@
* Written By: Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -398,7 +398,6 @@ extern int ibmphp_hpc_readslot (struct slot *, u8, u8 *);
extern int ibmphp_hpc_writeslot (struct slot *, u8);
extern void ibmphp_lock_operations (void);
extern void ibmphp_unlock_operations (void);
extern int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *);
extern int ibmphp_hpc_start_poll_thread (void);
extern void ibmphp_hpc_stop_poll_thread (void);
......
......@@ -3,8 +3,8 @@
*
* Written By: Chuck Cole, Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -739,26 +739,8 @@ static void free_slots (void)
debug ("%s -- enter\n", __FUNCTION__);
list_for_each_safe (tmp, next, &ibmphp_slot_head) {
slot_cur = list_entry (tmp, struct slot, ibm_slot_list);
pci_hp_deregister (slot_cur->hotplug_slot);
if (slot_cur->hotplug_slot) {
kfree (slot_cur->hotplug_slot);
slot_cur->hotplug_slot = NULL;
}
if (slot_cur->ctrl)
slot_cur->ctrl = NULL;
if (slot_cur->bus_on)
slot_cur->bus_on = NULL;
ibmphp_unconfigure_card (&slot_cur, -1); /* we don't want to actually remove the resources, since free_resources will do just that */
kfree (slot_cur);
slot_cur = NULL;
}
debug ("%s -- exit\n", __FUNCTION__);
}
......@@ -1221,7 +1203,6 @@ int ibmphp_do_disable_slot (struct slot *slot_cur)
{
int rc;
u8 flag;
int parm = 0;
debug ("DISABLING SLOT... \n");
......@@ -1270,7 +1251,7 @@ int ibmphp_do_disable_slot (struct slot *slot_cur)
return 0;
}
rc = ibmphp_unconfigure_card (&slot_cur, parm);
rc = ibmphp_unconfigure_card (&slot_cur, 0);
slot_cur->func = NULL;
debug ("in disable_slot. after unconfigure_card\n");
if (rc) {
......
......@@ -3,8 +3,8 @@
*
* Written By: Tong Yu, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -727,6 +727,64 @@ static char *create_file_name (struct slot * slot_cur)
return str;
}
static int fillslotinfo(struct hotplug_slot *hotplug_slot)
{
struct slot *slot;
int rc = 0;
if (!hotplug_slot || !hotplug_slot->private)
return -EINVAL;
slot = hotplug_slot->private;
rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL);
if (rc)
return rc;
// power - enabled:1 not:0
hotplug_slot->info->power_status = SLOT_POWER(slot->status);
// attention - off:0, on:1, blinking:2
hotplug_slot->info->attention_status = SLOT_ATTN(slot->status, slot->ext_status);
// latch - open:1 closed:0
hotplug_slot->info->latch_status = SLOT_LATCH(slot->status);
// pci board - present:1 not:0
if (SLOT_PRESENT (slot->status))
hotplug_slot->info->adapter_status = 1;
else
hotplug_slot->info->adapter_status = 0;
/*
if (slot->bus_on->supported_bus_mode
&& (slot->bus_on->supported_speed == BUS_SPEED_66))
hotplug_slot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
else
hotplug_slot->info->max_bus_speed_status = slot->bus_on->supported_speed;
*/
return rc;
}
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot;
if (!hotplug_slot || !hotplug_slot->private)
return;
slot = hotplug_slot->private;
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
slot->ctrl = NULL;
slot->bus_on = NULL;
/* we don't want to actually remove the resources, since free_resources will do just that */
ibmphp_unconfigure_card(&slot, -1);
kfree (slot);
}
static struct pci_driver ibmphp_driver;
/*
......@@ -900,32 +958,32 @@ static int __init ebda_rsrc_controller (void)
// register slots with hpc core as well as create linked list of ibm slot
for (index = 0; index < hpc_ptr->slot_count; index++) {
hp_slot_ptr = (struct hotplug_slot *) kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
if (!hp_slot_ptr) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
memset (hp_slot_ptr, 0, sizeof (struct hotplug_slot));
memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
hp_slot_ptr->info = (struct hotplug_slot_info *) kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!hp_slot_ptr->info) {
rc = -ENOMEM;
goto error_no_hp_info;
}
memset (hp_slot_ptr->info, 0, sizeof (struct hotplug_slot_info));
memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
hp_slot_ptr->name = (char *) kmalloc (30, GFP_KERNEL);
hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
if (!hp_slot_ptr->name) {
rc = -ENOMEM;
goto error_no_hp_name;
}
tmp_slot = kmalloc (sizeof (struct slot), GFP_KERNEL);
tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
if (!tmp_slot) {
rc = -ENOMEM;
goto error_no_slot;
}
memset (tmp_slot, 0, sizeof (*tmp_slot));
memset(tmp_slot, 0, sizeof(*tmp_slot));
tmp_slot->flag = TRUE;
......@@ -959,8 +1017,9 @@ static int __init ebda_rsrc_controller (void)
tmp_slot->hotplug_slot = hp_slot_ptr;
hp_slot_ptr->private = tmp_slot;
hp_slot_ptr->release = release_slot;
rc = ibmphp_hpc_fillhpslotinfo (hp_slot_ptr);
rc = fillslotinfo(hp_slot_ptr);
if (rc)
goto error;
......
......@@ -3,7 +3,7 @@
*
* Written By: Jyoti Shah, IBM Corporation
*
* Copyright (c) 2001-2002 IBM Corp.
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -114,7 +114,6 @@ static u8 hpc_readcmdtoindex (u8, u8);
static void get_hpc_access (void);
static void free_hpc_access (void);
static void poll_hpc (void);
static int update_slot (struct slot *, u8);
static int process_changeinstatus (struct slot *, struct slot *);
static int process_changeinlatch (u8, u8, struct controller *);
static int hpc_poll_thread (void *);
......@@ -917,71 +916,6 @@ static void poll_hpc (void)
}
/* ----------------------------------------------------------------------
* Name: ibmphp_hpc_fillhpslotinfo(hotplug_slot * phpslot)
*
* Action: fill out the hotplug_slot info
*
* Input: pointer to hotplug_slot
*
* Return
* Value: 0 or error codes
*-----------------------------------------------------------------------*/
int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *phpslot)
{
int rc = 0;
struct slot *pslot;
if (phpslot && phpslot->private) {
pslot = (struct slot *) phpslot->private;
rc = update_slot (pslot, (u8) TRUE);
if (!rc) {
// power - enabled:1 not:0
phpslot->info->power_status = SLOT_POWER (pslot->status);
// attention - off:0, on:1, blinking:2
phpslot->info->attention_status = SLOT_ATTN (pslot->status, pslot->ext_status);
// latch - open:1 closed:0
phpslot->info->latch_status = SLOT_LATCH (pslot->status);
// pci board - present:1 not:0
if (SLOT_PRESENT (pslot->status))
phpslot->info->adapter_status = 1;
else
phpslot->info->adapter_status = 0;
/*
if (pslot->bus_on->supported_bus_mode
&& (pslot->bus_on->supported_speed == BUS_SPEED_66))
phpslot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
else
phpslot->info->max_bus_speed_status = pslot->bus_on->supported_speed;
*/ } else
rc = -EINVAL;
} else
rc = -EINVAL;
return rc;
}
/*----------------------------------------------------------------------
* Name: update_slot
*
* Action: fill out slot status and extended status, controller status
*
* Input: pointer to slot struct
*---------------------------------------------------------------------*/
static int update_slot (struct slot *pslot, u8 update)
{
int rc = 0;
debug ("%s - Entry pslot[%p]\n", __FUNCTION__, pslot);
rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL);
debug ("%s - Exit rc[%d]\n", __FUNCTION__, rc);
return rc;
}
/*----------------------------------------------------------------------
* Name: process_changeinstatus
*
......
/*
* PCI Hot Plug Controller Skeleton Driver - 0.1
* PCI Hot Plug Controller Skeleton Driver - 0.2
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001 IBM Corp.
* Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2003 IBM Corp.
*
* All rights reserved.
*
......@@ -69,7 +69,7 @@ static LIST_HEAD(slot_list);
static int debug;
static int num_slots;
#define DRIVER_VERSION "0.1"
#define DRIVER_VERSION "0.2"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
#define DRIVER_DESC "Hot Plug PCI Controller Skeleton Driver"
......@@ -288,6 +288,21 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
return retval;
}
static void release_slots(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval = 0;
if (slot == NULL)
return -ENODEV;
dbg(__FUNCTION__" - physical_slot = %s\n", hotplug_slot->name);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
#define SLOT_NAME_SIZE 10
static void make_slot_name (struct slot *slot)
{
......@@ -347,6 +362,7 @@ static int init_slots (void)
slot->number = i;
hotplug_slot->private = slot;
hotplug_slot->release = &release_slot;
make_slot_name (slot);
hotplug_slot->ops = &skel_hotplug_slot_ops;
......@@ -376,27 +392,23 @@ static int init_slots (void)
return retval;
}
static void cleanup_slots (void)
static void cleanup_slots(void)
{
struct list_head *tmp;
struct list_head *next;
struct slot *slot;
/*
* Unregister all of our slots with the pci_hotplug subsystem,
* and free up all memory that we had allocated.
* Unregister all of our slots with the pci_hotplug subsystem.
* Memory will be freed in release_slot() callback after slot's
* lifespan is finished.
*/
list_for_each (tmp, &slot_list) {
list_for_each_safe (tmp, next, &slot_list) {
slot = list_entry (tmp, struct slot, slot_list);
list_del (&slot->slot_list);
pci_hp_deregister (slot->hotplug_slot);
kfree (slot->hotplug_slot->info);
kfree (slot->hotplug_slot->name);
kfree (slot->hotplug_slot);
kfree (slot);
}
return;
}
static int __init pcihp_skel_init(void)
......
......@@ -109,7 +109,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
(((unsigned long) ~sz) << 32);
#else
if (l) {
printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", dev->slot_name);
printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", pci_name(dev));
res->start = 0;
res->flags = 0;
continue;
......@@ -304,7 +304,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
DBG("Scanning behind PCI bridge %s, config %06x, pass %d\n",
dev->slot_name, buses & 0xffffff, pass);
pci_name(dev), buses & 0xffffff, pass);
if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) {
unsigned int cmax;
......@@ -403,8 +403,9 @@ static int pci_setup_device(struct pci_dev * dev)
{
u32 class;
sprintf(dev->slot_name, "%02x:%02x.%d", dev->bus->number,
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
dev->slot_name = dev->dev.bus_id;
sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
sprintf(dev->dev.name, "PCI device %04x:%04x",
dev->vendor, dev->device);
......@@ -452,12 +453,12 @@ static int pci_setup_device(struct pci_dev * dev)
default: /* unknown header */
printk(KERN_ERR "PCI: device %s has unknown header type %02x, ignoring.\n",
dev->slot_name, dev->hdr_type);
pci_name(dev), dev->hdr_type);
return -1;
bad:
printk(KERN_ERR "PCI: %s: class %x doesn't match header type %02x. Ignoring class.\n",
dev->slot_name, class, dev->hdr_type);
pci_name(dev), class, dev->hdr_type);
dev->class = PCI_CLASS_NOT_DEFINED;
}
......@@ -531,9 +532,6 @@ pci_scan_device(struct pci_bus *bus, int devfn)
pci_name_device(dev);
/* now put in global tree */
sprintf(dev->dev.bus_id, "%04x:%s", pci_domain_nr(bus),
dev->slot_name);
dev->dev.dma_mask = &dev->dma_mask;
return dev;
......
......@@ -414,7 +414,7 @@ struct pci_dev {
struct resource dma_resource[DEVICE_COUNT_DMA];
struct resource irq_resource[DEVICE_COUNT_IRQ];
char slot_name[8]; /* slot name */
char * slot_name; /* pointer to dev.bus_id */
/* These fields are used by common fixups */
unsigned int transparent:1; /* Transparent PCI bridge */
......@@ -804,6 +804,14 @@ static inline void pci_set_drvdata (struct pci_dev *pdev, void *data)
dev_set_drvdata(&pdev->dev, data);
}
/* If you want to know what to call your pci_dev, ask this function.
* Again, it's a wrapper around the generic device.
*/
static inline char *pci_name(struct pci_dev *pdev)
{
return pdev->dev.bus_id;
}
/*
* The world is not perfect and supplies us with broken PCI devices.
* For at least a part of these bugs we need a work-around, so both
......
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