All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Daniel Scheller <d.scheller.oss@gmail.com>
Cc: linux-media@vger.kernel.org, mchehab@s-opensource.com
Subject: Re: [PATCH v2 08/12] [media] ngene: deduplicate I2C adapter evaluation
Date: Tue, 6 Mar 2018 13:06:15 -0300	[thread overview]
Message-ID: <20180306130615.25fd87b5@vento.lan> (raw)
In-Reply-To: <20180225123140.19486-9-d.scheller.oss@gmail.com>

Em Sun, 25 Feb 2018 13:31:36 +0100
Daniel Scheller <d.scheller.oss@gmail.com> escreveu:

> From: Daniel Scheller <d.scheller@gmx.net>
> 
> The I2C adapter evaluation (based on chan->number) is duplicated at
> several places (tuner_attach_() functions, demod_attach_stv0900() and
> cineS2_probe()). Clean this up by wrapping that construct in a separate
> function which all users of that can pass the ngene_channel pointer and
> get the correct I2C adapter from.

This patch doesn't apply. 

Please rebase from this point at the top of the media tree.

PS.: Perhaps I ended by merging an older version of some of your
patches, as I noticed that some e-mails got lost either by me or
by patch work along those days.

> 
> Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
> ---
>  drivers/media/pci/ngene/ngene-cards.c | 41 +++++++++++++----------------------
>  1 file changed, 15 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c
> index 00b100660784..dff55c7c9f86 100644
> --- a/drivers/media/pci/ngene/ngene-cards.c
> +++ b/drivers/media/pci/ngene/ngene-cards.c
> @@ -118,17 +118,25 @@ static int i2c_read_reg(struct i2c_adapter *adapter, u8 adr, u8 reg, u8 *val)
>  /* Demod/tuner attachment ***************************************************/
>  /****************************************************************************/
>  
> +static struct i2c_adapter *i2c_adapter_from_chan(struct ngene_channel *chan)
> +{
> +	/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
> +	if (chan->number < 2)
> +		return &chan->dev->channel[0].i2c_adapter;
> +
> +	return &chan->dev->channel[1].i2c_adapter;
> +}
> +
>  static int tuner_attach_stv6110(struct ngene_channel *chan)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct stv090x_config *feconf = (struct stv090x_config *)
>  		chan->dev->card_info->fe_config[chan->number];
>  	struct stv6110x_config *tunerconf = (struct stv6110x_config *)
>  		chan->dev->card_info->tuner_config[chan->number];
>  	const struct stv6110x_devctl *ctl;
>  
> -	/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
>  	if (chan->number < 2)
>  		i2c = &chan->dev->channel[0].i2c_adapter;
>  	else
> @@ -158,16 +166,10 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
>  static int tuner_attach_stv6111(struct ngene_channel *chan)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct dvb_frontend *fe;
>  	u8 adr = 4 + ((chan->number & 1) ? 0x63 : 0x60);
>  
> -	/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
> -	if (chan->number < 2)
> -		i2c = &chan->dev->channel[0].i2c_adapter;
> -	else
> -		i2c = &chan->dev->channel[1].i2c_adapter;
> -
>  	fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr);
>  	if (!fe) {
>  		fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr & ~4);
> @@ -197,10 +199,9 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
>  static int tuner_attach_tda18271(struct ngene_channel *chan)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct dvb_frontend *fe;
>  
> -	i2c = &chan->dev->channel[0].i2c_adapter;
>  	if (chan->fe->ops.i2c_gate_ctrl)
>  		chan->fe->ops.i2c_gate_ctrl(chan->fe, 1);
>  	fe = dvb_attach(tda18271c2dd_attach, chan->fe, i2c, 0x60);
> @@ -240,7 +241,7 @@ static int tuner_tda18212_ping(struct ngene_channel *chan,
>  static int tuner_attach_tda18212(struct ngene_channel *chan, u32 dmdtype)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct i2c_client *client;
>  	struct tda18212_config config = {
>  		.fe = chan->fe,
> @@ -262,12 +263,6 @@ static int tuner_attach_tda18212(struct ngene_channel *chan, u32 dmdtype)
>  	else
>  		board_info.addr = 0x60;
>  
> -	/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
> -	if (chan->number < 2)
> -		i2c = &chan->dev->channel[0].i2c_adapter;
> -	else
> -		i2c = &chan->dev->channel[1].i2c_adapter;
> -
>  	/*
>  	 * due to a hardware quirk with the I2C gate on the stv0367+tda18212
>  	 * combo, the tda18212 must be probed by reading it's id _twice_ when
> @@ -320,7 +315,7 @@ static int tuner_attach_probe(struct ngene_channel *chan)
>  static int demod_attach_stv0900(struct ngene_channel *chan)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct stv090x_config *feconf = (struct stv090x_config *)
>  		chan->dev->card_info->fe_config[chan->number];
>  
> @@ -620,7 +615,7 @@ static int port_has_xo2(struct i2c_adapter *i2c, u8 *type, u8 *id)
>  static int cineS2_probe(struct ngene_channel *chan)
>  {
>  	struct device *pdev = &chan->dev->pci_dev->dev;
> -	struct i2c_adapter *i2c;
> +	struct i2c_adapter *i2c = i2c_adapter_from_chan(chan);
>  	struct stv090x_config *fe_conf;
>  	u8 buf[3];
>  	u8 xo2_type, xo2_id, xo2_demodtype;
> @@ -628,12 +623,6 @@ static int cineS2_probe(struct ngene_channel *chan)
>  	struct i2c_msg i2c_msg = { .flags = 0, .buf = buf };
>  	int rc;
>  
> -	/* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
> -	if (chan->number < 2)
> -		i2c = &chan->dev->channel[0].i2c_adapter;
> -	else
> -		i2c = &chan->dev->channel[1].i2c_adapter;
> -
>  	if (port_has_xo2(i2c, &xo2_type, &xo2_id)) {
>  		xo2_id >>= 2;
>  		dev_dbg(pdev, "XO2 on channel %d (type %d, id %d)\n",



Thanks,
Mauro

  reply	other threads:[~2018-03-06 16:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-25 12:31 [PATCH v2 00/12] ngene-updates: Hardware support, TS buffer shift fix Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 01/12] [media] ngene: add two additional PCI IDs Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 02/12] [media] ngene: convert kernellog printing from printk() to dev_*() macros Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 03/12] [media] ngene: use defines to identify the demod_type Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 04/12] [media] ngene: support STV0367 DVB-C/T DuoFlex addons Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 05/12] [media] ngene: add XO2 module support Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 06/12] [media] ngene: add support for Sony CXD28xx-based DuoFlex modules Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 07/12] [media] ngene: add support for DuoFlex S2 V4 addon modules Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 08/12] [media] ngene: deduplicate I2C adapter evaluation Daniel Scheller
2018-03-06 16:06   ` Mauro Carvalho Chehab [this message]
2018-03-06 16:14     ` Mauro Carvalho Chehab
2018-02-25 12:31 ` [PATCH v2 09/12] [media] ngene: check for CXD2099AR presence before attaching Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 10/12] [media] ngene: don't treat non-existing demods as error Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 11/12] [media] ngene: move the tsin_exchange() stripcopy block into a function Daniel Scheller
2018-03-06 16:18   ` Mauro Carvalho Chehab
2018-02-25 12:31 ` [PATCH v2 12/12] [media] ngene: compensate for TS buffer offset shifts Daniel Scheller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306130615.25fd87b5@vento.lan \
    --to=mchehab@kernel.org \
    --cc=d.scheller.oss@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@s-opensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.