Thread (1 message) 1 message, 1 author, 2011-09-15

Re: [PATCH v2] i2c: Add Device Tree support to versatile-i2c driver

From: Pawel Moll <hidden>
Date: 2011-09-15 08:55:13
Also in: linux-i2c

Morning,
quoted
This patch adds Device Tree binding ("arm,versatile-i2c") and
basic support (bus population) to versatile-i2c driver.
what happens when !CONFIG_OF ?
Nothing sinister, really...
 
quoted
@@ -99,6 +100,7 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
 	i2c->adap.algo_data = &i2c->algo;
 	i2c->adap.dev.parent = &dev->dev;
+	i2c->adap.dev.of_node = dev->dev.of_node;
 	i2c->algo = i2c_versatile_algo;
 	i2c->algo.data = i2c;
include/linux/device.h:551
struct device {
<...>
        struct dev_archdata     archdata;
        
        struct device_node      *of_node; /* associated device tree node */

        dev_t                   devt;   /* dev_t, creates the sysfs "dev" */
<...>
}

As you see of_node is always present...
 
quoted
@@ -111,6 +113,7 @@ static int i2c_versatile_probe(struct platform_device *dev)
 		ret = i2c_bit_add_bus(&i2c->adap);
 	if (ret >= 0) {
 		platform_set_drvdata(dev, i2c);
+		of_i2c_register_devices(&i2c->adap);
 		return 0;
 	}
include/linux/of_i2c.h:

#if defined(CONFIG_OF_I2C) || defined(CONFIG_OF_I2C_MODULE)
<...>
#else
static inline void of_i2c_register_devices(struct i2c_adapter *adap)
{
        return;
}       
#endif /* CONFIG_OF_I2C */
quoted
@@ -133,12 +136,19 @@ static int i2c_versatile_remove(struct platform_device *dev)
 	return 0;
 }
 
+static struct of_device_id i2c_versatile_match[] = {
+	{ .compatible = "arm,versatile-i2c", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, i2c_versatile_match);
+
 static struct platform_driver i2c_versatile_driver = {
 	.probe		= i2c_versatile_probe,
 	.remove		= i2c_versatile_remove,
 	.driver		= {
 		.name	= "versatile-i2c",
 		.owner	= THIS_MODULE,
+		.of_match_table = i2c_versatile_match,
 	},
 };
include/linux/device.h:185:

struct device_driver {
<...>
        bool suppress_bind_attrs;       /* disables bind/unbind via sysfs */
        
        const struct of_device_id       *of_match_table;
        
        int (*probe) (struct device *dev);
<...>
}

Same here.

Generally Grant claims that there is no more need for #ifdef CONFIG_OF,
and I trust him :-)

Cheers!

Paweł
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help