lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZSBH1pd2cfk83QZ4@smile.fi.intel.com>
Date:   Fri, 6 Oct 2023 20:45:58 +0300
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     Michal Wilczynski <michal.wilczynski@...el.com>
Cc:     linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
        nvdimm@...ts.linux.dev, rafael.j.wysocki@...el.com,
        lenb@...nel.org, dan.j.williams@...el.com,
        vishal.l.verma@...el.com, ira.weiny@...el.com
Subject: Re: [PATCH v2 3/6] ACPI: AC: Replace acpi_driver with platform_driver

On Fri, Oct 06, 2023 at 08:30:52PM +0300, Michal Wilczynski wrote:
> AC driver uses struct acpi_driver incorrectly to register itself. This
> is wrong as the instances of the ACPI devices are not meant to
> be literal devices, they're supposed to describe ACPI entry of a
> particular device.
> 
> Use platform_driver instead of acpi_driver. In relevant places call
> platform devices instances pdev to make a distinction with ACPI
> devices instances.
> 
> Drop unnecessary casts from acpi_bus_generate_netlink_event() and
> acpi_notifier_call_chain().
> 
> Add a blank line to distinguish pdev API vs local ACPI notify function.

...

>  struct acpi_ac {
>  	struct power_supply *charger;
>  	struct power_supply_desc charger_desc;
> -	struct acpi_device *device;
> +	struct device *dev;
>  	unsigned long long state;
>  	struct notifier_block battery_nb;
>  };

When changing this, also makes sense just to check if the moving a member in
the data structure makes code shorter, but it's not a show stopper.

...

> -	status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL,
> +	status = acpi_evaluate_integer(ACPI_HANDLE(ac->dev), "_PSR", NULL,
>  				       &ac->state);
>  	if (ACPI_FAILURE(status)) {
> -		acpi_handle_info(ac->device->handle,
> +		acpi_handle_info(ACPI_HANDLE(ac->dev),

Can we call ACPI_HANDLE() only once and cache that in a local variable and use
in all places?

...

> -	struct acpi_ac *ac = acpi_driver_data(device);
> +	struct acpi_ac *ac = data;
> +	struct acpi_device *device = ACPI_COMPANION(ac->dev);
>  
>  	switch (event) {
>  	default:

> -		acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
> +		acpi_handle_debug(ACPI_HANDLE(ac->dev), "Unsupported event [0x%x]\n",
>  				  event);

Does it makes any sense now? Basically it duplicates the ACPI_COMPANION() call
as Rafael pointed out in previous version discussion.

>  		fallthrough;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ