From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Xi Huang <xuiagnh@gmail.com>
Cc: jeremy@system76.com, productdev@system76.com,
Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: system76: Reducing redundant conditional judgments in system76_add()
Date: Tue, 20 Aug 2024 14:06:40 +0300 (EEST) [thread overview]
Message-ID: <079a7474-0255-f486-9847-97d67c2e44d2@linux.intel.com> (raw)
In-Reply-To: <20240820090239.17771-1-xuiagnh@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]
On Tue, 20 Aug 2024, Xi Huang wrote:
> In case of an error, goto jumps to the “error” label,
> where the if (data->has_open_ec) check is redundant in most cases.
> Since the conditions for most goto statements have already
> been satisfied by if (data->has_open_ec),the code has been modified to
> improve execution speed.
And why would the error rollback path need to be improved in execution
speed? In any case, this change is going to below the noise level when it
comes to a measurable impact.
I'm sorry but I don't think this change is useful.
--
i.
> Signed-off-by: Xi Huang <xuiagnh@gmail.com>
> ---
> drivers/platform/x86/system76_acpi.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
> index 3da753b3d..05b4bf18f 100644
> --- a/drivers/platform/x86/system76_acpi.c
> +++ b/drivers/platform/x86/system76_acpi.c
> @@ -757,33 +757,34 @@ static int system76_add(struct acpi_device *acpi_dev)
>
> err = input_register_device(data->input);
> if (err)
> - goto error;
> + if (data->has_open_ec)
> + goto free_error;
> + else
> + return err;
>
> if (data->has_open_ec) {
> err = system76_get_object(data, "NFAN", &data->nfan);
> if (err)
> - goto error;
> + goto free_error;
>
> err = system76_get_object(data, "NTMP", &data->ntmp);
> if (err)
> - goto error;
> + goto free_error;
>
> data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
> "system76_acpi", data, &thermal_chip_info, NULL);
> err = PTR_ERR_OR_ZERO(data->therm);
> if (err)
> - goto error;
> + goto free_error;
>
> system76_battery_init();
> }
>
> return 0;
>
> -error:
> - if (data->has_open_ec) {
> - kfree(data->ntmp);
> - kfree(data->nfan);
> - }
> +free_error:
> + kfree(data->ntmp);
> + kfree(data->nfan);
> return err;
> }
>
>
next prev parent reply other threads:[~2024-08-20 11:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 9:02 [PATCH] platform/x86: system76: Reducing redundant conditional judgments in system76_add() Xi Huang
2024-08-20 11:06 ` Ilpo Järvinen [this message]
2024-08-20 19:18 ` kernel test robot
2024-08-20 19:18 ` kernel test robot
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=079a7474-0255-f486-9847-97d67c2e44d2@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=jeremy@system76.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=productdev@system76.com \
--cc=xuiagnh@gmail.com \
/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