public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Wolfram Sang <wsa@kernel.org>,
	kernel@pengutronix.de, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 7/9] i2c: Switch .probe() to not take an id parameter
Date: Fri, 24 Feb 2023 17:02:18 +0100	[thread overview]
Message-ID: <20230224170218.22c0af0c@booty> (raw)
In-Reply-To: <20230224120600.1681685-8-u.kleine-koenig@pengutronix.de>

Hi Uwe,

On Fri, 24 Feb 2023 13:05:58 +0100
Uwe Kleine-König         <u.kleine-koenig@pengutronix.de> wrote:

> Commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back
> type") introduced a new probe callback to convert i2c init routines to
> not take an i2c_device_id parameter. Now that all in-tree drivers are
> converted to the temporary .probe_new() callback, .probe() can be
> modified to match the desired prototype.
> 
> Now that .probe() and .probe_new() have the same semantic, they can be
> defined as members of an anonymous union to save some memory and
> simplify the core code a bit.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thank you, I love this cleanup!

> ---
>  drivers/i2c/i2c-core-base.c | 11 ++---------
>  include/linux/i2c.h         | 14 +++++++++-----
>  2 files changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 087e480b624c..1fbe16221085 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -558,15 +558,8 @@ static int i2c_device_probe(struct device *dev)
>  		goto err_detach_pm_domain;
>  	}
>  
> -	/*
> -	 * When there are no more users of probe(),
> -	 * rename probe_new to probe.
> -	 */
> -	if (driver->probe_new)
> -		status = driver->probe_new(client);
> -	else if (driver->probe)
> -		status = driver->probe(client,
> -				       i2c_match_id(driver->id_table, client));
> +	if (driver->probe)
> +		status = driver->probe(client);
>  	else
>  		status = -EINVAL;
>  
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index d84e0e99f084..c3e022d53182 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -272,14 +272,18 @@ enum i2c_driver_flags {
>  struct i2c_driver {
>  	unsigned int class;
>  
> +	union {
>  	/* Standard driver model interfaces */
> -	int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
> +		int (*probe)(struct i2c_client *client);
> +		/*
> +		 * Legacy callback that was part of a conversion of .probe().
> +		 * Today it has the same semantic as .probe(). Don't use for new
> +		 * code.
> +		 */
> +		int (*probe_new)(struct i2c_client *client);
> +	};
>  	void (*remove)(struct i2c_client *client);
>  
> -	/* New driver model interface to aid the seamless removal of the
> -	 * current probe()'s, more commonly unused than used second parameter.
> -	 */
> -	int (*probe_new)(struct i2c_client *client);

The kerneldoc for this struct should also be updated:

- * @probe: Callback for device binding - soon to be deprecated
- * @probe_new: New callback for device binding
+ * @probe: Callback for device binding 
+ * @probe_new: Transitional callback for device binding - do not use

Otherwise LGTM.

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2023-02-24 16:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 12:05 [PATCH 0/9] i2c: Switch .probe() to not take an id parameter Uwe Kleine-König
2023-02-24 12:05 ` [PATCH 1/9] misc: ad525x_dpot-i2c: Convert to i2c's .probe_new() Uwe Kleine-König
2023-02-24 12:05 ` [PATCH 2/9] mtd: maps: pismo: " Uwe Kleine-König
2023-02-24 12:05 ` [PATCH 3/9] serial: sc16is7xx: " Uwe Kleine-König
2023-02-24 12:05 ` [PATCH 4/9] w1: ds2482: " Uwe Kleine-König
2023-02-27 12:36   ` Jean Delvare
2023-02-24 12:05 ` [PATCH 5/9] media: i2c: ov5695: convert " Uwe Kleine-König
2023-02-24 12:41   ` Hans Verkuil
2023-02-24 12:05 ` [PATCH 6/9] media: i2c: ov2685: " Uwe Kleine-König
2023-02-24 12:41   ` Hans Verkuil
2023-02-24 12:05 ` [PATCH 7/9] i2c: Switch .probe() to not take an id parameter Uwe Kleine-König
2023-02-24 16:02   ` Luca Ceresoli [this message]
2023-02-24 18:03     ` Uwe Kleine-König
2023-02-24 12:05 ` [PATCH 8/9] i2c: mux: Convert all drivers to new .probe() callback Uwe Kleine-König
2023-02-24 15:23   ` Guenter Roeck
2023-02-24 15:51   ` Peter Rosin
2023-02-24 12:06 ` [PATCH 9/9] i2c: Convert " Uwe Kleine-König

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=20230224170218.22c0af0c@booty \
    --to=luca.ceresoli@bootlin.com \
    --cc=kernel@pengutronix.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wsa@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox