Re: [PATCH 3/6] i2c pca954x: add dts-binding facility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxx
Linux Device Driver                          giometti@xxxxxxxx
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux