* Re: [PATCH 3/6] i2c pca954x: add dts-binding facility
[not found] ` <1251192994-25779-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
@ 2009-08-25 10:08 ` Rodolfo Giometti
0 siblings, 0 replies; only message in thread
From: Rodolfo Giometti @ 2009-08-25 10:08 UTC (permalink / raw)
To: Christian Herzig
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, chris-jmrfutXsf6TiB9QmIjCX8w
On Tue, Aug 25, 2009 at 11:36:34AM +0200, Christian Herzig wrote:
> At the end of probe, the driver is checking the i2c_clients
> corresponding device_node entry. If an entry is found, the
> binding is forced according the device tree.
>
> Signed-off-by: Christian Herzig <christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
> ---
> drivers/i2c/muxes/pca954x.c | 28 ++++++++++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> index ba4fef1..7dd1000 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -40,6 +40,7 @@
> #include <linux/module.h>
> #include <linux/i2c.h>
> #include <linux/init.h>
> +#include <linux/of_i2c.h>
>
> #include <linux/i2c/pca954x.h>
>
> @@ -57,6 +58,9 @@ enum pca_type {
> };
>
> static u8 channel;
> +struct i2c_adapter *virt_adap;
> +int adap_nbr;
> +int ret;
Nack. Use reentrant code.
> struct pca954x {
> struct i2c_client *client;
> @@ -233,6 +237,13 @@ static int pca954x_probe(struct i2c_client *client,
> int i, n, f;
> struct pca954x *data;
> int ret = -ENODEV;
> + struct device_node *ofdn;
> +
> + /* count registered i2c-adapters */
> + int reg_adaps = 0;
> + while (i2c_get_adapter(reg_adaps))
> + reg_adaps++;
> + pr_debug("pca954x: already %i i2c-adapters registrated\n", reg_adaps);
>
> if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE))
> goto err;
> @@ -289,6 +300,23 @@ static int pca954x_probe(struct i2c_client *client,
> if (0 != ret)
> printk(KERN_ERR "creating file in sysfs failed\n");
>
> + /* arch specific code for of-support.
> + * checkup dts binding in kernel-documentation
> + * Documentation/powerpc/dts_binding/mux/pca954x.txt.
> + */
> + ofdn = dev_archdata_get_node(&client->dev.archdata);
> + if (ofdn) {
> + for (adap_nbr = reg_adaps;
> + adap_nbr < chips[data->type].nchans + reg_adaps;
> + adap_nbr++) {
> + pr_debug("register devices at adap i2c-%i\n", adap_nbr);
> +
> + virt_adap = i2c_get_adapter(adap_nbr);
> + of_register_i2c_devices_behind_muxes
> + (virt_adap, ofdn, adap_nbr - reg_adaps);
> + }
> + }
> +
What happens if current arch has no of-support?
> return 0;
>
> virt_reg_failed:
> --
> 1.6.0.1
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org
Linux Device Driver giometti-k2GhghHVRtY@public.gmane.org
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-25 10:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1251192994-25779-1-git-send-email-christian.herzig@keymile.com>
[not found] ` <1251192994-25779-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2009-08-25 10:08 ` [PATCH 3/6] i2c pca954x: add dts-binding facility Rodolfo Giometti
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).