mbox series

[v1,0/2] hwmon: introduce hwmon_sanitize()

Message ID 20220328115226.3042322-1-michael@walle.cc (mailing list archive)
Headers show
Series hwmon: introduce hwmon_sanitize() | expand

Message

Michael Walle March 28, 2022, 11:52 a.m. UTC
During development of the support for the temperature sensor on the GPY
PHY, I've noticed that there is ususually a loop over the name to
replace any invalid characters. Instead of open coding it in the drivers
provide a convenience function.

I'm not sure how to handle this correctly, as this touches both the
network tree and the hwmon tree. Also, the GPY PHY temperature senors
driver would use it.

Michael Walle (2):
  hwmon: introduce hwmon_sanitize_name()
  net: phy: use hwmon_sanitize_name()

 drivers/hwmon/intel-m10-bmc-hwmon.c |  5 +----
 drivers/net/phy/nxp-tja11xx.c       |  5 +----
 drivers/net/phy/sfp.c               |  6 ++----
 include/linux/hwmon.h               | 16 ++++++++++++++++
 4 files changed, 20 insertions(+), 12 deletions(-)

Comments

Andrew Lunn March 28, 2022, 12:56 p.m. UTC | #1
> I'm not sure how to handle this correctly, as this touches both the
> network tree and the hwmon tree. Also, the GPY PHY temperature senors
> driver would use it.

There are a few options:

1) Get the hwmon_sanitize_name() merged into hwmon, ask for a stable
branch, and get it merged into netdev net-next.

2) Have the hwmon maintainers ACK the change and agree that it can be
merged via netdev.

Probably the second option is easiest, and since it is not touching
the core of hwmon, it is unlikely to cause merge conflicts.

    Andrew
Guenter Roeck March 28, 2022, 4:27 p.m. UTC | #2
On 3/28/22 05:56, Andrew Lunn wrote:
>> I'm not sure how to handle this correctly, as this touches both the
>> network tree and the hwmon tree. Also, the GPY PHY temperature senors
>> driver would use it.
> 
> There are a few options:
> 
> 1) Get the hwmon_sanitize_name() merged into hwmon, ask for a stable
> branch, and get it merged into netdev net-next.
> 
> 2) Have the hwmon maintainers ACK the change and agree that it can be
> merged via netdev.
> 
> Probably the second option is easiest, and since it is not touching
> the core of hwmon, it is unlikely to cause merge conflicts.
> 

No, it isn't the easiest solution because it also modifies a hwmon
driver to use it.

Guenter
Michael Walle March 28, 2022, 10:50 p.m. UTC | #3
Am 2022-03-28 18:27, schrieb Guenter Roeck:
> On 3/28/22 05:56, Andrew Lunn wrote:
>>> I'm not sure how to handle this correctly, as this touches both the
>>> network tree and the hwmon tree. Also, the GPY PHY temperature senors
>>> driver would use it.
>> 
>> There are a few options:
>> 
>> 1) Get the hwmon_sanitize_name() merged into hwmon, ask for a stable
>> branch, and get it merged into netdev net-next.
>> 
>> 2) Have the hwmon maintainers ACK the change and agree that it can be
>> merged via netdev.
>> 
>> Probably the second option is easiest, and since it is not touching
>> the core of hwmon, it is unlikely to cause merge conflicts.
>> 
> 
> No, it isn't the easiest solution because it also modifies a hwmon
> driver to use it.

So that leaves us with option 1? The next version will contain the
additional patch which moves the hwmon_is_bad_char() from the include
to the core and make it private. That will then need an immutable
branch from netdev to get merged back into hwmon before that patch
can be applied, right?

-michael
Jakub Kicinski March 28, 2022, 11 p.m. UTC | #4
On Tue, 29 Mar 2022 00:50:28 +0200 Michael Walle wrote:
> > No, it isn't the easiest solution because it also modifies a hwmon
> > driver to use it.  
> 
> So that leaves us with option 1? The next version will contain the
> additional patch which moves the hwmon_is_bad_char() from the include
> to the core and make it private. That will then need an immutable
> branch from netdev to get merged back into hwmon before that patch
> can be applied, right?

If anything immutable branch from hwmon that we can pull, because hwmon
is the home of the API, and netdev is just _a_ consumer.

Either way I think you can post the patch that adds the new helper
for review.
Guenter Roeck March 29, 2022, 1:52 p.m. UTC | #5
On 3/28/22 15:50, Michael Walle wrote:
> Am 2022-03-28 18:27, schrieb Guenter Roeck:
>> On 3/28/22 05:56, Andrew Lunn wrote:
>>>> I'm not sure how to handle this correctly, as this touches both the
>>>> network tree and the hwmon tree. Also, the GPY PHY temperature senors
>>>> driver would use it.
>>>
>>> There are a few options:
>>>
>>> 1) Get the hwmon_sanitize_name() merged into hwmon, ask for a stable
>>> branch, and get it merged into netdev net-next.
>>>
>>> 2) Have the hwmon maintainers ACK the change and agree that it can be
>>> merged via netdev.
>>>
>>> Probably the second option is easiest, and since it is not touching
>>> the core of hwmon, it is unlikely to cause merge conflicts.
>>>
>>
>> No, it isn't the easiest solution because it also modifies a hwmon
>> driver to use it.
> 
> So that leaves us with option 1? The next version will contain the
> additional patch which moves the hwmon_is_bad_char() from the include
> to the core and make it private. That will then need an immutable
> branch from netdev to get merged back into hwmon before that patch
> can be applied, right?

We can not control if someone else starts using the function before
it is removed. As pointed out, the immutable branch needs to be from hwmon,
and the patch to make hwmon_is_bad_char private can only be applied
after all of its users are gone from the mainline kernel.

I would actually suggest to allocate the new string as part of the
function and have it return a pointer to a new string. Something like
	char *devm_hwmon_sanitize_name(struct device *dev, const char *name);
and
         char *hwmon_sanitize_name(const char *name);

because the string duplication is also part of all calling code.

Guenter