All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kurt Borja" <kuurtb@gmail.com>
To: "Joshua Grisham" <josh@joshuagrisham.com>,
	"Thomas Weißschuh" <linux@weissschuh.net>
Cc: <W_Armin@gmx.de>, <ilpo.jarvinen@linux.intel.com>,
	<hdegoede@redhat.com>, <platform-driver-x86@vger.kernel.org>,
	<corbet@lwn.net>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v8] platform/x86: samsung-galaxybook: Add samsung-galaxybook driver
Date: Sat, 25 Jan 2025 10:06:04 -0500	[thread overview]
Message-ID: <D7B8WVUD7F4B.1BL2WE2BNRCX6@gmail.com> (raw)
In-Reply-To: <CAMF+Keb5UzEUeim=33JR=Vv8qK7xqGn_jjNdtZMQTFtrpKrgSA@mail.gmail.com>

On Sat Jan 25, 2025 at 6:45 AM -05, Joshua Grisham wrote:
> Hi Thomas, thank you for the review and taking the time to go through it again!
>
> Den fre 24 jan. 2025 kl 00:42 skrev Thomas Weißschuh <linux@weissschuh.net>:
>>
>> Hi Joshua,
>>
>> looks good to me.
>> I have some nitpicks inline, but even for the current state:
>>
>> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
>>
>> > +static ssize_t charge_control_end_threshold_show(struct device *dev, struct device_attribute *attr,
>> > +                                              char *buf)
>> > +{
>> > +     struct samsung_galaxybook *galaxybook =
>> > +             container_of(attr, struct samsung_galaxybook, charge_control_end_threshold_attr);
>> > +     u8 value;
>> > +     int err;
>> > +
>> > +     err = charge_control_end_threshold_acpi_get(galaxybook, &value);
>> > +     if (err)
>> > +             return err;
>> > +
>> > +     /*
>> > +      * device stores "no end threshold" as 0 instead of 100;
>> > +      * if device has 0, report 100
>> > +      */
>> > +     if (value == 0)
>> > +             value = 100;
>> > +
>> > +     return sysfs_emit(buf, "%u\n", value);
>> > +}
>>
>> For the next revision you should be able to use the power supply
>> extension framework.
>>
>
> I looked around a bit in the mailing lists and saw some of the
> proposed patches now which add power_supply_sysfs_add_extension() and
> similar functions, but do not see them yet in for-next of the pdx86
> repository. Do you think it makes more sense to wait on
> samsung-galaxybook and then add these changes from the start, or go
> ahead with samsung-galaxybook and then update it after with using the
> new framework?
>
>> > +
>> > +#define gb_pfmode(profile) galaxybook->profile_performance_modes[profile]
>>
>> The usage sites of this macro don't look like regular C syntax.
>> This is iffy and can confuse some code parsers.
>> Any chance it could be reworked to look more regular?
>>
>
> Good point, and to be honest the only reason for this was to give me a
> way to keep all of the lines below 100 characters :) Now I have just
> made it a local pointer within galaxybook_platform_profile_probe in
> order to achieve the same effect, so hopefully it looks and feels more
> "standard" now, but please take a look when I eventually send this
> later as v9 !
>
>> > +static const struct platform_profile_ops galaxybook_platform_profile_ops = {
>> > +     .probe = galaxybook_platform_profile_probe,
>> > +     .profile_get = galaxybook_platform_profile_get,
>> > +     .profile_set = galaxybook_platform_profile_set,
>> > +};
>> > +
>> > +static int galaxybook_platform_profile_init(struct samsung_galaxybook *galaxybook)
>> > +{
>> > +     struct device *platform_profile_dev;
>> > +     u8 performance_mode;
>> > +     int err;
>> > +
>> > +     /* check that performance mode appears to be supported on this device */
>> > +     err = performance_mode_acpi_get(galaxybook, &performance_mode);
>> > +     if (err) {
>> > +             dev_dbg(&galaxybook->platform->dev,
>> > +                     "failed to get initial performance mode, error %d\n", err);
>> > +             return 0;
>> > +     }
>> > +
>> > +     galaxybook->has_performance_mode = true;
>>
>> This should be set *after* devm_platform_profile_register() succeeded, no?
>> I would prefer it slightly if the flags where set by galaxybook_probe()
>> instead of the _init() functions.
>>
>
> Here it gets a bit tricky. Originally, I had much of the logic from
> galaxybook_platform_profile_probe in this
> galaxybook_platform_profile_init function, as I really wanted to
> evaluate if all of the ACPI methods were working and it was possible
> to map at least one Samsung "performance mode" to a profile, but
> feedback from Kurt (which I agree with) is that it is within the probe
> that should really be handling this kind of logic.
>
> At that point I decided that it was ONLY success of
> performance_mode_acpi_get that I am now using to determine
> has_performance_mode, so I set it immediately after more from a
> "self-documenting" perspective.
>
> Now the code works so that if galaxybook_platform_profile_probe fails,
> then that failure will bubble up to galaxybook_probe which will then
> cause the entire driver to unload ... so it will not matter anyway if
> or where the value was set, the module will no longer even be loaded
> :)

Now I understand the original problem better. I didn't consider this
possibility when designing the callback.

While this is a fine solution I believe Thomas' EOPNOTSUPP solution is
the way to go. I think positive err value would be the safest but you
should wait for the advice of someone with more experience.

Aside from that I really like how the whole platform profile sections
works now. Good design choices :)

~ Kurt

> <snip>

  parent reply	other threads:[~2025-01-25 15:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-18 20:26 [PATCH v8] platform/x86: samsung-galaxybook: Add samsung-galaxybook driver Joshua Grisham
2025-01-23 23:42 ` Thomas Weißschuh
2025-01-25 11:45   ` Joshua Grisham
2025-01-25 12:26     ` Thomas Weißschuh
2025-01-25 13:42       ` Joshua Grisham
2025-01-25 15:06     ` Kurt Borja [this message]
2025-01-28 19:17       ` Joshua Grisham
2025-01-28 21:17         ` Thomas Weißschuh
2025-01-30 17:17           ` Joshua Grisham
2025-01-30 18:51             ` Thomas Weißschuh
2025-01-29 13:47         ` Ilpo Järvinen
2025-01-26 14:34 ` Armin Wolf

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=D7B8WVUD7F4B.1BL2WE2BNRCX6@gmail.com \
    --to=kuurtb@gmail.com \
    --cc=W_Armin@gmx.de \
    --cc=corbet@lwn.net \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=josh@joshuagrisham.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=platform-driver-x86@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 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.