Commit cbb2a299 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] af9013: fix logging

We can simplify logging as we now have a proper i2c client
to pass for kernel dev_* logging functions.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 903b0e58
...@@ -51,14 +51,15 @@ struct af9013_state { ...@@ -51,14 +51,15 @@ struct af9013_state {
}; };
/* write multiple registers */ /* write multiple registers */
static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg, static int af9013_wr_regs_i2c(struct af9013_state *state, u8 mbox, u16 reg,
const u8 *val, int len) const u8 *val, int len)
{ {
struct i2c_client *client = state->client;
int ret; int ret;
u8 buf[MAX_XFER_SIZE]; u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = { struct i2c_msg msg[1] = {
{ {
.addr = priv->client->addr, .addr = state->client->addr,
.flags = 0, .flags = 0,
.len = 3 + len, .len = 3 + len,
.buf = buf, .buf = buf,
...@@ -66,9 +67,8 @@ static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg, ...@@ -66,9 +67,8 @@ static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg,
}; };
if (3 + len > sizeof(buf)) { if (3 + len > sizeof(buf)) {
dev_warn(&priv->client->dev, dev_warn(&client->dev, "i2c wr reg %04x, len %d, is too big!\n",
"%s: i2c wr reg=%04x: len=%d is too big!\n", reg, len);
KBUILD_MODNAME, reg, len);
return -EINVAL; return -EINVAL;
} }
...@@ -77,31 +77,32 @@ static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg, ...@@ -77,31 +77,32 @@ static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg,
buf[2] = mbox; buf[2] = mbox;
memcpy(&buf[3], val, len); memcpy(&buf[3], val, len);
ret = i2c_transfer(priv->client->adapter, msg, 1); ret = i2c_transfer(state->client->adapter, msg, 1);
if (ret == 1) { if (ret == 1) {
ret = 0; ret = 0;
} else { } else {
dev_warn(&priv->client->dev, "%s: i2c wr failed=%d reg=%04x " \ dev_warn(&client->dev, "i2c wr failed %d, reg %04x, len %d\n",
"len=%d\n", KBUILD_MODNAME, ret, reg, len); ret, reg, len);
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
return ret; return ret;
} }
/* read multiple registers */ /* read multiple registers */
static int af9013_rd_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg, static int af9013_rd_regs_i2c(struct af9013_state *state, u8 mbox, u16 reg,
u8 *val, int len) u8 *val, int len)
{ {
struct i2c_client *client = state->client;
int ret; int ret;
u8 buf[3]; u8 buf[3];
struct i2c_msg msg[2] = { struct i2c_msg msg[2] = {
{ {
.addr = priv->client->addr, .addr = state->client->addr,
.flags = 0, .flags = 0,
.len = 3, .len = 3,
.buf = buf, .buf = buf,
}, { }, {
.addr = priv->client->addr, .addr = state->client->addr,
.flags = I2C_M_RD, .flags = I2C_M_RD,
.len = len, .len = len,
.buf = val, .buf = val,
...@@ -112,31 +113,31 @@ static int af9013_rd_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg, ...@@ -112,31 +113,31 @@ static int af9013_rd_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg,
buf[1] = (reg >> 0) & 0xff; buf[1] = (reg >> 0) & 0xff;
buf[2] = mbox; buf[2] = mbox;
ret = i2c_transfer(priv->client->adapter, msg, 2); ret = i2c_transfer(state->client->adapter, msg, 2);
if (ret == 2) { if (ret == 2) {
ret = 0; ret = 0;
} else { } else {
dev_warn(&priv->client->dev, "%s: i2c rd failed=%d reg=%04x " \ dev_warn(&client->dev, "i2c rd failed %d, reg %04x, len %d\n",
"len=%d\n", KBUILD_MODNAME, ret, reg, len); ret, reg, len);
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
return ret; return ret;
} }
/* write multiple registers */ /* write multiple registers */
static int af9013_wr_regs(struct af9013_state *priv, u16 reg, const u8 *val, static int af9013_wr_regs(struct af9013_state *state, u16 reg, const u8 *val,
int len) int len)
{ {
int ret, i; int ret, i;
u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(1 << 0); u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(1 << 0);
if ((priv->ts_mode == AF9013_TS_USB) && if ((state->ts_mode == AF9013_TS_USB) &&
((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) { ((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) {
mbox |= ((len - 1) << 2); mbox |= ((len - 1) << 2);
ret = af9013_wr_regs_i2c(priv, mbox, reg, val, len); ret = af9013_wr_regs_i2c(state, mbox, reg, val, len);
} else { } else {
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
ret = af9013_wr_regs_i2c(priv, mbox, reg+i, val+i, 1); ret = af9013_wr_regs_i2c(state, mbox, reg+i, val+i, 1);
if (ret) if (ret)
goto err; goto err;
} }
...@@ -147,18 +148,18 @@ static int af9013_wr_regs(struct af9013_state *priv, u16 reg, const u8 *val, ...@@ -147,18 +148,18 @@ static int af9013_wr_regs(struct af9013_state *priv, u16 reg, const u8 *val,
} }
/* read multiple registers */ /* read multiple registers */
static int af9013_rd_regs(struct af9013_state *priv, u16 reg, u8 *val, int len) static int af9013_rd_regs(struct af9013_state *state, u16 reg, u8 *val, int len)
{ {
int ret, i; int ret, i;
u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(0 << 0); u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(0 << 0);
if ((priv->ts_mode == AF9013_TS_USB) && if ((state->ts_mode == AF9013_TS_USB) &&
((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) { ((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) {
mbox |= ((len - 1) << 2); mbox |= ((len - 1) << 2);
ret = af9013_rd_regs_i2c(priv, mbox, reg, val, len); ret = af9013_rd_regs_i2c(state, mbox, reg, val, len);
} else { } else {
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
ret = af9013_rd_regs_i2c(priv, mbox, reg+i, val+i, 1); ret = af9013_rd_regs_i2c(state, mbox, reg+i, val+i, 1);
if (ret) if (ret)
goto err; goto err;
} }
...@@ -169,15 +170,15 @@ static int af9013_rd_regs(struct af9013_state *priv, u16 reg, u8 *val, int len) ...@@ -169,15 +170,15 @@ static int af9013_rd_regs(struct af9013_state *priv, u16 reg, u8 *val, int len)
} }
/* write single register */ /* write single register */
static int af9013_wr_reg(struct af9013_state *priv, u16 reg, u8 val) static int af9013_wr_reg(struct af9013_state *state, u16 reg, u8 val)
{ {
return af9013_wr_regs(priv, reg, &val, 1); return af9013_wr_regs(state, reg, &val, 1);
} }
/* read single register */ /* read single register */
static int af9013_rd_reg(struct af9013_state *priv, u16 reg, u8 *val) static int af9013_rd_reg(struct af9013_state *state, u16 reg, u8 *val)
{ {
return af9013_rd_regs(priv, reg, val, 1); return af9013_rd_regs(state, reg, val, 1);
} }
static int af9013_write_ofsm_regs(struct af9013_state *state, u16 reg, u8 *val, static int af9013_write_ofsm_regs(struct af9013_state *state, u16 reg, u8 *val,
...@@ -226,12 +227,12 @@ static int af9013_rd_reg_bits(struct af9013_state *state, u16 reg, int pos, ...@@ -226,12 +227,12 @@ static int af9013_rd_reg_bits(struct af9013_state *state, u16 reg, int pos,
static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval) static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval)
{ {
struct i2c_client *client = state->client;
int ret; int ret;
u8 pos; u8 pos;
u16 addr; u16 addr;
dev_dbg(&state->client->dev, "%s: gpio=%d gpioval=%02x\n", dev_dbg(&client->dev, "gpio %u, gpioval %02x\n", gpio, gpioval);
__func__, gpio, gpioval);
/* /*
* GPIO0 & GPIO1 0xd735 * GPIO0 & GPIO1 0xd735
...@@ -249,8 +250,6 @@ static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval) ...@@ -249,8 +250,6 @@ static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval)
break; break;
default: default:
dev_err(&state->client->dev, "%s: invalid gpio=%d\n",
KBUILD_MODNAME, gpio);
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
...@@ -273,16 +272,17 @@ static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval) ...@@ -273,16 +272,17 @@ static int af9013_set_gpio(struct af9013_state *state, u8 gpio, u8 gpioval)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_power_ctrl(struct af9013_state *state, u8 onoff) static int af9013_power_ctrl(struct af9013_state *state, u8 onoff)
{ {
struct i2c_client *client = state->client;
int ret, i; int ret, i;
u8 tmp; u8 tmp;
dev_dbg(&state->client->dev, "%s: onoff=%d\n", __func__, onoff); dev_dbg(&client->dev, "onoff %d\n", onoff);
/* enable reset */ /* enable reset */
ret = af9013_wr_reg_bits(state, 0xd417, 4, 1, 1); ret = af9013_wr_reg_bits(state, 0xd417, 4, 1, 1);
...@@ -327,16 +327,17 @@ static int af9013_power_ctrl(struct af9013_state *state, u8 onoff) ...@@ -327,16 +327,17 @@ static int af9013_power_ctrl(struct af9013_state *state, u8 onoff)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_statistics_ber_unc_start(struct dvb_frontend *fe) static int af9013_statistics_ber_unc_start(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* reset and start BER counter */ /* reset and start BER counter */
ret = af9013_wr_reg_bits(state, 0xd391, 4, 1, 1); ret = af9013_wr_reg_bits(state, 0xd391, 4, 1, 1);
...@@ -345,17 +346,18 @@ static int af9013_statistics_ber_unc_start(struct dvb_frontend *fe) ...@@ -345,17 +346,18 @@ static int af9013_statistics_ber_unc_start(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe) static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
u8 buf[5]; u8 buf[5];
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* check if error bit count is ready */ /* check if error bit count is ready */
ret = af9013_rd_reg_bits(state, 0xd391, 4, 1, &buf[0]); ret = af9013_rd_reg_bits(state, 0xd391, 4, 1, &buf[0]);
...@@ -363,7 +365,7 @@ static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe) ...@@ -363,7 +365,7 @@ static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe)
goto err; goto err;
if (!buf[0]) { if (!buf[0]) {
dev_dbg(&state->client->dev, "%s: not ready\n", __func__); dev_dbg(&client->dev, "not ready\n");
return 0; return 0;
} }
...@@ -376,16 +378,17 @@ static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe) ...@@ -376,16 +378,17 @@ static int af9013_statistics_ber_unc_result(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_statistics_snr_start(struct dvb_frontend *fe) static int af9013_statistics_snr_start(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* start SNR meas */ /* start SNR meas */
ret = af9013_wr_reg_bits(state, 0xd2e1, 3, 1, 1); ret = af9013_wr_reg_bits(state, 0xd2e1, 3, 1, 1);
...@@ -394,19 +397,20 @@ static int af9013_statistics_snr_start(struct dvb_frontend *fe) ...@@ -394,19 +397,20 @@ static int af9013_statistics_snr_start(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_statistics_snr_result(struct dvb_frontend *fe) static int af9013_statistics_snr_result(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret, i, len; int ret, i, len;
u8 buf[3], tmp; u8 buf[3], tmp;
u32 snr_val; u32 snr_val;
const struct af9013_snr *uninitialized_var(snr_lut); const struct af9013_snr *uninitialized_var(snr_lut);
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* check if SNR ready */ /* check if SNR ready */
ret = af9013_rd_reg_bits(state, 0xd2e1, 3, 1, &tmp); ret = af9013_rd_reg_bits(state, 0xd2e1, 3, 1, &tmp);
...@@ -414,7 +418,7 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe) ...@@ -414,7 +418,7 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe)
goto err; goto err;
if (!tmp) { if (!tmp) {
dev_dbg(&state->client->dev, "%s: not ready\n", __func__); dev_dbg(&client->dev, "not ready\n");
return 0; return 0;
} }
...@@ -457,18 +461,19 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe) ...@@ -457,18 +461,19 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_statistics_signal_strength(struct dvb_frontend *fe) static int af9013_statistics_signal_strength(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret = 0; int ret = 0;
u8 buf[2], rf_gain, if_gain; u8 buf[2], rf_gain, if_gain;
int signal_strength; int signal_strength;
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
if (!state->signal_strength_en) if (!state->signal_strength_en)
return 0; return 0;
...@@ -494,7 +499,7 @@ static int af9013_statistics_signal_strength(struct dvb_frontend *fe) ...@@ -494,7 +499,7 @@ static int af9013_statistics_signal_strength(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
...@@ -559,14 +564,15 @@ static int af9013_get_tune_settings(struct dvb_frontend *fe, ...@@ -559,14 +564,15 @@ static int af9013_get_tune_settings(struct dvb_frontend *fe,
static int af9013_set_frontend(struct dvb_frontend *fe) static int af9013_set_frontend(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret, i, sampling_freq; int ret, i, sampling_freq;
bool auto_mode, spec_inv; bool auto_mode, spec_inv;
u8 buf[6]; u8 buf[6];
u32 if_frequency, freq_cw; u32 if_frequency, freq_cw;
dev_dbg(&state->client->dev, "%s: frequency=%d bandwidth_hz=%d\n", dev_dbg(&client->dev, "frequency %u, bandwidth_hz %u\n",
__func__, c->frequency, c->bandwidth_hz); c->frequency, c->bandwidth_hz);
/* program tuner */ /* program tuner */
if (fe->ops.tuner_ops.set_params) if (fe->ops.tuner_ops.set_params)
...@@ -599,8 +605,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -599,8 +605,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
else else
if_frequency = state->if_frequency; if_frequency = state->if_frequency;
dev_dbg(&state->client->dev, "%s: if_frequency=%d\n", dev_dbg(&client->dev, "if_frequency %u\n", if_frequency);
__func__, if_frequency);
sampling_freq = if_frequency; sampling_freq = if_frequency;
...@@ -673,8 +678,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -673,8 +678,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[0] |= (1 << 0); buf[0] |= (1 << 0);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid transmission_mode\n", dev_dbg(&client->dev, "invalid transmission_mode\n");
__func__);
auto_mode = true; auto_mode = true;
} }
...@@ -694,8 +698,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -694,8 +698,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[0] |= (3 << 2); buf[0] |= (3 << 2);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid guard_interval\n", dev_dbg(&client->dev, "invalid guard_interval\n");
__func__);
auto_mode = true; auto_mode = true;
} }
...@@ -715,7 +718,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -715,7 +718,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[0] |= (3 << 4); buf[0] |= (3 << 4);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid hierarchy\n", __func__); dev_dbg(&client->dev, "invalid hierarchy\n");
auto_mode = true; auto_mode = true;
} }
...@@ -732,7 +735,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -732,7 +735,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[1] |= (2 << 6); buf[1] |= (2 << 6);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid modulation\n", __func__); dev_dbg(&client->dev, "invalid modulation\n");
auto_mode = true; auto_mode = true;
} }
...@@ -758,8 +761,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -758,8 +761,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[2] |= (4 << 0); buf[2] |= (4 << 0);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid code_rate_HP\n", dev_dbg(&client->dev, "invalid code_rate_HP\n");
__func__);
auto_mode = true; auto_mode = true;
} }
...@@ -784,8 +786,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -784,8 +786,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
case FEC_NONE: case FEC_NONE:
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid code_rate_LP\n", dev_dbg(&client->dev, "invalid code_rate_LP\n");
__func__);
auto_mode = true; auto_mode = true;
} }
...@@ -799,8 +800,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -799,8 +800,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
buf[1] |= (2 << 2); buf[1] |= (2 << 2);
break; break;
default: default:
dev_dbg(&state->client->dev, "%s: invalid bandwidth_hz\n", dev_dbg(&client->dev, "invalid bandwidth_hz\n");
__func__);
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
...@@ -815,7 +815,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -815,7 +815,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
if (ret) if (ret)
goto err; goto err;
dev_dbg(&state->client->dev, "%s: auto params\n", __func__); dev_dbg(&client->dev, "auto params\n");
} else { } else {
/* set easy mode flag */ /* set easy mode flag */
ret = af9013_wr_reg(state, 0xaefd, 1); ret = af9013_wr_reg(state, 0xaefd, 1);
...@@ -826,7 +826,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -826,7 +826,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
if (ret) if (ret)
goto err; goto err;
dev_dbg(&state->client->dev, "%s: manual params\n", __func__); dev_dbg(&client->dev, "manual params\n");
} }
/* tune */ /* tune */
...@@ -840,7 +840,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe) ...@@ -840,7 +840,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
...@@ -848,10 +848,11 @@ static int af9013_get_frontend(struct dvb_frontend *fe, ...@@ -848,10 +848,11 @@ static int af9013_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c) struct dtv_frontend_properties *c)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
u8 buf[3]; u8 buf[3];
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
ret = af9013_rd_regs(state, 0xd3c0, buf, 3); ret = af9013_rd_regs(state, 0xd3c0, buf, 3);
if (ret) if (ret)
...@@ -957,13 +958,14 @@ static int af9013_get_frontend(struct dvb_frontend *fe, ...@@ -957,13 +958,14 @@ static int af9013_get_frontend(struct dvb_frontend *fe,
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status) static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
u8 tmp; u8 tmp;
...@@ -1007,7 +1009,7 @@ static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -1007,7 +1009,7 @@ static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
...@@ -1042,12 +1044,13 @@ static int af9013_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) ...@@ -1042,12 +1044,13 @@ static int af9013_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
static int af9013_init(struct dvb_frontend *fe) static int af9013_init(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret, i, len; int ret, i, len;
u8 buf[3], tmp; u8 buf[3], tmp;
u32 adc_cw; u32 adc_cw;
const struct af9013_reg_bit *init; const struct af9013_reg_bit *init;
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* power on */ /* power on */
ret = af9013_power_ctrl(state, 1); ret = af9013_power_ctrl(state, 1);
...@@ -1079,9 +1082,8 @@ static int af9013_init(struct dvb_frontend *fe) ...@@ -1079,9 +1082,8 @@ static int af9013_init(struct dvb_frontend *fe)
tmp = 3; tmp = 3;
break; break;
default: default:
dev_err(&state->client->dev, "%s: invalid clock\n", ret = -EINVAL;
KBUILD_MODNAME); goto err;
return -EINVAL;
} }
adc_cw = div_u64((u64)state->clk * 0x80000, 1000000); adc_cw = div_u64((u64)state->clk * 0x80000, 1000000);
...@@ -1139,7 +1141,7 @@ static int af9013_init(struct dvb_frontend *fe) ...@@ -1139,7 +1141,7 @@ static int af9013_init(struct dvb_frontend *fe)
goto err; goto err;
/* load OFSM settings */ /* load OFSM settings */
dev_dbg(&state->client->dev, "%s: load ofsm settings\n", __func__); dev_dbg(&client->dev, "load ofsm settings\n");
len = ARRAY_SIZE(ofsm_init); len = ARRAY_SIZE(ofsm_init);
init = ofsm_init; init = ofsm_init;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
...@@ -1150,8 +1152,7 @@ static int af9013_init(struct dvb_frontend *fe) ...@@ -1150,8 +1152,7 @@ static int af9013_init(struct dvb_frontend *fe)
} }
/* load tuner specific settings */ /* load tuner specific settings */
dev_dbg(&state->client->dev, "%s: load tuner specific settings\n", dev_dbg(&client->dev, "load tuner specific settings\n");
__func__);
switch (state->tuner) { switch (state->tuner) {
case AF9013_TUNER_MXL5003D: case AF9013_TUNER_MXL5003D:
len = ARRAY_SIZE(tuner_init_mxl5003d); len = ARRAY_SIZE(tuner_init_mxl5003d);
...@@ -1262,16 +1263,17 @@ static int af9013_init(struct dvb_frontend *fe) ...@@ -1262,16 +1263,17 @@ static int af9013_init(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
static int af9013_sleep(struct dvb_frontend *fe) static int af9013_sleep(struct dvb_frontend *fe)
{ {
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret; int ret;
dev_dbg(&state->client->dev, "%s:\n", __func__); dev_dbg(&client->dev, "\n");
/* stop statistics polling */ /* stop statistics polling */
cancel_delayed_work_sync(&state->statistics_work); cancel_delayed_work_sync(&state->statistics_work);
...@@ -1288,7 +1290,7 @@ static int af9013_sleep(struct dvb_frontend *fe) ...@@ -1288,7 +1290,7 @@ static int af9013_sleep(struct dvb_frontend *fe)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
...@@ -1296,8 +1298,9 @@ static int af9013_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -1296,8 +1298,9 @@ static int af9013_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{ {
int ret; int ret;
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
dev_dbg(&state->client->dev, "%s: enable=%d\n", __func__, enable); dev_dbg(&client->dev, "enable %d\n", enable);
/* gate already open or close */ /* gate already open or close */
if (state->i2c_gate_state == enable) if (state->i2c_gate_state == enable)
...@@ -1314,7 +1317,7 @@ static int af9013_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -1314,7 +1317,7 @@ static int af9013_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
return ret; return ret;
err: err:
dev_dbg(&state->client->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&client->dev, "failed %d\n", ret);
return ret; return ret;
} }
...@@ -1323,6 +1326,8 @@ static void af9013_release(struct dvb_frontend *fe) ...@@ -1323,6 +1326,8 @@ static void af9013_release(struct dvb_frontend *fe)
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client; struct i2c_client *client = state->client;
dev_dbg(&client->dev, "\n");
i2c_unregister_device(client); i2c_unregister_device(client);
} }
...@@ -1330,6 +1335,7 @@ static const struct dvb_frontend_ops af9013_ops; ...@@ -1330,6 +1335,7 @@ static const struct dvb_frontend_ops af9013_ops;
static int af9013_download_firmware(struct af9013_state *state) static int af9013_download_firmware(struct af9013_state *state)
{ {
struct i2c_client *client = state->client;
int i, len, remaining, ret; int i, len, remaining, ret;
const struct firmware *fw; const struct firmware *fw;
u16 checksum = 0; u16 checksum = 0;
...@@ -1343,28 +1349,24 @@ static int af9013_download_firmware(struct af9013_state *state) ...@@ -1343,28 +1349,24 @@ static int af9013_download_firmware(struct af9013_state *state)
if (ret) if (ret)
goto err; goto err;
else else
dev_dbg(&state->client->dev, "%s: firmware status=%02x\n", dev_dbg(&client->dev, "firmware status %02x\n", val);
__func__, val);
if (val == 0x0c) /* fw is running, no need for download */ if (val == 0x0c) /* fw is running, no need for download */
goto exit; goto exit;
dev_info(&state->client->dev, "%s: found a '%s' in cold state, will try " \ dev_info(&client->dev, "found a '%s' in cold state, will try to load a firmware\n",
"to load a firmware\n", af9013_ops.info.name);
KBUILD_MODNAME, af9013_ops.info.name);
/* request the firmware, this will block and timeout */ /* request the firmware, this will block and timeout */
ret = request_firmware(&fw, fw_file, &state->client->dev); ret = request_firmware(&fw, fw_file, &client->dev);
if (ret) { if (ret) {
dev_info(&state->client->dev, "%s: did not find the firmware " \ dev_info(&client->dev, "firmware file '%s' not found %d\n",
"file. (%s) Please see linux/Documentation/dvb/ for " \ fw_file, ret);
"more details on firmware-problems. (%d)\n",
KBUILD_MODNAME, fw_file, ret);
goto err; goto err;
} }
dev_info(&state->client->dev, "%s: downloading firmware from file '%s'\n", dev_info(&client->dev, "downloading firmware from file '%s'\n",
KBUILD_MODNAME, fw_file); fw_file);
/* calc checksum */ /* calc checksum */
for (i = 0; i < fw->size; i++) for (i = 0; i < fw->size; i++)
...@@ -1392,9 +1394,8 @@ static int af9013_download_firmware(struct af9013_state *state) ...@@ -1392,9 +1394,8 @@ static int af9013_download_firmware(struct af9013_state *state)
FW_ADDR + fw->size - remaining, FW_ADDR + fw->size - remaining,
(u8 *) &fw->data[fw->size - remaining], len); (u8 *) &fw->data[fw->size - remaining], len);
if (ret) { if (ret) {
dev_err(&state->client->dev, dev_err(&client->dev, "firmware download failed %d\n",
"%s: firmware download failed=%d\n", ret);
KBUILD_MODNAME, ret);
goto err_release; goto err_release;
} }
} }
...@@ -1412,20 +1413,17 @@ static int af9013_download_firmware(struct af9013_state *state) ...@@ -1412,20 +1413,17 @@ static int af9013_download_firmware(struct af9013_state *state)
if (ret) if (ret)
goto err_release; goto err_release;
dev_dbg(&state->client->dev, "%s: firmware status=%02x\n", dev_dbg(&client->dev, "firmware status %02x\n", val);
__func__, val);
if (val == 0x0c || val == 0x04) /* success or fail */ if (val == 0x0c || val == 0x04) /* success or fail */
break; break;
} }
if (val == 0x04) { if (val == 0x04) {
dev_err(&state->client->dev, "%s: firmware did not run\n", dev_err(&client->dev, "firmware did not run\n");
KBUILD_MODNAME);
ret = -ENODEV; ret = -ENODEV;
} else if (val != 0x0c) { } else if (val != 0x0c) {
dev_err(&state->client->dev, "%s: firmware boot timeout\n", dev_err(&client->dev, "firmware boot timeout\n");
KBUILD_MODNAME);
ret = -ENODEV; ret = -ENODEV;
} }
...@@ -1434,8 +1432,8 @@ static int af9013_download_firmware(struct af9013_state *state) ...@@ -1434,8 +1432,8 @@ static int af9013_download_firmware(struct af9013_state *state)
err: err:
exit: exit:
if (!ret) if (!ret)
dev_info(&state->client->dev, "%s: found a '%s' in warm state\n", dev_info(&client->dev, "found a '%s' in warm state\n",
KBUILD_MODNAME, af9013_ops.info.name); af9013_ops.info.name);
return ret; return ret;
} }
......
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