* i2c-ocores changes
@ 2010-11-24 14:09 Jonas Bonn
[not found] ` <1290607789-8996-1-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Jonas Bonn @ 2010-11-24 14:09 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Here are a couple of patches that fix up the initialization path of
the i2c-cores driver:
i) Support for device tree configuration of i2c devices
ii) Use devres routines in the resource reservation paths for device
initialization
This has been tested on an OpenRISC 1200 board; the OpenRISC Linux port
depends on device trees for device enumeration.
/Jonas
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] i2c-ocores: Adapt for device tree
[not found] ` <1290607789-8996-1-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
@ 2010-11-24 14:09 ` Jonas Bonn
[not found] ` <1290607789-8996-2-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
2010-11-24 14:09 ` [PATCH 2/2] i2c-ocores: Use devres for resource allocation Jonas Bonn
1 sibling, 1 reply; 7+ messages in thread
From: Jonas Bonn @ 2010-11-24 14:09 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jonas Bonn
This patch adapts the i2c-ocores driver for being defined and configured via
a device tree description.
The device tree bits need to be protected by CONFIG_OF guards as this is
still an optional feature.
Signed-off-by: Jonas Bonn <jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
---
drivers/i2c/busses/i2c-ocores.c | 63 ++++++++++++++++++++++++++++++++++-----
1 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 0070371..86a536c 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -210,6 +210,31 @@ static struct i2c_adapter ocores_adapter = {
.algo = &ocores_algorithm,
};
+#ifdef CONFIG_OF
+static int ocores_i2c_of_probe(struct platform_device* pdev,
+ struct ocores_i2c* i2c)
+{
+ int* val;
+
+ val = (int*) of_get_property(pdev->dev.of_node, "regstep", NULL);
+ if (!val) {
+ dev_err(&pdev->dev, "Missing required paramter 'regstep'");
+ return -ENODEV;
+ }
+
+ i2c->regstep = *val;
+ val = (int*) of_get_property(pdev->dev.of_node, "clock_khz", NULL);
+ if (!val) {
+ dev_err(&pdev->dev, "Missing required paramter 'clock_khz'");
+ return -ENODEV;
+ }
+ i2c->clock_khz = *val;
+
+ return 0;
+}
+#else
+#define ocores_i2c_of_probe(pdev,i2c) -ENODEV
+#endif
static int __devinit ocores_i2c_probe(struct platform_device *pdev)
{
@@ -227,10 +252,6 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
if (!res2)
return -ENODEV;
- pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
- if (!pdata)
- return -ENODEV;
-
i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
@@ -249,8 +270,16 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
goto map_failed;
}
- i2c->regstep = pdata->regstep;
- i2c->clock_khz = pdata->clock_khz;
+ pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
+ if (pdata) {
+ i2c->regstep = pdata->regstep;
+ i2c->clock_khz = pdata->clock_khz;
+ } else {
+ ret = ocores_i2c_of_probe(pdev, i2c);
+ if (ret)
+ return ret;
+ }
+
ocores_init(i2c);
init_waitqueue_head(&i2c->wait);
@@ -265,6 +294,9 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
i2c->adap = ocores_adapter;
i2c_set_adapdata(&i2c->adap, i2c);
i2c->adap.dev.parent = &pdev->dev;
+#ifdef CONFIG_OF
+ i2c->adap.dev.of_node = pdev->dev.of_node;
+#endif
/* add i2c adapter to i2c tree */
ret = i2c_add_adapter(&i2c->adap);
@@ -274,8 +306,10 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
}
/* add in known devices to the bus */
- for (i = 0; i < pdata->num_devices; i++)
- i2c_new_device(&i2c->adap, pdata->devices + i);
+ if (pdata) {
+ for (i = 0; i < pdata->num_devices; i++)
+ i2c_new_device(&i2c->adap, pdata->devices + i);
+ }
return 0;
@@ -344,6 +378,16 @@ static int ocores_i2c_resume(struct platform_device *pdev)
#define ocores_i2c_resume NULL
#endif
+#ifdef CONFIG_OF
+static struct of_device_id ocores_i2c_match[] = {
+ {
+ .compatible = "opencores,i2c-ocores",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, ocores_i2c_match);
+#endif
+
/* work with hotplug and coldplug */
MODULE_ALIAS("platform:ocores-i2c");
@@ -355,6 +399,9 @@ static struct platform_driver ocores_i2c_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "ocores-i2c",
+#ifdef CONFIG_OF
+ .of_match_table = ocores_i2c_match,
+#endif
},
};
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] i2c-ocores: Use devres for resource allocation
[not found] ` <1290607789-8996-1-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
2010-11-24 14:09 ` [PATCH 1/2] i2c-ocores: Adapt for device tree Jonas Bonn
@ 2010-11-24 14:09 ` Jonas Bonn
1 sibling, 0 replies; 7+ messages in thread
From: Jonas Bonn @ 2010-11-24 14:09 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jonas Bonn
This patch converts the i2c-cores driver to use devres routines for
resource allocation.
Signed-off-by: Jonas Bonn <jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
---
drivers/i2c/busses/i2c-ocores.c | 46 +++++++++-----------------------------
1 files changed, 11 insertions(+), 35 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 86a536c..d10c51a 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -252,22 +252,21 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
if (!res2)
return -ENODEV;
- i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+ i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
- if (!request_mem_region(res->start, resource_size(res),
- pdev->name)) {
+ if (!devm_request_mem_region(&pdev->dev, res->start,
+ resource_size(res), pdev->name)) {
dev_err(&pdev->dev, "Memory region busy\n");
- ret = -EBUSY;
- goto request_mem_failed;
+ return -EBUSY;
}
- i2c->base = ioremap(res->start, resource_size(res));
+ i2c->base = devm_ioremap_nocache(&pdev->dev, res->start,
+ resource_size(res));
if (!i2c->base) {
dev_err(&pdev->dev, "Unable to map registers\n");
- ret = -EIO;
- goto map_failed;
+ return -EIO;
}
pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
@@ -283,10 +282,11 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
ocores_init(i2c);
init_waitqueue_head(&i2c->wait);
- ret = request_irq(res2->start, ocores_isr, 0, pdev->name, i2c);
+ ret = devm_request_irq(&pdev->dev, res2->start, ocores_isr, 0,
+ pdev->name, i2c);
if (ret) {
dev_err(&pdev->dev, "Cannot claim IRQ\n");
- goto request_irq_failed;
+ return ret;
}
/* hook up driver to tree */
@@ -302,7 +302,7 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
ret = i2c_add_adapter(&i2c->adap);
if (ret) {
dev_err(&pdev->dev, "Failed to add adapter\n");
- goto add_adapter_failed;
+ return ret;
}
/* add in known devices to the bus */
@@ -312,23 +312,11 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
}
return 0;
-
-add_adapter_failed:
- free_irq(res2->start, i2c);
-request_irq_failed:
- iounmap(i2c->base);
-map_failed:
- release_mem_region(res->start, resource_size(res));
-request_mem_failed:
- kfree(i2c);
-
- return ret;
}
static int __devexit ocores_i2c_remove(struct platform_device* pdev)
{
struct ocores_i2c *i2c = platform_get_drvdata(pdev);
- struct resource *res;
/* disable i2c logic */
oc_setreg(i2c, OCI2C_CONTROL, oc_getreg(i2c, OCI2C_CONTROL)
@@ -338,18 +326,6 @@ static int __devexit ocores_i2c_remove(struct platform_device* pdev)
i2c_del_adapter(&i2c->adap);
platform_set_drvdata(pdev, NULL);
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (res)
- free_irq(res->start, i2c);
-
- iounmap(i2c->base);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res)
- release_mem_region(res->start, resource_size(res));
-
- kfree(i2c);
-
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] i2c-ocores: Adapt for device tree
[not found] ` <1290607789-8996-2-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
@ 2010-11-24 14:58 ` Wolfram Sang
[not found] ` <20101124145843.GD6812-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-11-24 15:22 ` Grant Likely
1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2010-11-24 14:58 UTC (permalink / raw)
To: Jonas Bonn
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
[-- Attachment #1: Type: text/plain, Size: 4717 bytes --]
Hi,
quick review (hopefully not too quick)...
On Wed, Nov 24, 2010 at 03:09:48PM +0100, Jonas Bonn wrote:
> This patch adapts the i2c-ocores driver for being defined and configured via
> a device tree description.
>
> The device tree bits need to be protected by CONFIG_OF guards as this is
> still an optional feature.
>
> Signed-off-by: Jonas Bonn <jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-ocores.c | 63 ++++++++++++++++++++++++++++++++++-----
> 1 files changed, 55 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> index 0070371..86a536c 100644
> --- a/drivers/i2c/busses/i2c-ocores.c
> +++ b/drivers/i2c/busses/i2c-ocores.c
> @@ -210,6 +210,31 @@ static struct i2c_adapter ocores_adapter = {
> .algo = &ocores_algorithm,
> };
>
> +#ifdef CONFIG_OF
> +static int ocores_i2c_of_probe(struct platform_device* pdev,
> + struct ocores_i2c* i2c)
> +{
> + int* val;
> +
> + val = (int*) of_get_property(pdev->dev.of_node, "regstep", NULL);
> + if (!val) {
> + dev_err(&pdev->dev, "Missing required paramter 'regstep'");
> + return -ENODEV;
> + }
New properties need to be documented (e.g. like here¹). What is regstep?
¹ http://lists.ozlabs.org/pipermail/devicetree-discuss/2010-November/003569.html
> +
> + i2c->regstep = *val;
> + val = (int*) of_get_property(pdev->dev.of_node, "clock_khz", NULL);
> + if (!val) {
> + dev_err(&pdev->dev, "Missing required paramter 'clock_khz'");
> + return -ENODEV;
> + }
Other i2c-drivers use "clock-frequency", you should as well.
> + i2c->clock_khz = *val;
> +
> + return 0;
> +}
> +#else
> +#define ocores_i2c_of_probe(pdev,i2c) -ENODEV
> +#endif
>
> static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> {
> @@ -227,10 +252,6 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> if (!res2)
> return -ENODEV;
>
> - pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
> - if (!pdata)
> - return -ENODEV;
> -
> i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
> if (!i2c)
> return -ENOMEM;
> @@ -249,8 +270,16 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> goto map_failed;
> }
>
> - i2c->regstep = pdata->regstep;
> - i2c->clock_khz = pdata->clock_khz;
> + pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
The cast can be dropped.
> + if (pdata) {
> + i2c->regstep = pdata->regstep;
> + i2c->clock_khz = pdata->clock_khz;
> + } else {
> + ret = ocores_i2c_of_probe(pdev, i2c);
> + if (ret)
> + return ret;
> + }
> +
> ocores_init(i2c);
>
> init_waitqueue_head(&i2c->wait);
> @@ -265,6 +294,9 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> i2c->adap = ocores_adapter;
> i2c_set_adapdata(&i2c->adap, i2c);
> i2c->adap.dev.parent = &pdev->dev;
> +#ifdef CONFIG_OF
> + i2c->adap.dev.of_node = pdev->dev.of_node;
> +#endif
No need for the ifdef here.
>
> /* add i2c adapter to i2c tree */
> ret = i2c_add_adapter(&i2c->adap);
> @@ -274,8 +306,10 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> }
>
> /* add in known devices to the bus */
> - for (i = 0; i < pdata->num_devices; i++)
> - i2c_new_device(&i2c->adap, pdata->devices + i);
> + if (pdata) {
> + for (i = 0; i < pdata->num_devices; i++)
> + i2c_new_device(&i2c->adap, pdata->devices + i);
> + }
>
> return 0;
>
> @@ -344,6 +378,16 @@ static int ocores_i2c_resume(struct platform_device *pdev)
> #define ocores_i2c_resume NULL
> #endif
>
> +#ifdef CONFIG_OF
> +static struct of_device_id ocores_i2c_match[] = {
> + {
> + .compatible = "opencores,i2c-ocores",
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, ocores_i2c_match);
> +#endif
ditto
> +
> /* work with hotplug and coldplug */
> MODULE_ALIAS("platform:ocores-i2c");
>
> @@ -355,6 +399,9 @@ static struct platform_driver ocores_i2c_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "ocores-i2c",
> +#ifdef CONFIG_OF
> + .of_match_table = ocores_i2c_match,
> +#endif
ditto
> },
> };
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] i2c-ocores: Adapt for device tree
[not found] ` <1290607789-8996-2-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
2010-11-24 14:58 ` Wolfram Sang
@ 2010-11-24 15:22 ` Grant Likely
1 sibling, 0 replies; 7+ messages in thread
From: Grant Likely @ 2010-11-24 15:22 UTC (permalink / raw)
To: Jonas Bonn
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
On Wed, Nov 24, 2010 at 7:09 AM, Jonas Bonn <jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org> wrote:
> This patch adapts the i2c-ocores driver for being defined and configured via
> a device tree description.
>
> The device tree bits need to be protected by CONFIG_OF guards as this is
> still an optional feature.
>
> Signed-off-by: Jonas Bonn <jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-ocores.c | 63 ++++++++++++++++++++++++++++++++++-----
> 1 files changed, 55 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> index 0070371..86a536c 100644
> --- a/drivers/i2c/busses/i2c-ocores.c
> +++ b/drivers/i2c/busses/i2c-ocores.c
> @@ -210,6 +210,31 @@ static struct i2c_adapter ocores_adapter = {
> .algo = &ocores_algorithm,
> };
>
> +#ifdef CONFIG_OF
> +static int ocores_i2c_of_probe(struct platform_device* pdev,
> + struct ocores_i2c* i2c)
> +{
> + int* val;
__be32 *val;
> +
> + val = (int*) of_get_property(pdev->dev.of_node, "regstep", NULL);
of_get_property returns a void*. Drop the unnecessary cast.
> + if (!val) {
> + dev_err(&pdev->dev, "Missing required paramter 'regstep'");
spelling: parameter
> + return -ENODEV;
> + }
> +
> + i2c->regstep = *val;
i2c->regstep = be32_to_cpup(val);
> + val = (int*) of_get_property(pdev->dev.of_node, "clock_khz", NULL);
Drop the cast. It is also considered bad form to use '_' in property
names. Use '-' instead. Traditionally, clock frequencies are
specified in Hz (not kHz), and the property name is something like
'bus-frequency' or 'clock-frequency'.
> + if (!val) {
> + dev_err(&pdev->dev, "Missing required paramter 'clock_khz'");
> + return -ENODEV;
> + }
> + i2c->clock_khz = *val;
i2c->clock_khz = be32_to_cpup(val);
> +
> + return 0;
> +}
> +#else
> +#define ocores_i2c_of_probe(pdev,i2c) -ENODEV
> +#endif
>
> static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> {
> @@ -227,10 +252,6 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> if (!res2)
> return -ENODEV;
>
> - pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
> - if (!pdata)
> - return -ENODEV;
> -
> i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
> if (!i2c)
> return -ENOMEM;
> @@ -249,8 +270,16 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> goto map_failed;
> }
>
> - i2c->regstep = pdata->regstep;
> - i2c->clock_khz = pdata->clock_khz;
> + pdata = (struct ocores_i2c_platform_data*) pdev->dev.platform_data;
Drop the unnecessary cast
> + if (pdata) {
> + i2c->regstep = pdata->regstep;
> + i2c->clock_khz = pdata->clock_khz;
> + } else {
> + ret = ocores_i2c_of_probe(pdev, i2c);
> + if (ret)
> + return ret;
> + }
> +
> ocores_init(i2c);
>
> init_waitqueue_head(&i2c->wait);
> @@ -265,6 +294,9 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> i2c->adap = ocores_adapter;
> i2c_set_adapdata(&i2c->adap, i2c);
> i2c->adap.dev.parent = &pdev->dev;
> +#ifdef CONFIG_OF
> + i2c->adap.dev.of_node = pdev->dev.of_node;
> +#endif
>
> /* add i2c adapter to i2c tree */
> ret = i2c_add_adapter(&i2c->adap);
> @@ -274,8 +306,10 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> }
>
> /* add in known devices to the bus */
> - for (i = 0; i < pdata->num_devices; i++)
> - i2c_new_device(&i2c->adap, pdata->devices + i);
> + if (pdata) {
> + for (i = 0; i < pdata->num_devices; i++)
> + i2c_new_device(&i2c->adap, pdata->devices + i);
> + }
>
> return 0;
>
> @@ -344,6 +378,16 @@ static int ocores_i2c_resume(struct platform_device *pdev)
> #define ocores_i2c_resume NULL
> #endif
>
> +#ifdef CONFIG_OF
> +static struct of_device_id ocores_i2c_match[] = {
> + {
> + .compatible = "opencores,i2c-ocores",
Is this binding documented somewhere? If not, you can use devicetree.org
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, ocores_i2c_match);
> +#endif
> +
> /* work with hotplug and coldplug */
> MODULE_ALIAS("platform:ocores-i2c");
>
> @@ -355,6 +399,9 @@ static struct platform_driver ocores_i2c_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "ocores-i2c",
> +#ifdef CONFIG_OF
> + .of_match_table = ocores_i2c_match,
> +#endif
> },
> };
>
> --
> 1.7.1
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] i2c-ocores: Adapt for device tree
[not found] ` <20101124145843.GD6812-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-11-24 15:32 ` Jonas Bonn
2010-11-24 15:42 ` Wolfram Sang
0 siblings, 1 reply; 7+ messages in thread
From: Jonas Bonn @ 2010-11-24 15:32 UTC (permalink / raw)
To: Wolfram Sang
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
On Wed, 2010-11-24 at 15:58 +0100, Wolfram Sang wrote:
> Hi,
>
> quick review (hopefully not too quick)...
>
Thanks... see my comments below.
> > + val = (int*) of_get_property(pdev->dev.of_node, "regstep", NULL);
> > + if (!val) {
> > + dev_err(&pdev->dev, "Missing required paramter 'regstep'");
> > + return -ENODEV;
> > + }
>
> New properties need to be documented (e.g. like here¹). What is regstep?
>
> ¹ http://lists.ozlabs.org/pipermail/devicetree-discuss/2010-November/003569.html
>
While I agree that these parameters need documentation, I haven't seen
that there is an agreed upon place to put such documentation as of yet.
I followed your link but didn't find the corresponding document in the
kernel tree. Should I really be putting my documentation in the
Documentation/powerpc directory?
> > i2c->adap = ocores_adapter;
> > i2c_set_adapdata(&i2c->adap, i2c);
> > i2c->adap.dev.parent = &pdev->dev;
> > +#ifdef CONFIG_OF
> > + i2c->adap.dev.of_node = pdev->dev.of_node;
> > +#endif
>
> No need for the ifdef here.
>
Why? of_node is protected by CONFIG_OF in linux/device.h
> >
> > +#ifdef CONFIG_OF
> > +static struct of_device_id ocores_i2c_match[] = {
> > + {
> > + .compatible = "opencores,i2c-ocores",
> > + },
> > + {},
> > +};
> > +MODULE_DEVICE_TABLE(of, ocores_i2c_match);
> > +#endif
>
> ditto
Dropping the ifdef begets a build warning...
> > .name = "ocores-i2c",
> > +#ifdef CONFIG_OF
> > + .of_match_table = ocores_i2c_match,
> > +#endif
>
> ditto
Same here, of_match_table is protected by CONFIG_OF. How is this ifdef
not necessary?
Thanks again for the review.
Cheers,
Jonas
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] i2c-ocores: Adapt for device tree
2010-11-24 15:32 ` Jonas Bonn
@ 2010-11-24 15:42 ` Wolfram Sang
0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2010-11-24 15:42 UTC (permalink / raw)
To: Jonas Bonn
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
> While I agree that these parameters need documentation, I haven't seen
> that there is an agreed upon place to put such documentation as of yet.
> I followed your link but didn't find the corresponding document in the
> kernel tree.
Because it has not been applied yet; that was the "template" patch I
could dig up fastest.
> Should I really be putting my documentation in the
> Documentation/powerpc directory?
Not necessarily. You could post a patch moving the generic parts to a
better location, too :)
> > > +#ifdef CONFIG_OF
> > > + i2c->adap.dev.of_node = pdev->dev.of_node;
> > > +#endif
> >
> > No need for the ifdef here.
> >
>
> Why? of_node is protected by CONFIG_OF in linux/device.h
Ehrm, seems my mind broke :( Apologies, I probably was mixing it up with
another issue.
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-11-24 15:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-24 14:09 i2c-ocores changes Jonas Bonn
[not found] ` <1290607789-8996-1-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
2010-11-24 14:09 ` [PATCH 1/2] i2c-ocores: Adapt for device tree Jonas Bonn
[not found] ` <1290607789-8996-2-git-send-email-jonas-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
2010-11-24 14:58 ` Wolfram Sang
[not found] ` <20101124145843.GD6812-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-11-24 15:32 ` Jonas Bonn
2010-11-24 15:42 ` Wolfram Sang
2010-11-24 15:22 ` Grant Likely
2010-11-24 14:09 ` [PATCH 2/2] i2c-ocores: Use devres for resource allocation Jonas Bonn
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).