All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Shalygin <eugene.shalygin@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: darcagn@protonmail.com, Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] hwmon: (asus-ec-sensors) introduce ec_board_info struct for board data
Date: Wed, 30 Mar 2022 09:51:24 +0200	[thread overview]
Message-ID: <CAB95QAQGWRT=UsXPn65oiiwBRa1RKj61sg7wq9d7VntnFWzaOg@mail.gmail.com> (raw)
In-Reply-To: <1239901b-9b4a-53ef-be86-1aa8337e0f31@roeck-us.net>

On Tue, 29 Mar 2022 at 22:28, Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 3/29/22 12:22, Eugene Shalygin wrote:
> > On Tue, 29 Mar 2022 at 15:44, Guenter Roeck <linux@roeck-us.net> wrote:
> >>>
> >>>    struct ec_sensors_data {
> >>> -     unsigned long board_sensors;
> >>> +     struct ec_board_info board_info;
> >>
> >> Please explain why this needs to be the entire structure and not
> >> just a pointer to it.
> >
> > I marked the board_info array as __initconst assuming that this large
> > array will be unloaded from memory after the init phase, while we keep
> > only a single element. Is that assumption incorrect?
> >
>
> What happens if you build the driver into the kernel and then instantiate
> and de-instantiate it multiple times ?

Sorry, I have no idea because I don't know how to load a built-in
driver multiple times. But since this driver is attached to a
motherboard device, which is persistent and always single, do I need
to consider such a scenario?

>
> >>> +static int sensor_count(const struct ec_board_info *board)
> >>> +{
> >>> +     return hweight_long(board->sensors);
> >>> +}
> >>
> >> This function is called several times. Does it really make sense, or is it
> >> necessary, to re-calculate the number of sensors over and over again
> >> instead of keeping it in ec->nr_sensors as before ? What are the benefits ?
> >> Unless there is a good explanation I see that as unrelated and unnecessary
> >> change.
> >
> > This had something to do with data deduplication. However, I need the
> > count value only for looping over the sensor array, thus I can as well
> > add an invalid element to the end of the array. I rushed to submit
> > this driver to replace the wmi one, and it still has an artifact for
> > the WMI code I'd like to get rid of eventually, which is the read
> > buffer and the registers array. This will remove all the nr_ variables
> > and two dynamically allocated arrays. I will understand, of course, if
> > you ask to submit that refactoring separately.
> >
>
> The rule of "one logical change per patch" still applies. If you start
> intermixing parts of future clean-up efforts into current patches, you'll
> see a very unhappy maintainer - especially since this change makes up
> a significant part of this patch, complicates review significantly,
> and makes me wonder if other unrelated changes are included that I don't
> see right now due to all the noise.
>
> Besides, at least in this patch, I don't buy the "deduplication" argument.
> Keeping a single additional variable in a data structure is much simpler
> and straightforward than calling hweight_long() several times. I'd call
> that "complification".

OK, I'll roll it back until I remove the other size variables and arrays.

Best regards,
Eugene

  reply	other threads:[~2022-03-30  7:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-27 12:14 [PATCH 0/4] asus-ec-sensors: add support for board families Eugene Shalygin
2022-03-27 12:14 ` [PATCH 1/4] hwmon: (asus-ec-sensors) introduce ec_board_info struct for board data Eugene Shalygin
2022-03-29 13:44   ` Guenter Roeck
2022-03-29 19:22     ` Eugene Shalygin
2022-03-29 20:26       ` Guenter Roeck
2022-03-30  7:51         ` Eugene Shalygin [this message]
2022-03-30 14:09           ` Guenter Roeck
2022-03-27 12:14 ` [PATCH 2/4] hwmon: (asus-ec-sensors) implement locking via the ACPI global lock Eugene Shalygin
2022-03-27 16:21   ` Eugene Shalygin
2022-03-27 18:04     ` Guenter Roeck
2022-03-27 18:51       ` Eugene Shalygin
2022-03-27 23:25         ` Guenter Roeck
2022-03-28 14:44           ` Eugene Shalygin
2022-03-28 15:50             ` Nathan Chancellor
2022-03-29 11:36               ` Eugene Shalygin
2022-03-29 21:23   ` Guenter Roeck
2022-03-29 22:11     ` Eugene Shalygin
2022-03-29 23:37       ` Guenter Roeck
2022-03-30  7:36         ` Eugene Shalygin
2022-03-27 12:14 ` [PATCH 3/4] hwmon: (asus-ec-sensors) add support for board families Eugene Shalygin
2022-03-27 12:14 ` [PATCH 4/4] hwmon: (asus-ec-sensors) add PRIME X470-PRO board Eugene Shalygin

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='CAB95QAQGWRT=UsXPn65oiiwBRa1RKj61sg7wq9d7VntnFWzaOg@mail.gmail.com' \
    --to=eugene.shalygin@gmail.com \
    --cc=darcagn@protonmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.