mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/7] led: pca955x: fix probing from device tree
Date: Tue, 29 Sep 2020 09:19:45 +0200	[thread overview]
Message-ID: <20200929071945.GT11648@pengutronix.de> (raw)
In-Reply-To: <20200928154247.15619-2-a.fatoum@pengutronix.de>

On Mon, Sep 28, 2020 at 05:42:42PM +0200, Ahmad Fatoum wrote:
> dev->id_entry is not populated for devices probed from the device
> tree. It was used unconditionally however. Use device_get_match_data
> instead to support device tree probing.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/led/led-pca955x.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/led/led-pca955x.c b/drivers/led/led-pca955x.c
> index 27fefce8d524..f89fcbfba5ac 100644
> --- a/drivers/led/led-pca955x.c
> +++ b/drivers/led/led-pca955x.c
> @@ -349,8 +349,11 @@ static int led_pca955x_probe(struct device_d *dev)
>  	struct i2c_client *client;
>  	int err;
>  	struct pca955x_platform_data *pdata;
> +	enum pca955x_type type;
>  
> -	chip = &pca955x_chipdefs[dev->id_entry->driver_data];
> +	type = (enum pca955x_type)device_get_match_data(dev);

In this driver we have this:

static struct pca955x_chipdef pca955x_chipdefs[] = {
	[pca9550] = {
		.bits		= 2,
		.slv_addr	= /* 110000x */ 0x60,
		.slv_addr_shift	= 1,
	},
	[pca9551] = {
		.bits		= 8,
		.slv_addr	= /* 1100xxx */ 0x60,
		.slv_addr_shift	= 3,
	},
	[pca9552] = {
		.bits		= 16,
		.slv_addr	= /* 1100xxx */ 0x60,
		.slv_addr_shift	= 3,
	},
	[pca9553] = {
		.bits		= 4,
		.slv_addr	= /* 110001x */ 0x62,
		.slv_addr_shift	= 1,
	},
};

So instead of putting the enum casted to void pointer into the matchdata
we could put pointers to struct pca955x_chipdef directly into the
matchdata.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-09-29  7:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 15:42 [PATCH 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 2/7] led: pca955x: fix probing from device tree Ahmad Fatoum
2020-09-29  7:19   ` Sascha Hauer [this message]
2020-09-30  7:28     ` Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 3/7] dma: apbh: fix out-of-bounds write on 64-bit SoCs Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 4/7] aiodev: lm75: " Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 5/7] mtd: nand-mxs: " Ahmad Fatoum
2020-09-28 16:01   ` Marco Felsch
2020-09-28 16:03     ` Ahmad Fatoum
2020-09-28 16:08       ` Marco Felsch
2020-09-28 15:42 ` [PATCH 6/7] video: imx-hdmi: fix dev_get_drvdata misuse Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 7/7] driver: migrate some from dev_get_drvdata to device_get_match_data Ahmad Fatoum
2020-09-28 15:46 ` [PATCH 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-09-29  6:45 ` Sascha Hauer
2020-09-29  7:32 ` Sascha Hauer
2020-09-29  9:42   ` Ahmad Fatoum
2020-09-30  7:48     ` Sascha Hauer
2020-09-30 13:13       ` Ahmad Fatoum
2020-10-05  8:31         ` Ahmad Fatoum
2020-10-07  8:43           ` Sascha Hauer

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=20200929071945.GT11648@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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