All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Kieran Bingham <kieran.bingham@ideasonboard.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-i2c@vger.kernel.org, Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] i2c: replace i2c_new_secondary_device with an ERR_PTR variant
Date: Thu, 8 Aug 2019 17:57:09 +0200	[thread overview]
Message-ID: <20190808155709.GA1316@ninjato> (raw)
In-Reply-To: <9b71c556-bd70-4d29-dba5-fbeaefb5f3b4@ideasonboard.com>

[-- Attachment #1: Type: text/plain, Size: 7902 bytes --]

On Tue, Jul 23, 2019 at 04:47:09PM +0100, Kieran Bingham wrote:
> Hi Wolfram,
> 
> On 22/07/2019 18:26, Wolfram Sang wrote:
> > In the general move to have i2c_new_*_device functions which return
> > ERR_PTR instead of NULL, this patch converts i2c_new_secondary_device().
> > 
> > There are only few users, so this patch converts the I2C core and all
> > users in one go. The function gets renamed to i2c_new_ancillary_device()
> > so out-of-tree users will get a build failure to understand they need to
> > adapt their error checking code.
> > 
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > ---
> > 
> > Kindly asking for acks/revs/tests from people knowing the modified
> > drivers.
> 
> Certainly, this looks good for the adv748x.
> 
> The ADV7511, and adv7604 are not mine, but they also look fine to me.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>


Thanks, Kieran! Gently pinging for acks for ADV7511 and ADV7604.


> 
> 
> >  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 18 +++++++++---------
> >  drivers/i2c/i2c-core-base.c                  | 10 +++++-----
> >  drivers/media/i2c/adv748x/adv748x-core.c     |  6 +++---
> >  drivers/media/i2c/adv7604.c                  | 10 +++++-----
> >  include/linux/i2c.h                          |  2 +-
> >  5 files changed, 23 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > index f6d2681f6927..9e13e466e72c 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > @@ -981,10 +981,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
> >  {
> >  	int ret;
> >  
> > -	adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec",
> > +	adv->i2c_cec = i2c_new_ancillary_device(adv->i2c_main, "cec",
> >  						ADV7511_CEC_I2C_ADDR_DEFAULT);
> > -	if (!adv->i2c_cec)
> > -		return -EINVAL;
> > +	if (IS_ERR(adv->i2c_cec))
> > +		return PTR_ERR(adv->i2c_cec);
> >  	i2c_set_clientdata(adv->i2c_cec, adv);
> >  
> >  	adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec,
> > @@ -1165,20 +1165,20 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >  
> >  	adv7511_packet_disable(adv7511, 0xffff);
> >  
> > -	adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid",
> > +	adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid",
> >  					ADV7511_EDID_I2C_ADDR_DEFAULT);
> > -	if (!adv7511->i2c_edid) {
> > -		ret = -EINVAL;
> > +	if (IS_ERR(adv7511->i2c_edid)) {
> > +		ret = PTR_ERR(adv7511->i2c_edid);
> >  		goto uninit_regulators;
> >  	}
> >  
> >  	regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
> >  		     adv7511->i2c_edid->addr << 1);
> >  
> > -	adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet",
> > +	adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet",
> >  					ADV7511_PACKET_I2C_ADDR_DEFAULT);
> > -	if (!adv7511->i2c_packet) {
> > -		ret = -EINVAL;
> > +	if (IS_ERR(adv7511->i2c_packet)) {
> > +		ret = PTR_ERR(adv7511->i2c_packet);
> >  		goto err_i2c_unregister_edid;
> >  	}
> >  
> > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> > index f26ed495d384..76cb91e064b8 100644
> > --- a/drivers/i2c/i2c-core-base.c
> > +++ b/drivers/i2c/i2c-core-base.c
> > @@ -966,7 +966,7 @@ struct i2c_client *devm_i2c_new_dummy_device(struct device *dev,
> >  EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device);
> >  
> >  /**
> > - * i2c_new_secondary_device - Helper to get the instantiated secondary address
> > + * i2c_new_ancillary_device - Helper to get the instantiated secondary address
> >   * and create the associated device
> >   * @client: Handle to the primary client
> >   * @name: Handle to specify which secondary address to get
> > @@ -985,9 +985,9 @@ EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device);
> >   * cell whose "reg-names" value matches the slave name.
> >   *
> >   * This returns the new i2c client, which should be saved for later use with
> > - * i2c_unregister_device(); or NULL to indicate an error.
> > + * i2c_unregister_device(); or an ERR_PTR to describe the error.
> >   */
> > -struct i2c_client *i2c_new_secondary_device(struct i2c_client *client,
> > +struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client,
> >  						const char *name,
> >  						u16 default_addr)
> >  {
> > @@ -1002,9 +1002,9 @@ struct i2c_client *i2c_new_secondary_device(struct i2c_client *client,
> >  	}
> >  
> >  	dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr);
> > -	return i2c_new_dummy(client->adapter, addr);
> > +	return i2c_new_dummy_device(client->adapter, addr);
> >  }
> > -EXPORT_SYMBOL_GPL(i2c_new_secondary_device);
> > +EXPORT_SYMBOL_GPL(i2c_new_ancillary_device);
> >  
> >  /* ------------------------------------------------------------------------- */
> >  
> > diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> > index f57cd77a32fa..2567de2b0037 100644
> > --- a/drivers/media/i2c/adv748x/adv748x-core.c
> > +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> > @@ -183,14 +183,14 @@ static int adv748x_initialise_clients(struct adv748x_state *state)
> >  	int ret;
> >  
> >  	for (i = ADV748X_PAGE_DPLL; i < ADV748X_PAGE_MAX; ++i) {
> > -		state->i2c_clients[i] = i2c_new_secondary_device(
> > +		state->i2c_clients[i] = i2c_new_ancillary_device(
> >  				state->client,
> >  				adv748x_default_addresses[i].name,
> >  				adv748x_default_addresses[i].default_addr);
> >  
> > -		if (state->i2c_clients[i] == NULL) {
> > +		if (IS_ERR(state->i2c_clients[i])) {
> >  			adv_err(state, "failed to create i2c client %u\n", i);
> > -			return -ENOMEM;
> > +			return PTR_ERR(state->i2c_clients[i]);
> >  		}
> >  
> >  		ret = adv748x_configure_regmap(state, i);
> > diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> > index 28a84bf9f8a9..8ed1d9b59dd2 100644
> > --- a/drivers/media/i2c/adv7604.c
> > +++ b/drivers/media/i2c/adv7604.c
> > @@ -2878,14 +2878,14 @@ static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd,
> >  	struct i2c_client *new_client;
> >  
> >  	if (pdata && pdata->i2c_addresses[page])
> > -		new_client = i2c_new_dummy(client->adapter,
> > +		new_client = i2c_new_dummy_device(client->adapter,
> >  					   pdata->i2c_addresses[page]);
> >  	else
> > -		new_client = i2c_new_secondary_device(client,
> > +		new_client = i2c_new_ancillary_device(client,
> >  				adv76xx_default_addresses[page].name,
> >  				adv76xx_default_addresses[page].default_addr);
> >  
> > -	if (new_client)
> > +	if (!IS_ERR(new_client))
> >  		io_write(sd, io_reg, new_client->addr << 1);
> >  
> >  	return new_client;
> > @@ -3520,8 +3520,8 @@ static int adv76xx_probe(struct i2c_client *client,
> >  			continue;
> >  
> >  		state->i2c_clients[i] = adv76xx_dummy_client(sd, i);
> > -		if (!state->i2c_clients[i]) {
> > -			err = -EINVAL;
> > +		if (IS_ERR(state->i2c_clients[i])) {
> > +			err = PTR_ERR(state->i2c_clients[i]);
> >  			v4l2_err(sd, "failed to create i2c client %u\n", i);
> >  			goto err_i2c;
> >  		}
> > diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> > index fa5552c2307b..ebbe024dd9e0 100644
> > --- a/include/linux/i2c.h
> > +++ b/include/linux/i2c.h
> > @@ -473,7 +473,7 @@ extern struct i2c_client *
> >  devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address);
> >  
> >  extern struct i2c_client *
> > -i2c_new_secondary_device(struct i2c_client *client,
> > +i2c_new_ancillary_device(struct i2c_client *client,
> >  				const char *name,
> >  				u16 default_addr);
> >  
> > 
> 
> -- 
> Regards
> --
> Kieran

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-08-08 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22 17:26 [PATCH] i2c: replace i2c_new_secondary_device with an ERR_PTR variant Wolfram Sang
2019-07-23 15:47 ` Kieran Bingham
2019-08-08 15:57   ` Wolfram Sang [this message]
2019-08-08 16:04     ` Laurent Pinchart
2019-08-09 15:41       ` Wolfram Sang

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=20190808155709.GA1316@ninjato \
    --to=wsa@the-dreams.de \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=wsa+renesas@sang-engineering.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.