Commit 278d927d authored by Arend van Spriel's avatar Arend van Spriel Committed by Greg Kroah-Hartman

staging: brcm80211: cleanup declaration in osl.h

Several declarations and macro definitions in osl.h are still needed
and therefore moved to bcmutils.h or hnddma.h. The osl_assert function
is moved to bcmutils.c accordingly.
Reviewed-by: default avatarBrett Rudley <brudley@broadcom.com>
Reviewed-by: default avatarHenry Ptasinski <henryp@broadcom.com>
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4fe9042f
......@@ -28,11 +28,11 @@
#include <pcicfg.h>
#include <bcmdefs.h>
#include <bcmdevs.h>
#include <bcmutils.h>
#if defined(OOB_INTR_ONLY)
#include <linux/irq.h>
extern void dhdsdio_isr(void *args);
#include <bcmutils.h>
#include <dngl_stats.h>
#include <dhd.h>
#endif /* defined(OOB_INTR_ONLY) */
......
......@@ -359,7 +359,137 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
#define REG_MAP(pa, size) (void *)(0)
#endif
/* Register operations */
extern u32 g_assert_type;
#if defined(BCMDBG_ASSERT)
#define ASSERT(exp) \
do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
extern void osl_assert(char *exp, char *file, int line);
#else
#define ASSERT(exp) do {} while (0)
#endif /* defined(BCMDBG_ASSERT) */
/* register access macros */
#if defined(BCMSDIO)
#ifdef BRCM_FULLMAC
#include <bcmsdh.h>
#endif
#define OSL_WRITE_REG(r, v) \
(bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v)))
#define OSL_READ_REG(r) \
(bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r))))
#endif
#if defined(BCMSDIO)
#define SELECT_BUS_WRITE(mmap_op, bus_op) bus_op
#define SELECT_BUS_READ(mmap_op, bus_op) bus_op
#else
#define SELECT_BUS_WRITE(mmap_op, bus_op) mmap_op
#define SELECT_BUS_READ(mmap_op, bus_op) mmap_op
#endif
/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
#define PKTBUFSZ 2048
#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ))
#ifdef BRCM_FULLMAC
#include <linux/kernel.h> /* for vsn/printf's */
#include <linux/string.h> /* for mem*, str* */
#endif
/* bcopy's: Linux kernel doesn't provide these (anymore) */
#define bcopy(src, dst, len) memcpy((dst), (src), (len))
/* register access macros */
#ifndef IL_BIGENDIAN
#ifndef __mips__
#define R_REG(r) (\
SELECT_BUS_READ(sizeof(*(r)) == sizeof(u8) ? \
readb((volatile u8*)(r)) : \
sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
readl((volatile u32*)(r)), OSL_READ_REG(r)) \
)
#else /* __mips__ */
#define R_REG(r) (\
SELECT_BUS_READ( \
({ \
__typeof(*(r)) __osl_v; \
__asm__ __volatile__("sync"); \
switch (sizeof(*(r))) { \
case sizeof(u8): \
__osl_v = readb((volatile u8*)(r)); \
break; \
case sizeof(u16): \
__osl_v = readw((volatile u16*)(r)); \
break; \
case sizeof(u32): \
__osl_v = \
readl((volatile u32*)(r)); \
break; \
} \
__asm__ __volatile__("sync"); \
__osl_v; \
}), \
({ \
__typeof(*(r)) __osl_v; \
__asm__ __volatile__("sync"); \
__osl_v = OSL_READ_REG(r); \
__asm__ __volatile__("sync"); \
__osl_v; \
})) \
)
#endif /* __mips__ */
#define W_REG(r, v) do { \
SELECT_BUS_WRITE( \
switch (sizeof(*(r))) { \
case sizeof(u8): \
writeb((u8)(v), (volatile u8*)(r)); break; \
case sizeof(u16): \
writew((u16)(v), (volatile u16*)(r)); break; \
case sizeof(u32): \
writel((u32)(v), (volatile u32*)(r)); break; \
}, \
(OSL_WRITE_REG(r, v))); \
} while (0)
#else /* IL_BIGENDIAN */
#define R_REG(r) (\
SELECT_BUS_READ( \
({ \
__typeof(*(r)) __osl_v; \
switch (sizeof(*(r))) { \
case sizeof(u8): \
__osl_v = \
readb((volatile u8*)((r)^3)); \
break; \
case sizeof(u16): \
__osl_v = \
readw((volatile u16*)((r)^2)); \
break; \
case sizeof(u32): \
__osl_v = readl((volatile u32*)(r)); \
break; \
} \
__osl_v; \
}), \
OSL_READ_REG(r)) \
)
#define W_REG(r, v) do { \
SELECT_BUS_WRITE( \
switch (sizeof(*(r))) { \
case sizeof(u8): \
writeb((u8)(v), \
(volatile u8*)((r)^3)); break; \
case sizeof(u16): \
writew((u16)(v), \
(volatile u16*)((r)^2)); break; \
case sizeof(u32): \
writel((u32)(v), \
(volatile u32*)(r)); break; \
}, \
(OSL_WRITE_REG(r, v))); \
} while (0)
#endif /* IL_BIGENDIAN */
#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
......
......@@ -22,6 +22,11 @@
struct hnddma_pub;
#endif /* _hnddma_pub_ */
/* map/unmap direction */
#define DMA_TX 1 /* TX direction for DMA */
#define DMA_RX 2 /* RX direction for DMA */
#define BUS_SWAP32(v) (v)
/* range param for dma_getnexttxp() and dma_txreclaim */
typedef enum txd_range {
HNDDMA_RANGE_ALL = 1,
......
......@@ -29,146 +29,4 @@ typedef struct osl_dmainfo osldma_t;
extern struct osl_info *osl_attach(void *pdev, uint bustype);
extern void osl_detach(struct osl_info *osh);
extern u32 g_assert_type;
#if defined(BCMDBG_ASSERT)
#define ASSERT(exp) \
do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
extern void osl_assert(char *exp, char *file, int line);
#else
#define ASSERT(exp) do {} while (0)
#endif /* defined(BCMDBG_ASSERT) */
/* PCI device bus # and slot # */
#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
extern uint osl_pci_bus(struct osl_info *osh);
extern uint osl_pci_slot(struct osl_info *osh);
#define BUS_SWAP32(v) (v)
/* map/unmap direction */
#define DMA_TX 1 /* TX direction for DMA */
#define DMA_RX 2 /* RX direction for DMA */
/* register access macros */
#if defined(BCMSDIO)
#ifdef BRCM_FULLMAC
#include <bcmsdh.h>
#endif
#define OSL_WRITE_REG(r, v) \
(bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v)))
#define OSL_READ_REG(r) \
(bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r))))
#endif
#if defined(BCMSDIO)
#define SELECT_BUS_WRITE(mmap_op, bus_op) bus_op
#define SELECT_BUS_READ(mmap_op, bus_op) bus_op
#else
#define SELECT_BUS_WRITE(mmap_op, bus_op) mmap_op
#define SELECT_BUS_READ(mmap_op, bus_op) mmap_op
#endif
/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
#define PKTBUFSZ 2048
#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ))
#ifdef BRCM_FULLMAC
#include <linux/kernel.h> /* for vsn/printf's */
#include <linux/string.h> /* for mem*, str* */
#endif
/* register access macros */
#ifndef IL_BIGENDIAN
#ifndef __mips__
#define R_REG(r) (\
SELECT_BUS_READ(sizeof(*(r)) == sizeof(u8) ? \
readb((volatile u8*)(r)) : \
sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
readl((volatile u32*)(r)), OSL_READ_REG(r)) \
)
#else /* __mips__ */
#define R_REG(r) (\
SELECT_BUS_READ( \
({ \
__typeof(*(r)) __osl_v; \
__asm__ __volatile__("sync"); \
switch (sizeof(*(r))) { \
case sizeof(u8): \
__osl_v = readb((volatile u8*)(r)); \
break; \
case sizeof(u16): \
__osl_v = readw((volatile u16*)(r)); \
break; \
case sizeof(u32): \
__osl_v = \
readl((volatile u32*)(r)); \
break; \
} \
__asm__ __volatile__("sync"); \
__osl_v; \
}), \
({ \
__typeof(*(r)) __osl_v; \
__asm__ __volatile__("sync"); \
__osl_v = OSL_READ_REG(r); \
__asm__ __volatile__("sync"); \
__osl_v; \
})) \
)
#endif /* __mips__ */
#define W_REG(r, v) do { \
SELECT_BUS_WRITE( \
switch (sizeof(*(r))) { \
case sizeof(u8): \
writeb((u8)(v), (volatile u8*)(r)); break; \
case sizeof(u16): \
writew((u16)(v), (volatile u16*)(r)); break; \
case sizeof(u32): \
writel((u32)(v), (volatile u32*)(r)); break; \
}, \
(OSL_WRITE_REG(r, v))); \
} while (0)
#else /* IL_BIGENDIAN */
#define R_REG(r) (\
SELECT_BUS_READ( \
({ \
__typeof(*(r)) __osl_v; \
switch (sizeof(*(r))) { \
case sizeof(u8): \
__osl_v = \
readb((volatile u8*)((r)^3)); \
break; \
case sizeof(u16): \
__osl_v = \
readw((volatile u16*)((r)^2)); \
break; \
case sizeof(u32): \
__osl_v = readl((volatile u32*)(r)); \
break; \
} \
__osl_v; \
}), \
OSL_READ_REG(r)) \
)
#define W_REG(r, v) do { \
SELECT_BUS_WRITE( \
switch (sizeof(*(r))) { \
case sizeof(u8): \
writeb((u8)(v), \
(volatile u8*)((r)^3)); break; \
case sizeof(u16): \
writew((u16)(v), \
(volatile u16*)((r)^2)); break; \
case sizeof(u32): \
writel((u32)(v), \
(volatile u32*)(r)); break; \
}, \
(OSL_WRITE_REG(r, v))); \
} while (0)
#endif /* IL_BIGENDIAN */
#endif /* _osl_h_ */
......@@ -17,11 +17,12 @@
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <bcmdefs.h>
#include <stdarg.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/sched.h>
#include <bcmdefs.h>
#include <stdarg.h>
#include <osl.h>
#include <bcmutils.h>
#include <siutils.h>
......@@ -29,6 +30,9 @@
#include <bcmdevs.h>
#include <proto/802.11.h>
/* Global ASSERT type flag */
u32 g_assert_type;
struct sk_buff *BCMFASTPATH pkt_buf_get_skb(struct osl_info *osh, uint len)
{
struct sk_buff *skb;
......@@ -1091,3 +1095,49 @@ int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
return r;
}
#if defined(BCMDBG_ASSERT)
void osl_assert(char *exp, char *file, int line)
{
char tempbuf[256];
char *basename;
basename = strrchr(file, '/');
/* skip the '/' */
if (basename)
basename++;
if (!basename)
basename = file;
snprintf(tempbuf, 256,
"assertion \"%s\" failed: file \"%s\", line %d\n", exp,
basename, line);
/*
* Print assert message and give it time to
* be written to /var/log/messages
*/
if (!in_interrupt()) {
const int delay = 3;
printk(KERN_ERR "%s", tempbuf);
printk(KERN_ERR "panic in %d seconds\n", delay);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(delay * HZ);
}
switch (g_assert_type) {
case 0:
panic(KERN_ERR "%s", tempbuf);
break;
case 1:
printk(KERN_ERR "%s", tempbuf);
BUG();
break;
case 2:
printk(KERN_ERR "%s", tempbuf);
break;
default:
break;
}
}
#endif /* defined(BCMDBG_ASSERT) */
......@@ -32,9 +32,6 @@
#define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */
#define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */
/* Global ASSERT type flag */
u32 g_assert_type;
struct osl_info *osl_attach(void *pdev, uint bustype)
{
struct osl_info *osh;
......@@ -55,51 +52,3 @@ void osl_detach(struct osl_info *osh)
ASSERT(osh->magic == OS_HANDLE_MAGIC);
kfree(osh);
}
#if defined(BCMDBG_ASSERT)
void osl_assert(char *exp, char *file, int line)
{
char tempbuf[256];
char *basename;
basename = strrchr(file, '/');
/* skip the '/' */
if (basename)
basename++;
if (!basename)
basename = file;
#ifdef BCMDBG_ASSERT
snprintf(tempbuf, 256,
"assertion \"%s\" failed: file \"%s\", line %d\n", exp,
basename, line);
/* Print assert message and give it time to be written to /var/log/messages */
if (!in_interrupt()) {
const int delay = 3;
printk(KERN_ERR "%s", tempbuf);
printk(KERN_ERR "panic in %d seconds\n", delay);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(delay * HZ);
}
switch (g_assert_type) {
case 0:
panic(KERN_ERR "%s", tempbuf);
break;
case 1:
printk(KERN_ERR "%s", tempbuf);
BUG();
break;
case 2:
printk(KERN_ERR "%s", tempbuf);
break;
default:
break;
}
#endif /* BCMDBG_ASSERT */
}
#endif /* defined(BCMDBG_ASSERT) */
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