staging Patch 03/04: Crystal HD

From: Manu Abraham
Date: Sat Jan 02 2010 - 15:18:06 EST



From 074c65b2ff8277b1eff863fa64c03c2f9047a661 Mon Sep 17 00:00:00 2001
From: Manu Abraham <manu@xxxxxxxxxxxxxxx>
Date: Sat, 2 Jan 2010 22:06:15 +0400
Subject: [PATCH] [Crystal HD] Coding style cleanups

Signed-off-by: Manu Abraham <abraham.manu@xxxxxxxxx>
---
drivers/staging/crystal-hd/bc_dts_defs.h | 124 ++++++++++++--------------
drivers/staging/crystal-hd/bc_dts_glob_lnx.h | 10 +-
drivers/staging/crystal-hd/bc_dts_types.h | 16 ++--
drivers/staging/crystal-hd/crystalhd_cmds.c | 77 ++++++++--------
drivers/staging/crystal-hd/crystalhd_cmds.h | 6 +-
drivers/staging/crystal-hd/crystalhd_fw_if.h | 22 ++---
drivers/staging/crystal-hd/crystalhd_hw.c | 97 ++++++++++----------
drivers/staging/crystal-hd/crystalhd_hw.h | 10 +-
drivers/staging/crystal-hd/crystalhd_lnx.c | 91 +++++++++----------
drivers/staging/crystal-hd/crystalhd_misc.c | 106 ++++++++++------------
drivers/staging/crystal-hd/crystalhd_misc.h | 29 +++---
11 files changed, 281 insertions(+), 307 deletions(-)

diff --git a/drivers/staging/crystal-hd/bc_dts_defs.h b/drivers/staging/crystal-hd/bc_dts_defs.h
index 405bd16..c34cc07 100644
--- a/drivers/staging/crystal-hd/bc_dts_defs.h
+++ b/drivers/staging/crystal-hd/bc_dts_defs.h
@@ -29,7 +29,7 @@
#include "bc_dts_types.h"

/* BIT Mask */
-#define BC_BIT(_x) ( 1 << (_x) )
+#define BC_BIT(_x) (1 << (_x))

typedef enum _BC_STATUS {
BC_STS_SUCCESS = 0,
@@ -195,9 +195,9 @@ typedef struct _BC_PIB_EXT_H264 {

/* H264_VALID_PANSCAN */
uint32_t pan_scan_count;
- int32_t pan_scan_left [3];
- int32_t pan_scan_right [3];
- int32_t pan_scan_top [3];
+ int32_t pan_scan_left[3];
+ int32_t pan_scan_right[3];
+ int32_t pan_scan_top[3];
int32_t pan_scan_bottom[3];

/* H264_VALID_SPS_CROP */
@@ -241,8 +241,7 @@ typedef struct _BC_PIB_EXT_VC1 {
#if defined(_WIN32) || defined(_WIN64) || defined(__LINUX_USER__)
/* Values for 'pulldown' field. '0' means no pulldown information
* was present for this picture. */
-enum
-{
+enum {
vdecNoPulldownInfo = 0,
vdecTop = 1,
vdecBottom = 2,
@@ -257,8 +256,7 @@ enum
};

/* Values for the 'frame_rate' field. */
-enum
-{
+enum {
vdecFrameRateUnknown = 0,
vdecFrameRate23_97,
vdecFrameRate24,
@@ -271,8 +269,7 @@ enum
};

/* Values for the 'aspect_ratio' field. */
-enum
-{
+enum {
vdecAspectRatioUnknown = 0,
vdecAspectRatioSquare,
vdecAspectRatio12_11,
@@ -294,8 +291,7 @@ enum
};

/* Values for the 'colour_primaries' field. */
-enum
-{
+enum {
vdecColourPrimariesUnknown = 0,
vdecColourPrimariesBT709,
vdecColourPrimariesUnspecified,
@@ -307,43 +303,42 @@ enum
vdecColourPrimariesGenericFilm,
};

-enum
-{
- vdecRESOLUTION_CUSTOM = 0x00000000, // custom
- vdecRESOLUTION_480i = 0x00000001, // 480i
- vdecRESOLUTION_1080i = 0x00000002, // 1080i (1920x1080, 60i)
- vdecRESOLUTION_NTSC = 0x00000003, // NTSC (720x483, 60i)
- vdecRESOLUTION_480p = 0x00000004, // 480p (720x480, 60p)
- vdecRESOLUTION_720p = 0x00000005, // 720p (1280x720, 60p)
- vdecRESOLUTION_PAL1 = 0x00000006, // PAL_1 (720x576, 50i)
- vdecRESOLUTION_1080i25 = 0x00000007, // 1080i25 (1920x1080, 50i)
- vdecRESOLUTION_720p50 = 0x00000008, // 720p50 (1280x720, 50p)
- vdecRESOLUTION_576p = 0x00000009, // 576p (720x576, 50p)
- vdecRESOLUTION_1080i29_97 = 0x0000000A, // 1080i (1920x1080, 59.94i)
- vdecRESOLUTION_720p59_94 = 0x0000000B, // 720p (1280x720, 59.94p)
- vdecRESOLUTION_SD_DVD = 0x0000000C, // SD DVD (720x483, 60i)
- vdecRESOLUTION_480p656 = 0x0000000D, // 480p (720x480, 60p), output bus width 8 bit, clock 74.25MHz.
- vdecRESOLUTION_1080p23_976 = 0x0000000E, // 1080p23_976 (1920x1080, 23.976p)
- vdecRESOLUTION_720p23_976 = 0x0000000F, // 720p23_976 (1280x720p, 23.976p)
- vdecRESOLUTION_240p29_97 = 0x00000010, // 240p (1440x240, 29.97p )
- vdecRESOLUTION_240p30 = 0x00000011, // 240p (1440x240, 30p)
- vdecRESOLUTION_288p25 = 0x00000012, // 288p (1440x288p, 25p)
- vdecRESOLUTION_1080p29_97 = 0x00000013, // 1080p29_97 (1920x1080, 29.97p)
- vdecRESOLUTION_1080p30 = 0x00000014, // 1080p30 (1920x1080, 30p)
- vdecRESOLUTION_1080p24 = 0x00000015, // 1080p24 (1920x1080, 24p)
- vdecRESOLUTION_1080p25 = 0x00000016, // 1080p25 (1920x1080, 25p)
- vdecRESOLUTION_720p24 = 0x00000017, // 720p24 (1280x720, 25p)
- vdecRESOLUTION_720p29_97 = 0x00000018, // 720p29.97 (1280x720, 29.97p)
- vdecRESOLUTION_480p23_976 = 0x00000019, // 480p23.976 (720*480, 23.976)
- vdecRESOLUTION_480p29_97 = 0x0000001A, // 480p29.976 (720*480, 29.97p)
- vdecRESOLUTION_576p25 = 0x0000001B, // 576p25 (720*576, 25p)
- //For Zero Frame Rate
- vdecRESOLUTION_480p0 = 0x0000001C, // 480p (720x480, 0p)
- vdecRESOLUTION_480i0 = 0x0000001D, // 480i (720x480, 0i)
- vdecRESOLUTION_576p0 = 0x0000001E, // 576p (720x576, 0p)
- vdecRESOLUTION_720p0 = 0x0000001F, // 720p (1280x720, 0p)
- vdecRESOLUTION_1080p0 = 0x00000020, // 1080p (1920x1080, 0p)
- vdecRESOLUTION_1080i0 = 0x00000021, // 1080i (1920x1080, 0i)
+enum {
+ vdecRESOLUTION_CUSTOM = 0x00000000, /* custom */
+ vdecRESOLUTION_480i = 0x00000001, /* 480i */
+ vdecRESOLUTION_1080i = 0x00000002, /* 1080i (1920x1080, 60i) */
+ vdecRESOLUTION_NTSC = 0x00000003, /* NTSC (720x483, 60i) */
+ vdecRESOLUTION_480p = 0x00000004, /* 480p (720x480, 60p) */
+ vdecRESOLUTION_720p = 0x00000005, /* 720p (1280x720, 60p) */
+ vdecRESOLUTION_PAL1 = 0x00000006, /* PAL_1 (720x576, 50i) */
+ vdecRESOLUTION_1080i25 = 0x00000007, /* 1080i25 (1920x1080, 50i) */
+ vdecRESOLUTION_720p50 = 0x00000008, /* 720p50 (1280x720, 50p) */
+ vdecRESOLUTION_576p = 0x00000009, /* 576p (720x576, 50p) */
+ vdecRESOLUTION_1080i29_97 = 0x0000000A, /* 1080i (1920x1080, 59.94i) */
+ vdecRESOLUTION_720p59_94 = 0x0000000B, /* 720p (1280x720, 59.94p) */
+ vdecRESOLUTION_SD_DVD = 0x0000000C, /* SD DVD (720x483, 60i) */
+ vdecRESOLUTION_480p656 = 0x0000000D, /* 480p (720x480, 60p), output bus width 8 bit, clock 74.25MHz */
+ vdecRESOLUTION_1080p23_976 = 0x0000000E, /* 1080p23_976 (1920x1080, 23.976p) */
+ vdecRESOLUTION_720p23_976 = 0x0000000F, /* 720p23_976 (1280x720p, 23.976p) */
+ vdecRESOLUTION_240p29_97 = 0x00000010, /* 240p (1440x240, 29.97p ) */
+ vdecRESOLUTION_240p30 = 0x00000011, /* 240p (1440x240, 30p) */
+ vdecRESOLUTION_288p25 = 0x00000012, /* 288p (1440x288p, 25p) */
+ vdecRESOLUTION_1080p29_97 = 0x00000013, /* 1080p29_97 (1920x1080, 29.97p) */
+ vdecRESOLUTION_1080p30 = 0x00000014, /* 1080p30 (1920x1080, 30p) */
+ vdecRESOLUTION_1080p24 = 0x00000015, /* 1080p24 (1920x1080, 24p) */
+ vdecRESOLUTION_1080p25 = 0x00000016, /* 1080p25 (1920x1080, 25p) */
+ vdecRESOLUTION_720p24 = 0x00000017, /* 720p24 (1280x720, 25p) */
+ vdecRESOLUTION_720p29_97 = 0x00000018, /* 720p29.97 (1280x720, 29.97p) */
+ vdecRESOLUTION_480p23_976 = 0x00000019, /* 480p23.976 (720*480, 23.976) */
+ vdecRESOLUTION_480p29_97 = 0x0000001A, /* 480p29.976 (720*480, 29.97p) */
+ vdecRESOLUTION_576p25 = 0x0000001B, /* 576p25 (720*576, 25p) */
+ /* For Zero Frame Rate */
+ vdecRESOLUTION_480p0 = 0x0000001C, /* 480p (720x480, 0p) */
+ vdecRESOLUTION_480i0 = 0x0000001D, /* 480i (720x480, 0i) */
+ vdecRESOLUTION_576p0 = 0x0000001E, /* 576p (720x576, 0p) */
+ vdecRESOLUTION_720p0 = 0x0000001F, /* 720p (1280x720, 0p) */
+ vdecRESOLUTION_1080p0 = 0x00000020, /* 1080p (1920x1080, 0p) */
+ vdecRESOLUTION_1080i0 = 0x00000021, /* 1080i (1920x1080, 0i) */
};

/* Bit definitions for 'flags' field */
@@ -363,7 +358,7 @@ enum

#define VDEC_FLAG_PICTURE_META_DATA_PRESENT (0x40000)

-#endif // _WIN32 || _WIN64
+#endif /* _WIN32 || _WIN64 */

enum _BC_OUTPUT_FORMAT {
MODE420 = 0x0,
@@ -390,11 +385,10 @@ typedef struct _BC_PIC_INFO_BLOCK {
uint32_t n_drop; /* number of non-reference frames remaining to be dropped */

/* Protocol-specific extensions. */
- union
- {
- BC_PIB_EXT_H264 h264;
- BC_PIB_EXT_MPEG mpeg;
- BC_PIB_EXT_VC1 vc1;
+ union {
+ BC_PIB_EXT_H264 h264;
+ BC_PIB_EXT_MPEG mpeg;
+ BC_PIB_EXT_VC1 vc1;
} other;

} BC_PIC_INFO_BLOCK, *PBC_PIC_INFO_BLOCK;
@@ -419,14 +413,14 @@ enum _POUT_OPTIONAL_IN_FLAGS_{
};

#if defined(__KERNEL__) || defined(__LINUX_USER__)
-typedef BC_STATUS (*dts_pout_callback)(void *shnd, uint32_t width, uint32_t height, uint32_t stride, void *pOut);
+typedef BC_STATUS(*dts_pout_callback)(void *shnd, uint32_t width, uint32_t height, uint32_t stride, void *pOut);
#else
-typedef BC_STATUS (*dts_pout_callback)(void *shnd, uint32_t width, uint32_t height, uint32_t stride, struct _BC_DTS_PROC_OUT *pOut);
+typedef BC_STATUS(*dts_pout_callback)(void *shnd, uint32_t width, uint32_t height, uint32_t stride, struct _BC_DTS_PROC_OUT *pOut);
#endif

-//Line 21 Closed Caption
-//User Data
-#define MAX_UD_SIZE 1792 //1920 - 128
+/* Line 21 Closed Caption */
+/* User Data */
+#define MAX_UD_SIZE 1792 /* 1920 - 128 */

typedef struct _BC_DTS_PROC_OUT {
uint8_t *Ybuff; /* Caller Supplied buffer for Y data */
@@ -444,8 +438,8 @@ typedef struct _BC_DTS_PROC_OUT {

BC_PIC_INFO_BLOCK PicInfo; /* Picture Information Block Data */

- //Line 21 Closed Caption
- //User Data
+ /* Line 21 Closed Caption */
+ /* User Data */
uint32_t UserDataSz;
uint8_t UserData[MAX_UD_SIZE];

@@ -488,10 +482,10 @@ typedef struct _BC_DTS_STATUS {
} BC_DTS_STATUS;

#define BC_SWAP32(_v) \
- ( (((_v) & 0xFF000000)>>24)| \
+ ((((_v) & 0xFF000000)>>24)| \
(((_v) & 0x00FF0000)>>8)| \
(((_v) & 0x0000FF00)<<8)| \
- (((_v) & 0x000000FF)<<24) )
+ (((_v) & 0x000000FF)<<24))

#define WM_AGENT_TRAYICON_DECODER_OPEN 10001
#define WM_AGENT_TRAYICON_DECODER_CLOSE 10002
@@ -501,4 +495,4 @@ typedef struct _BC_DTS_STATUS {
#define WM_AGENT_TRAYICON_DECODER_PAUSE 10006


-#endif //_BC_DTS_DEFS_H_
+#endif /* _BC_DTS_DEFS_H_ */
diff --git a/drivers/staging/crystal-hd/bc_dts_glob_lnx.h b/drivers/staging/crystal-hd/bc_dts_glob_lnx.h
index cd24fae..b3125e3 100644
--- a/drivers/staging/crystal-hd/bc_dts_glob_lnx.h
+++ b/drivers/staging/crystal-hd/bc_dts_glob_lnx.h
@@ -189,12 +189,12 @@ typedef struct _BC_DEC_OUT_BUFF{
BC_PIC_INFO_BLOCK PibInfo;
uint32_t Flags;
uint32_t BadFrCnt;
-}BC_DEC_OUT_BUFF;
+} BC_DEC_OUT_BUFF;

typedef struct _BC_NOTIFY_MODE {
uint32_t Mode;
uint32_t Rsvr[3];
-}BC_NOTIFY_MODE;
+} BC_NOTIFY_MODE;

typedef struct _BC_CLOCK {
uint32_t clk;
@@ -220,7 +220,7 @@ typedef struct _BC_IOCTL_DATA {
BC_DTS_STATS drvStat;
BC_NOTIFY_MODE NotifyMode;
BC_CLOCK clockValue;
- }u;
+ } u;
struct _BC_IOCTL_DATA *next;
} BC_IOCTL_DATA;

@@ -249,11 +249,11 @@ typedef enum _BC_DRV_CMD{

/* MUST be the last one.. */
DRV_CMD_END, /* End of the List.. */
-}BC_DRV_CMD;
+} BC_DRV_CMD;

#define BC_IOC_BASE 'b'
#define BC_IOC_VOID _IOC_NONE
-#define BC_IOC_IOWR(nr,type) _IOWR(BC_IOC_BASE,nr,type)
+#define BC_IOC_IOWR(nr, type) _IOWR(BC_IOC_BASE, nr, type)
#define BC_IOCTL_MB BC_IOCTL_DATA

#define BCM_IOC_GET_VERSION BC_IOC_IOWR(DRV_CMD_VERSION, BC_IOCTL_MB)
diff --git a/drivers/staging/crystal-hd/bc_dts_types.h b/drivers/staging/crystal-hd/bc_dts_types.h
index a28c7af..e073d74 100644
--- a/drivers/staging/crystal-hd/bc_dts_types.h
+++ b/drivers/staging/crystal-hd/bc_dts_types.h
@@ -25,10 +25,6 @@
#ifndef _BC_DTS_TYPES_H_
#define _BC_DTS_TYPES_H_

-#ifdef __LINUX_USER__ // Don't include these for KERNEL..
-#include <stdint.h>
-#endif
-
#if defined(_WIN64) || defined(_WIN32)
typedef uint32_t U32;
typedef int32_t S32;
@@ -39,7 +35,7 @@ typedef char S8;
#endif

#ifndef PVOID
-typedef void * PVOID;
+typedef void *PVOID;
#endif

#ifndef BOOL
@@ -56,13 +52,13 @@ typedef int BOOL;
#if !(defined(POINTER_32))
#define POINTER_32 __ptr32
#endif
-#else //_WIN32
+#else /* _WIN32 */
#define POINTER_32
#endif

#if defined(__KERNEL__) || defined(__LINUX_USER__)

-#ifdef __LINUX_USER__ // Don't include these for KERNEL..
+#ifdef __LINUX_USER__ /* Don't include these for KERNEL */
typedef uint32_t ULONG;
typedef int32_t LONG;
typedef void *HANDLE;
@@ -74,15 +70,17 @@ typedef uint32_t *LPDWORD;
typedef unsigned char *PUCHAR;

#ifndef TRUE
-#define TRUE 1
+ #define TRUE 1
#endif

#ifndef FALSE
-#define FALSE 0
+ #define FALSE 0
#endif

#define TEXT
+
#else
+
/* For Kernel usage.. */
typedef bool bc_bool_t;
#endif
diff --git a/drivers/staging/crystal-hd/crystalhd_cmds.c b/drivers/staging/crystal-hd/crystalhd_cmds.c
index 457f267..39c641d 100644
--- a/drivers/staging/crystal-hd/crystalhd_cmds.c
+++ b/drivers/staging/crystal-hd/crystalhd_cmds.c
@@ -88,7 +88,7 @@ static BC_STATUS bc_cproc_notify_mode(struct crystalhd_cmd *ctx,
return BC_STS_SUCCESS;
}
if (ctx->state != BC_LINK_INVALID) {
- BCMLOG_ERR("Link invalid state %d \n",ctx->state);
+ BCMLOG_ERR("Link invalid state %d \n", ctx->state);
return BC_STS_ERR_USAGE;
}
/* Check for duplicate playback sessions..*/
@@ -236,7 +236,7 @@ static BC_STATUS bc_cproc_cfg_rd(struct crystalhd_cmd *ctx,
if (!ctx || !idata)
return BC_STS_INV_ARG;

- temp = (uint32_t*)idata->udata.u.pciCfg.pci_cfg_space;
+ temp = (uint32_t *) idata->udata.u.pciCfg.pci_cfg_space;
off = idata->udata.u.pciCfg.Offset;
len = idata->udata.u.pciCfg.Size;

@@ -268,7 +268,7 @@ static BC_STATUS bc_cproc_cfg_wr(struct crystalhd_cmd *ctx,
if (!ctx || !idata)
return BC_STS_INV_ARG;

- temp = (uint32_t*)idata->udata.u.pciCfg.pci_cfg_space;
+ temp = (uint32_t *) idata->udata.u.pciCfg.pci_cfg_space;
off = idata->udata.u.pciCfg.Offset;
len = idata->udata.u.pciCfg.Size;

@@ -307,6 +307,7 @@ static BC_STATUS bc_cproc_download_fw(struct crystalhd_cmd *ctx,

sts = crystalhd_download_fw(ctx->adp, (uint8_t *)idata->add_cdata,
idata->add_cdata_sz);
+
if (sts != BC_STS_SUCCESS) {
BCMLOG_ERR("Firmware Download Failure!! - %d\n", sts);
} else
@@ -334,7 +335,7 @@ static BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx, crystalhd_ioctl_d
uint32_t *cmd;

if (!(ctx->state & BC_LINK_INIT)) {
- BCMLOG_ERR("Link invalid state %d \n",ctx->state);
+ BCMLOG_ERR("Link invalid state %d \n", ctx->state);
return BC_STS_ERR_USAGE;
}

@@ -347,7 +348,7 @@ static BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx, crystalhd_ioctl_d
crystalhd_hw_unpause(&ctx->hw_ctx);
}
} else if (cmd[0] == eCMD_C011_DEC_CHAN_FLUSH) {
- BCMLOG(BCMLOG_INFO,"Flush issued\n");
+ BCMLOG(BCMLOG_INFO, "Flush issued\n");
if (cmd[3])
ctx->cin_wait_exit = 1;
}
@@ -373,8 +374,7 @@ static BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx, crystalhd_ioctl_d
static void bc_proc_in_completion(crystalhd_dio_req *dio_hnd,
wait_queue_head_t *event, BC_STATUS sts)
{
- if (!dio_hnd || !event)
- {
+ if (!dio_hnd || !event) {
BCMLOG_ERR("Invalid Arg!!\n");
return;
}
@@ -423,8 +423,8 @@ static BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx,
crystalhd_create_event(&event);

ctx->tx_list_id = 0;
- //msleep_interruptible(2000);
- sts = crystalhd_hw_post_tx(&ctx->hw_ctx,dio, bc_proc_in_completion,
+ /* msleep_interruptible(2000); */
+ sts = crystalhd_hw_post_tx(&ctx->hw_ctx, dio, bc_proc_in_completion,
&event, &tx_listid,
idata->udata.u.ProcInput.Encrypted);

@@ -432,13 +432,13 @@ static BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx,
sts = bc_cproc_codein_sleep(ctx);
if (sts != BC_STS_SUCCESS)
break;
- sts = crystalhd_hw_post_tx(&ctx->hw_ctx,dio,
+ sts = crystalhd_hw_post_tx(&ctx->hw_ctx, dio,
bc_proc_in_completion,
&event, &tx_listid,
idata->udata.u.ProcInput.Encrypted);
}
if (sts != BC_STS_SUCCESS) {
- BCMLOG(BCMLOG_DBG,"_hw_txdma returning sts:%d\n",sts);
+ BCMLOG(BCMLOG_DBG, "_hw_txdma returning sts:%d\n", sts);
return sts;
}
if (ctx->cin_wait_exit)
@@ -452,10 +452,10 @@ static BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx,
if (!rc) {
return dio->uinfo.comp_sts;
} else if (rc == -EBUSY) {
- BCMLOG(BCMLOG_DBG,"_tx_post() T/O \n");
+ BCMLOG(BCMLOG_DBG, "_tx_post() T/O \n");
sts = BC_STS_TIMEOUT;
} else if (rc == -EINTR) {
- BCMLOG(BCMLOG_DBG,"Tx Wait Signal int.\n");
+ BCMLOG(BCMLOG_DBG, "Tx Wait Signal int.\n");
sts = BC_STS_IO_USER_ABORT;
} else {
sts = BC_STS_IO_ERROR;
@@ -476,14 +476,14 @@ static BC_STATUS bc_cproc_check_inbuffs(bool pin, void *ubuff, uint32_t ub_sz,
{
if (!ubuff || !ub_sz) {
BCMLOG_ERR("%s->Invalid Arg %p %x\n",
- ((pin)?"TX":"RX"),ubuff,ub_sz);
+ ((pin) ? "TX" : "RX"), ubuff, ub_sz);
return BC_STS_INV_ARG;
}

/* Check for alignment */
if (((uintptr_t)ubuff) & 0x03) {
BCMLOG_ERR("%s-->Un-aligned address not implemented yet.. %p \n",
- ((pin)?"TX":"RX"),ubuff);
+ ((pin) ? "TX" : "RX"), ubuff);
return BC_STS_NOT_IMPL;
}
if (pin)
@@ -517,13 +517,13 @@ static BC_STATUS bc_cproc_proc_input(struct crystalhd_cmd *ctx, crystalhd_ioctl_
ubuff = idata->udata.u.ProcInput.pDmaBuff;
ub_sz = idata->udata.u.ProcInput.BuffSz;

- sts = bc_cproc_check_inbuffs(1, ubuff, ub_sz, 0,0);
+ sts = bc_cproc_check_inbuffs(1, ubuff, ub_sz, 0, 0);
if (sts != BC_STS_SUCCESS)
return sts;

- sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz,0,0,1,&dio_hnd);
+ sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, 0, 0, 1, &dio_hnd);
if (sts != BC_STS_SUCCESS) {
- BCMLOG_ERR("dio map - %d \n",sts);
+ BCMLOG_ERR("dio map - %d \n", sts);
return sts;
}

@@ -543,7 +543,7 @@ static BC_STATUS bc_cproc_add_cap_buff(struct crystalhd_cmd *ctx,
void *ubuff;
uint32_t ub_sz, uv_off;
bool en_422;
- crystalhd_dio_req *dio_hnd=NULL;
+ crystalhd_dio_req *dio_hnd = NULL;
BC_STATUS sts = BC_STS_SUCCESS;

if (!ctx || !idata) {
@@ -556,24 +556,23 @@ static BC_STATUS bc_cproc_add_cap_buff(struct crystalhd_cmd *ctx,
uv_off = idata->udata.u.RxBuffs.UVbuffOffset;
en_422 = idata->udata.u.RxBuffs.b422Mode;

- sts = bc_cproc_check_inbuffs(0, ubuff, ub_sz, uv_off,en_422);
+ sts = bc_cproc_check_inbuffs(0, ubuff, ub_sz, uv_off, en_422);
if (sts != BC_STS_SUCCESS)
return sts;

sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, uv_off,
en_422, 0, &dio_hnd);
if (sts != BC_STS_SUCCESS) {
- BCMLOG_ERR("dio map - %d \n",sts);
+ BCMLOG_ERR("dio map - %d \n", sts);
return sts;
}

if (!dio_hnd)
return BC_STS_ERROR;

- sts = crystalhd_hw_add_cap_buffer(&ctx->hw_ctx,dio_hnd,
- (ctx->state == BC_LINK_READY));
+ sts = crystalhd_hw_add_cap_buffer(&ctx->hw_ctx, dio_hnd, (ctx->state == BC_LINK_READY));
if ((sts != BC_STS_SUCCESS) && (sts != BC_STS_BUSY)) {
- crystalhd_unmap_dio(ctx->adp,dio_hnd);
+ crystalhd_unmap_dio(ctx->adp, dio_hnd);
return sts;
}

@@ -609,7 +608,7 @@ static BC_STATUS bc_cproc_fetch_frame(struct crystalhd_cmd *ctx,
}

if (!(ctx->state & BC_LINK_CAP_EN)) {
- BCMLOG(BCMLOG_DBG,"Capture not enabled..%x\n", ctx->state);
+ BCMLOG(BCMLOG_DBG, "Capture not enabled..%x\n", ctx->state);
return BC_STS_ERR_USAGE;
}

@@ -617,13 +616,12 @@ static BC_STATUS bc_cproc_fetch_frame(struct crystalhd_cmd *ctx,

sts = crystalhd_hw_get_cap_buffer(&ctx->hw_ctx, &frame->PibInfo, &dio);
if (sts != BC_STS_SUCCESS)
- return ((ctx->state & BC_LINK_SUSPEND) ?
- BC_STS_IO_USER_ABORT : sts);
+ return (ctx->state & BC_LINK_SUSPEND) ? BC_STS_IO_USER_ABORT : sts;

frame->Flags = dio->uinfo.comp_flags;

if (frame->Flags & COMP_FLAG_FMT_CHANGE)
- return bc_cproc_fmt_change(ctx,dio);
+ return bc_cproc_fmt_change(ctx, dio);

frame->OutPutBuffs.YuvBuff = dio->uinfo.xfr_buff;
frame->OutPutBuffs.YuvBuffSz = dio->uinfo.xfr_len;
@@ -673,12 +671,11 @@ static BC_STATUS bc_cproc_flush_cap_buffs(struct crystalhd_cmd *ctx,
frame = &idata->udata.u.DecOutData;
for (count = 0; count < BC_RX_LIST_CNT; count++) {

- sts = crystalhd_hw_get_cap_buffer(&ctx->hw_ctx,
- &frame->PibInfo,&dio);
+ sts = crystalhd_hw_get_cap_buffer(&ctx->hw_ctx, &frame->PibInfo, &dio);
if (sts != BC_STS_SUCCESS)
break;

- crystalhd_unmap_dio(ctx->adp,dio);
+ crystalhd_unmap_dio(ctx->adp, dio);
}

return crystalhd_hw_stop_capture(&ctx->hw_ctx);
@@ -737,7 +734,7 @@ static BC_STATUS bc_cproc_chg_clk(struct crystalhd_cmd *ctx,
}

clock = &idata->udata.u.clockValue;
- oldClk= ctx->hw_ctx.core_clock_mhz;
+ oldClk = ctx->hw_ctx.core_clock_mhz;
ctx->hw_ctx.core_clock_mhz = clock->clk;

if (ctx->state & BC_LINK_READY) {
@@ -812,7 +809,7 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida
return BC_STS_SUCCESS;

if (ctx->state == BC_LINK_INVALID) {
- BCMLOG(BCMLOG_DBG," Nothing To Do Suspend Success\n");
+ BCMLOG(BCMLOG_DBG, "Nothing To Do Suspend Success\n");
return BC_STS_SUCCESS;
}

@@ -821,13 +818,13 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida
bc_cproc_mark_pwr_state(ctx);

if (ctx->state & BC_LINK_CAP_EN) {
- sts = bc_cproc_flush_cap_buffs(ctx,idata);
+ sts = bc_cproc_flush_cap_buffs(ctx, idata);
if (sts != BC_STS_SUCCESS)
return sts;
}

if (ctx->tx_list_id) {
- sts = crystalhd_hw_cancel_tx(&ctx->hw_ctx,ctx->tx_list_id);
+ sts = crystalhd_hw_cancel_tx(&ctx->hw_ctx, ctx->tx_list_id);
if (sts != BC_STS_SUCCESS)
return sts;
}
@@ -836,7 +833,7 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida
if (sts != BC_STS_SUCCESS)
return sts;

- BCMLOG(BCMLOG_DBG," BCM70012 suspend success\n");
+ BCMLOG(BCMLOG_DBG, "BCM70012 suspend success\n");

return BC_STS_SUCCESS;
}
@@ -859,7 +856,7 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida
*/
BC_STATUS crystalhd_resume(struct crystalhd_cmd *ctx)
{
- BCMLOG(BCMLOG_DBG," crystalhd_resume Success %x\n",ctx->state);
+ BCMLOG(BCMLOG_DBG, "crystalhd_resume Success %x\n", ctx->state);

bc_cproc_mark_pwr_state(ctx);

@@ -890,11 +887,11 @@ BC_STATUS crystalhd_user_open(struct crystalhd_cmd *ctx,

uc = bc_cproc_get_uid(ctx);
if (!uc) {
- BCMLOG(BCMLOG_INFO,"No free user context...\n");
+ BCMLOG(BCMLOG_INFO, "No free user context...\n");
return BC_STS_BUSY;
}

- BCMLOG(BCMLOG_INFO, "Opening new user[%x] handle\n",uc->uid);
+ BCMLOG(BCMLOG_INFO, "Opening new user[%x] handle\n", uc->uid);

crystalhd_hw_open(&ctx->hw_ctx, ctx->adp);

@@ -1029,7 +1026,7 @@ crystalhd_cmd_proc crystalhd_get_cmd_proc(struct crystalhd_cmd *ctx, uint32_t cm
if (g_crystalhd_cproc_tbl[i].cmd_id == cmd) {
if ((uc->mode == DTS_MONITOR_MODE) &&
(g_crystalhd_cproc_tbl[i].block_mon)) {
- BCMLOG(BCMLOG_INFO,"Blocking cmd %d \n",cmd);
+ BCMLOG(BCMLOG_INFO, "Blocking cmd %d \n", cmd);
break;
}
cproc = g_crystalhd_cproc_tbl[i].cmd_proc;
diff --git a/drivers/staging/crystal-hd/crystalhd_cmds.h b/drivers/staging/crystal-hd/crystalhd_cmds.h
index f1f15c6..6b290ae 100644
--- a/drivers/staging/crystal-hd/crystalhd_cmds.h
+++ b/drivers/staging/crystal-hd/crystalhd_cmds.h
@@ -79,9 +79,9 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida
BC_STATUS crystalhd_resume(struct crystalhd_cmd *ctx);
crystalhd_cmd_proc crystalhd_get_cmd_proc(struct crystalhd_cmd *ctx, uint32_t cmd,
struct crystalhd_user *uc);
-BC_STATUS crystalhd_user_open(struct crystalhd_cmd *ctx, struct crystalhd_user**user_ctx);
-BC_STATUS crystalhd_user_close(struct crystalhd_cmd *ctx,struct crystalhd_user *uc);
-BC_STATUS crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx,struct crystalhd_adp *adp);
+BC_STATUS crystalhd_user_open(struct crystalhd_cmd *ctx, struct crystalhd_user **user_ctx);
+BC_STATUS crystalhd_user_close(struct crystalhd_cmd *ctx, struct crystalhd_user *uc);
+BC_STATUS crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx, struct crystalhd_adp *adp);
BC_STATUS crystalhd_delete_cmd_context(struct crystalhd_cmd *ctx);
bool crystalhd_cmd_interrupt(struct crystalhd_cmd *ctx);

diff --git a/drivers/staging/crystal-hd/crystalhd_fw_if.h b/drivers/staging/crystal-hd/crystalhd_fw_if.h
index cc7cce2..261cd19 100644
--- a/drivers/staging/crystal-hd/crystalhd_fw_if.h
+++ b/drivers/staging/crystal-hd/crystalhd_fw_if.h
@@ -28,8 +28,8 @@
#define _CRYSTALHD_FW_IF_H_

/* TBD: Pull in only required defs into this file.. */
-//#include "7411d.h"
-//#include "vdec_info.h"
+
+

/* User Data Header */
typedef struct user_data {
@@ -102,10 +102,10 @@ typedef struct {
* Content of the film grain SEI message.
*/

-//maximum number of model-values as for Thomson spec(standard says 5)
+/* maximum number of model-values as for Thomson spec(standard says 5) */
#define MAX_FGT_MODEL_VALUE (3)

-//maximum number of intervals(as many as 256 intervals?)
+/* maximum number of intervals(as many as 256 intervals?) */
#define MAX_FGT_VALUE_INTERVAL (256)

typedef struct FGT_SEI {
@@ -117,7 +117,7 @@ typedef struct FGT_SEI {
unsigned char cancel_flag; /* Cancel flag: 1 no film grain. */
unsigned char model_id; /* Model id. */

- //+unused SE based on Thomson spec
+ /* +unused SE based on Thomson spec */
unsigned char color_desc_flag; /* Separate color descrition flag. */
unsigned char bit_depth_luma; /* Bit depth luma minus 8. */
unsigned char bit_depth_chroma; /* Bit depth chroma minus 8. */
@@ -125,7 +125,7 @@ typedef struct FGT_SEI {
unsigned char color_primaries; /* Color primaries. */
unsigned char transfer_charact; /* Transfer characteristics. */
unsigned char matrix_coeff; /*< Matrix coefficients. */
- //-unused SE based on Thomson spec
+ /* -unused SE based on Thomson spec */

unsigned char blending_mode_id; /* Blending mode. */
unsigned char log2_scale_factor; /* Log2 scale factor (2-7). */
@@ -256,12 +256,10 @@ typedef struct {
#define eCMD_C011_CMD_BASE (0x73763000)

/* host commands */
-typedef enum
-{
-
- eCMD_TS_GET_NEXT_PIC = 0x7376F100, // debug get next picture
- eCMD_TS_GET_LAST_PIC = 0x7376F102, // debug get last pic status
- eCMD_TS_READ_WRITE_MEM = 0x7376F104, // debug read write memory
+typedef enum {
+ eCMD_TS_GET_NEXT_PIC = 0x7376F100, /* debug get next picture */
+ eCMD_TS_GET_LAST_PIC = 0x7376F102, /* debug get last pic status */
+ eCMD_TS_READ_WRITE_MEM = 0x7376F104, /* debug read write memory */

/* New API commands */
/* General commands */
diff --git a/drivers/staging/crystal-hd/crystalhd_hw.c b/drivers/staging/crystal-hd/crystalhd_hw.c
index 412aff3..01819d3 100644
--- a/drivers/staging/crystal-hd/crystalhd_hw.c
+++ b/drivers/staging/crystal-hd/crystalhd_hw.c
@@ -30,8 +30,8 @@

static void crystalhd_enable_uarts(struct crystalhd_adp *adp)
{
- bc_dec_reg_wr(adp,UartSelectA,BSVS_UART_STREAM);
- bc_dec_reg_wr(adp,UartSelectB,BSVS_UART_DEC_OUTER);
+ bc_dec_reg_wr(adp, UartSelectA, BSVS_UART_STREAM);
+ bc_dec_reg_wr(adp, UartSelectB, BSVS_UART_DEC_OUTER);
}


@@ -69,7 +69,7 @@ static bool crystalhd_bring_out_of_rst(struct crystalhd_adp *adp)
* delay to allow PLL to lock Clear alternate clock, stop clock bits
*/
rst_clk_cntrl.whole_reg = crystalhd_reg_rd(adp, MISC_PERST_CLOCK_CTRL);
- rst_clk_cntrl.pll_pwr_dn =0;
+ rst_clk_cntrl.pll_pwr_dn = 0;
crystalhd_reg_wr(adp, MISC_PERST_CLOCK_CTRL, rst_clk_cntrl.whole_reg);
msleep_interruptible(50);

@@ -104,7 +104,7 @@ static bool crystalhd_bring_out_of_rst(struct crystalhd_adp *adp)
msleep_interruptible(50);

/* Disable OTP_CONTENT_MISC to 0 to disable all secure modes */
- crystalhd_reg_wr(adp,OTP_CONTENT_MISC, 0);
+ crystalhd_reg_wr(adp, OTP_CONTENT_MISC, 0);

/* Clear bit 29 of 0x404 */
temp = crystalhd_reg_rd(adp, PCIE_TL_TRANSACTION_CONFIGURATION);
@@ -202,7 +202,7 @@ static void crystalhd_enable_interrupts(struct crystalhd_adp *adp)
intr_mask.mask_rx_err = 1;
intr_mask.mask_tx_done = 1;
intr_mask.mask_tx_err = 1;
- crystalhd_reg_wr(adp,INTR_INTR_MSK_CLR_REG,intr_mask.whole_reg);
+ crystalhd_reg_wr(adp, INTR_INTR_MSK_CLR_REG, intr_mask.whole_reg);

return;
}
@@ -326,7 +326,7 @@ static bool crystalhd_stop_device(struct crystalhd_adp *adp)
{
uint32_t reg;

- BCMLOG(BCMLOG_INFO,"Stopping BCM70012 Device\n");
+ BCMLOG(BCMLOG_INFO, "Stopping BCM70012 Device\n");
/* Clear and disable interrupts */
crystalhd_disable_interrupts(adp);
crystalhd_clear_errors(adp);
@@ -363,7 +363,7 @@ static crystalhd_rx_dma_pkt *crystalhd_hw_alloc_rx_pkt(struct crystalhd_hw *hw)
temp->pkt_tag = 0;
temp->flags = 0;
}
- spin_unlock_irqrestore(&hw->lock,flags);
+ spin_unlock_irqrestore(&hw->lock, flags);

return temp;
}
@@ -408,7 +408,7 @@ static void crystalhd_rx_pkt_rel_call_back(void *context, void *data)
crystalhd_rx_dma_pkt *pkt = (crystalhd_rx_dma_pkt *)data;

if (!pkt || !hw) {
- BCMLOG_ERR("Invalid arg - %p %p\n",hw,pkt);
+ BCMLOG_ERR("Invalid arg - %p %p\n", hw, pkt);
return;
}

@@ -431,7 +431,7 @@ static void crystalhd_hw_delete_ioqs(struct crystalhd_hw *hw)
if (!hw)
return;

- BCMLOG(BCMLOG_DBG,"Deleting IOQs \n");
+ BCMLOG(BCMLOG_DBG, "Deleting IOQs \n");
crystalhd_hw_delete_ioq(hw->adp, hw->tx_actq);
crystalhd_hw_delete_ioq(hw->adp, hw->tx_freeq);
crystalhd_hw_delete_ioq(hw->adp, hw->rx_actq);
@@ -440,9 +440,11 @@ static void crystalhd_hw_delete_ioqs(struct crystalhd_hw *hw)
}

#define crystalhd_hw_create_ioq(sts, hw, q, cb) \
- sts = crystalhd_create_dioq(hw->adp, &q, cb, hw); \
+do { \
+ sts = crystalhd_create_dioq(hw->adp, &q, cb, hw); \
if (sts != BC_STS_SUCCESS) \
- goto hw_create_ioq_err;
+ goto hw_create_ioq_err; \
+} while (0)

/*
* Create IOQs..
@@ -567,7 +569,7 @@ static bool crystalhd_tx_list0_handler(struct crystalhd_hw *hw, uint32_t err_sts
if (!(err_sts & err_mask))
return false;

- BCMLOG_ERR("Error on Tx-L0 %x \n",err_sts);
+ BCMLOG_ERR("Error on Tx-L0 %x \n", err_sts);

tmp = err_mask;

@@ -590,7 +592,7 @@ static bool crystalhd_tx_list0_handler(struct crystalhd_hw *hw, uint32_t err_sts
static bool crystalhd_tx_list1_handler(struct crystalhd_hw *hw, uint32_t err_sts)
{
uint32_t err_mask, tmp;
- unsigned long flags=0;
+ unsigned long flags = 0;

err_mask = MISC1_TX_DMA_ERROR_STATUS_TX_L1_DESC_TX_ABORT_ERRORS_MASK |
MISC1_TX_DMA_ERROR_STATUS_TX_L1_DMA_DATA_TX_ABORT_ERRORS_MASK |
@@ -599,7 +601,7 @@ static bool crystalhd_tx_list1_handler(struct crystalhd_hw *hw, uint32_t err_sts
if (!(err_sts & err_mask))
return false;

- BCMLOG_ERR("Error on Tx-L1 %x \n",err_sts);
+ BCMLOG_ERR("Error on Tx-L1 %x \n", err_sts);

tmp = err_mask;

@@ -661,11 +663,12 @@ static void crystalhd_hw_dump_desc(pdma_descriptor p_dma_desc,

/* FIXME: jarod: perhaps a modparam desc_debug to enable this, rather than
* setting ll (log level, I presume) to non-zero? */
- if (!ll) return;
+ if (!ll)
+ return;

- for (ix=ul_desc_index; ix<(ul_desc_index+cnt); ix++) {
- BCMLOG(ll,"%s[%d] Buff[%x:%x] Next:[%x:%x] XferSz:%x Intr:%x,Last:%x\n",
- ((p_dma_desc[ul_desc_index].dma_dir)?"TDesc":"RDesc"),
+ for (ix = ul_desc_index; ix < (ul_desc_index + cnt); ix++) {
+ BCMLOG(ll, "%s[%d] Buff[%x:%x] Next:[%x:%x] XferSz:%x Intr:%x,Last:%x\n",
+ ((p_dma_desc[ul_desc_index].dma_dir) ? "TDesc" : "RDesc"),
ul_desc_index,
p_dma_desc[ul_desc_index].buff_addr_high,
p_dma_desc[ul_desc_index].buff_addr_low,
@@ -721,11 +724,11 @@ static BC_STATUS crystalhd_hw_fill_desc(crystalhd_dio_req *ioreq,
desc[ix].next_desc_addr_low = addr_temp.low_part;
desc[ix].next_desc_addr_high = addr_temp.high_part;

- if ((count+len) > xfr_sz)
+ if ((count + len) > xfr_sz)
len = xfr_sz - count;

/* Debug.. */
- if ((!len) || (len>crystalhd_get_sgle_len(ioreq,sg_ix)) ) {
+ if ((!len) || (len > crystalhd_get_sgle_len(ioreq, sg_ix))) {
BCMLOG_ERR("inv-len(%x) Ix(%d) count:%x xfr_sz:%x sg_cnt:%d\n",
len, ix, count, xfr_sz, sg_cnt);
return BC_STS_ERROR;
@@ -877,20 +880,18 @@ static BC_STATUS crystalhd_stop_tx_dma_engine(struct crystalhd_hw *hw)
dma_cntrl &= ~DMA_START_BIT;
crystalhd_reg_wr(hw->adp, MISC1_TX_SW_DESC_LIST_CTRL_STS, dma_cntrl);

- BCMLOG(BCMLOG_DBG,"Cleared the DMA Start bit\n");
+ BCMLOG(BCMLOG_DBG, "Cleared the DMA Start bit\n");

/* Poll for 3seconds (30 * 100ms) on both the lists..*/
while ((l1 || l2) && cnt) {

if (l1) {
- l1 = crystalhd_reg_rd(hw->adp,
- MISC1_TX_FIRST_DESC_L_ADDR_LIST0);
+ l1 = crystalhd_reg_rd(hw->adp, MISC1_TX_FIRST_DESC_L_ADDR_LIST0);
l1 &= DMA_START_BIT;
}

if (l2) {
- l2 = crystalhd_reg_rd(hw->adp,
- MISC1_TX_FIRST_DESC_L_ADDR_LIST1);
+ l2 = crystalhd_reg_rd(hw->adp, MISC1_TX_FIRST_DESC_L_ADDR_LIST1);
l2 &= DMA_START_BIT;
}

@@ -984,8 +985,7 @@ static uint32_t crystalhd_get_addr_from_pib_Q(struct crystalhd_hw *hw)
return addr_entry;
}

-static bool crystalhd_rel_addr_to_pib_Q(struct crystalhd_hw* hw,
- uint32_t addr_to_rel)
+static bool crystalhd_rel_addr_to_pib_Q(struct crystalhd_hw *hw, uint32_t addr_to_rel)
{
uint32_t Q_addr;
uint32_t r_offset, w_offset, n_offset;
@@ -1286,7 +1286,7 @@ static void crystalhd_hw_finalize_pause(struct crystalhd_hw *hw)

aspm = crystalhd_reg_rd(hw->adp, PCIE_DLL_DATA_LINK_CONTROL);
aspm |= ASPM_L1_ENABLE;
-// NAREN BCMLOG(BCMLOG_INFO, "aspm on\n");
+ /* NAREN BCMLOG(BCMLOG_INFO, "aspm on\n"); */
crystalhd_reg_wr(hw->adp, PCIE_DLL_DATA_LINK_CONTROL, aspm);
}

@@ -1506,7 +1506,7 @@ static void crystalhd_rx_isr(struct crystalhd_hw *hw, uint32_t intr_sts)
hw->stats.rx_errors++;
crystalhd_get_dnsz(hw, i, &y_dn_sz, &uv_dn_sz);
/* FIXME: jarod: this is where my mini pci-e card is tripping up */
- BCMLOG(BCMLOG_DBG,"list_index:%x rx[%d] Y:%x "
+ BCMLOG(BCMLOG_DBG, "list_index:%x rx[%d] Y:%x "
"UV:%x Int:%x YDnSz:%x UVDnSz:%x\n",
i, hw->stats.rx_errors, y_err_sts,
uv_err_sts, intr_sts, y_dn_sz, uv_dn_sz);
@@ -1550,7 +1550,7 @@ static BC_STATUS crystalhd_fw_cmd_post_proc(struct crystalhd_hw *hw,
st_rsp = (DecRspChannelStartVideo *)fw_cmd->rsp;
hw->pib_del_Q_addr = st_rsp->picInfoDeliveryQ;
hw->pib_rel_Q_addr = st_rsp->picInfoReleaseQ;
- BCMLOG(BCMLOG_DBG,"DelQAddr:%x RelQAddr:%x\n",
+ BCMLOG(BCMLOG_DBG, "DelQAddr:%x RelQAddr:%x\n",
hw->pib_del_Q_addr, hw->pib_rel_Q_addr);
break;
case eCMD_C011_INIT:
@@ -1692,7 +1692,7 @@ BC_STATUS crystalhd_download_fw(struct crystalhd_adp *adp, void *buffer, uint32_
crystalhd_reg_wr(adp, DCI_CMD, reg_data);
msleep_interruptible(10);

- reg_data =0;
+ reg_data = 0;
reg_data = crystalhd_reg_rd(adp, DCI_STATUS);

if ((reg_data & BC_BIT(9)) == BC_BIT(9)) {
@@ -1714,7 +1714,7 @@ BC_STATUS crystalhd_download_fw(struct crystalhd_adp *adp, void *buffer, uint32_
return BC_STS_FW_AUTH_FAILED;
}

- BCMLOG(BCMLOG_INFO,"Firmware Downloaded Successfully\n");
+ BCMLOG(BCMLOG_INFO, "Firmware Downloaded Successfully\n");
return BC_STS_SUCCESS;;
}

@@ -1871,8 +1871,8 @@ BC_STATUS crystalhd_hw_open(struct crystalhd_hw *hw, struct crystalhd_adp *adp)
memset(hw, 0, sizeof(struct crystalhd_hw));

hw->adp = adp;
- hw->lock = SPIN_LOCK_UNLOCKED;
- hw->rx_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&hw->lock);
+ spin_lock_init(&hw->rx_lock);
/* FIXME: jarod: what are these magic numbers?!? */
hw->tx_ioq_tag_seed = 0x70023070;
hw->rx_pkt_tag_seed = 0x70029070;
@@ -1916,12 +1916,13 @@ BC_STATUS crystalhd_hw_setup_dma_rings(struct crystalhd_hw *hw)
BC_STATUS sts = BC_STS_SUCCESS;
crystalhd_rx_dma_pkt *rpkt;

- if (!hw || !hw->adp ) {
+ if (!hw || !hw->adp) {
BCMLOG_ERR("Invalid Arguments\n");
return BC_STS_INV_ARG;
}

- if ((sts = crystalhd_hw_create_ioqs(hw)) != BC_STS_SUCCESS) {
+ sts = crystalhd_hw_create_ioqs(hw);
+ if (sts != BC_STS_SUCCESS) {
BCMLOG_ERR("Failed to create IOQs..\n");
return sts;
}
@@ -1973,7 +1974,7 @@ BC_STATUS crystalhd_hw_setup_dma_rings(struct crystalhd_hw *hw)
rpkt->desc_mem.phy_addr = phy_addr;
rpkt->desc_mem.sz = BC_LINK_MAX_SGLS * sizeof(dma_descriptor);
rpkt->pkt_tag = hw->rx_pkt_tag_seed + i;
- crystalhd_hw_free_rx_pkt(hw,rpkt);
+ crystalhd_hw_free_rx_pkt(hw, rpkt);
}

return BC_STS_SUCCESS;
@@ -1982,7 +1983,7 @@ BC_STATUS crystalhd_hw_setup_dma_rings(struct crystalhd_hw *hw)
BC_STATUS crystalhd_hw_free_dma_rings(struct crystalhd_hw *hw)
{
unsigned int i;
- crystalhd_rx_dma_pkt *rpkt=NULL;
+ crystalhd_rx_dma_pkt *rpkt = NULL;

if (!hw || !hw->adp) {
BCMLOG_ERR("Invalid Arguments\n");
@@ -2003,7 +2004,7 @@ BC_STATUS crystalhd_hw_free_dma_rings(struct crystalhd_hw *hw)
}
}

- BCMLOG(BCMLOG_DBG,"Releasing RX Pkt pool\n");
+ BCMLOG(BCMLOG_DBG, "Releasing RX Pkt pool\n");
do {
rpkt = crystalhd_hw_alloc_rx_pkt(hw);
if (!rpkt)
@@ -2094,7 +2095,7 @@ BC_STATUS crystalhd_hw_post_tx(struct crystalhd_hw *hw, crystalhd_dio_req *ioreq

hw->tx_list_post_index = (hw->tx_list_post_index + 1) % DMA_ENGINE_CNT;

- spin_unlock_irqrestore(&hw->lock,flags);
+ spin_unlock_irqrestore(&hw->lock, flags);


/* Insert in Active Q..*/
@@ -2162,7 +2163,7 @@ BC_STATUS crystalhd_hw_add_cap_buffer(struct crystalhd_hw *hw,
if (sts != BC_STS_SUCCESS)
return sts;

- rpkt->uv_phy_addr=0;
+ rpkt->uv_phy_addr = 0;

/* Store the address of UV in the rx packet for post*/
if (uv_desc_ix)
@@ -2279,7 +2280,7 @@ BC_STATUS crystalhd_hw_unpause(struct crystalhd_hw *hw)

aspm = crystalhd_reg_rd(hw->adp, PCIE_DLL_DATA_LINK_CONTROL);
aspm &= ~ASPM_L1_ENABLE;
-// NAREN BCMLOG(BCMLOG_INFO, "aspm off\n");
+/* NAREN BCMLOG(BCMLOG_INFO, "aspm off\n"); */
crystalhd_reg_wr(hw->adp, PCIE_DLL_DATA_LINK_CONTROL, aspm);

sts = crystalhd_hw_start_capture(hw);
@@ -2338,14 +2339,14 @@ BC_STATUS crystalhd_hw_set_core_clock(struct crystalhd_hw *hw)
}

/* FIXME: jarod: wha? */
-// n = (hw->core_clock_mhz * 3) / 20 + 1;
+ /*n = (hw->core_clock_mhz * 3) / 20 + 1; */
n = hw->core_clock_mhz/5;

if (n == hw->prev_n)
return BC_STS_CLK_NOCHG;

if (hw->pwr_lock > 0) {
- //BCMLOG(BCMLOG_INFO,"pwr_lock is %u\n", hw->pwr_lock)
+ /* BCMLOG(BCMLOG_INFO,"pwr_lock is %u\n", hw->pwr_lock) */
return BC_STS_CLK_NOCHG;
}

@@ -2365,7 +2366,7 @@ BC_STATUS crystalhd_hw_set_core_clock(struct crystalhd_hw *hw)
reg |= n;
reg |= vco_mg << 12;

- BCMLOG(BCMLOG_INFO,"clock is moving to %d with n %d with vco_mg %d\n",
+ BCMLOG(BCMLOG_INFO, "clock is moving to %d with n %d with vco_mg %d\n",
hw->core_clock_mhz, n, vco_mg);

/* Change the DRAM refresh rate to accomodate the new frequency */
@@ -2378,17 +2379,17 @@ BC_STATUS crystalhd_hw_set_core_clock(struct crystalhd_hw *hw)
i = 0;

for (i = 0; i < 10; i++) {
- reg = bc_dec_reg_rd(hw->adp,DecHt_PllACtl);
+ reg = bc_dec_reg_rd(hw->adp, DecHt_PllACtl);

if (reg & 0x00020000) {
hw->prev_n = n;
/* FIXME: jarod: outputting a random "C" is... confusing... */
- BCMLOG(BCMLOG_INFO,"C");
+ BCMLOG(BCMLOG_INFO, "C");
return BC_STS_SUCCESS;
} else {
msleep_interruptible(10);
}
}
- BCMLOG(BCMLOG_INFO,"clk change failed\n");
+ BCMLOG(BCMLOG_INFO, "clk change failed\n");
return BC_STS_CLK_NOCHG;
}
diff --git a/drivers/staging/crystal-hd/crystalhd_hw.h b/drivers/staging/crystal-hd/crystalhd_hw.h
index 076150d..1c6318e 100644
--- a/drivers/staging/crystal-hd/crystalhd_hw.h
+++ b/drivers/staging/crystal-hd/crystalhd_hw.h
@@ -103,7 +103,7 @@
**************************************************/
#define BC_FWIMG_ST_ADDR 0x00000000
/* FIXME: jarod: there's a kernel function that'll do this for us... */
-#define rotr32_1(x,n) (((x) >> n) | ((x) << (32 - n)))
+#define rotr32_1(x, n) (((x) >> n) | ((x) << (32 - n)))
#define bswap_32_1(x) ((rotr32_1((x), 24) & 0x00ff00ff) | (rotr32_1((x), 8) & 0xff00ff00))

#define DecHt_HostSwReset 0x340000
@@ -166,10 +166,10 @@ typedef union _link_misc_perst_clk_ctrl_ {

typedef union _link_misc_perst_decoder_ctrl_ {
struct {
- uint32_t bcm_7412_rst:1; /* 1 -> BCM7412 is held in reset. Reset value 1.*/
- uint32_t res0:3; /* Reserved.No Effect*/
- uint32_t stop_7412_clk:1; /* 1 ->Stops branch of 27MHz clk used to clk BCM7412*/
- uint32_t res1:27; /* Reseved. No Effect*/
+ uint32_t bcm_7412_rst:1; /* 1 -> BCM7412 is held in reset. Reset value 1.*/
+ uint32_t res0:3; /* Reserved.No Effect*/
+ uint32_t stop_7412_clk:1; /* 1 ->Stops branch of 27MHz clk used to clk BCM7412*/
+ uint32_t res1:27; /* Reseved. No Effect */
};

uint32_t whole_reg;
diff --git a/drivers/staging/crystal-hd/crystalhd_lnx.c b/drivers/staging/crystal-hd/crystalhd_lnx.c
index d3d62d0..ce89ec0 100644
--- a/drivers/staging/crystal-hd/crystalhd_lnx.c
+++ b/drivers/staging/crystal-hd/crystalhd_lnx.c
@@ -28,15 +28,11 @@

#include "crystalhd_lnx.h"

-static struct crystalhd_adp *g_adp_info = NULL;
+static struct crystalhd_adp *g_adp_info;

-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
static irqreturn_t chd_dec_isr(int irq, void *arg)
-#else
-static irqreturn_t chd_dec_isr(int irq, void *arg, struct pt_regs *r)
-#endif
{
- struct crystalhd_adp *adp = (struct crystalhd_adp*)arg;
+ struct crystalhd_adp *adp = (struct crystalhd_adp *) arg;
int rc = 0;
if (adp)
rc = crystalhd_cmd_interrupt(&adp->cmds);
@@ -59,7 +55,7 @@ static int chd_dec_enable_int(struct crystalhd_adp *adp)
adp->msi = pci_enable_msi(adp->pdev);

rc = request_irq(adp->pdev->irq, chd_dec_isr, IRQF_SHARED,
- adp->name, (void*)adp);
+ adp->name, (void *)adp);
if (rc) {
BCMLOG_ERR("Interrupt request failed.. \n");
pci_disable_msi(adp->pdev);
@@ -77,9 +73,8 @@ static int chd_dec_disable_int(struct crystalhd_adp *adp)

free_irq(adp->pdev->irq, adp);

- if (adp->msi) {
+ if (adp->msi)
pci_disable_msi(adp->pdev);
- }

return 0;
}
@@ -100,7 +95,7 @@ crystalhd_ioctl_data *chd_dec_alloc_iodata(struct crystalhd_adp *adp, bool isr)
memset(temp, 0, sizeof(*temp));
}

- spin_unlock_irqrestore(&adp->lock,flags);
+ spin_unlock_irqrestore(&adp->lock, flags);
return temp;
}

@@ -118,7 +113,7 @@ void chd_dec_free_iodata(struct crystalhd_adp *adp, crystalhd_ioctl_data *iodata
spin_unlock_irqrestore(&adp->lock, flags);
}

-inline static int crystalhd_user_data(unsigned long ud,void *dr, int size,int set)
+static inline int crystalhd_user_data(unsigned long ud, void *dr, int size, int set)
{
int rc;

@@ -153,7 +148,7 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp, crystalhd_ioctl_data *

io->add_cdata = vmalloc(m_sz);
if (!io->add_cdata) {
- BCMLOG_ERR("kalloc fail for sz:%x\n",m_sz);
+ BCMLOG_ERR("kalloc fail for sz:%x\n", m_sz);
return -ENOMEM;
}

@@ -222,17 +217,17 @@ static int chd_dec_proc_user_data(struct crystalhd_adp *adp,
}

switch (io->cmd) {
- case BCM_IOC_MEM_RD:
- case BCM_IOC_MEM_WR:
- case BCM_IOC_FW_DOWNLOAD:
- m_sz = io->udata.u.devMem.NumDwords * 4;
- if (set)
- rc = chd_dec_release_cdata(adp, io, ua);
- else
- rc = chd_dec_fetch_cdata(adp, io, m_sz, ua);
- break;
- default:
- break;
+ case BCM_IOC_MEM_RD:
+ case BCM_IOC_MEM_WR:
+ case BCM_IOC_FW_DOWNLOAD:
+ m_sz = io->udata.u.devMem.NumDwords * 4;
+ if (set)
+ rc = chd_dec_release_cdata(adp, io, ua);
+ else
+ rc = chd_dec_fetch_cdata(adp, io, m_sz, ua);
+ break;
+ default:
+ break;
}

return rc;
@@ -245,7 +240,7 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
crystalhd_ioctl_data *temp;
BC_STATUS sts = BC_STS_SUCCESS;

- temp = chd_dec_alloc_iodata(adp,0);
+ temp = chd_dec_alloc_iodata(adp, 0);
if (!temp) {
BCMLOG_ERR("Failed to get iodata..\n");
return -EINVAL;
@@ -264,7 +259,7 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
}

if (temp) {
- chd_dec_free_iodata(adp, temp,0);
+ chd_dec_free_iodata(adp, temp, 0);
temp = NULL;
}

@@ -284,7 +279,7 @@ static int chd_dec_ioctl(struct inode *in, struct file *fd,
return -EINVAL;
}

- uc = (struct crystalhd_user*)fd->private_data;
+ uc = (struct crystalhd_user *)fd->private_data;
if (!uc) {
BCMLOG_ERR("Failed to get uc\n");
return -ENODATA;
@@ -313,13 +308,13 @@ static int chd_dec_open(struct inode *in, struct file *fd)
}

if (adp->cfg_users >= BC_LINK_MAX_OPENS) {
- BCMLOG(BCMLOG_INFO,"Already in use.%d\n",adp->cfg_users);
+ BCMLOG(BCMLOG_INFO, "Already in use.%d\n", adp->cfg_users);
return -EBUSY;
}

sts = crystalhd_user_open(&adp->cmds, &uc);
if (sts != BC_STS_SUCCESS) {
- BCMLOG_ERR("cmd_user_open - %d \n",sts);
+ BCMLOG_ERR("cmd_user_open - %d \n", sts);
rc = -EBUSY;
}

@@ -347,14 +342,14 @@ static int chd_dec_close(struct inode *in, struct file *fd)
return -ENODATA;
}

- crystalhd_user_close(&adp->cmds,uc);
+ crystalhd_user_close(&adp->cmds, uc);

adp->cfg_users--;

return 0;
}

-static struct file_operations chd_dec_fops = {
+static const struct file_operations chd_dec_fops = {
.owner = THIS_MODULE,
.ioctl = chd_dec_ioctl,
.open = chd_dec_open,
@@ -462,11 +457,11 @@ static int chd_pci_reserve_mem(struct crystalhd_adp *pinfo)

rc = pci_request_regions(pinfo->pdev, pinfo->name);
if (rc < 0) {
- BCMLOG_ERR("Region request failed: %d\n",rc);
+ BCMLOG_ERR("Region request failed: %d\n", rc);
return rc;
}

- BCMLOG(BCMLOG_SSTEP,"Mapped addr:0x%08lx i2o_addr:0x%08lx\n",
+ BCMLOG(BCMLOG_SSTEP, "Mapped addr:0x%08lx i2o_addr:0x%08lx\n",
(unsigned long)pinfo->addr, (unsigned long)pinfo->i2o_addr);

return 0;
@@ -494,7 +489,7 @@ static void chd_dec_pci_remove(struct pci_dev *pdev)

BCMLOG_ENTER;

- pinfo = (struct crystalhd_adp*)pci_get_drvdata(pdev);
+ pinfo = (struct crystalhd_adp *) pci_get_drvdata(pdev);
if (!pinfo) {
BCMLOG_ERR("could not get adp\n");
return;
@@ -502,7 +497,7 @@ static void chd_dec_pci_remove(struct pci_dev *pdev)

sts = crystalhd_delete_cmd_context(&pinfo->cmds);
if (sts != BC_STS_SUCCESS)
- BCMLOG_ERR("cmd delete :%d \n",sts);
+ BCMLOG_ERR("cmd delete :%d \n", sts);

chd_dec_release_chdev(pinfo);

@@ -556,13 +551,13 @@ static int chd_dec_pci_probe(struct pci_dev *pdev,
pinfo->drv_data = entry->driver_data;

/* Setup adapter level lock.. */
- pinfo->lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&pinfo->lock);

/* setup api stuff.. */
chd_dec_init_chdev(pinfo);
rc = chd_dec_enable_int(pinfo);
if (rc) {
- BCMLOG_ERR("_enable_int err:%d \n",rc);
+ BCMLOG_ERR("_enable_int err:%d \n", rc);
pci_disable_device(pdev);
return -ENODEV;
}
@@ -575,14 +570,14 @@ static int chd_dec_pci_probe(struct pci_dev *pdev,
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
pinfo->dmabits = 32;
} else {
- BCMLOG_ERR("Unabled to setup DMA %d\n",rc);
+ BCMLOG_ERR("Unabled to setup DMA %d\n", rc);
pci_disable_device(pdev);
return -ENODEV;
}

sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo);
if (sts != BC_STS_SUCCESS) {
- BCMLOG_ERR("cmd setup :%d \n",sts);
+ BCMLOG_ERR("cmd setup :%d \n", sts);
pci_disable_device(pdev);
return -ENODEV;
}
@@ -657,7 +652,7 @@ int chd_dec_pci_resume(struct pci_dev *pdev)

rc = chd_dec_enable_int(adp);
if (rc) {
- BCMLOG_ERR("_enable_int err:%d \n",rc);
+ BCMLOG_ERR("_enable_int err:%d \n", rc);
pci_disable_device(pdev);
return -ENODEV;
}
@@ -696,17 +691,17 @@ void chd_set_log_level(struct crystalhd_adp *adp, char *arg)
{
if ((!arg) || (strlen(arg) < 3))
g_linklog_level = BCMLOG_ERROR | BCMLOG_DATA;
- else if (!strncmp(arg,"sstep",5))
+ else if (!strncmp(arg, "sstep", 5))
g_linklog_level = BCMLOG_INFO | BCMLOG_DATA | BCMLOG_DBG |
BCMLOG_SSTEP | BCMLOG_ERROR;
- else if (!strncmp(arg,"info",4))
+ else if (!strncmp(arg, "info", 4))
g_linklog_level = BCMLOG_ERROR | BCMLOG_DATA | BCMLOG_INFO;
- else if (!strncmp(arg,"debug",5))
+ else if (!strncmp(arg, "debug", 5))
g_linklog_level = BCMLOG_ERROR | BCMLOG_DATA | BCMLOG_INFO |
BCMLOG_DBG;
- else if (!strncmp(arg,"pball",5))
+ else if (!strncmp(arg, "pball", 5))
g_linklog_level = 0xFFFFFFFF & ~(BCMLOG_SPINLOCK);
- else if (!strncmp(arg,"silent",6))
+ else if (!strncmp(arg, "silent", 6))
g_linklog_level = 0;
else
g_linklog_level = 0;
@@ -722,20 +717,20 @@ int __init chd_dec_module_init(void)
int rc;

chd_set_log_level(NULL, "debug");
- BCMLOG(BCMLOG_DATA,"Loading crystalhd %d.%d.%d \n",
+ BCMLOG(BCMLOG_DATA, "Loading crystalhd %d.%d.%d \n",
crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev);

rc = pci_register_driver(&bc_chd_70012_driver);

if (rc < 0)
- BCMLOG_ERR("Could not find any devices. err:%d \n",rc);
+ BCMLOG_ERR("Could not find any devices. err:%d \n", rc);

return rc;
}

-void __exit chd_dec_module_cleanup( void )
+void __exit chd_dec_module_cleanup(void)
{
- BCMLOG(BCMLOG_DATA,"unloading crystalhd %d.%d.%d \n",
+ BCMLOG(BCMLOG_DATA, "unloading crystalhd %d.%d.%d \n",
crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev);

pci_unregister_driver(&bc_chd_70012_driver);
diff --git a/drivers/staging/crystal-hd/crystalhd_misc.c b/drivers/staging/crystal-hd/crystalhd_misc.c
index 82ea277..8798b90 100644
--- a/drivers/staging/crystal-hd/crystalhd_misc.c
+++ b/drivers/staging/crystal-hd/crystalhd_misc.c
@@ -35,15 +35,13 @@ static inline uint32_t crystalhd_dram_rd(struct crystalhd_adp *adp, uint32_t mem
return bc_dec_reg_rd(adp, (0x00380000 | (mem_off & 0x0007FFFF)));
}

-static inline void crystalhd_dram_wr(struct crystalhd_adp*adp,
- uint32_t mem_off, uint32_t val)
+static inline void crystalhd_dram_wr(struct crystalhd_adp *adp, uint32_t mem_off, uint32_t val)
{
crystalhd_reg_wr(adp, DCI_DRAM_BASE_ADDR, (mem_off >> 19));
- bc_dec_reg_wr(adp, (0x00380000 | (mem_off & 0x0007FFFF)),val);
+ bc_dec_reg_wr(adp, (0x00380000 | (mem_off & 0x0007FFFF)), val);
}

-static inline BC_STATUS bc_chk_dram_range(struct crystalhd_adp *adp,
- uint32_t start_off, uint32_t cnt)
+static inline BC_STATUS bc_chk_dram_range(struct crystalhd_adp *adp, uint32_t start_off, uint32_t cnt)
{
return BC_STS_SUCCESS;
}
@@ -58,11 +56,11 @@ static crystalhd_dio_req *crystalhd_alloc_dio(struct crystalhd_adp *adp)
return temp;
}

- spin_lock_irqsave(&adp->lock,flags);
+ spin_lock_irqsave(&adp->lock, flags);
temp = adp->ua_map_free_head;
if (temp)
adp->ua_map_free_head = adp->ua_map_free_head->next;
- spin_unlock_irqrestore(&adp->lock,flags);
+ spin_unlock_irqrestore(&adp->lock, flags);

return temp;
}
@@ -73,30 +71,30 @@ static void crystalhd_free_dio(struct crystalhd_adp *adp, crystalhd_dio_req *dio

if (!adp || !dio)
return;
- spin_lock_irqsave(&adp->lock,flags);
+ spin_lock_irqsave(&adp->lock, flags);
dio->sig = crystalhd_dio_inv;
dio->page_cnt = 0;
dio->fb_size = 0;
- memset(&dio->uinfo,0,sizeof(dio->uinfo));
+ memset(&dio->uinfo, 0, sizeof(dio->uinfo));
dio->next = adp->ua_map_free_head;
adp->ua_map_free_head = dio;
- spin_unlock_irqrestore(&adp->lock,flags);
+ spin_unlock_irqrestore(&adp->lock, flags);
}

static crystalhd_elem_t *crystalhd_alloc_elem(struct crystalhd_adp *adp)
{
- unsigned long flags=0;
- crystalhd_elem_t *temp=NULL;
+ unsigned long flags = 0;
+ crystalhd_elem_t *temp = NULL;

if (!adp)
return temp;
- spin_lock_irqsave(&adp->lock,flags);
+ spin_lock_irqsave(&adp->lock, flags);
temp = adp->elem_pool_head;
if (temp) {
adp->elem_pool_head = adp->elem_pool_head->flink;
memset(temp, 0, sizeof(*temp));
}
- spin_unlock_irqrestore(&adp->lock,flags);
+ spin_unlock_irqrestore(&adp->lock, flags);

return temp;
}
@@ -106,33 +104,25 @@ static void crystalhd_free_elem(struct crystalhd_adp *adp, crystalhd_elem_t *ele

if (!adp || !elem)
return;
- spin_lock_irqsave(&adp->lock,flags);
+ spin_lock_irqsave(&adp->lock, flags);
elem->flink = adp->elem_pool_head;
adp->elem_pool_head = elem;
- spin_unlock_irqrestore(&adp->lock,flags);
+ spin_unlock_irqrestore(&adp->lock, flags);
}

static inline void crystalhd_set_sg(struct scatterlist *sg, struct page *page,
unsigned int len, unsigned int offset)
{
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
sg_set_page(sg, page, len, offset);
-#else
- sg->page = page;
- sg->offset = offset;
- sg->length = len;
#ifdef CONFIG_X86_64
sg->dma_length = len;
#endif
-#endif
}

static inline void crystalhd_init_sg(struct scatterlist *sg, unsigned int entries)
{
-// http://lkml.org/lkml/2007/11/27/68
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
+ /* http://lkml.org/lkml/2007/11/27/68 */
sg_init_table(sg, entries);
-#endif
}

/*========================== Extern ========================================*/
@@ -151,7 +141,7 @@ static inline void crystalhd_init_sg(struct scatterlist *sg, unsigned int entrie
uint32_t bc_dec_reg_rd(struct crystalhd_adp *adp, uint32_t reg_off)
{
if (!adp || (reg_off > adp->pci_mem_len)) {
- BCMLOG_ERR("dec_rd_reg_off outof range: 0x%08x\n",reg_off);
+ BCMLOG_ERR("dec_rd_reg_off outof range: 0x%08x\n", reg_off);
return 0;
}

@@ -174,7 +164,7 @@ uint32_t bc_dec_reg_rd(struct crystalhd_adp *adp, uint32_t reg_off)
void bc_dec_reg_wr(struct crystalhd_adp *adp, uint32_t reg_off, uint32_t val)
{
if (!adp || (reg_off > adp->pci_mem_len)) {
- BCMLOG_ERR("dec_wr_reg_off outof range: 0x%08x\n",reg_off);
+ BCMLOG_ERR("dec_wr_reg_off outof range: 0x%08x\n", reg_off);
return;
}
writel(val, adp->addr + reg_off);
@@ -194,10 +184,10 @@ void bc_dec_reg_wr(struct crystalhd_adp *adp, uint32_t reg_off, uint32_t val)
* configuration space.
*
*/
-uint32_t crystalhd_reg_rd(struct crystalhd_adp *adp,uint32_t reg_off)
+uint32_t crystalhd_reg_rd(struct crystalhd_adp *adp, uint32_t reg_off)
{
if (!adp || (reg_off > adp->pci_i2o_len)) {
- BCMLOG_ERR("link_rd_reg_off outof range: 0x%08x\n",reg_off);
+ BCMLOG_ERR("link_rd_reg_off outof range: 0x%08x\n", reg_off);
return 0;
}
return readl(adp->i2o_addr + reg_off);
@@ -220,7 +210,7 @@ uint32_t crystalhd_reg_rd(struct crystalhd_adp *adp,uint32_t reg_off)
void crystalhd_reg_wr(struct crystalhd_adp *adp, uint32_t reg_off, uint32_t val)
{
if (!adp || (reg_off > adp->pci_i2o_len)) {
- BCMLOG_ERR("link_wr_reg_off outof range: 0x%08x\n",reg_off);
+ BCMLOG_ERR("link_wr_reg_off outof range: 0x%08x\n", reg_off);
return;
}
writel(val, adp->i2o_addr + reg_off);
@@ -307,18 +297,18 @@ BC_STATUS crystalhd_pci_cfg_rd(struct crystalhd_adp *adp, uint32_t off,

switch (len) {
case 1:
- rc = pci_read_config_byte(adp->pdev, off, (u8*)val);
+ rc = pci_read_config_byte(adp->pdev, off, (u8 *)val);
break;
case 2:
- rc = pci_read_config_word(adp->pdev, off, (u16*)val);
+ rc = pci_read_config_word(adp->pdev, off, (u16 *)val);
break;
case 4:
- rc = pci_read_config_dword(adp->pdev, off, (u32*)val);
+ rc = pci_read_config_dword(adp->pdev, off, (u32 *)val);
break;
default:
rc = -EINVAL;
sts = BC_STS_INV_ARG;
- BCMLOG_ERR("Invalid len:%d\n",len);
+ BCMLOG_ERR("Invalid len:%d\n", len);
};

if (rc && (sts == BC_STS_SUCCESS))
@@ -363,7 +353,7 @@ BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *adp, uint32_t off,
default:
rc = -EINVAL;
sts = BC_STS_INV_ARG;
- BCMLOG_ERR("Invalid len:%d\n",len);
+ BCMLOG_ERR("Invalid len:%d\n", len);
};

if (rc && (sts == BC_STS_SUCCESS))
@@ -452,7 +442,7 @@ BC_STATUS crystalhd_create_dioq(struct crystalhd_adp *adp,
if (!dioq)
return BC_STS_INSUFF_RES;

- dioq->lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&dioq->lock);
dioq->sig = BC_LINK_DIOQ_SIG;
dioq->head = (crystalhd_elem_t *)&dioq->head;
dioq->tail = (crystalhd_elem_t *)&dioq->head;
@@ -562,7 +552,7 @@ void *crystalhd_dioq_fetch(crystalhd_dioq_t *ioq)

spin_lock_irqsave(&ioq->lock, flags);
tmp = ioq->head;
- if (tmp != (crystalhd_elem_t*)&ioq->head) {
+ if (tmp != (crystalhd_elem_t *)&ioq->head) {
ret = tmp;
tmp->flink->blink = tmp->blink;
tmp->blink->flink = tmp->flink;
@@ -598,9 +588,9 @@ void *crystalhd_dioq_find_and_fetch(crystalhd_dioq_t *ioq, uint32_t tag)
return data;
}

- spin_lock_irqsave(&ioq->lock,flags);
+ spin_lock_irqsave(&ioq->lock, flags);
tmp = ioq->head;
- while (tmp != (crystalhd_elem_t*)&ioq->head) {
+ while (tmp != (crystalhd_elem_t *)&ioq->head) {
if (tmp->tag == tag) {
ret = tmp;
tmp->flink->blink = tmp->blink;
@@ -610,7 +600,7 @@ void *crystalhd_dioq_find_and_fetch(crystalhd_dioq_t *ioq, uint32_t tag)
}
tmp = tmp->flink;
}
- spin_unlock_irqrestore(&ioq->lock,flags);
+ spin_unlock_irqrestore(&ioq->lock, flags);

if (ret) {
data = ret->data;
@@ -648,11 +638,11 @@ void *crystalhd_dioq_fetch_wait(crystalhd_dioq_t *ioq, uint32_t to_secs,
while ((ioq->count == 0) && count) {
spin_unlock_irqrestore(&ioq->lock, flags);

- crystalhd_wait_on_event(&ioq->event, (ioq->count>0), 1000, rc, 0);
+ crystalhd_wait_on_event(&ioq->event, (ioq->count > 0), 1000, rc, 0);
if (rc == 0) {
goto out;
} else if (rc == -EINTR) {
- BCMLOG(BCMLOG_INFO,"Cancelling fetch wait\n");
+ BCMLOG(BCMLOG_INFO, "Cancelling fetch wait\n");
*sig_pend = 1;
return tmp;
}
@@ -725,7 +715,7 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff,
if (nr_pages > dio->max_pages) {
BCMLOG_ERR("max_pages(%d) exceeded(%d)!!\n",
dio->max_pages, nr_pages);
- crystalhd_unmap_dio(adp,dio);
+ crystalhd_unmap_dio(adp, dio);
return BC_STS_INSUFF_RES;
}

@@ -743,8 +733,8 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff,
if (res) {
BCMLOG_ERR("failed %d to copy %u fill bytes from %p\n",
res, dio->fb_size,
- (void *)(uaddr+count-dio->fb_size));
- crystalhd_unmap_dio(adp,dio);
+ (void *)(uaddr + count-dio->fb_size));
+ crystalhd_unmap_dio(adp, dio);
return BC_STS_INSUFF_RES;
}
}
@@ -769,7 +759,7 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff,
crystalhd_set_sg(&dio->sg[0], dio->pages[0], 0, uaddr & ~PAGE_MASK);
if (nr_pages > 1) {
dio->sg[0].length = PAGE_SIZE - dio->sg[0].offset;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) || defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_64)
dio->sg[0].dma_length = dio->sg[0].length;
#endif
count -= dio->sg[0].length;
@@ -787,19 +777,19 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff,
} else {
if (count < 4) {
dio->sg[0].length = count;
- skip_fb_sg=1;
+ skip_fb_sg = 1;
} else {
dio->sg[0].length = count - dio->fb_size;
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) || defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_64)
dio->sg[0].dma_length = dio->sg[0].length;
#endif
}
dio->sg_cnt = pci_map_sg(adp->pdev, dio->sg,
dio->page_cnt, dio->direction);
if (dio->sg_cnt <= 0) {
- BCMLOG_ERR("sg map %d-%d \n",dio->sg_cnt, dio->page_cnt);
- crystalhd_unmap_dio(adp,dio);
+ BCMLOG_ERR("sg map %d-%d \n", dio->sg_cnt, dio->page_cnt);
+ crystalhd_unmap_dio(adp, dio);
return BC_STS_ERROR;
}
if (dio->sg_cnt && skip_fb_sg)
@@ -832,7 +822,7 @@ BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *adp, crystalhd_dio_req *dio)
struct page *page = NULL;
int j = 0;

- if (!adp || !dio ) {
+ if (!adp || !dio) {
BCMLOG_ERR("Invalid arg \n");
return BC_STS_INV_ARG;
}
@@ -890,19 +880,19 @@ int crystalhd_create_dio_pool(struct crystalhd_adp *adp, uint32_t max_pages)
asz = (sizeof(*dio->pages) * max_pages) +
(sizeof(*dio->sg) * max_pages) + sizeof(*dio);

- BCMLOG(BCMLOG_DBG,"Initializing Dio pool %d %d %x %p\n",
+ BCMLOG(BCMLOG_DBG, "Initializing Dio pool %d %d %x %p\n",
BC_LINK_SG_POOL_SZ, max_pages, asz, adp->fill_byte_pool);

for (i = 0; i < BC_LINK_SG_POOL_SZ; i++) {
temp = (uint8_t *)kzalloc(asz, GFP_KERNEL);
if ((temp) == NULL) {
- BCMLOG_ERR("Failed to alloc %d mem\n",asz);
+ BCMLOG_ERR("Failed to alloc %d mem\n", asz);
return -ENOMEM;
}

dio = (crystalhd_dio_req *)temp;
temp += sizeof(*dio);
- dio->pages = (struct page**)temp;
+ dio->pages = (struct page **)temp;
temp += (sizeof(*dio->pages) * max_pages);
dio->sg = (struct scatterlist *)temp;
dio->max_pages = max_pages;
@@ -954,7 +944,7 @@ void crystalhd_destroy_dio_pool(struct crystalhd_adp *adp)
adp->fill_byte_pool = NULL;
}

- BCMLOG(BCMLOG_DBG,"Released dio pool %d \n",count);
+ BCMLOG(BCMLOG_DBG, "Released dio pool %d \n", count);
}

/**
@@ -1013,7 +1003,7 @@ void crystalhd_delete_elem_pool(struct crystalhd_adp *adp)
}
} while (temp);

- BCMLOG(BCMLOG_DBG,"released %d elem\n",dbg_cnt);
+ BCMLOG(BCMLOG_DBG, "released %d elem\n", dbg_cnt);
}

/*================ Debug support routines.. ================================*/
@@ -1025,13 +1015,13 @@ void crystalhd_show_buffer(uint32_t off, uint8_t *buff, uint32_t dwcount)
if (k == 1)
BCMLOG(BCMLOG_DATA, "0x%08X : ", off);

- BCMLOG(BCMLOG_DATA," 0x%08X ", *((uint32_t *)buff));
+ BCMLOG(BCMLOG_DATA, " 0x%08X ", *((uint32_t *)buff));

buff += sizeof(uint32_t);
off += sizeof(uint32_t);
k++;
if ((i == dwcount - 1) || (k > 4)) {
- BCMLOG(BCMLOG_DATA,"\n");
+ BCMLOG(BCMLOG_DATA, "\n");
k = 1;
}
}
diff --git a/drivers/staging/crystal-hd/crystalhd_misc.h b/drivers/staging/crystal-hd/crystalhd_misc.h
index 86ed922..a2aa6ad 100644
--- a/drivers/staging/crystal-hd/crystalhd_misc.h
+++ b/drivers/staging/crystal-hd/crystalhd_misc.h
@@ -132,19 +132,19 @@ BC_STATUS crystalhd_mem_wr(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t

/*==========Link (70012) PCIe Config access routines.================*/
BC_STATUS crystalhd_pci_cfg_rd(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t *);
-BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t );
+BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t);

/*========= Linux Kernel Interface routines. ======================= */
void *bc_kern_dma_alloc(struct crystalhd_adp *, uint32_t, dma_addr_t *);
void bc_kern_dma_free(struct crystalhd_adp *, uint32_t,
void *, dma_addr_t);
-#define crystalhd_create_event(_ev) init_waitqueue_head( _ev)
-#define crystalhd_set_event(_ev) wake_up_interruptible( _ev)
+#define crystalhd_create_event(_ev) init_waitqueue_head(_ev)
+#define crystalhd_set_event(_ev) wake_up_interruptible(_ev)
#define crystalhd_wait_on_event(ev, condition, timeout, ret, nosig) \
do { \
DECLARE_WAITQUEUE(entry, current); \
unsigned long end = jiffies + ((timeout * HZ) / 1000); \
- ret=0; \
+ ret = 0; \
add_wait_queue(ev, &entry); \
for (;;) { \
__set_current_state(TASK_INTERRUPTIBLE); \
@@ -163,14 +163,15 @@ do { \
} \
__set_current_state(TASK_RUNNING); \
remove_wait_queue(ev, &entry); \
-} while(0)
+} while (0)

/*================ Direct IO mapping routines ==================*/
-extern int crystalhd_create_dio_pool(struct crystalhd_adp *, uint32_t );
+extern int crystalhd_create_dio_pool(struct crystalhd_adp *, uint32_t);
extern void crystalhd_destroy_dio_pool(struct crystalhd_adp *);
-extern BC_STATUS crystalhd_map_dio(struct crystalhd_adp *,void *, uint32_t, uint32_t,
- bool, bool,crystalhd_dio_req** );
-extern BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *,crystalhd_dio_req*);
+extern BC_STATUS crystalhd_map_dio(struct crystalhd_adp *, void *, uint32_t,
+ uint32_t, bool, bool, crystalhd_dio_req**);
+
+extern BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *, crystalhd_dio_req*);
#define crystalhd_get_sgle_paddr(_dio, _ix) (cpu_to_le64(sg_dma_address(&_dio->sg[_ix])))
#define crystalhd_get_sgle_len(_dio, _ix) (cpu_to_le32(sg_dma_len(&_dio->sg[_ix])))

@@ -179,12 +180,12 @@ extern BC_STATUS crystalhd_create_dioq(struct crystalhd_adp *, crystalhd_dioq_t
extern void crystalhd_delete_dioq(struct crystalhd_adp *, crystalhd_dioq_t *);
extern BC_STATUS crystalhd_dioq_add(crystalhd_dioq_t *ioq, void *data, bool wake, uint32_t tag);
extern void *crystalhd_dioq_fetch(crystalhd_dioq_t *ioq);
-extern void *crystalhd_dioq_find_and_fetch(crystalhd_dioq_t *ioq,uint32_t tag);
+extern void *crystalhd_dioq_find_and_fetch(crystalhd_dioq_t *ioq, uint32_t tag);
extern void *crystalhd_dioq_fetch_wait(crystalhd_dioq_t *ioq, uint32_t to_secs, uint32_t *sig_pend);

#define crystalhd_dioq_count(_ioq) ((_ioq) ? _ioq->count : 0)

-extern int crystalhd_create_elem_pool(struct crystalhd_adp *, uint32_t );
+extern int crystalhd_create_elem_pool(struct crystalhd_adp *, uint32_t);
extern void crystalhd_delete_elem_pool(struct crystalhd_adp *);


@@ -220,9 +221,9 @@ if (g_linklog_level & trace) { \

#define BCMLOG_ERR(fmt, args...) \
do { \
- if(g_linklog_level & BCMLOG_ERROR){ \
- printk("*ERR*:%s:%d: "fmt,__FILE__,__LINE__, ##args); \
+ if (g_linklog_level & BCMLOG_ERROR) { \
+ printk("*ERR*:%s:%d: "fmt, __FILE__, __LINE__, ##args); \
} \
-} while(0);
+} while (0);

#endif
--
1.5.6