public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v2 8/9] i2c: i801: Improve register_dell_lis3lv02d_i2c_device
Date: Fri, 27 Aug 2021 18:21:35 +0200	[thread overview]
Message-ID: <20210827182135.1d9670c0@endymion> (raw)
In-Reply-To: <8ba091fd-b6ff-e800-1c46-aaf9992f1e03@gmail.com>

Hi Heiner, Andy,

On Wed, 11 Aug 2021 23:05:06 +0200, Heiner Kallweit wrote:
> On 11.08.2021 17:52, Andy Shevchenko wrote:
> > On Fri, Aug 06, 2021 at 11:18:05PM +0200, Heiner Kallweit wrote:  
> >> - Use an initializer for struct i2c_board_info info
> >> - Use dmi_match()
> >> - Simplify loop logic  
> > 
> > I'm wondering if changing this to a DMI match table will give better result.
> > 
> > Something like
> > (Sorry I forgot APIs, but plenty of examples are under PDx86: drivers/platform/x86):
> > 
> > struct dmi_..._id *id;
> > 
> > id = dmi_..._match();
> > if (!id) {
> > 	pci_warn();
> > 	return;
> > }
> > 
> > i2c_new_client_device(...);
> 
> We could do something like the following. Whether it's better may be a
> question of personal taste. I have no strong opinion here and would leave
> it to Jean.
> 
> const struct dmi_system_id lis3_id_table[] = {
>         {
>                 .driver_data = (void *)0x29,
>                 .matches = {
>                         DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E5550"),
>                 },
>         },
> 	...
> 
> dmi_system_id *id = dmi_first_match(lis3_id_table);
> if (id)
> 	i2c_new_client_device(..., (unsigned int)id->driver_data;
> else
> 	lament()
> 

I gave it an actual try, and must say I'm not convinced. Heiner's patch
is -6 lines of source code and +1 byte on the binary (according to
scripts/bloat-o-meter - ls -l disagrees, don't ask me why). My
suggested alternative (as discussed in the v1 of this patch set,
basically Heiner's patch minus the removal of dmi_product_name) is -3
lines of source code and +17 bytes on the binary, but should be faster
than Heiner's version.

Andy's approach results in an overall increase of the source code by 29
lines and +2582 bytes on the binary. Sure, if you break it down, it's
+2624 data and -42 code, so it does "simplify the code", but that's too
high a price to pay for a marginal code simplification. It also has the
downside of reintroducing a cast from int to pointer and back,
something we were trying to get rid of in another patch of this series.
This could of course be avoided but this would make the patch even
larger.

So thanks, but no thanks. Just because an API exists does not mean you
have to use it in all cases.

I stand on my original position, let's stick to dmi_get_system_info() +
strcmp() as the driver did originally. In other words, don't change
code that has been working for years when the alternatives bring no
clear benefit.

Thanks,
-- 
Jean Delvare
SUSE L3 Support

  parent reply	other threads:[~2021-08-27 16:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06 21:10 [PATCH v2 0/9] i2c: i801: Series with improvements Heiner Kallweit
2021-08-06 21:12 ` [PATCH v2 1/9] i2c: i801: Improve disabling runtime pm Heiner Kallweit
2021-08-10 20:37   ` Wolfram Sang
2021-08-11 15:41   ` Andy Shevchenko
2021-08-11 20:03     ` Heiner Kallweit
2021-08-12  9:48       ` Andy Shevchenko
2021-08-17 20:15         ` Wolfram Sang
2021-08-26 14:00           ` Jean Delvare
2021-08-26 14:34             ` Andy Shevchenko
2021-08-31  6:05             ` Heiner Kallweit
2021-08-31 11:26               ` Jean Delvare
2021-08-31 20:43                 ` Heiner Kallweit
2021-09-01  6:22                   ` Heiner Kallweit
2021-08-06 21:13 ` [PATCH v2 2/9] i2c: i801: make p2sb_spinlock a mutex Heiner Kallweit
2021-08-10 20:38   ` Wolfram Sang
2021-08-11 15:43   ` Andy Shevchenko
2021-08-11 20:27     ` Heiner Kallweit
2021-08-12  9:53       ` Andy Shevchenko
2021-08-06 21:14 ` [PATCH v2 3/9] i2c: i801: Remove not needed debug message Heiner Kallweit
2021-08-10 20:39   ` Wolfram Sang
2021-08-06 21:15 ` [PATCH v2 4/9] i2c: i801: Improve is_dell_system_with_lis3lv02d Heiner Kallweit
2021-08-11 15:45   ` Andy Shevchenko
2021-08-11 20:28     ` Heiner Kallweit
2021-08-12  9:55       ` Andy Shevchenko
2021-08-26 14:19         ` Jean Delvare
2021-08-26 13:21   ` Jean Delvare
2021-09-29 19:38   ` Wolfram Sang
2021-08-06 21:15 ` [PATCH v2 5/9] i2c: i801: Remove not needed check for PCI_COMMAND_INTX_DISABLE Heiner Kallweit
2021-08-11 15:46   ` Andy Shevchenko
2021-08-26 15:18   ` Jean Delvare
2021-09-29 19:38   ` Wolfram Sang
2021-08-06 21:16 ` [PATCH v2 6/9] i2c: i801: Improve i801_acpi_probe/remove functions Heiner Kallweit
2021-09-29 19:38   ` Wolfram Sang
2021-08-06 21:17 ` [PATCH v2 7/9] i2c: i801: Improve i801_add_mux Heiner Kallweit
2021-09-29 19:38   ` Wolfram Sang
2021-08-06 21:18 ` [PATCH v2 8/9] i2c: i801: Improve register_dell_lis3lv02d_i2c_device Heiner Kallweit
2021-08-11 15:52   ` Andy Shevchenko
2021-08-11 21:05     ` Heiner Kallweit
2021-08-12  9:57       ` Andy Shevchenko
2021-08-27 16:21       ` Jean Delvare [this message]
2021-09-29 20:11         ` Wolfram Sang
2021-10-01 11:46           ` Jean Delvare
2021-08-06 21:18 ` [PATCH v2 9/9] i2c: i801: Improve handling platform data for tco device Heiner Kallweit
2021-08-11 15:53   ` Andy Shevchenko
2021-10-02  7:44   ` Wolfram Sang
2021-11-29  8:58     ` Wolfram Sang
2021-11-29 19:54       ` Heiner Kallweit
2021-11-29 19:53 ` [PATCH v3] " Heiner Kallweit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210827182135.1d9670c0@endymion \
    --to=jdelvare@suse.de \
    --cc=andriy.shevchenko@intel.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox