diff mbox series

i2c: brcmstb: Fixed adapter named with optional interrupts

Message ID 20220706172115.224240-1-f.fainelli@gmail.com
State New
Headers show
Series i2c: brcmstb: Fixed adapter named with optional interrupts | expand

Commit Message

Florian Fainelli July 6, 2022, 5:21 p.m. UTC
When the adapter is registered without interrupts, we would be showing
the following:

  # i2cdetect -l
  i2c-3   i2c             Broadcom STB :                          I2C adapter

which is visually disturbing, only add the separator if we do have an
interrupt.

Fixes: dd1aa2524bc5 ("i2c: brcmstb: Add Broadcom settop SoC i2c controller driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/i2c/busses/i2c-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Wolfram Sang July 16, 2022, 12:40 p.m. UTC | #1
On Wed, Jul 06, 2022 at 10:21:15AM -0700, Florian Fainelli wrote:
> When the adapter is registered without interrupts, we would be showing
> the following:
> 
>   # i2cdetect -l
>   i2c-3   i2c             Broadcom STB :                          I2C adapter

What about switching to pdev->name here? That way you also get the base
address for free to differentiate if there are multiple instances on the
SoC?

> 
> which is visually disturbing, only add the separator if we do have an
> interrupt.
> 
> Fixes: dd1aa2524bc5 ("i2c: brcmstb: Add Broadcom settop SoC i2c controller driver")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/i2c/busses/i2c-brcmstb.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
> index b00f35c0b066..538a51299e04 100644
> --- a/drivers/i2c/busses/i2c-brcmstb.c
> +++ b/drivers/i2c/busses/i2c-brcmstb.c
> @@ -684,9 +684,11 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
>  	adap = &dev->adapter;
>  	i2c_set_adapdata(adap, dev);
>  	adap->owner = THIS_MODULE;
> -	strlcpy(adap->name, "Broadcom STB : ", sizeof(adap->name));
> -	if (int_name)
> +	strlcpy(adap->name, "Broadcom STB", sizeof(adap->name));
> +	if (int_name) {
> +		strlcat(adap->name, ": ", sizeof(adap->name));
>  		strlcat(adap->name, int_name, sizeof(adap->name));
> +	}
>  	adap->algo = &brcmstb_i2c_algo;
>  	adap->dev.parent = &pdev->dev;
>  	adap->dev.of_node = pdev->dev.of_node;
> -- 
> 2.25.1
>
Florian Fainelli July 19, 2022, 12:15 a.m. UTC | #2
On 7/16/2022 5:40 AM, Wolfram Sang wrote:
> On Wed, Jul 06, 2022 at 10:21:15AM -0700, Florian Fainelli wrote:
>> When the adapter is registered without interrupts, we would be showing
>> the following:
>>
>>    # i2cdetect -l
>>    i2c-3   i2c             Broadcom STB :                          I2C adapter
> 
> What about switching to pdev->name here? That way you also get the base
> address for free to differentiate if there are multiple instances on the
> SoC?

I was not sure if we could change the adapter name reported as one could 
argue this is now ABI, but if we can, then using dev_name() is probably 
better. You are the maintainer you so know the rules on what is 
considered stable ABI and what is not :)
Wolfram Sang July 19, 2022, 3:57 a.m. UTC | #3
> I was not sure if we could change the adapter name reported as one could
> argue this is now ABI, but if we can, then using dev_name() is probably
> better. You are the maintainer you so know the rules on what is considered
> stable ABI and what is not :)

Well, then even removing ":" would break the ABI :)

Please use dev_name. Other drivers changed that string, too. We never
gave guarantees for that one.
Florian Fainelli July 19, 2022, 4:06 a.m. UTC | #4
On 7/18/2022 8:57 PM, Wolfram Sang wrote:
> 
>> I was not sure if we could change the adapter name reported as one could
>> argue this is now ABI, but if we can, then using dev_name() is probably
>> better. You are the maintainer you so know the rules on what is considered
>> stable ABI and what is not :)
> 
> Well, then even removing ":" would break the ABI :)
> 
> Please use dev_name. Other drivers changed that string, too. We never
> gave guarantees for that one.
> 

Fair enough, sent a v2 using dev_name(), thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index b00f35c0b066..538a51299e04 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -684,9 +684,11 @@  static int brcmstb_i2c_probe(struct platform_device *pdev)
 	adap = &dev->adapter;
 	i2c_set_adapdata(adap, dev);
 	adap->owner = THIS_MODULE;
-	strlcpy(adap->name, "Broadcom STB : ", sizeof(adap->name));
-	if (int_name)
+	strlcpy(adap->name, "Broadcom STB", sizeof(adap->name));
+	if (int_name) {
+		strlcat(adap->name, ": ", sizeof(adap->name));
 		strlcat(adap->name, int_name, sizeof(adap->name));
+	}
 	adap->algo = &brcmstb_i2c_algo;
 	adap->dev.parent = &pdev->dev;
 	adap->dev.of_node = pdev->dev.of_node;