[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jk=Kow_YrB5HgO2gd-bHcNx+6GKTXThf5js_ZjxaAM8w@mail.gmail.com>
Date: Wed, 22 Mar 2023 15:15:06 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org
Subject: Re: [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
On Wed, Mar 22, 2023 at 9:36 AM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
>
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: "Rafael J. Wysocki" <rafael@...nel.org>
> Cc: Len Brown <lenb@...nel.org>
> Cc: linux-acpi@...r.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> ---
> v2: - change logic to test for dev_root at the beginning of the function
> and error out then based on review comments from Rafael.
> - fix error handling for ioremap() call to properly drop the
> reference on dev_root if it failed.
>
> drivers/acpi/acpi_lpit.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index 3843d2576d3f..c5598b6d5db8 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -98,6 +98,12 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
> static void lpit_update_residency(struct lpit_residency_info *info,
> struct acpi_lpit_native *lpit_native)
> {
> + struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +
> + /* Silently fail, if cpuidle attribute group is not present */
> + if (!dev_root)
> + return;
> +
> info->frequency = lpit_native->counter_frequency ?
> lpit_native->counter_frequency : tsc_khz * 1000;
> if (!info->frequency)
> @@ -108,18 +114,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
> info->iomem_addr = ioremap(info->gaddr.address,
> info->gaddr.bit_width / 8);
> if (!info->iomem_addr)
> - return;
> + goto exit;
>
> - /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> + sysfs_add_file_to_group(&dev_root->kobj,
> &dev_attr_low_power_idle_system_residency_us.attr,
> "cpuidle");
> } else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
> - /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> + sysfs_add_file_to_group(&dev_root->kobj,
> &dev_attr_low_power_idle_cpu_residency_us.attr,
> "cpuidle");
> }
> +exit:
> + put_device(dev_root);
> }
>
> static void lpit_process(u64 begin, u64 end)
> --
> 2.40.0
>
Powered by blists - more mailing lists