From: Karol Lewandowski <k.lewandowsk@samsung.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: ben-linux@fluff.org, thomas.abraham@linaro.org,
m.szyprowski@samsung.com, linux-kernel@vger.kernel.org,
linux-i2c@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
linux-samsung-soc@vger.kernel.org, t.stanislaws@samsung.com,
Kyungmin Park <kyungmin.park@samsung.com>,
w.sang@pengutronix.de
Subject: Re: [PATCH 2/3] i2c-s3c2410: Rework device type handling
Date: Wed, 21 Mar 2012 11:33:58 +0100 [thread overview]
Message-ID: <4F69AE96.6060901@samsung.com> (raw)
In-Reply-To: <20120319195540.GH12384@opensource.wolfsonmicro.com>
On 19.03.2012 20:55, Mark Brown wrote:
> On Thu, Mar 15, 2012 at 05:54:33PM +0100, Karol Lewandowski wrote:
>
>> If you consider code to be inherently less readable because of this
>> approach I'll rework it. If it's not a such big deal for you I would
>> prefer to keep it as is.
>
> The thing that was causing me to think the code was funny was mainly the
> fact that we're now combining both quirk based selection and chip type
> based selection into the same bitmask. If the chip types were quirks
> it'd probably not have looked odd, and that might just be a case of
> renaming them - I can't remember what they do.
What do you think about following changes, then?
diff --git a/drivers/i2c/busses/i2c-s3c2410.c
b/drivers/i2c/busses/i2c-s3c2410.c
index fa5f8c4..18c9760 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -48,12 +48,9 @@
static const struct of_device_id s3c24xx_i2c_match[];
#endif
-/* reserve lower 8 bits for device type, use remaining space for hw
quirks */
-#define TYPE_BITS 0x000000ff
-#define TYPE_S3C2410 0x00000001
-#define TYPE_S3C2440 0x00000002
-#define FLAG_HDMIPHY 0x00000100
-#define FLAG_NO_GPIO 0x00000200
+#define QUIRK_S3C2440 (1 << 0)
+#define QUIRK_HDMIPHY (1 << 1)
+#define QUIRK_NO_GPIO (1 << 2)
/* i2c controller state */
enum s3c24xx_i2c_state {
@@ -67,7 +64,7 @@ enum s3c24xx_i2c_state {
struct s3c24xx_i2c {
spinlock_t lock;
wait_queue_head_t wait;
- unsigned int type;
+ unsigned int quirks;
unsigned int suspended:1;
struct i2c_msg *msg;
@@ -94,22 +91,12 @@ struct s3c24xx_i2c {
#endif
};
-/* s3c24xx_i2c_is_type()
- *
- * return true if this controller is of specified type
-*/
-
-static inline int s3c24xx_i2c_is_type(struct s3c24xx_i2c *i2c, unsigned
int type)
-{
- return (i2c->type & TYPE_BITS) == type;
-}
-
-/* s3c24xx_get_device_type
+/* s3c24xx_get_device_quirks
*
* Get controller type either from device tree or platform device variant.
*/
-static inline unsigned int s3c24xx_get_device_type(struct
platform_device *pdev)
+static inline unsigned int s3c24xx_get_device_quirks(struct
platform_device *pdev)
{
#ifdef CONFIG_OF
if (pdev->dev.of_node) {
@@ -487,7 +474,7 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c
*i2c)
* the hangup is expected to happen, so waiting 400 ms
* causes only unnecessary system hangup
*/
- if (i2c->type & FLAG_HDMIPHY)
+ if (i2c->quirks & QUIRK_HDMIPHY)
timeout = 10;
while (timeout-- > 0) {
@@ -500,7 +487,7 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c
*i2c)
}
/* hang-up of bus dedicated for HDMIPHY occurred, resetting */
- if (i2c->type & FLAG_HDMIPHY) {
+ if (i2c->quirks & QUIRK_HDMIPHY) {
writel(0, i2c->regs + S3C2410_IICCON);
writel(0, i2c->regs + S3C2410_IICSTAT);
writel(0, i2c->regs + S3C2410_IICDS);
@@ -704,7 +691,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c
*i2c, unsigned int *got)
writel(iiccon, i2c->regs + S3C2410_IICCON);
- if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440)) {
+ if (i2c->quirks & QUIRK_S3C2440) {
unsigned long sda_delay;
if (pdata->sda_delay) {
@@ -789,7 +776,7 @@ static int s3c24xx_i2c_parse_dt_gpio(struct
s3c24xx_i2c *i2c)
{
int idx, gpio, ret;
- if (i2c->type & FLAG_NO_GPIO)
+ if (i2c->quirks & QUIRK_NO_GPIO)
return 0;
for (idx = 0; idx < 2; idx++) {
@@ -817,7 +804,7 @@ static void s3c24xx_i2c_dt_gpio_free(struct
s3c24xx_i2c *i2c)
{
unsigned int idx;
- if (i2c->type & FLAG_NO_GPIO)
+ if (i2c->quirks & QUIRK_NO_GPIO)
return;
for (idx = 0; idx < 2; idx++)
@@ -898,10 +885,10 @@ s3c24xx_i2c_parse_dt(struct device_node *np,
struct s3c24xx_i2c *i2c)
pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
if (of_get_property(np, "samsung,i2c-quirk-hdmiphy", NULL))
- i2c->type |= FLAG_HDMIPHY;
+ i2c->quirks |= QUIRK_HDMIPHY;
if (of_get_property(np, "samsung,i2c-no-gpio", NULL))
- i2c->type |= FLAG_NO_GPIO;
+ i2c->quirks |= QUIRK_NO_GPIO;
of_property_read_u32(np, "samsung,i2c-sda-delay", &pdata->sda_delay);
of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr);
@@ -948,7 +935,7 @@ static int s3c24xx_i2c_probe(struct platform_device
*pdev)
goto err_noclk;
}
- i2c->type = s3c24xx_get_device_type(pdev);
+ i2c->quirks = s3c24xx_get_device_quirks(pdev);
if (pdata)
memcpy(i2c->pdata, pdata, sizeof(*pdata));
else
@@ -1156,21 +1143,21 @@ 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,
}, {
.name = "s3c2440-hdmiphy-i2c",
- .driver_data = TYPE_S3C2440 | FLAG_HDMIPHY | FLAG_NO_GPIO,
+ .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,
}, { },
};
MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
#ifdef CONFIG_OF
static const struct of_device_id s3c24xx_i2c_match[] = {
- { .compatible = "samsung,s3c2410-i2c", .data = (void *)TYPE_S3C2410 },
- { .compatible = "samsung,s3c2440-i2c", .data = (void *)TYPE_S3C2440 },
+ { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
+ { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
{},
};
MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
Regards,
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
next prev parent reply other threads:[~2012-03-21 10:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-13 16:54 [PATCH 0/3 v2] Updates for exynos4210 and DT-based systems Karol Lewandowski
2012-03-13 16:54 ` Karol Lewandowski
2012-03-13 16:54 ` [PATCH 1/3] i2c-s3c2410: Drop unused define Karol Lewandowski
2012-03-18 20:49 ` Grant Likely
2012-03-18 20:49 ` Grant Likely
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
2012-03-14 17:29 ` Mark Brown
[not found] ` <20120314172915.GB13393-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-03-15 10:04 ` Karol Lewandowski
2012-03-15 10:04 ` Karol Lewandowski
[not found] ` <4F61BEC8.4030008-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-15 12:56 ` Mark Brown
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-15 16:54 ` Karol Lewandowski
2012-03-19 19:55 ` Mark Brown
2012-03-21 10:33 ` Karol Lewandowski [this message]
[not found] ` <4F69AE96.6060901-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-21 11:50 ` Mark Brown
2012-03-21 11:50 ` Mark Brown
2012-03-21 11:54 ` Karol Lewandowski
[not found] ` <1331657679-31302-1-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-13 16:54 ` [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 Karol Lewandowski
2012-03-13 16:54 ` Karol Lewandowski
[not found] ` <1331657679-31302-4-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-13 17:27 ` Tomasz Stanislawski
2012-03-13 17:27 ` Tomasz Stanislawski
[not found] ` <4F5F838A.6030908-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-13 18:00 ` Karol Lewandowski
2012-03-13 18:00 ` Karol Lewandowski
2012-03-13 18:13 ` [PATCH] " Karol Lewandowski
2012-03-13 18:13 ` Karol Lewandowski
2012-03-14 1:49 ` [PATCH 0/3 v2] Updates for exynos4210 and DT-based systems Kyungmin Park
-- strict thread matches above, loose matches on Subject: below --
2012-03-21 19:11 [PATCH v3 0/3] i2c-s3c2410: " 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-03-21 20:30 ` Mark Brown
2012-04-17 17:31 ` Wolfram Sang
2012-04-17 17:31 ` Wolfram Sang
[not found] ` <20120417173136.GB22406-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-18 11:55 ` Karol Lewandowski
2012-04-18 11:55 ` Karol Lewandowski
2012-04-18 13:39 ` 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=4F69AE96.6060901@samsung.com \
--to=k.lewandowsk@samsung.com \
--cc=ben-linux@fluff.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=t.stanislaws@samsung.com \
--cc=thomas.abraham@linaro.org \
--cc=w.sang@pengutronix.de \
/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.