From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>, Takashi Iwai <tiwai@suse.de>,
LKML <linux-kernel@vger.kernel.org>,
Zhang Qilong <zhangqilong3@huawei.com>,
Frank Li <Frank.Li@nxp.com>, Dhruva Gole <d-gole@ti.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH v2 2/2] ACPI: TAD: Improve runtime PM using guard macros
Date: Mon, 20 Oct 2025 16:11:22 +0100 [thread overview]
Message-ID: <20251020161122.00006179@huawei.com> (raw)
In-Reply-To: <22877917.EfDdHjke4D@rafael.j.wysocki>
On Sat, 18 Oct 2025 14:24:42 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Use guard pm_runtime_active_try to simplify runtime PM cleanup and
> implement runtime resume error handling in multiple places.
>
> Also use guard pm_runtime_noresume to simplify acpi_tad_remove().
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/acpi/acpi_tad.c | 57 +++++++++++++++++++++---------------------------
> 1 file changed, 25 insertions(+), 32 deletions(-)
>
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c
> @@ -111,12 +110,11 @@ static int acpi_tad_get_real_time(struct
> acpi_status status;
> int ret = -EIO;
>
> - pm_runtime_get_sync(dev);
> + ACQUIRE(pm_runtime_active_try, pm)(dev);
> + if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
> + return -ENXIO;
>
> status = acpi_evaluate_object(handle, "_GRT", NULL, &output);
> -
> - pm_runtime_put_sync(dev);
> -
> if (ACPI_FAILURE(status))
Whilst it isn't actually a bug, this does run up against the guidance
in cleanup.h to avoid mixing gotos and cleanup.h usage in a single function.
That's partly a simplification to avoid having to explain the issues with
jumping past inline declarations.
If you want to follow that guidance, either you'd need to add a helper along the
lines of:
DEFINE_FREE(acpi_buffer, void *m ACPI_FREE(_T));
void *acpi_eval_grt(acpi_handle handle, struct acpi_buffer *output)
{
acpi_status status = acpi_evaluate_object(handle, "_GRT", NULL, &output);
if (ACPI_FAILURE(status)) {
ACPI_FREE(output.pointer);
return ERR_PTR(-EIO); //whatever error makse sense.
}
return output.pointer;
}
void *out_obj __free(acpi_buffer) = acpi_eval_grt(handle, &output);
Then can return directly at all error paths. Not the nicest bit of
code though.
Or, factor out everthing after that allocation down
to the label as helper function and have direct returns in that.
or leave it all as is and hope Linus doesn't get grumpy about mix
and match (which lead to that guidance being so general in the first place!)
The rest look good to me.
Jonathan
> goto out_free;
>
prev parent reply other threads:[~2025-10-20 15:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-18 12:22 [PATCH v2 0/2] ACPI: TAD: Use auto-cleanup macros for runtime PM Rafael J. Wysocki
2025-10-18 12:23 ` [PATCH v2 1/2] ACPI: TAD: Rearrange runtime PM operations in acpi_tad_remove() Rafael J. Wysocki
2025-10-18 12:24 ` [PATCH v2 2/2] ACPI: TAD: Improve runtime PM using guard macros Rafael J. Wysocki
2025-10-20 15:11 ` Jonathan Cameron [this message]
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=20251020161122.00006179@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Frank.Li@nxp.com \
--cc=d-gole@ti.com \
--cc=dan.j.williams@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
--cc=tiwai@suse.de \
--cc=zhangqilong3@huawei.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