From: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Karol Lewandowski <k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: t.stanislaws-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH 2/3] i2c-s3c2410: Rework device type handling
Date: Tue, 17 Apr 2012 19:31:36 +0200 [thread overview]
Message-ID: <20120417173136.GB22406@pengutronix.de> (raw)
In-Reply-To: <1332357113-2973-3-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 5069 bytes --]
Hi,
On Wed, Mar 21, 2012 at 08:11:52PM +0100, Karol Lewandowski wrote:
> Reorganize driver a bit to better handle device tree-based systems:
>
> - move machine type to driver's private structure instead of
> quering platform device variants in runtime
>
> - replace s3c24xx_i2c_type enum with unsigned int that holds
> bitmask with revision-specific quirks
>
> Signed-off-by: Karol Lewandowski <k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Kyungmin Park <kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Okay, so this driver needs to the 'data' field from either
platform_device_id or of_device_id and implements a function for that,
namely s3c24xx_get_device_quirks(). Grant, Rob: I'd think there might be
more drivers in need of that, so maybe it makes sense to have a generic
of-helper function?
> ---
> drivers/i2c/busses/i2c-s3c2410.c | 47 ++++++++++++++++++-------------------
> 1 files changed, 23 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 85e3664..f7b6a14 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -44,8 +44,14 @@
> #include <plat/regs-iic.h>
> #include <plat/iic.h>
>
> -/* i2c controller state */
> +#ifdef CONFIG_OF
> +static const struct of_device_id s3c24xx_i2c_match[];
> +#endif
Uh, forward declaration with #ifdef. I'd think we should get this simply
to the front.
> dd
> +/* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
> +#define QUIRK_S3C2440 (1 << 0)
Minor: Is it really a quirk being s3c2440? Maybe FLAG_*, dunno.
> +
> +/* i2c controller state */
> enum s3c24xx_i2c_state {
> STATE_IDLE,
> STATE_START,
> @@ -54,14 +60,10 @@ enum s3c24xx_i2c_state {
> STATE_STOP
> };
>
> -enum s3c24xx_i2c_type {
> - TYPE_S3C2410,
> - TYPE_S3C2440,
> -};
> -
> struct s3c24xx_i2c {
> spinlock_t lock;
> wait_queue_head_t wait;
> + unsigned int quirks;
> unsigned int suspended:1;
>
> struct i2c_msg *msg;
> @@ -88,26 +90,22 @@ struct s3c24xx_i2c {
> #endif
> };
>
> -/* default platform data removed, dev should always carry data. */
> -
> -/* s3c24xx_i2c_is2440()
> +/* s3c24xx_get_device_quirks
> *
> - * return true is this is an s3c2440
> + * Get controller type either from device tree or platform device variant.
> */
>
> -static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
> +static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pdev)
> {
> - struct platform_device *pdev = to_platform_device(i2c->dev);
> - enum s3c24xx_i2c_type type;
> -
> #ifdef CONFIG_OF
> - if (i2c->dev->of_node)
> - return of_device_is_compatible(i2c->dev->of_node,
> - "samsung,s3c2440-i2c");
> + if (pdev->dev.of_node) {
> + const struct of_device_id *match;
> + match = of_match_node(&s3c24xx_i2c_match[0], pdev->dev.of_node);
Minor: I think it is more readable to drop the [0]
> + return (unsigned int)match->data;
> + }
> #endif
>
> - type = platform_get_device_id(pdev)->driver_data;
> - return type == TYPE_S3C2440;
> + return platform_get_device_id(pdev)->driver_data;
> }
>
> /* s3c24xx_i2c_master_complete
> @@ -676,7 +674,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
>
> writel(iiccon, i2c->regs + S3C2410_IICCON);
>
> - if (s3c24xx_i2c_is2440(i2c)) {
> + if (i2c->quirks & QUIRK_S3C2440) {
> unsigned long sda_delay;
>
> if (pdata->sda_delay) {
> @@ -906,6 +904,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
> goto err_noclk;
> }
>
> + i2c->quirks = s3c24xx_get_device_quirks(pdev);
> if (pdata)
> memcpy(i2c->pdata, pdata, sizeof(*pdata));
> else
> @@ -1113,18 +1112,18 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
> static struct platform_device_id s3c24xx_driver_ids[] = {
> {
> .name = "s3c2410-i2c",
> - .driver_data = TYPE_S3C2410,
> + .driver_data = 0,
> }, {
> .name = "s3c2440-i2c",
> - .driver_data = TYPE_S3C2440,
> + .driver_data = QUIRK_S3C2440,
> }, { },
> };
> MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
>
> #ifdef CONFIG_OF
> static const struct of_device_id s3c24xx_i2c_match[] = {
> - { .compatible = "samsung,s3c2410-i2c" },
> - { .compatible = "samsung,s3c2440-i2c" },
> + { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
> + { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
Hmm, the need to sepcify the quirks twice may lead to only one instance
being updated in future patches, but I don't see a way around that,
currently :(
> {},
> };
> MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
> --
> 1.7.9
>
Thanks,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
next prev parent reply other threads:[~2012-04-17 17:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 19:11 [PATCH v3 0/3] i2c-s3c2410: Updates for exynos4210 and DT-based systems Karol Lewandowski
2012-03-21 19:11 ` [PATCH 2/3] i2c-s3c2410: Rework device type handling Karol Lewandowski
[not found] ` <1332357113-2973-3-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-21 20:30 ` Mark Brown
2012-04-17 17:31 ` Wolfram Sang [this message]
[not found] ` <20120417173136.GB22406-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-18 11:55 ` Karol Lewandowski
2012-04-18 13:39 ` Wolfram Sang
[not found] ` <1332357113-2973-1-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-21 19:11 ` [PATCH 1/3] i2c-s3c2410: Drop unused define Karol Lewandowski
[not found] ` <1332357113-2973-2-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-04-18 10:56 ` Wolfram Sang
2012-03-21 19:11 ` [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 Karol Lewandowski
2012-04-17 17:40 ` Wolfram Sang
[not found] ` <20120417174029.GC22406-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-18 12:11 ` Marek Szyprowski
2012-04-18 13:46 ` Wolfram Sang
[not found] ` <20120418134644.GB19220-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-18 16:31 ` Karol Lewandowski
2012-04-23 10:01 ` Wolfram Sang
2012-04-23 16:22 ` Karol Lewandowski
2012-04-13 9:30 ` [PATCH v3 0/3] i2c-s3c2410: Updates for exynos4210 and DT-based systems Karol Lewandowski
-- strict thread matches above, loose matches on Subject: below --
2012-03-13 16:54 [PATCH 0/3 v2] " Karol Lewandowski
2012-03-13 16:54 ` [PATCH 2/3] i2c-s3c2410: Rework device type handling Karol Lewandowski
[not found] ` <1331657679-31302-3-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-14 17:29 ` Mark Brown
[not found] ` <20120314172915.GB13393-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-03-15 10:04 ` Karol Lewandowski
[not found] ` <4F61BEC8.4030008-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-15 12:56 ` Mark Brown
[not found] ` <20120315125630.GK3138-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-03-15 16:54 ` Karol Lewandowski
2012-03-19 19:55 ` Mark Brown
2012-03-21 10:33 ` Karol Lewandowski
[not found] ` <4F69AE96.6060901-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-21 11:50 ` Mark Brown
2012-03-21 11:54 ` Karol Lewandowski
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=20120417173136.GB22406@pengutronix.de \
--to=w.sang-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=t.stanislaws-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).