Re: [PATCH v2 5/5] i2c-piix4: Add adapter port name support for SB800 chipset

2015-11-02 Thread Mika Westerberg
On Sun, Nov 01, 2015 at 05:32:09PM +0100, Christian Fetzer wrote:
> This patch adds support for port names for the SB800 chipset.
> Since the chipset supports a multiplexed main SMBus controller, adding
> the channel name to the adapter name is necessary to differentiate the
> ports better (for example in sensors output).
> 
> Signed-off-by: Christian Fetzer 
> ---
>  drivers/i2c/busses/i2c-piix4.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 54f8af5..18ea5d7 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -132,6 +132,10 @@ static const struct dmi_system_id piix4_dmi_ibm[] = {
>  /* SB800 globals */
>  DEFINE_MUTEX(piix4_mutex_sb800);
>  static unsigned short piix4_smb_idx_sb800;
> +static const char *piix4_main_port_names_sb800[4] = {
> + "SDA0", "SDA2", "SDA3", "SDA4"
> +};
> +static const char *piix4_aux_port_name_sb800 = "SDA1";
>  
>  struct i2c_piix4_adapdata {
>   unsigned short smba;
> @@ -613,7 +617,7 @@ static struct i2c_adapter 
> *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
>  static struct i2c_adapter *piix4_aux_adapter;
>  
>  static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
> -  struct i2c_adapter **padap)
> +  const char *name, struct i2c_adapter **padap)
>  {
>   struct i2c_adapter *adap;
>   struct i2c_piix4_adapdata *adapdata;
> @@ -642,7 +646,7 @@ static int piix4_add_adapter(struct pci_dev *dev, 
> unsigned short smba,
>   adap->dev.parent = >dev;
>  
>   snprintf(adap->name, sizeof(adap->name),
> - "SMBus PIIX4 adapter at %04x", smba);
> + "SMBus PIIX4 adapter %s at %04x", name, smba);
>  
>   i2c_set_adapdata(adap, adapdata);
>  
> @@ -667,6 +671,7 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, 
> unsigned short smba)
>  
>   for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
>   retval = piix4_add_adapter(dev, smba,
> +piix4_main_port_names_sb800[port],
>  _main_adapters[port]);
>   if (retval < 0)
>   goto error;
> @@ -726,7 +731,7 @@ static int piix4_probe(struct pci_dev *dev, const struct 
> pci_device_id *id)
>   return retval;
>  
>   /* Try to register main SMBus adapter, give up if we can't */
> - retval = piix4_add_adapter(dev, retval,
> + retval = piix4_add_adapter(dev, retval, "",

Why not use some useful name here instead of "" ?

Otherwise looks good,

Reviewed-by: Mika Westerberg 


>  _main_adapters[0]);
>   }
>  
> @@ -755,7 +760,8 @@ static int piix4_probe(struct pci_dev *dev, const struct 
> pci_device_id *id)
>   if (retval > 0) {
>   /* Try to add the aux adapter if it exists,
>* piix4_add_adapter will clean up if this fails */
> - piix4_add_adapter(dev, retval, _aux_adapter);
> + piix4_add_adapter(dev, retval, piix4_aux_port_name_sb800,
> +   _aux_adapter);
>   }
>  
>   return 0;
> -- 
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 5/5] i2c-piix4: Add adapter port name support for SB800 chipset

2015-11-02 Thread Andy Shevchenko
On Sun, 2015-11-01 at 17:32 +0100, Christian Fetzer wrote:
> This patch adds support for port names for the SB800 chipset.
> Since the chipset supports a multiplexed main SMBus controller,
> adding
> the channel name to the adapter name is necessary to differentiate
> the
> ports better (for example in sensors output).


> +static const char *piix4_main_port_names_sb800[4] = {

Would it be constant you defined instead of magic number?

> + "SDA0", "SDA2", "SDA3", "SDA4"


> +};
> +static const char *piix4_aux_port_name_sb800 = "SDA1";


-- 
Andy Shevchenko 
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/5] i2c-piix4: Add adapter port name support for SB800 chipset

2015-11-01 Thread Christian Fetzer
This patch adds support for port names for the SB800 chipset.
Since the chipset supports a multiplexed main SMBus controller, adding
the channel name to the adapter name is necessary to differentiate the
ports better (for example in sensors output).

Signed-off-by: Christian Fetzer 
---
 drivers/i2c/busses/i2c-piix4.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 54f8af5..18ea5d7 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -132,6 +132,10 @@ static const struct dmi_system_id piix4_dmi_ibm[] = {
 /* SB800 globals */
 DEFINE_MUTEX(piix4_mutex_sb800);
 static unsigned short piix4_smb_idx_sb800;
+static const char *piix4_main_port_names_sb800[4] = {
+   "SDA0", "SDA2", "SDA3", "SDA4"
+};
+static const char *piix4_aux_port_name_sb800 = "SDA1";
 
 struct i2c_piix4_adapdata {
unsigned short smba;
@@ -613,7 +617,7 @@ static struct i2c_adapter 
*piix4_main_adapters[PIIX4_MAX_ADAPTERS];
 static struct i2c_adapter *piix4_aux_adapter;
 
 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
-struct i2c_adapter **padap)
+const char *name, struct i2c_adapter **padap)
 {
struct i2c_adapter *adap;
struct i2c_piix4_adapdata *adapdata;
@@ -642,7 +646,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned 
short smba,
adap->dev.parent = >dev;
 
snprintf(adap->name, sizeof(adap->name),
-   "SMBus PIIX4 adapter at %04x", smba);
+   "SMBus PIIX4 adapter %s at %04x", name, smba);
 
i2c_set_adapdata(adap, adapdata);
 
@@ -667,6 +671,7 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, 
unsigned short smba)
 
for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
retval = piix4_add_adapter(dev, smba,
+  piix4_main_port_names_sb800[port],
   _main_adapters[port]);
if (retval < 0)
goto error;
@@ -726,7 +731,7 @@ static int piix4_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
return retval;
 
/* Try to register main SMBus adapter, give up if we can't */
-   retval = piix4_add_adapter(dev, retval,
+   retval = piix4_add_adapter(dev, retval, "",
   _main_adapters[0]);
}
 
@@ -755,7 +760,8 @@ static int piix4_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
if (retval > 0) {
/* Try to add the aux adapter if it exists,
 * piix4_add_adapter will clean up if this fails */
-   piix4_add_adapter(dev, retval, _aux_adapter);
+   piix4_add_adapter(dev, retval, piix4_aux_port_name_sb800,
+ _aux_adapter);
}
 
return 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html