linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
To: Christian Herzig
	<christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	chris-jmrfutXsf6TiB9QmIjCX8w@public.gmane.org
Subject: Re: [PATCH 3/6] i2c pca954x: add dts-binding facility
Date: Tue, 25 Aug 2009 12:08:16 +0200	[thread overview]
Message-ID: <20090825100815.GH2039@gundam.enneenne.com> (raw)
In-Reply-To: <1251192994-25779-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>

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

           reply	other threads:[~2009-08-25 10:08 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1251192994-25779-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>]

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=20090825100815.GH2039@gundam.enneenne.com \
    --to=giometti-avvdyk/kqijwk0htik3j/w@public.gmane.org \
    --cc=chris-jmrfutXsf6TiB9QmIjCX8w@public.gmane.org \
    --cc=christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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).