[media] drx-j: Some cleanups at drx_driver.c source

This is mostly CodingStyle fixes and improvements.

No functional changes.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
Mauro Carvalho Chehab 2014-01-22 10:21:55 -03:00
parent 96b43136b8
commit 1e76a99963
2 changed files with 117 additions and 152 deletions

View File

@ -31,7 +31,7 @@ struct drx39xxj_state {
struct drx_demod_instance *demod; struct drx_demod_instance *demod;
enum drx_standard current_standard; enum drx_standard current_standard;
struct dvb_frontend frontend; struct dvb_frontend frontend;
int powered_up:1; unsigned int powered_up:1;
unsigned int i2c_gate_open:1; unsigned int i2c_gate_open:1;
const struct firmware *fw; const struct firmware *fw;
}; };

View File

@ -32,70 +32,42 @@
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
INCLUDE FILES INCLUDE FILES
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#include "drx_driver.h" #include "drx_driver.h"
#define VERSION_FIXED 0
#if VERSION_FIXED
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#else
#include "drx_driver_version.h"
#endif
/*------------------------------------------------------------------------------ /*
DEFINES * DEFINES
------------------------------------------------------------------------------*/ */
/*============================================================================*/ /*
/*=== MICROCODE RELATED DEFINES ==============================================*/ /* MICROCODE RELATED DEFINES
/*============================================================================*/ */
/** \brief Magic word for checking correct Endianess of microcode data. */ /* Magic word for checking correct Endianess of microcode data */
#ifndef DRX_UCODE_MAGIC_WORD
#define DRX_UCODE_MAGIC_WORD ((((u16)'H')<<8)+((u16)'L')) #define DRX_UCODE_MAGIC_WORD ((((u16)'H')<<8)+((u16)'L'))
#endif
/** \brief CRC flag in ucode header, flags field. */ /* CRC flag in ucode header, flags field. */
#ifndef DRX_UCODE_CRC_FLAG
#define DRX_UCODE_CRC_FLAG (0x0001) #define DRX_UCODE_CRC_FLAG (0x0001)
#endif
/** \brief Compression flag in ucode header, flags field. */ /*
#ifndef DRX_UCODE_COMPRESSION_FLAG * Maximum size of buffer used to verify the microcode.
#define DRX_UCODE_COMPRESSION_FLAG (0x0002) * Must be an even number
#endif */
/** \brief Maximum size of buffer used to verify the microcode.
Must be an even number. */
#ifndef DRX_UCODE_MAX_BUF_SIZE
#define DRX_UCODE_MAX_BUF_SIZE (DRXDAP_MAX_RCHUNKSIZE) #define DRX_UCODE_MAX_BUF_SIZE (DRXDAP_MAX_RCHUNKSIZE)
#endif
#if DRX_UCODE_MAX_BUF_SIZE & 1 #if DRX_UCODE_MAX_BUF_SIZE & 1
#error DRX_UCODE_MAX_BUF_SIZE must be an even number #error DRX_UCODE_MAX_BUF_SIZE must be an even number
#endif #endif
/*============================================================================*/ /*
/*=== CHANNEL SCAN RELATED DEFINES ===========================================*/ * Power mode macros
/*============================================================================*/ */
/**
* \brief Maximum progress indication.
*
* Progress indication will run from 0 upto DRX_SCAN_MAX_PROGRESS during scan.
*
*/
#ifndef DRX_SCAN_MAX_PROGRESS
#define DRX_SCAN_MAX_PROGRESS 1000
#endif
/*============================================================================*/
/*=== MACROS =================================================================*/
/*============================================================================*/
#define DRX_ISPOWERDOWNMODE(mode) ((mode == DRX_POWER_MODE_9) || \ #define DRX_ISPOWERDOWNMODE(mode) ((mode == DRX_POWER_MODE_9) || \
(mode == DRX_POWER_MODE_10) || \ (mode == DRX_POWER_MODE_10) || \
@ -107,42 +79,41 @@ DEFINES
(mode == DRX_POWER_MODE_16) || \ (mode == DRX_POWER_MODE_16) || \
(mode == DRX_POWER_DOWN)) (mode == DRX_POWER_DOWN))
/*------------------------------------------------------------------------------
GLOBAL VARIABLES
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
STRUCTURES STRUCTURES
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
/** \brief Structure of the microcode block headers */
/**
* struct drxu_code_block_hdr - Structure of the microcode block headers
*
* @addr: Destination address of the data in this block
* @size: Size of the block data following this header counted in
* 16 bits words
* @CRC: CRC value of the data block, only valid if CRC flag is
* set.
*/
struct drxu_code_block_hdr { struct drxu_code_block_hdr {
u32 addr; u32 addr;
/**< Destination address of the data in this block */
u16 size; u16 size;
/**< Size of the block data following this header counted in
16 bits words */
u16 flags; u16 flags;
/**< Flags for this data block: u16 CRC;
- bit[0]= CRC on/off };
- bit[1]= compression on/off
- bit[15..2]=reserved */
u16 CRC;/**< CRC value of the data block, only valid if CRC flag is
set. */};
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
FUNCTIONS FUNCTIONS
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
/*============================================================================*/ /*
/*===Microcode related functions==============================================*/ * Microcode related functions
/*============================================================================*/ */
/** /**
* \brief Compute CRC of block of microcode data. * u_code_compute_crc - Compute CRC of block of microcode data.
* \param block_data: Pointer to microcode data. * @block_data: Pointer to microcode data.
* \param nr_words: Size of microcode block (number of 16 bits words). * @nr_words: Size of microcode block (number of 16 bits words).
* \return u16 The computed CRC residu. *
*/ * returns The computed CRC residue.
*/
static u16 u_code_compute_crc(u8 *block_data, u16 nr_words) static u16 u_code_compute_crc(u8 *block_data, u16 nr_words)
{ {
u16 i = 0; u16 i = 0;
@ -151,7 +122,7 @@ static u16 u_code_compute_crc(u8 *block_data, u16 nr_words)
u32 carry = 0; u32 carry = 0;
while (i < nr_words) { while (i < nr_words) {
crc_word |= (u32) be16_to_cpu(*(u32 *)(block_data)); crc_word |= (u32)be16_to_cpu(*(u32 *)(block_data));
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
crc_word <<= 1; crc_word <<= 1;
if (carry != 0) if (carry != 0)
@ -164,9 +135,13 @@ static u16 u_code_compute_crc(u8 *block_data, u16 nr_words)
return (u16)(crc_word >> 16); return (u16)(crc_word >> 16);
} }
/*============================================================================*/ /**
* check_firmware - checks if the loaded firmware is valid
*
* @demod: demod structure
* @mc_data: pointer to the start of the firmware
* @size: firmware size
*/
static int check_firmware(struct drx_demod_instance *demod, u8 *mc_data, static int check_firmware(struct drx_demod_instance *demod, u8 *mc_data,
unsigned size) unsigned size)
{ {
@ -247,26 +222,27 @@ eof:
} }
/** /**
* \brief Handle microcode upload or verify. * ctrl_u_code - Handle microcode upload or verify.
* \param dev_addr: Address of device. * @dev_addr: Address of device.
* \param mc_info: Pointer to information about microcode data. * @mc_info: Pointer to information about microcode data.
* \param action: Either UCODE_UPLOAD or UCODE_VERIFY * @action: Either UCODE_UPLOAD or UCODE_VERIFY
* \return int. *
* \retval 0: * This function returns:
* - In case of UCODE_UPLOAD: code is successfully uploaded. * 0:
* - In case of UCODE_VERIFY: image on device is equal to * - In case of UCODE_UPLOAD: code is successfully uploaded.
* image provided to this control function. * - In case of UCODE_VERIFY: image on device is equal to
* \retval -EIO: * image provided to this control function.
* - In case of UCODE_UPLOAD: I2C error. * -EIO:
* - In case of UCODE_VERIFY: I2C error or image on device * - In case of UCODE_UPLOAD: I2C error.
* is not equal to image provided to this control function. * - In case of UCODE_VERIFY: I2C error or image on device
* \retval -EINVAL: * is not equal to image provided to this control function.
* - Invalid arguments. * -EINVAL:
* - Provided image is corrupt * - Invalid arguments.
*/ * - Provided image is corrupt
static int */
ctrl_u_code(struct drx_demod_instance *demod, static int ctrl_u_code(struct drx_demod_instance *demod,
struct drxu_code_info *mc_info, enum drxu_code_action action) struct drxu_code_info *mc_info,
enum drxu_code_action action)
{ {
struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
int rc; int rc;
@ -448,15 +424,16 @@ release:
/*============================================================================*/ /*============================================================================*/
/** /**
* \brief Build list of version information. * ctrl_version - Build list of version information.
* \param demod: A pointer to a demodulator instance. * @demod: A pointer to a demodulator instance.
* \param version_list: Pointer to linked list of versions. * @version_list: Pointer to linked list of versions.
* \return int. *
* \retval 0: Version information stored in version_list * This function returns:
* \retval -EINVAL: Invalid arguments. * 0: Version information stored in version_list
*/ * -EINVAL: Invalid arguments.
static int */
ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version_list) static int ctrl_version(struct drx_demod_instance *demod,
struct drx_version_list **version_list)
{ {
static char drx_driver_core_module_name[] = "Core driver"; static char drx_driver_core_module_name[] = "Core driver";
static char drx_driver_core_version_text[] = static char drx_driver_core_version_text[] =
@ -465,7 +442,7 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
static struct drx_version drx_driver_core_version; static struct drx_version drx_driver_core_version;
static struct drx_version_list drx_driver_core_version_list; static struct drx_version_list drx_driver_core_version_list;
struct drx_version_list *demod_version_list = (struct drx_version_list *) (NULL); struct drx_version_list *demod_version_list = NULL;
int return_status = -EIO; int return_status = -EIO;
/* Check arguments */ /* Check arguments */
@ -507,22 +484,21 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
return 0; return 0;
} }
/*============================================================================*/ /*
/*============================================================================*/ * Exported functions
/*== Exported functions ======================================================*/ */
/*============================================================================*/
/*============================================================================*/
/** /**
* \brief Open a demodulator instance. * drx_open - Open a demodulator instance.
* \param demod: A pointer to a demodulator instance. * @demod: A pointer to a demodulator instance.
* \return int Return status. *
* \retval 0: Opened demod instance with succes. * This function returns:
* \retval -EIO: Driver not initialized or unable to initialize * 0: Opened demod instance with succes.
* demod. * -EIO: Driver not initialized or unable to initialize
* \retval -EINVAL: Demod instance has invalid content. * demod.
* * -EINVAL: Demod instance has invalid content.
*/ *
*/
int drx_open(struct drx_demod_instance *demod) int drx_open(struct drx_demod_instance *demod)
{ {
@ -548,18 +524,18 @@ int drx_open(struct drx_demod_instance *demod)
/*============================================================================*/ /*============================================================================*/
/** /**
* \brief Close device. * drx_close - Close device
* \param demod: A pointer to a demodulator instance. * @demod: A pointer to a demodulator instance.
* \return int Return status. *
* \retval 0: Closed demod instance with succes. * Free resources occupied by device instance.
* \retval -EIO: Driver not initialized or error during close * Put device into sleep mode.
* demod. *
* \retval -EINVAL: Demod instance has invalid content. * This function returns:
* * 0: Closed demod instance with succes.
* Free resources occupied by device instance. * -EIO: Driver not initialized or error during close
* Put device into sleep mode. * demod.
*/ * -EINVAL: Demod instance has invalid content.
*/
int drx_close(struct drx_demod_instance *demod) int drx_close(struct drx_demod_instance *demod)
{ {
int status = 0; int status = 0;
@ -579,29 +555,22 @@ int drx_close(struct drx_demod_instance *demod)
return status; return status;
} }
/*============================================================================*/
/** /**
* \brief Control the device. * drx_ctrl - Control the device.
* \param demod: A pointer to a demodulator instance. * @demod: A pointer to a demodulator instance.
* \param ctrl: Reference to desired control function. * @ctrl: Reference to desired control function.
* \param ctrl_data: Pointer to data structure for control function. * @ctrl_data: Pointer to data structure for control function.
* \return int Return status. *
* \retval 0: Control function completed successfully. * Data needed or returned by the control function is stored in ctrl_data.
* \retval -EIO: Driver not initialized or error during *
* control demod. * This function returns:
* \retval -EINVAL: Demod instance or ctrl_data has invalid * 0: Control function completed successfully.
* content. * -EIO: Driver not initialized or error during control demod.
* \retval -ENOTSUPP: Specified control function is not * -EINVAL: Demod instance or ctrl_data has invalid content.
* available. * -ENOTSUPP: Specified control function is not available.
* */
* Data needed or returned by the control function is stored in ctrl_data.
*
*/
int int drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
{ {
int status = -EIO; int status = -EIO;
@ -680,7 +649,3 @@ drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
return 0; return 0;
} }
/*============================================================================*/
/* END OF FILE */