From: "Wilczynski, Michal" <michal.wilczynski@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <linux-acpi@vger.kernel.org>, <dan.j.williams@intel.com>,
<vishal.l.verma@intel.com>, <lenb@kernel.org>,
<dave.jiang@intel.com>, <ira.weiny@intel.com>,
<rui.zhang@intel.com>, <linux-kernel@vger.kernel.org>,
<nvdimm@lists.linux.dev>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH v5 04/10] acpi/video: Move handler installing logic to driver
Date: Fri, 30 Jun 2023 11:42:31 +0200 [thread overview]
Message-ID: <a7d71bff-8577-09f5-5014-5987da1b7c6b@intel.com> (raw)
In-Reply-To: <CAJZ5v0hZ-2Ee0DCcgzHJrOikRTOJuCbEbQj24xui_-vmbd+47Q@mail.gmail.com>
On 6/29/2023 5:58 PM, Rafael J. Wysocki wrote:
> On Fri, Jun 16, 2023 at 6:51 PM Michal Wilczynski
> <michal.wilczynski@intel.com> wrote:
>> Currently logic for installing notifications from ACPI devices is
>> implemented using notify callback in struct acpi_driver. Preparations
>> are being made to replace acpi_driver with more generic struct
>> platform_driver, which doesn't contain notify callback. Furthermore
>> as of now handlers are being called indirectly through
>> acpi_notify_device(), which decreases performance.
>>
>> Call acpi_dev_install_notify_handler() at the end of .add() callback.
>> Call acpi_dev_remove_notify_handler() at the beginning of .remove()
>> callback. Change arguments passed to the notify function to match with
>> what's required by acpi_install_notify_handler(). Remove .notify
>> callback initialization in acpi_driver.
>>
>> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
>> ---
>> drivers/acpi/acpi_video.c | 26 ++++++++++++++++++++++----
>> 1 file changed, 22 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
>> index 62f4364e4460..60b7013d0009 100644
>> --- a/drivers/acpi/acpi_video.c
>> +++ b/drivers/acpi/acpi_video.c
>> @@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock);
>> static LIST_HEAD(video_bus_head);
>> static int acpi_video_bus_add(struct acpi_device *device);
>> static void acpi_video_bus_remove(struct acpi_device *device);
>> -static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
>> +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data);
>>
>> /*
>> * Indices in the _BCL method response: the first two items are special,
>> @@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = {
>> .ops = {
>> .add = acpi_video_bus_add,
>> .remove = acpi_video_bus_remove,
>> - .notify = acpi_video_bus_notify,
>> },
>> };
>>
>> @@ -1527,12 +1526,15 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
>> acpi_osi_is_win8() ? 0 : 1);
>> }
>>
>> -static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
>> +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
>> {
>> - struct acpi_video_bus *video = acpi_driver_data(device);
>> + struct acpi_device *device = data;
>> + struct acpi_video_bus *video;
>> struct input_dev *input;
>> int keycode = 0;
>>
>> + video = acpi_driver_data(device);
>> +
>> if (!video || !video->input)
>> return;
>>
>> @@ -2053,8 +2055,20 @@ static int acpi_video_bus_add(struct acpi_device *device)
>>
>> acpi_video_bus_add_notify_handler(video);
>>
>> + error = acpi_dev_install_notify_handler(device,
>> + ACPI_DEVICE_NOTIFY,
>> + acpi_video_bus_notify);
>> + if (error)
>> + goto err_remove_and_unregister_video;
> This label name is a bit too long and the second half of it doesn't
> really add any value IMV. err_remove would be sufficient.
I've seen different patterns in the code, sometimes the label describe what failed,
sometimes it describe what needs to be cleaned up. I don't really have a strong
preference, just thought it might be useful to the reader. Will change as suggested.
>
>> +
>> return 0;
>>
>> +err_remove_and_unregister_video:
>> + mutex_lock(&video_list_lock);
>> + list_del(&video->entry);
>> + mutex_unlock(&video_list_lock);
>> + acpi_video_bus_remove_notify_handler(video);
>> + acpi_video_bus_unregister_backlight(video);
>> err_put_video:
>> acpi_video_bus_put_devices(video);
>> kfree(video->attached_array);
>> @@ -2075,6 +2089,10 @@ static void acpi_video_bus_remove(struct acpi_device *device)
>>
>> video = acpi_driver_data(device);
>>
>> + acpi_dev_remove_notify_handler(device,
>> + ACPI_DEVICE_NOTIFY,
>> + acpi_video_bus_notify);
>> +
>> mutex_lock(&video_list_lock);
>> list_del(&video->entry);
>> mutex_unlock(&video_list_lock);
>> --
>> 2.41.0
>>
next prev parent reply other threads:[~2023-06-30 9:42 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 16:50 [PATCH v5 00/10] Remove .notify callback in acpi_device_ops Michal Wilczynski
2023-06-16 16:50 ` [PATCH v5 01/10] acpi/bus: Introduce wrappers for ACPICA event handler install/remove Michal Wilczynski
2023-06-16 16:50 ` [PATCH v5 02/10] acpi/bus: Set driver_data to NULL every time .add() fails Michal Wilczynski
2023-06-16 16:50 ` [PATCH v5 03/10] acpi/ac: Move handler installing logic to driver Michal Wilczynski
2023-06-29 15:55 ` Rafael J. Wysocki
2023-06-30 9:39 ` Wilczynski, Michal
2023-06-30 9:41 ` Rafael J. Wysocki
2023-06-30 9:45 ` Rafael J. Wysocki
2023-06-16 16:50 ` [PATCH v5 04/10] acpi/video: " Michal Wilczynski
2023-06-29 15:58 ` Rafael J. Wysocki
2023-06-30 9:42 ` Wilczynski, Michal [this message]
2023-06-16 16:50 ` [PATCH v5 05/10] acpi/battery: " Michal Wilczynski
2023-06-29 16:05 ` Rafael J. Wysocki
2023-06-30 9:48 ` Wilczynski, Michal
2023-06-16 16:50 ` [PATCH v5 06/10] acpi/hed: " Michal Wilczynski
2023-06-16 16:50 ` [PATCH v5 07/10] acpi/nfit: Move acpi_nfit_notify() before acpi_nfit_add() Michal Wilczynski
2023-06-29 16:06 ` Rafael J. Wysocki
2023-06-30 9:48 ` Wilczynski, Michal
2023-06-30 10:52 ` Rafael J. Wysocki
2023-06-16 16:50 ` [PATCH v5 08/10] acpi/nfit: Improve terminator line in acpi_nfit_ids Michal Wilczynski
2023-06-29 16:14 ` Rafael J. Wysocki
2023-06-30 9:52 ` Wilczynski, Michal
2023-06-30 11:04 ` Rafael J. Wysocki
2023-06-30 11:13 ` Rafael J. Wysocki
2023-06-30 12:02 ` Wilczynski, Michal
2023-06-29 20:51 ` Dan Williams
2023-06-30 10:10 ` Wilczynski, Michal
2023-06-16 16:50 ` [PATCH v5 09/10] acpi/nfit: Move handler installing logic to driver Michal Wilczynski
2023-06-29 16:18 ` Rafael J. Wysocki
2023-06-30 9:55 ` Wilczynski, Michal
2023-06-30 11:00 ` Rafael J. Wysocki
2023-06-29 20:54 ` Dan Williams
2023-06-30 16:56 ` Wilczynski, Michal
2023-06-30 17:19 ` Dan Williams
2023-06-30 17:26 ` Wilczynski, Michal
2023-06-16 16:50 ` [PATCH v5 10/10] acpi/thermal: " Michal Wilczynski
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=a7d71bff-8577-09f5-5014-5987da1b7c6b@intel.com \
--to=michal.wilczynski@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=vishal.l.verma@intel.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
all inboxes | Powered by JetHome®