Skip to content

Commit

Permalink
[media] dvb: don't require a parameter for get_frontend
Browse files Browse the repository at this point in the history
Just like set_frontend, use the dvb cache properties for get_frontend.
This is more consistent, as both functions are now symetric. Also,
at the places get_frontend is called, it makes sense to update the
cache.

Most of this patch were generated by this small perl script:

	while (<>) { $file .= $_; }
	if ($file =~ m/\.get_frontend\s*=\s*([\d\w_]+)/) {
		my $get = $1;
		$file =~ s/($get)(\s*\([^\,\)]+)\,\s*struct\s+dtv_frontend_properties\s*\*\s*([_\d\w]+)\)\s*\{/\1\2)\n{\n\tstruct dtv_frontend_properties *\3 = &fe->dtv_property_cache;/g;
	}
	print $file;

Of course, the changes at dvb_frontend.[ch] were made by hand,
as well as the changes on a few other places, where get_frontend()
is called internally inside the driver.

On some places, get_frontend() were just a void function. Those
occurrences were removed, as the DVB core handles such cases.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Dec 31, 2011
1 parent ac3852c commit 7c61d80
Show file tree
Hide file tree
Showing 57 changed files with 123 additions and 170 deletions.
3 changes: 2 additions & 1 deletion drivers/media/dvb/bt8xx/dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,9 @@ static int dst_get_tuning_algo(struct dvb_frontend *fe)
return dst_algo ? DVBFE_ALGO_HW : DVBFE_ALGO_SW;
}

static int dst_get_frontend(struct dvb_frontend *fe, struct dtv_frontend_properties *p)
static int dst_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct dst_state *state = fe->demodulator_priv;

p->frequency = state->decode_freq;
Expand Down
30 changes: 7 additions & 23 deletions drivers/media/dvb/dvb-core/dvb_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ struct dvb_frontend_private {

static void dvb_frontend_wakeup(struct dvb_frontend *fe);
static int dtv_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c,
struct dvb_frontend_parameters *p_out);

static bool has_get_frontend(struct dvb_frontend *fe)
Expand All @@ -161,7 +160,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
dprintk ("%s\n", __func__);

if ((status & FE_HAS_LOCK) && has_get_frontend(fe))
dtv_get_frontend(fe, NULL, &fepriv->parameters_out);
dtv_get_frontend(fe, &fepriv->parameters_out);

mutex_lock(&events->mtx);

Expand Down Expand Up @@ -1261,33 +1260,20 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe)
* If p_out is not null, it will update the DVBv3 params pointed by it.
*/
static int dtv_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c,
struct dvb_frontend_parameters *p_out)
{
const struct dtv_frontend_properties *cache = &fe->dtv_property_cache;
struct dtv_frontend_properties tmp_cache;
struct dvb_frontend_parameters tmp_out;
bool fill_params = (p_out != NULL);
int r;

if (!p_out)
p_out = &tmp_out;

if (!c)
c = &tmp_cache;
else
memcpy(c, cache, sizeof(*c));

if (fe->ops.get_frontend) {
r = fe->ops.get_frontend(fe, c);
r = fe->ops.get_frontend(fe);
if (unlikely(r < 0))
return r;
if (fill_params)
if (p_out)
dtv_property_legacy_params_sync(fe, p_out);
return 0;
}

/* As everything is in cache, this is always supported */
/* As everything is in cache, get_frontend fops are always supported */
return 0;
}

Expand Down Expand Up @@ -1717,8 +1703,6 @@ static int dvb_frontend_ioctl_properties(struct file *file,

} else
if(cmd == FE_GET_PROPERTY) {
struct dtv_frontend_properties cache_out;

tvps = (struct dtv_properties __user *)parg;

dprintk("%s() properties.num = %d\n", __func__, tvps->num);
Expand All @@ -1744,9 +1728,9 @@ static int dvb_frontend_ioctl_properties(struct file *file,
* Fills the cache out struct with the cache contents, plus
* the data retrieved from get_frontend.
*/
dtv_get_frontend(fe, &cache_out, NULL);
dtv_get_frontend(fe, NULL);
for (i = 0; i < tvps->num; i++) {
err = dtv_property_process_get(fe, &cache_out, tvp + i, file);
err = dtv_property_process_get(fe, c, tvp + i, file);
if (err < 0)
goto out;
(tvp + i)->result = err;
Expand Down Expand Up @@ -2043,7 +2027,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
break;

case FE_GET_FRONTEND:
err = dtv_get_frontend(fe, NULL, &fepriv->parameters_out);
err = dtv_get_frontend(fe, &fepriv->parameters_out);
if (err >= 0)
memcpy(parg, &fepriv->parameters_out,
sizeof(struct dvb_frontend_parameters));
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-core/dvb_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ struct dvb_frontend_ops {
int (*set_frontend)(struct dvb_frontend *fe);
int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);

int (*get_frontend)(struct dvb_frontend *fe, struct dtv_frontend_properties *props);
int (*get_frontend)(struct dvb_frontend *fe);

int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
int (*read_ber)(struct dvb_frontend* fe, u32* ber);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/dvb-usb/af9005-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,9 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe)
return 0;
}

static int af9005_fe_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *fep)
static int af9005_fe_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u8 temp;
Expand Down
7 changes: 0 additions & 7 deletions drivers/media/dvb/dvb-usb/cinergyT2-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,6 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
return (err < 0) ? err : 0;
}

static int cinergyt2_fe_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *fep)
{
return 0;
}

static void cinergyt2_fe_release(struct dvb_frontend *fe)
{
struct cinergyt2_fe_state *state = fe->demodulator_priv;
Expand Down Expand Up @@ -352,7 +346,6 @@ static struct dvb_frontend_ops cinergyt2_fe_ops = {
.sleep = cinergyt2_fe_sleep,

.set_frontend = cinergyt2_fe_set_frontend,
.get_frontend = cinergyt2_fe_get_frontend,
.get_tune_settings = cinergyt2_fe_get_tune_settings,

.read_status = cinergyt2_fe_read_status,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/dvb-usb/dtt200u-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ static int dtt200u_fe_set_frontend(struct dvb_frontend *fe)
return 0;
}

static int dtt200u_fe_get_frontend(struct dvb_frontend* fe,
struct dtv_frontend_properties *fep)
static int dtt200u_fe_get_frontend(struct dvb_frontend* fe)
{
struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
struct dtt200u_fe_state *state = fe->demodulator_priv;
memcpy(fep, &state->fep, sizeof(struct dtv_frontend_properties));
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/dvb-usb/friio-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ static int jdvbt90502_set_property(struct dvb_frontend *fe,
return r;
}

static int jdvbt90502_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *p)
static int jdvbt90502_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
p->inversion = INVERSION_AUTO;
p->bandwidth_hz = 6000000;
p->code_rate_HP = FEC_AUTO;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/dvb-usb/mxl111sf-demod.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ static int mxl111sf_demod_read_signal_strength(struct dvb_frontend *fe,
return 0;
}

static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *p)
static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct mxl111sf_demod_state *state = fe->demodulator_priv;

mxl_dbg("()");
Expand Down
8 changes: 0 additions & 8 deletions drivers/media/dvb/dvb-usb/vp702x-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,6 @@ static int vp702x_fe_sleep(struct dvb_frontend *fe)
return 0;
}

static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
struct dtv_frontend_properties *fep)
{
deb_fe("%s\n",__func__);
return 0;
}

static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
struct dvb_diseqc_master_cmd *m)
{
Expand Down Expand Up @@ -372,7 +365,6 @@ static struct dvb_frontend_ops vp702x_fe_ops = {
.sleep = vp702x_fe_sleep,

.set_frontend = vp702x_fe_set_frontend,
.get_frontend = vp702x_fe_get_frontend,
.get_tune_settings = vp702x_fe_get_tune_settings,

.read_status = vp702x_fe_read_status,
Expand Down
20 changes: 0 additions & 20 deletions drivers/media/dvb/firewire/firedtv-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ static int fdtv_set_frontend(struct dvb_frontend *fe)
return avc_tuner_dsd(fdtv, p);
}

static int fdtv_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *params)
{
return -EOPNOTSUPP;
}

static int fdtv_get_property(struct dvb_frontend *fe, struct dtv_property *tvp)
{
return 0;
}

static int fdtv_set_property(struct dvb_frontend *fe, struct dtv_property *tvp)
{
return 0;
}

void fdtv_frontend_init(struct firedtv *fdtv, const char *name)
{
struct dvb_frontend_ops *ops = &fdtv->fe.ops;
Expand All @@ -174,10 +158,6 @@ void fdtv_frontend_init(struct firedtv *fdtv, const char *name)
ops->sleep = fdtv_sleep;

ops->set_frontend = fdtv_set_frontend;
ops->get_frontend = fdtv_get_frontend;

ops->get_property = fdtv_get_property;
ops->set_property = fdtv_set_property;

ops->read_status = fdtv_read_status;
ops->read_ber = fdtv_read_ber;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/af9013.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,9 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
return ret;
}

static int af9013_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int af9013_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct af9013_state *state = fe->demodulator_priv;
int ret;
u8 buf[3];
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/atbm8830.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ static int atbm8830_set_fe(struct dvb_frontend *fe)
return 0;
}

static int atbm8830_get_fe(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int atbm8830_get_fe(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
dprintk("%s\n", __func__);

/* TODO: get real readings from device */
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/au8522_dig.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ static int au8522_read_ber(struct dvb_frontend *fe, u32 *ber)
return au8522_read_ucblocks(fe, ber);
}

static int au8522_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int au8522_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct au8522_state *state = fe->demodulator_priv;

c->frequency = state->current_frequency;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/cx22700.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ static int cx22700_set_frontend(struct dvb_frontend *fe)
return 0;
}

static int cx22700_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int cx22700_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx22700_state* state = fe->demodulator_priv;
u8 reg09 = cx22700_readreg (state, 0x09);

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/cx22702.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
return 0;
}

static int cx22702_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int cx22702_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx22702_state *state = fe->demodulator_priv;

u8 reg0C = cx22702_readreg(state, 0x0C);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/cx24110.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ static int cx24110_set_frontend(struct dvb_frontend *fe)
return 0;
}

static int cx24110_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *p)
static int cx24110_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct cx24110_state *state = fe->demodulator_priv;
s32 afc; unsigned sclk;

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/cx24123.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,9 @@ static int cx24123_set_frontend(struct dvb_frontend *fe)
return 0;
}

static int cx24123_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *p)
static int cx24123_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct cx24123_state *state = fe->demodulator_priv;

dprintk("\n");
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/dvb/frontends/cxd2820r_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ static int cxd2820r_read_status(struct dvb_frontend *fe, fe_status_t *status)
return ret;
}

static int cxd2820r_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
static int cxd2820r_get_frontend(struct dvb_frontend *fe)
{
int ret;

Expand Down
9 changes: 4 additions & 5 deletions drivers/media/dvb/frontends/dib3000mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
}
};

static int dib3000mb_get_frontend(struct dvb_frontend* fe,
struct dtv_frontend_properties *c);
static int dib3000mb_get_frontend(struct dvb_frontend* fe);

static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
{
Expand Down Expand Up @@ -360,7 +359,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);

if (search_state == 1) {
if (dib3000mb_get_frontend(fe, c) == 0) {
if (dib3000mb_get_frontend(fe) == 0) {
deb_setf("reading tuning data from frontend succeeded.\n");
return dib3000mb_set_frontend(fe, 0);
}
Expand Down Expand Up @@ -451,9 +450,9 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
return 0;
}

static int dib3000mb_get_frontend(struct dvb_frontend* fe,
struct dtv_frontend_properties *c)
static int dib3000mb_get_frontend(struct dvb_frontend* fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct dib3000_state* state = fe->demodulator_priv;
fe_code_rate_t *cr;
u16 tps_val;
Expand Down
10 changes: 4 additions & 6 deletions drivers/media/dvb/frontends/dib3000mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod,

EXPORT_SYMBOL(dib3000mc_get_tuner_i2c_master);

static int dib3000mc_get_frontend(struct dvb_frontend* fe,
struct dtv_frontend_properties *fep)
static int dib3000mc_get_frontend(struct dvb_frontend* fe)
{
struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
struct dib3000mc_state *state = fe->demodulator_priv;
u16 tps = dib3000mc_read_word(state,458);

Expand Down Expand Up @@ -689,7 +689,7 @@ static int dib3000mc_get_frontend(struct dvb_frontend* fe,

static int dib3000mc_set_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *fep = &fe->dtv_property_cache, tmp;
struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
struct dib3000mc_state *state = fe->demodulator_priv;
int ret;

Expand All @@ -712,8 +712,6 @@ static int dib3000mc_set_frontend(struct dvb_frontend *fe)
fep->code_rate_HP == FEC_AUTO) {
int i = 1000, found;

tmp = *fep;

dib3000mc_autosearch_start(fe);
do {
msleep(1);
Expand All @@ -724,7 +722,7 @@ static int dib3000mc_set_frontend(struct dvb_frontend *fe)
if (found == 0 || found == 1)
return 0; // no channel found

dib3000mc_get_frontend(fe, &tmp);
dib3000mc_get_frontend(fe);
}

ret = dib3000mc_tune(fe);
Expand Down
Loading

0 comments on commit 7c61d80

Please sign in to comment.