[04/12] cx231xx: give each master i2c bus a seperate name

Message ID 1411621684-8295-4-git-send-email-zzam@gentoo.org (mailing list archive)
State Superseded, archived
Headers

Commit Message

Matthias Schwarzott Sept. 25, 2014, 5:07 a.m. UTC
  Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Antti Palosaari Sept. 25, 2014, 3:04 p.m. UTC | #1
So this patch adds bus number to adapter name as postfix?

"cx231xx" => "cx231xx-1"

I have no clear opinion for that. I think name should be given when 
adapter is crated, not afterwards.

regards
Antti

On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
>   drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index a30d400..178fa48 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -506,6 +506,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
>   int cx231xx_i2c_register(struct cx231xx_i2c *bus)
>   {
>   	struct cx231xx *dev = bus->dev;
> +	char bus_name[3];
>
>   	BUG_ON(!dev->cx231xx_send_usb_command);
>
> @@ -513,6 +514,10 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
>   	bus->i2c_adap.dev.parent = &dev->udev->dev;
>
>   	strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
> +	bus_name[0] = '-';
> +	bus_name[1] = '0' + bus->nr;
> +	bus_name[2] = '\0';
> +	strlcat(bus->i2c_adap.name, bus_name, sizeof(bus->i2c_adap.name));
>
>   	bus->i2c_adap.algo_data = bus;
>   	i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
>
  
Matthias Schwarzott Sept. 26, 2014, 4:34 a.m. UTC | #2
On 25.09.2014 17:04, Antti Palosaari wrote:
> So this patch adds bus number to adapter name as postfix?
> 
> "cx231xx" => "cx231xx-1"
> 
Yes, it is attached, and the result looks like
* cx231xx #0-0
* cx231xx #0-1
* cx231xx #0-2

> I have no clear opinion for that. I think name should be given when
> adapter is crated, not afterwards.
> 
It is written to the i2c_adapter before calling i2c_add_adapter. Is this
good enough?

Regards
Matthias

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Antti Palosaari Sept. 26, 2014, 12:32 p.m. UTC | #3
On 09/26/2014 07:34 AM, Matthias Schwarzott wrote:
> On 25.09.2014 17:04, Antti Palosaari wrote:
>> So this patch adds bus number to adapter name as postfix?
>>
>> "cx231xx" => "cx231xx-1"
>>
> Yes, it is attached, and the result looks like
> * cx231xx #0-0
> * cx231xx #0-1
> * cx231xx #0-2
>
>> I have no clear opinion for that. I think name should be given when
>> adapter is crated, not afterwards.
>>
> It is written to the i2c_adapter before calling i2c_add_adapter. Is this
> good enough?

ah, OK, yes.

Antti

>
> Regards
> Matthias
>
  

Patch

diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index a30d400..178fa48 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -506,6 +506,7 @@  void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
 int cx231xx_i2c_register(struct cx231xx_i2c *bus)
 {
 	struct cx231xx *dev = bus->dev;
+	char bus_name[3];
 
 	BUG_ON(!dev->cx231xx_send_usb_command);
 
@@ -513,6 +514,10 @@  int cx231xx_i2c_register(struct cx231xx_i2c *bus)
 	bus->i2c_adap.dev.parent = &dev->udev->dev;
 
 	strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
+	bus_name[0] = '-';
+	bus_name[1] = '0' + bus->nr;
+	bus_name[2] = '\0';
+	strlcat(bus->i2c_adap.name, bus_name, sizeof(bus->i2c_adap.name));
 
 	bus->i2c_adap.algo_data = bus;
 	i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);