[media] drx-j: Use the Linux error codes
Instead of defining its own set of error codes, use the linux native ones. Please note that this patch made a "stupid" error code mapping, just replacing the codes with the closest one. In special, -EIO is being used on several places. I'm pretty sure this could be better assigned, but a change like that would require lots o time and efforts, without much benefit. So lets do adjstments at the error codes latter, when we have more time. Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
6371351777
commit
9482354f4a
|
@ -71,8 +71,8 @@ Exported FUNCTIONS
|
|||
* \fn drxbsp_i2c_init()
|
||||
* \brief Initialize I2C communication module.
|
||||
* \return drx_status_t Return status.
|
||||
* \retval DRX_STS_OK Initialization successful.
|
||||
* \retval DRX_STS_ERROR Initialization failed.
|
||||
* \retval 0 Initialization successful.
|
||||
* \retval -EIO Initialization failed.
|
||||
*/
|
||||
drx_status_t drxbsp_i2c_init(void);
|
||||
|
||||
|
@ -80,8 +80,8 @@ Exported FUNCTIONS
|
|||
* \fn drxbsp_i2c_term()
|
||||
* \brief Terminate I2C communication module.
|
||||
* \return drx_status_t Return status.
|
||||
* \retval DRX_STS_OK Termination successful.
|
||||
* \retval DRX_STS_ERROR Termination failed.
|
||||
* \retval 0 Termination successful.
|
||||
* \retval -EIO Termination failed.
|
||||
*/
|
||||
drx_status_t drxbsp_i2c_term(void);
|
||||
|
||||
|
@ -100,9 +100,9 @@ Exported FUNCTIONS
|
|||
* \param r_count The number of bytes to read
|
||||
* \param r_data The array to read the data from
|
||||
* \return drx_status_t Return status.
|
||||
* \retval DRX_STS_OK Succes.
|
||||
* \retval DRX_STS_ERROR Failure.
|
||||
* \retval DRX_STS_INVALID_ARG Parameter 'wcount' is not zero but parameter
|
||||
* \retval 0 Succes.
|
||||
* \retval -EIO Failure.
|
||||
* \retval -EINVAL Parameter 'wcount' is not zero but parameter
|
||||
* 'wdata' contains NULL.
|
||||
* Idem for 'rcount' and 'rdata'.
|
||||
* Both w_dev_addr and r_dev_addr are NULL.
|
||||
|
|
|
@ -43,7 +43,7 @@ static int drx39xxj_set_powerstate(struct dvb_frontend *fe, int enable)
|
|||
power_mode = DRX_POWER_DOWN;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_POWER_MODE, &power_mode);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Power state change failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ static int drx39xxj_read_status(struct dvb_frontend *fe, fe_status_t *status)
|
|||
*status = 0;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_status);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not get lock status!\n");
|
||||
*status = 0;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ static int drx39xxj_read_ber(struct dvb_frontend *fe, u32 *ber)
|
|||
struct drx_sig_quality sig_quality;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not get ber!\n");
|
||||
*ber = 0;
|
||||
return 0;
|
||||
|
@ -126,7 +126,7 @@ static int drx39xxj_read_signal_strength(struct dvb_frontend *fe,
|
|||
struct drx_sig_quality sig_quality;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not get signal strength!\n");
|
||||
*strength = 0;
|
||||
return 0;
|
||||
|
@ -145,7 +145,7 @@ static int drx39xxj_read_snr(struct dvb_frontend *fe, u16 *snr)
|
|||
struct drx_sig_quality sig_quality;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not read snr!\n");
|
||||
*snr = 0;
|
||||
return 0;
|
||||
|
@ -163,7 +163,7 @@ static int drx39xxj_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
|
|||
struct drx_sig_quality sig_quality;
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not get uc blocks!\n");
|
||||
*ucblocks = 0;
|
||||
return 0;
|
||||
|
@ -217,7 +217,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
|
|||
if (standard != state->current_standard || state->powered_up == 0) {
|
||||
/* Set the standard (will be powered up if necessary */
|
||||
result = drx_ctrl(demod, DRX_CTRL_SET_STANDARD, &standard);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Failed to set standard! result=%02x\n",
|
||||
result);
|
||||
return -EINVAL;
|
||||
|
@ -234,7 +234,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
|
|||
|
||||
/* program channel */
|
||||
result = drx_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Failed to set channel!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
|
|||
uio_data.uio = DRX_UIO1;
|
||||
uio_data.value = false;
|
||||
result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Failed to disable LNA!\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
|
|||
}
|
||||
|
||||
result = drx_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &i2c_gate_state);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "drx39xxj: could not open i2c gate [%d]\n",
|
||||
result);
|
||||
dump_stack();
|
||||
|
@ -382,7 +382,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
|
|||
demod->my_tuner = NULL;
|
||||
|
||||
result = drx_open(demod);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "DRX open failed! Aborting\n");
|
||||
kfree(state);
|
||||
return NULL;
|
||||
|
@ -393,7 +393,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
|
|||
uio_cfg.mode = DRX_UIO_MODE_READWRITE;
|
||||
/* Configure user-I/O #3: enable read/write */
|
||||
result = drx_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Failed to setup LNA GPIO!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
|
|||
uio_data.uio = DRX_UIO1;
|
||||
uio_data.value = false;
|
||||
result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
|
||||
if (result != DRX_STS_OK) {
|
||||
if (result != 0) {
|
||||
printk(KERN_ERR "Failed to disable LNA!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -13,19 +13,19 @@
|
|||
/* Dummy function to satisfy drxj.c */
|
||||
int drxbsp_tuner_open(struct tuner_instance *tuner)
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drxbsp_tuner_close(struct tuner_instance *tuner)
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drxbsp_tuner_set_frequency(struct tuner_instance *tuner,
|
||||
u32 mode,
|
||||
s32 center_frequency)
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -34,13 +34,13 @@ drxbsp_tuner_get_frequency(struct tuner_instance *tuner,
|
|||
s32 *r_ffrequency,
|
||||
s32 *i_ffrequency)
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drxbsp_hst_sleep(u32 n)
|
||||
{
|
||||
msleep(n);
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 drxbsp_hst_clock(void)
|
||||
|
@ -107,7 +107,7 @@ int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
|
|||
return -EREMOTEIO;
|
||||
}
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
|
||||
#ifdef DJH_DEBUG
|
||||
struct drx39xxj_state *state = w_dev_addr->user_data;
|
||||
|
|
|
@ -154,7 +154,7 @@ static int drxdap_fasi_write_reg8(struct i2c_device_addr *dev_addr, /* address o
|
|||
u8 data, /* data to write */
|
||||
u32 flags)
|
||||
{ /* special device flags */
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int drxdap_fasi_read_reg8(struct i2c_device_addr *dev_addr, /* address of I2C device */
|
||||
|
@ -162,7 +162,7 @@ static int drxdap_fasi_read_reg8(struct i2c_device_addr *dev_addr, /* address of
|
|||
u8 *data, /* buffer to receive data */
|
||||
u32 flags)
|
||||
{ /* special device flags */
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int drxdap_fasi_read_modify_write_reg8(struct i2c_device_addr *dev_addr, /* address of I2C device */
|
||||
|
@ -171,7 +171,7 @@ static int drxdap_fasi_read_modify_write_reg8(struct i2c_device_addr *dev_addr,
|
|||
u8 datain, /* data to send */
|
||||
u8 *dataout)
|
||||
{ /* data to receive back */
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int drxdap_fasi_read_modify_write_reg32(struct i2c_device_addr *dev_addr, /* address of I2C device */
|
||||
|
@ -180,7 +180,7 @@ static int drxdap_fasi_read_modify_write_reg32(struct i2c_device_addr *dev_addr,
|
|||
u32 datain, /* data to send */
|
||||
u32 *dataout)
|
||||
{ /* data to receive back */
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -204,9 +204,9 @@ static int drxdap_fasi_read_modify_write_reg32(struct i2c_device_addr *dev_addr,
|
|||
* the target platform.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if reading was successful
|
||||
* - 0 if reading was successful
|
||||
* in that case: data read is in *data.
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -222,7 +222,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
|
|||
|
||||
/* Check parameters ******************************************************* */
|
||||
if (dev_addr == NULL) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
overhead_size = (IS_I2C_10BIT(dev_addr->i2c_addr) ? 2 : 1) +
|
||||
|
@ -233,7 +233,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
|
|||
DRXDAP_FASI_LONG_FORMAT(addr)) ||
|
||||
(overhead_size > (DRXDAP_MAX_WCHUNKSIZE)) ||
|
||||
((datasize != 0) && (data == NULL)) || ((datasize & 1) == 1)) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* ReadModifyWrite & mode flag bits are not allowed */
|
||||
|
@ -284,7 +284,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
|
|||
* No special action is needed for write chunks here.
|
||||
*/
|
||||
rc = drxbsp_i2c_write_read(dev_addr, bufx, buf, 0, 0, 0);
|
||||
if (rc == DRX_STS_OK)
|
||||
if (rc == 0)
|
||||
rc = drxbsp_i2c_write_read(0, 0, 0, dev_addr, todo, data);
|
||||
#else
|
||||
/* In multi master mode, do everything in one RW action */
|
||||
|
@ -294,7 +294,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
|
|||
data += todo;
|
||||
addr += (todo >> 1);
|
||||
datasize -= todo;
|
||||
} while (datasize && rc == DRX_STS_OK);
|
||||
} while (datasize && rc == 0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -318,9 +318,9 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
|
|||
* master on the I2C bus.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if reading was successful
|
||||
* - 0 if reading was successful
|
||||
* in that case: read back data is at *rdata
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -329,15 +329,15 @@ static int drxdap_fasi_read_modify_write_reg16(struct i2c_device_addr *dev_addr,
|
|||
u32 raddr,
|
||||
u16 wdata, u16 *rdata)
|
||||
{
|
||||
int rc = DRX_STS_ERROR;
|
||||
int rc = -EIO;
|
||||
|
||||
#if (DRXDAPFASI_LONG_ADDR_ALLOWED == 1)
|
||||
if (rdata == NULL) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = drxdap_fasi_write_reg16(dev_addr, waddr, wdata, DRXDAP_FASI_RMW);
|
||||
if (rc == DRX_STS_OK)
|
||||
if (rc == 0)
|
||||
rc = drxdap_fasi_read_reg16(dev_addr, raddr, rdata, 0);
|
||||
#endif
|
||||
|
||||
|
@ -356,9 +356,9 @@ static int drxdap_fasi_read_modify_write_reg16(struct i2c_device_addr *dev_addr,
|
|||
* converted back to the target platform's endianness.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if reading was successful
|
||||
* - 0 if reading was successful
|
||||
* in that case: read data is at *data
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -370,7 +370,7 @@ static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr,
|
|||
int rc;
|
||||
|
||||
if (!data) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
rc = drxdap_fasi_read_block(dev_addr, addr, sizeof(*data), buf, flags);
|
||||
*data = buf[0] + (((u16) buf[1]) << 8);
|
||||
|
@ -389,9 +389,9 @@ static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr,
|
|||
* converted back to the target platform's endianness.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if reading was successful
|
||||
* - 0 if reading was successful
|
||||
* in that case: read data is at *data
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -403,7 +403,7 @@ static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr,
|
|||
int rc;
|
||||
|
||||
if (!data) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
rc = drxdap_fasi_read_block(dev_addr, addr, sizeof(*data), buf, flags);
|
||||
*data = (((u32) buf[0]) << 0) +
|
||||
|
@ -429,8 +429,8 @@ static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr,
|
|||
* the target platform.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if writing was successful
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - 0 if writing was successful
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -440,14 +440,14 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
|
|||
u8 *data, u32 flags)
|
||||
{
|
||||
u8 buf[DRXDAP_MAX_WCHUNKSIZE];
|
||||
int st = DRX_STS_ERROR;
|
||||
int first_err = DRX_STS_OK;
|
||||
int st = -EIO;
|
||||
int first_err = 0;
|
||||
u16 overhead_size = 0;
|
||||
u16 block_size = 0;
|
||||
|
||||
/* Check parameters ******************************************************* */
|
||||
if (dev_addr == NULL) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
overhead_size = (IS_I2C_10BIT(dev_addr->i2c_addr) ? 2 : 1) +
|
||||
|
@ -458,7 +458,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
|
|||
DRXDAP_FASI_LONG_FORMAT(addr)) ||
|
||||
(overhead_size > (DRXDAP_MAX_WCHUNKSIZE)) ||
|
||||
((datasize != 0) && (data == NULL)) || ((datasize & 1) == 1)) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
flags &= DRXDAP_FASI_FLAGS;
|
||||
|
@ -527,7 +527,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
|
|||
(struct i2c_device_addr *)(NULL),
|
||||
0, (u8 *)(NULL));
|
||||
|
||||
if ((st != DRX_STS_OK) && (first_err == DRX_STS_OK)) {
|
||||
if ((st != 0) && (first_err == 0)) {
|
||||
/* at the end, return the first error encountered */
|
||||
first_err = st;
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
|
|||
(struct i2c_device_addr *)(NULL),
|
||||
0, (u8 *)(NULL));
|
||||
|
||||
if ((st != DRX_STS_OK) && (first_err == DRX_STS_OK)) {
|
||||
if ((st != 0) && (first_err == 0)) {
|
||||
/* at the end, return the first error encountered */
|
||||
first_err = st;
|
||||
}
|
||||
|
@ -568,8 +568,8 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
|
|||
* converted from the target platform's endianness to little endian.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if writing was successful
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - 0 if writing was successful
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
@ -597,8 +597,8 @@ static int drxdap_fasi_write_reg16(struct i2c_device_addr *dev_addr,
|
|||
* converted from the target platform's endianness to little endian.
|
||||
*
|
||||
* Output:
|
||||
* - DRX_STS_OK if writing was successful
|
||||
* - DRX_STS_ERROR if anything went wrong
|
||||
* - 0 if writing was successful
|
||||
* - -EIO if anything went wrong
|
||||
*
|
||||
******************************/
|
||||
|
||||
|
|
|
@ -197,8 +197,8 @@ static void *get_scan_context(struct drx_demod_instance *demod, void *scan_conte
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param lock_stat: Pointer to bool indicating if end result is lock or not.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Success
|
||||
* \retval DRX_STS_ERROR: I2C failure or bsp function failure.
|
||||
* \retval 0: Success
|
||||
* \retval -EIO: I2C failure or bsp function failure.
|
||||
*
|
||||
* Wait until timeout, desired lock or NEVER_LOCK.
|
||||
* Assume:
|
||||
|
@ -229,8 +229,8 @@ static int scan_wait_for_lock(struct drx_demod_instance *demod, bool *is_locked)
|
|||
while (!done_waiting) {
|
||||
|
||||
if (drx_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_state) !=
|
||||
DRX_STS_OK) {
|
||||
return DRX_STS_ERROR;
|
||||
0) {
|
||||
return -EIO;
|
||||
}
|
||||
current_time = drxbsp_hst_clock();
|
||||
|
||||
|
@ -246,14 +246,14 @@ static int scan_wait_for_lock(struct drx_demod_instance *demod, bool *is_locked)
|
|||
/* lock_state == DRX_NOT_LOCKED and timeout */
|
||||
done_waiting = true;
|
||||
} else {
|
||||
if (drxbsp_hst_sleep(10) != DRX_STS_OK) {
|
||||
return DRX_STS_ERROR;
|
||||
if (drxbsp_hst_sleep(10) != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
} /* if ( timer_value > timeout_value ) .. */
|
||||
|
||||
} /* while */
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -263,8 +263,8 @@ static int scan_wait_for_lock(struct drx_demod_instance *demod, bool *is_locked)
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param skip : Minimum frequency step to take.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Succes.
|
||||
* \retval DRX_STS_INVALID_ARG: Invalid frequency plan.
|
||||
* \retval 0: Succes.
|
||||
* \retval -EINVAL: Invalid frequency plan.
|
||||
*
|
||||
* Helper function for ctrl_scan_next() function.
|
||||
* Compute next frequency & index in frequency plan.
|
||||
|
@ -331,7 +331,7 @@ scan_prepare_next_scan(struct drx_demod_instance *demod, s32 skip)
|
|||
common_attr->scan_freq_plan_index = table_index;
|
||||
common_attr->scan_next_frequency = next_frequency;
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -345,10 +345,10 @@ scan_prepare_next_scan(struct drx_demod_instance *demod, s32 skip)
|
|||
* \param get_next_channel: Return true if next frequency is desired at next call
|
||||
*
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Channel found, DRX_CTRL_GET_CHANNEL can be used
|
||||
* \retval 0: Channel found, DRX_CTRL_GET_CHANNEL can be used
|
||||
* to retrieve channel parameters.
|
||||
* \retval DRX_STS_BUSY: Channel not found (yet).
|
||||
* \retval DRX_STS_ERROR: Something went wrong.
|
||||
* \retval -EBUSY: Channel not found (yet).
|
||||
* \retval -EIO: Something went wrong.
|
||||
*
|
||||
* scan_channel and get_next_channel will be NULL for INIT and STOP.
|
||||
*/
|
||||
|
@ -358,25 +358,25 @@ scan_function_default(void *scan_context,
|
|||
struct drx_channel *scan_channel, bool *get_next_channel)
|
||||
{
|
||||
struct drx_demod_instance *demod = NULL;
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
bool is_locked = false;
|
||||
|
||||
demod = (struct drx_demod_instance *) scan_context;
|
||||
|
||||
if (scan_command != DRX_SCAN_COMMAND_NEXT) {
|
||||
/* just return OK if not doing "scan next" */
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*get_next_channel = false;
|
||||
|
||||
status = drx_ctrl(demod, DRX_CTRL_SET_CHANNEL, scan_channel);
|
||||
if (status != DRX_STS_OK) {
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = scan_wait_for_lock(demod, &is_locked);
|
||||
if (status != DRX_STS_OK) {
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -385,10 +385,10 @@ scan_function_default(void *scan_context,
|
|||
|
||||
if (!is_locked) {
|
||||
/* no channel found */
|
||||
return DRX_STS_BUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
/* channel found */
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -398,10 +398,10 @@ scan_function_default(void *scan_context,
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param scan_param: Pointer to scan parameters.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Initialized for scan.
|
||||
* \retval DRX_STS_ERROR: No overlap between frequency plan and tuner
|
||||
* \retval 0: Initialized for scan.
|
||||
* \retval -EIO: No overlap between frequency plan and tuner
|
||||
* range.
|
||||
* \retval DRX_STS_INVALID_ARG: Wrong parameters.
|
||||
* \retval -EINVAL: Wrong parameters.
|
||||
*
|
||||
* This function should be called before starting a complete channel scan.
|
||||
* It will prepare everything for a complete channel scan.
|
||||
|
@ -413,7 +413,6 @@ scan_function_default(void *scan_context,
|
|||
static int
|
||||
ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_param)
|
||||
{
|
||||
int status = DRX_STS_ERROR;
|
||||
struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
|
||||
s32 max_tuner_freq = 0;
|
||||
s32 min_tuner_freq = 0;
|
||||
|
@ -437,7 +436,7 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
(scan_param->frequency_plan_size == 0)
|
||||
) {
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check frequency plan contents */
|
||||
|
@ -454,13 +453,13 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
if (step <= 0) {
|
||||
/* Step must be positive and non-zero */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (first_freq > last_freq) {
|
||||
/* First center frequency is higher than last center frequency */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
width = last_freq - first_freq;
|
||||
|
@ -469,7 +468,7 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
/* Difference between last and first center frequency is not
|
||||
an integer number of steps */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check if frequency plan entry intersects with tuner range */
|
||||
|
@ -517,7 +516,7 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
if (nr_channels_in_plan == 0) {
|
||||
/* Tuner range and frequency plan ranges do not overlap */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Store parameters */
|
||||
|
@ -528,12 +527,14 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
|
||||
scan_context = get_scan_context(demod, scan_context);
|
||||
|
||||
status = (*(get_scan_function(demod)))
|
||||
(scan_context, DRX_SCAN_COMMAND_INIT, NULL, NULL);
|
||||
/*
|
||||
* FIXME: Should we really ignore the result of the scan function?
|
||||
*/
|
||||
(*(get_scan_function(demod)))(scan_context, DRX_SCAN_COMMAND_INIT, NULL, NULL);
|
||||
|
||||
common_attr->scan_active = false;
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -542,13 +543,13 @@ ctrl_scan_init(struct drx_demod_instance *demod, struct drx_scan_param *scan_par
|
|||
* \brief Stop scanning.
|
||||
* \param demod: Pointer to demodulator instance.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Scan stopped.
|
||||
* \retval DRX_STS_ERROR: Something went wrong.
|
||||
* \retval DRX_STS_INVALID_ARG: Wrong parameters.
|
||||
* \retval 0: Scan stopped.
|
||||
* \retval -EIO: Something went wrong.
|
||||
* \retval -EINVAL: Wrong parameters.
|
||||
*/
|
||||
static int ctrl_scan_stop(struct drx_demod_instance *demod)
|
||||
{
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
|
||||
void *scan_context = NULL;
|
||||
|
||||
|
@ -559,7 +560,7 @@ static int ctrl_scan_stop(struct drx_demod_instance *demod)
|
|||
(common_attr->scan_max_channels == 0)) {
|
||||
/* Scan was not running, just return OK */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Call default or device-specific scanning stop function */
|
||||
|
@ -583,15 +584,15 @@ static int ctrl_scan_stop(struct drx_demod_instance *demod)
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param scan_progress: Pointer to scan progress.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Channel found, DRX_CTRL_GET_CHANNEL can be used
|
||||
* \retval 0: Channel found, DRX_CTRL_GET_CHANNEL can be used
|
||||
* to retrieve channel parameters.
|
||||
* \retval DRX_STS_BUSY: Tried part of the channels, as specified in
|
||||
* \retval -EBUSY: Tried part of the channels, as specified in
|
||||
* num_tries field of scan parameters. At least one
|
||||
* more call to DRX_CTRL_SCAN_NEXT is needed to
|
||||
* complete scanning.
|
||||
* \retval DRX_STS_READY: Reached end of scan range.
|
||||
* \retval DRX_STS_ERROR: Something went wrong.
|
||||
* \retval DRX_STS_INVALID_ARG: Wrong parameters. The scan_progress may be NULL.
|
||||
* \retval -ERANGE: Reached end of scan range.
|
||||
* \retval -EIO: Something went wrong.
|
||||
* \retval -EINVAL: Wrong parameters. The scan_progress may be NULL.
|
||||
*
|
||||
* Progress indication will run from 0 upto DRX_SCAN_MAX_PROGRESS during scan.
|
||||
*
|
||||
|
@ -609,7 +610,7 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
/* Check scan parameters */
|
||||
if (scan_progress == NULL) {
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*scan_progress = 0;
|
||||
|
@ -618,7 +619,7 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
(common_attr->scan_max_channels == 0)) {
|
||||
/* ctrl_scan_init() was not called succesfully before ctrl_scan_next() */
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
*scan_progress = (u16) (((common_attr->scan_channels_scanned) *
|
||||
|
@ -631,7 +632,7 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
|
||||
for (i = 0; ((i < num_tries) && (!(*scan_ready))); i++) {
|
||||
struct drx_channel scan_channel = { 0 };
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
struct drx_frequency_plan *freq_plan = (struct drx_frequency_plan *) (NULL);
|
||||
bool next_channel = false;
|
||||
void *scan_context = NULL;
|
||||
|
@ -666,10 +667,10 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
|
||||
/* Proceed to next channel if requested */
|
||||
if (next_channel) {
|
||||
int next_status = DRX_STS_ERROR;
|
||||
int next_status = -EIO;
|
||||
s32 skip = 0;
|
||||
|
||||
if (status == DRX_STS_OK) {
|
||||
if (status == 0) {
|
||||
/* a channel was found, so skip some frequency steps */
|
||||
skip = common_attr->scan_param->skip;
|
||||
}
|
||||
|
@ -681,12 +682,12 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
((u32) (max_progress))) /
|
||||
(common_attr->scan_max_channels));
|
||||
|
||||
if (next_status != DRX_STS_OK) {
|
||||
if (next_status != 0) {
|
||||
common_attr->scan_active = false;
|
||||
return next_status;
|
||||
}
|
||||
}
|
||||
if (status != DRX_STS_BUSY) {
|
||||
if (status != -EBUSY) {
|
||||
/* channel found or error */
|
||||
common_attr->scan_active = false;
|
||||
return status;
|
||||
|
@ -697,12 +698,12 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
/* End of scan reached: call stop-scan, ignore any error */
|
||||
ctrl_scan_stop(demod);
|
||||
common_attr->scan_active = false;
|
||||
return DRX_STS_READY;
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
common_attr->scan_active = false;
|
||||
|
||||
return DRX_STS_BUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
#endif /* #ifndef DRX_EXCLUDE_SCAN */
|
||||
|
@ -714,9 +715,9 @@ static int ctrl_scan_next(struct drx_demod_instance *demod, u16 *scan_progress)
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param tunerChannel: Pointer to tuning parameters.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Tuner programmed successfully.
|
||||
* \retval DRX_STS_ERROR: Something went wrong.
|
||||
* \retval DRX_STS_INVALID_ARG: Wrong parameters.
|
||||
* \retval 0: Tuner programmed successfully.
|
||||
* \retval -EIO: Something went wrong.
|
||||
* \retval -EINVAL: Wrong parameters.
|
||||
*
|
||||
* tunerChannel passes parameters to program the tuner,
|
||||
* but also returns the actual RF and IF frequency from the tuner.
|
||||
|
@ -728,20 +729,20 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
|
||||
enum drx_standard standard = DRX_STANDARD_UNKNOWN;
|
||||
u32 tuner_mode = 0;
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
s32 if_frequency = 0;
|
||||
bool tuner_slow_mode = false;
|
||||
|
||||
/* can't tune without a tuner */
|
||||
if (demod->my_tuner == NULL) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
common_attr = (struct drx_common_attr *) demod->my_common_attr;
|
||||
|
||||
/* select analog or digital tuner mode based on current standard */
|
||||
if (drx_ctrl(demod, DRX_CTRL_GET_STANDARD, &standard) != DRX_STS_OK) {
|
||||
return DRX_STS_ERROR;
|
||||
if (drx_ctrl(demod, DRX_CTRL_GET_STANDARD, &standard) != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (DRX_ISATVSTD(standard)) {
|
||||
|
@ -763,7 +764,7 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
tuner_mode |= TUNER_MODE_8MHZ;
|
||||
break;
|
||||
default: /* note: also for unknown bandwidth */
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
DRX_GET_TUNERSLOWMODE(demod, tuner_slow_mode);
|
||||
|
@ -777,11 +778,11 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
|
||||
if (common_attr->tuner_port_nr == 1) {
|
||||
bool bridge_closed = true;
|
||||
int status_bridge = DRX_STS_ERROR;
|
||||
int status_bridge = -EIO;
|
||||
|
||||
status_bridge =
|
||||
drx_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &bridge_closed);
|
||||
if (status_bridge != DRX_STS_OK) {
|
||||
if (status_bridge != 0) {
|
||||
return status_bridge;
|
||||
}
|
||||
}
|
||||
|
@ -792,17 +793,17 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
/* attempt restoring bridge before checking status of set_frequency */
|
||||
if (common_attr->tuner_port_nr == 1) {
|
||||
bool bridge_closed = false;
|
||||
int status_bridge = DRX_STS_ERROR;
|
||||
int status_bridge = -EIO;
|
||||
|
||||
status_bridge =
|
||||
drx_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &bridge_closed);
|
||||
if (status_bridge != DRX_STS_OK) {
|
||||
if (status_bridge != 0) {
|
||||
return status_bridge;
|
||||
}
|
||||
}
|
||||
|
||||
/* now check status of drxbsp_tuner_set_frequency */
|
||||
if (status != DRX_STS_OK) {
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -811,7 +812,7 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
tuner_mode,
|
||||
&(channel->frequency),
|
||||
&(if_frequency));
|
||||
if (status != DRX_STS_OK) {
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -819,7 +820,7 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
TODO: check if this is required and safe */
|
||||
DRX_SET_INTERMEDIATEFREQ(demod, if_frequency);
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -829,9 +830,9 @@ ctrl_program_tuner(struct drx_demod_instance *demod, struct drx_channel *channel
|
|||
* \param demod: Pointer to demodulator instance.
|
||||
* \param registers: Registers to dump.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Dump executed successfully.
|
||||
* \retval DRX_STS_ERROR: Something went wrong.
|
||||
* \retval DRX_STS_INVALID_ARG: Wrong parameters.
|
||||
* \retval 0: Dump executed successfully.
|
||||
* \retval -EIO: Something went wrong.
|
||||
* \retval -EINVAL: Wrong parameters.
|
||||
*
|
||||
*/
|
||||
static int ctrl_dump_registers(struct drx_demod_instance *demod,
|
||||
|
@ -841,12 +842,12 @@ static int ctrl_dump_registers(struct drx_demod_instance *demod,
|
|||
|
||||
if (registers == NULL) {
|
||||
/* registers not supplied */
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* start dumping registers */
|
||||
while (registers[i].address != 0) {
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
u16 value = 0;
|
||||
u32 data = 0;
|
||||
|
||||
|
@ -857,7 +858,7 @@ static int ctrl_dump_registers(struct drx_demod_instance *demod,
|
|||
|
||||
data = (u32) value;
|
||||
|
||||
if (status != DRX_STS_OK) {
|
||||
if (status != 0) {
|
||||
/* no breakouts;
|
||||
depending on device ID, some HW blocks might not be available */
|
||||
data |= ((u32) status) << 16;
|
||||
|
@ -867,7 +868,7 @@ static int ctrl_dump_registers(struct drx_demod_instance *demod,
|
|||
}
|
||||
|
||||
/* all done, all OK (any errors are saved inside data) */
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -963,15 +964,15 @@ static u16 u_code_compute_crc(u8 *block_data, u16 nr_words)
|
|||
* \param mc_info: Pointer to information about microcode data.
|
||||
* \param action: Either UCODE_UPLOAD or UCODE_VERIFY
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK:
|
||||
* \retval 0:
|
||||
* - In case of UCODE_UPLOAD: code is successfully uploaded.
|
||||
* - In case of UCODE_VERIFY: image on device is equal to
|
||||
* image provided to this control function.
|
||||
* \retval DRX_STS_ERROR:
|
||||
* \retval -EIO:
|
||||
* - In case of UCODE_UPLOAD: I2C error.
|
||||
* - In case of UCODE_VERIFY: I2C error or image on device
|
||||
* is not equal to image provided to this control function.
|
||||
* \retval DRX_STS_INVALID_ARG:
|
||||
* \retval -EINVAL:
|
||||
* - Invalid arguments.
|
||||
* - Provided image is corrupt
|
||||
*/
|
||||
|
@ -990,7 +991,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
|
||||
/* Check arguments */
|
||||
if ((mc_info == NULL) || (mc_info->mc_data == NULL)) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc_data = mc_info->mc_data;
|
||||
|
@ -1003,7 +1004,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
|
||||
if ((mc_magic_word != DRX_UCODE_MAGIC_WORD) || (mc_nr_of_blks == 0)) {
|
||||
/* wrong endianess or wrong data ? */
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Scan microcode blocks first for version info if uploading */
|
||||
|
@ -1053,7 +1054,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
It is also valid if no validation control exists.
|
||||
*/
|
||||
rc = drx_ctrl(demod, DRX_CTRL_VALIDATE_UCODE, NULL);
|
||||
if (rc != DRX_STS_OK && rc != DRX_STS_FUNC_NOT_AVAILABLE) {
|
||||
if (rc != 0 && rc != -ENOTSUPP) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1085,7 +1086,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
(block_hdr.CRC != u_code_compute_crc(mc_data, block_hdr.size)))
|
||||
) {
|
||||
/* Wrong data ! */
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc_block_nr_bytes = block_hdr.size * ((u16) sizeof(u16));
|
||||
|
@ -1103,8 +1104,8 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
addr, mc_block_nr_bytes,
|
||||
mc_data,
|
||||
0x0000) !=
|
||||
DRX_STS_OK) {
|
||||
return DRX_STS_ERROR;
|
||||
0) {
|
||||
return -EIO;
|
||||
} /* if */
|
||||
}
|
||||
break;
|
||||
|
@ -1144,8 +1145,8 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
(u8 *)
|
||||
mc_data_buffer,
|
||||
0x0000) !=
|
||||
DRX_STS_OK) {
|
||||
return DRX_STS_ERROR;
|
||||
0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
result =
|
||||
|
@ -1154,7 +1155,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
bytes_to_compare);
|
||||
|
||||
if (result != 0) {
|
||||
return DRX_STS_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
curr_addr +=
|
||||
|
@ -1170,7 +1171,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
|
||||
/*================================================================*/
|
||||
default:
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
break;
|
||||
|
||||
} /* switch ( action ) */
|
||||
|
@ -1182,7 +1183,7 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
|
||||
} /* for( i = 0 ; i<mc_nr_of_blks ; i++ ) */
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -1192,8 +1193,8 @@ ctrl_u_code(struct drx_demod_instance *demod,
|
|||
* \param demod: A pointer to a demodulator instance.
|
||||
* \param version_list: Pointer to linked list of versions.
|
||||
* \return int.
|
||||
* \retval DRX_STS_OK: Version information stored in version_list
|
||||
* \retval DRX_STS_INVALID_ARG: Invalid arguments.
|
||||
* \retval 0: Version information stored in version_list
|
||||
* \retval -EINVAL: Invalid arguments.
|
||||
*/
|
||||
static int
|
||||
ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version_list)
|
||||
|
@ -1206,11 +1207,11 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
|
|||
static struct drx_version_list drx_driver_core_version_list;
|
||||
|
||||
struct drx_version_list *demod_version_list = (struct drx_version_list *) (NULL);
|
||||
int return_status = DRX_STS_ERROR;
|
||||
int return_status = -EIO;
|
||||
|
||||
/* Check arguments */
|
||||
if (version_list == NULL) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get version info list from demod */
|
||||
|
@ -1230,7 +1231,7 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
|
|||
drx_driver_core_version_list.version = &drx_driver_core_version;
|
||||
drx_driver_core_version_list.next = (struct drx_version_list *) (NULL);
|
||||
|
||||
if ((return_status == DRX_STS_OK) && (demod_version_list != NULL)) {
|
||||
if ((return_status == 0) && (demod_version_list != NULL)) {
|
||||
/* Append versioninfo from driver to versioninfo from demod */
|
||||
/* Return version info in "bottom-up" order. This way, multiple
|
||||
devices can be handled without using malloc. */
|
||||
|
@ -1246,7 +1247,7 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
|
|||
*version_list = &drx_driver_core_version_list;
|
||||
}
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -1259,7 +1260,7 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
|
|||
* \brief This function is obsolete.
|
||||
* \param demods: Don't care, parameter is ignored.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK: Initialization completed.
|
||||
* \retval 0: Initialization completed.
|
||||
*
|
||||
* This function is obsolete, prototype available for backward compatability.
|
||||
*
|
||||
|
@ -1267,7 +1268,7 @@ ctrl_version(struct drx_demod_instance *demod, struct drx_version_list **version
|
|||
|
||||
int drx_init(struct drx_demod_instance *demods[])
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -1275,7 +1276,7 @@ int drx_init(struct drx_demod_instance *demods[])
|
|||
/**
|
||||
* \brief This function is obsolete.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK: Terminated driver successful.
|
||||
* \retval 0: Terminated driver successful.
|
||||
*
|
||||
* This function is obsolete, prototype available for backward compatability.
|
||||
*
|
||||
|
@ -1283,7 +1284,7 @@ int drx_init(struct drx_demod_instance *demods[])
|
|||
|
||||
int drx_term(void)
|
||||
{
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
@ -1292,16 +1293,16 @@ int drx_term(void)
|
|||
* \brief Open a demodulator instance.
|
||||
* \param demod: A pointer to a demodulator instance.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK: Opened demod instance with succes.
|
||||
* \retval DRX_STS_ERROR: Driver not initialized or unable to initialize
|
||||
* \retval 0: Opened demod instance with succes.
|
||||
* \retval -EIO: Driver not initialized or unable to initialize
|
||||
* demod.
|
||||
* \retval DRX_STS_INVALID_ARG: Demod instance has invalid content.
|
||||
* \retval -EINVAL: Demod instance has invalid content.
|
||||
*
|
||||
*/
|
||||
|
||||
int drx_open(struct drx_demod_instance *demod)
|
||||
{
|
||||
int status = DRX_STS_OK;
|
||||
int status = 0;
|
||||
|
||||
if ((demod == NULL) ||
|
||||
(demod->my_demod_funct == NULL) ||
|
||||
|
@ -1309,12 +1310,12 @@ int drx_open(struct drx_demod_instance *demod)
|
|||
(demod->my_ext_attr == NULL) ||
|
||||
(demod->my_i2c_dev_addr == NULL) ||
|
||||
(demod->my_common_attr->is_opened)) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
status = (*(demod->my_demod_funct->open_func)) (demod);
|
||||
|
||||
if (status == DRX_STS_OK)
|
||||
if (status == 0)
|
||||
demod->my_common_attr->is_opened = true;
|
||||
|
||||
return status;
|
||||
|
@ -1326,10 +1327,10 @@ int drx_open(struct drx_demod_instance *demod)
|
|||
* \brief Close device.
|
||||
* \param demod: A pointer to a demodulator instance.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK: Closed demod instance with succes.
|
||||
* \retval DRX_STS_ERROR: Driver not initialized or error during close
|
||||
* \retval 0: Closed demod instance with succes.
|
||||
* \retval -EIO: Driver not initialized or error during close
|
||||
* demod.
|
||||
* \retval DRX_STS_INVALID_ARG: Demod instance has invalid content.
|
||||
* \retval -EINVAL: Demod instance has invalid content.
|
||||
*
|
||||
* Free resources occupied by device instance.
|
||||
* Put device into sleep mode.
|
||||
|
@ -1337,7 +1338,7 @@ int drx_open(struct drx_demod_instance *demod)
|
|||
|
||||
int drx_close(struct drx_demod_instance *demod)
|
||||
{
|
||||
int status = DRX_STS_OK;
|
||||
int status = 0;
|
||||
|
||||
if ((demod == NULL) ||
|
||||
(demod->my_demod_funct == NULL) ||
|
||||
|
@ -1345,7 +1346,7 @@ int drx_close(struct drx_demod_instance *demod)
|
|||
(demod->my_ext_attr == NULL) ||
|
||||
(demod->my_i2c_dev_addr == NULL) ||
|
||||
(!demod->my_common_attr->is_opened)) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
status = (*(demod->my_demod_funct->close_func)) (demod);
|
||||
|
@ -1363,12 +1364,12 @@ int drx_close(struct drx_demod_instance *demod)
|
|||
* \param ctrl: Reference to desired control function.
|
||||
* \param ctrl_data: Pointer to data structure for control function.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK: Control function completed successfully.
|
||||
* \retval DRX_STS_ERROR: Driver not initialized or error during
|
||||
* \retval 0: Control function completed successfully.
|
||||
* \retval -EIO: Driver not initialized or error during
|
||||
* control demod.
|
||||
* \retval DRX_STS_INVALID_ARG: Demod instance or ctrl_data has invalid
|
||||
* \retval -EINVAL: Demod instance or ctrl_data has invalid
|
||||
* content.
|
||||
* \retval DRX_STS_FUNC_NOT_AVAILABLE: Specified control function is not
|
||||
* \retval -ENOTSUPP: Specified control function is not
|
||||
* available.
|
||||
*
|
||||
* Data needed or returned by the control function is stored in ctrl_data.
|
||||
|
@ -1378,20 +1379,20 @@ int drx_close(struct drx_demod_instance *demod)
|
|||
int
|
||||
drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
|
||||
{
|
||||
int status = DRX_STS_ERROR;
|
||||
int status = -EIO;
|
||||
|
||||
if ((demod == NULL) ||
|
||||
(demod->my_demod_funct == NULL) ||
|
||||
(demod->my_common_attr == NULL) ||
|
||||
(demod->my_ext_attr == NULL) || (demod->my_i2c_dev_addr == NULL)
|
||||
) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (((!demod->my_common_attr->is_opened) &&
|
||||
(ctrl != DRX_CTRL_PROBE_DEVICE) && (ctrl != DRX_CTRL_VERSION))
|
||||
) {
|
||||
return DRX_STS_INVALID_ARG;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode) &&
|
||||
|
@ -1400,7 +1401,7 @@ drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
|
|||
(ctrl != DRX_CTRL_NOP) && (ctrl != DRX_CTRL_VERSION)
|
||||
)
|
||||
) {
|
||||
return DRX_STS_FUNC_NOT_AVAILABLE;
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
/* Fixed control functions */
|
||||
|
@ -1408,7 +1409,7 @@ drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
|
|||
/*======================================================================*/
|
||||
case DRX_CTRL_NOP:
|
||||
/* No operation */
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
break;
|
||||
|
||||
/*======================================================================*/
|
||||
|
@ -1425,7 +1426,7 @@ drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
|
|||
/* Virtual functions */
|
||||
/* First try calling function from derived class */
|
||||
status = (*(demod->my_demod_funct->ctrl_func)) (demod, ctrl, ctrl_data);
|
||||
if (status == DRX_STS_FUNC_NOT_AVAILABLE) {
|
||||
if (status == -ENOTSUPP) {
|
||||
/* Now try calling a the base class function */
|
||||
switch (ctrl) {
|
||||
/*===================================================================*/
|
||||
|
@ -1488,13 +1489,13 @@ drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
|
|||
|
||||
/*===================================================================*/
|
||||
default:
|
||||
return DRX_STS_FUNC_NOT_AVAILABLE;
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
|
||||
return DRX_STS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*============================================================================*/
|
||||
|
|
|
@ -28,30 +28,11 @@
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file $Id: drx_driver.h,v 1.84 2010/01/14 22:47:50 dingtao Exp $
|
||||
*
|
||||
* \brief DRX driver API
|
||||
*
|
||||
*/
|
||||
#ifndef __DRXDRIVER_H__
|
||||
#define __DRXDRIVER_H__
|
||||
|
||||
#include <linux/kernel.h>
|
||||
/*-------------------------------------------------------------------------
|
||||
INCLUDES
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
enum drx_status {
|
||||
DRX_STS_READY = 3, /**< device/service is ready */
|
||||
DRX_STS_BUSY = 2, /**< device/service is busy */
|
||||
DRX_STS_OK = 1, /**< everything is OK */
|
||||
DRX_STS_INVALID_ARG = -1,
|
||||
/**< invalid arguments */
|
||||
DRX_STS_ERROR = -2, /**< general error */
|
||||
DRX_STS_FUNC_NOT_AVAILABLE = -3
|
||||
/**< unavailable functionality */
|
||||
};
|
||||
#include <linux/errno.h>
|
||||
|
||||
/*
|
||||
* This structure contains the I2C address, the device ID and a user_data pointer.
|
||||
|
@ -82,8 +63,8 @@ Exported FUNCTIONS
|
|||
* \fn drxbsp_i2c_init()
|
||||
* \brief Initialize I2C communication module.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK Initialization successful.
|
||||
* \retval DRX_STS_ERROR Initialization failed.
|
||||
* \retval 0 Initialization successful.
|
||||
* \retval -EIO Initialization failed.
|
||||
*/
|
||||
int drxbsp_i2c_init(void);
|
||||
|
||||
|
@ -91,8 +72,8 @@ int drxbsp_i2c_init(void);
|
|||
* \fn drxbsp_i2c_term()
|
||||
* \brief Terminate I2C communication module.
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK Termination successful.
|
||||
* \retval DRX_STS_ERROR Termination failed.
|
||||
* \retval 0 Termination successful.
|
||||
* \retval -EIO Termination failed.
|
||||
*/
|
||||
int drxbsp_i2c_term(void);
|
||||
|
||||
|
@ -111,9 +92,9 @@ int drxbsp_i2c_term(void);
|
|||
* \param r_count The number of bytes to read
|
||||
* \param r_data The array to read the data from
|
||||
* \return int Return status.
|
||||
* \retval DRX_STS_OK Succes.
|
||||
* \retval DRX_STS_ERROR Failure.
|
||||
* \retval DRX_STS_INVALID_ARG Parameter 'wcount' is not zero but parameter
|
||||
* \retval 0 Succes.
|
||||
* \retval -EIO Failure.
|
||||
* \retval -EINVAL Parameter 'wcount' is not zero but parameter
|
||||
* 'wdata' contains NULL.
|
||||
* Idem for 'rcount' and 'rdata'.
|
||||
* Both w_dev_addr and r_dev_addr are NULL.
|
||||
|
@ -2738,7 +2719,7 @@ Access macros
|
|||
config.cfg_type = cfg_name; \
|
||||
config.cfg_data = &cfg_data; \
|
||||
cfg_status = drx_ctrl(demod, DRX_CTRL_GET_CFG, &config); \
|
||||
if (cfg_status == DRX_STS_OK) { \
|
||||
if (cfg_status == 0) { \
|
||||
value = cfg_data; \
|
||||
} else { \
|
||||
value = (data_type)error_value; \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue