Re: [PATCH v9 2/4] media: i2c: Add MAX9286 driver

From: Kieran Bingham
Date: Thu May 14 2020 - 09:50:38 EST


On 14/05/2020 13:48, Manivannan Sadhasivam wrote:
> On Thu, May 14, 2020 at 01:59:35PM +0200, Geert Uytterhoeven wrote:
>> Hi Kieran,
>>
>> On Thu, May 14, 2020 at 1:47 PM Kieran Bingham
>> <kieran.bingham+renesas@xxxxxxxxxxxxxxxx> wrote:
>>> On 14/05/2020 11:13, Manivannan Sadhasivam wrote:
>>>> On Thu, May 14, 2020 at 11:02:53AM +0100, Kieran Bingham wrote:
>>>>> On 12/05/2020 19:17, Manivannan Sadhasivam wrote:
>>>>>> On Tue, May 12, 2020 at 04:51:03PM +0100, Kieran Bingham wrote:
>>>>>>> The MAX9286 is a 4-channel GMSL deserializer with coax or STP input and
>>>>>>> CSI-2 output. The device supports multicamera streaming applications,
>>>>>>> and features the ability to synchronise the attached cameras.
>>>>>>>
>>>>>>> CSI-2 output can be configured with 1 to 4 lanes, and a control channel
>>>>>>> is supported over I2C, which implements an I2C mux to facilitate
>>>>>>> communications with connected cameras across the reverse control
>>>>>>> channel.
>>>>>>>
>>>>>>> Signed-off-by: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>
>>>>>>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>
>>>>>>> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx>
>>>>>>> Signed-off-by: Niklas SÃderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
>>
>>>>>>> --- /dev/null
>>>>>>> +++ b/drivers/media/i2c/max9286.c
>>
>>>>>>> +static int max9286_register_gpio(struct max9286_priv *priv)
>>>>>>> +{
>>>>>>> + struct device *dev = &priv->client->dev;
>>>>>>> + struct gpio_chip *gpio = &priv->gpio;
>>>>>>> + int ret;
>>>>>>> +
>>>>>>> + static const char * const names[] = {
>>>>>>> + "GPIO0OUT",
>>>>>>> + "GPIO1OUT",
>>>>>>> + };
>>>>>>> +
>>>>>>> + /* Configure the GPIO */
>>>>>>> + gpio->label = dev_name(dev);
>>>>>>
>>>>>> So if you have more than one MAX9286 in a system, all gpiochips will appear
>>>>>> with the same name. I'd recommend to append the index to distinguish properly.
>>>>>
>>>>> Ah yes, that's a good point, and I think I've even seen that.
>>>>>
>>>>> I'll fix it now.
>>>
>>> Oh, in fact actually this doesn't.
>>>
>>> gpiodetect prints:
>>>
>>> gpiochip10 [4-004c] (2 lines)
>>> gpiochip11 [4-006c] (2 lines)
>>>
>>> and mostly references them as gpiochip10 and gpiochip11.
>>
>> Indeed, dev_name() should be different for each instance.
>>
>
> Ah, my bad! Somehow I got confused that this delivers static name... Sorry for
> the noise, Kieran.
>
>>> However,
>>>
>>>> [ 2.318533] gpio gpiochip11: Detected name collision for GPIO name 'GPIO0OUT'
>>>> [ 2.325739] gpio gpiochip11: Detected name collision for GPIO name 'GPIO1OUT'
>>>
>>> That seems to be more of a problem for the gpio library, so I think I'll
>>> just drop the const names. I don't think they add much value.
>>
>
> Well, I should've pointed this instead of above...
>
> (lack of coffee)
>
>> These are the line names. If they're not unique, a warning is printed,
>> but they are still registered.
>> So probably you want to use kasprintf("%s.%s", dev_name(dev), names[i]) to
>> generate names.
>>
>
> Ack.
>
> I think you should CC Linus W for next iteration to get review for gpiolib
> implementation.

Good idea. I think I'll drop the names though for now.

--
Kieran


>
> Thanks,
> Mani
>
>> See "[PATCH] gpiolib: Document that GPIO line names are not globally unique"
>> (https://lore.kernel.org/linux-gpio/20200511101828.30046-1-geert+renesas@xxxxxxxxx/)
>> to clear up the details.
>>
>> Gr{oetje,eeting}s,
>>
>> Geert
>>
>> --
>> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>>
>> In personal conversations with technical people, I call myself a hacker. But
>> when I'm talking to journalists I just say "programmer" or something like that.
>> -- Linus Torvalds