diff mbox series

[2/4] mfd: intel-lpss: Utilize i2c-designware.h

Message ID 20240423233622.1494708-3-florian.fainelli@broadcom.com
State New
Headers show
Series [1/4] i2c: designware: Create shared header hosting driver name | expand

Commit Message

Florian Fainelli April 23, 2024, 11:36 p.m. UTC
Rather than open code the i2c_designware string, utilize the newly
defined constant in i2c-designware.h.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/mfd/intel-lpss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Lee Jones May 2, 2024, 7:17 a.m. UTC | #1
On Tue, 23 Apr 2024, Florian Fainelli wrote:

> 
> 
> On 4/23/2024 5:00 PM, Andy Shevchenko wrote:
> > Tue, Apr 23, 2024 at 04:36:20PM -0700, Florian Fainelli kirjoitti:
> > > Rather than open code the i2c_designware string, utilize the newly
> > > defined constant in i2c-designware.h.
> > 
> > ...
> > 
> > >   static const struct mfd_cell intel_lpss_i2c_cell = {
> > > -	.name = "i2c_designware",
> > > +	.name = I2C_DESIGNWARE_NAME,
> > >   	.num_resources = ARRAY_SIZE(intel_lpss_dev_resources),
> > >   	.resources = intel_lpss_dev_resources,
> > >   };
> > 
> > We have tons of drivers that are using explicit naming, why is this case
> > special?
> > 
> 
> It is not special, just one of the 3 cases outside of drivers/i2c/busses
> that reference a driver living under drivers/i2c/busses, as I replied in the
> cover letter, this is a contract between the various device drivers and
> their users, so we should have a central place where it is defined, not
> repeated.

I have always held the opinion that replacing user-facing strings with
defines harms debugability, since grepping becomes a multi-stage
process, often with ambiguous results (in the case of multiple
definitions with the same name.  Please keep the string in-place.
Florian Fainelli May 2, 2024, 4:19 p.m. UTC | #2
On 5/2/24 00:17, Lee Jones wrote:
> On Tue, 23 Apr 2024, Florian Fainelli wrote:
> 
>>
>>
>> On 4/23/2024 5:00 PM, Andy Shevchenko wrote:
>>> Tue, Apr 23, 2024 at 04:36:20PM -0700, Florian Fainelli kirjoitti:
>>>> Rather than open code the i2c_designware string, utilize the newly
>>>> defined constant in i2c-designware.h.
>>>
>>> ...
>>>
>>>>    static const struct mfd_cell intel_lpss_i2c_cell = {
>>>> -	.name = "i2c_designware",
>>>> +	.name = I2C_DESIGNWARE_NAME,
>>>>    	.num_resources = ARRAY_SIZE(intel_lpss_dev_resources),
>>>>    	.resources = intel_lpss_dev_resources,
>>>>    };
>>>
>>> We have tons of drivers that are using explicit naming, why is this case
>>> special?
>>>
>>
>> It is not special, just one of the 3 cases outside of drivers/i2c/busses
>> that reference a driver living under drivers/i2c/busses, as I replied in the
>> cover letter, this is a contract between the various device drivers and
>> their users, so we should have a central place where it is defined, not
>> repeated.
> 
> I have always held the opinion that replacing user-facing strings with
> defines harms debugability, since grepping becomes a multi-stage
> process, often with ambiguous results (in the case of multiple
> definitions with the same name.  Please keep the string in-place.

I am not buying into that argument and the fact that Duangiang was able 
to trip over the lack of an explicit contract between drivers seems like 
a bigger obstacle than doing a multi-stage grep. Anyway, I have no skin 
in this game, I just don't like seeing repetition and not stating 
contracts between drivers more explicitly.
Lee Jones May 2, 2024, 4:42 p.m. UTC | #3
On Thu, 02 May 2024, Florian Fainelli wrote:

> On 5/2/24 00:17, Lee Jones wrote:
> > On Tue, 23 Apr 2024, Florian Fainelli wrote:
> > 
> > > 
> > > 
> > > On 4/23/2024 5:00 PM, Andy Shevchenko wrote:
> > > > Tue, Apr 23, 2024 at 04:36:20PM -0700, Florian Fainelli kirjoitti:
> > > > > Rather than open code the i2c_designware string, utilize the newly
> > > > > defined constant in i2c-designware.h.
> > > > 
> > > > ...
> > > > 
> > > > >    static const struct mfd_cell intel_lpss_i2c_cell = {
> > > > > -	.name = "i2c_designware",
> > > > > +	.name = I2C_DESIGNWARE_NAME,
> > > > >    	.num_resources = ARRAY_SIZE(intel_lpss_dev_resources),
> > > > >    	.resources = intel_lpss_dev_resources,
> > > > >    };
> > > > 
> > > > We have tons of drivers that are using explicit naming, why is this case
> > > > special?
> > > > 
> > > 
> > > It is not special, just one of the 3 cases outside of drivers/i2c/busses
> > > that reference a driver living under drivers/i2c/busses, as I replied in the
> > > cover letter, this is a contract between the various device drivers and
> > > their users, so we should have a central place where it is defined, not
> > > repeated.
> > 
> > I have always held the opinion that replacing user-facing strings with
> > defines harms debugability, since grepping becomes a multi-stage
> > process, often with ambiguous results (in the case of multiple
> > definitions with the same name.  Please keep the string in-place.
> 
> I am not buying into that argument and the fact that Duangiang was able to
> trip over the lack of an explicit contract between drivers seems like a
> bigger obstacle than doing a multi-stage grep. Anyway, I have no skin in
> this game, I just don't like seeing repetition and not stating contracts
> between drivers more explicitly.

Good thing no one is asking you to buy into it then. :)

I'm not sure how or if the code that failed to match was tested or what
went wrong exactly and I'm pleased that the bug was caught and fixed.

However, swapping out matching strings with a define is a regression
from a development perspective.  One which I've felt the pain of
personally in the past.  I've pushed back on it before and I'm pushing
back again.  We're not swapping out matching strings for defines.
diff mbox series

Patch

diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index 2a9018112dfc..4d2c5250046f 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -19,6 +19,7 @@ 
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/gfp_types.h>
+#include <linux/i2c-designware.h>
 #include <linux/idr.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
@@ -116,7 +117,7 @@  static const struct mfd_cell intel_lpss_idma64_cell = {
 };
 
 static const struct mfd_cell intel_lpss_i2c_cell = {
-	.name = "i2c_designware",
+	.name = I2C_DESIGNWARE_NAME,
 	.num_resources = ARRAY_SIZE(intel_lpss_dev_resources),
 	.resources = intel_lpss_dev_resources,
 };