Commit 9482354f authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 63713517
......@@ -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
*
******************************/
......
......@@ -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; \
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment