Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20985496rwd; Thu, 29 Jun 2023 09:23:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5AIZ/fWpuv69ZkAcE6X+41RKn5H8IxJ3MlnZ4v6QxWz5aNsLXLED5uVTOS+FnMDpEvwq9Z X-Received: by 2002:a17:902:ccc3:b0:1b1:9d3c:66c9 with SMTP id z3-20020a170902ccc300b001b19d3c66c9mr13398675ple.5.1688055814407; Thu, 29 Jun 2023 09:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688055814; cv=none; d=google.com; s=arc-20160816; b=W/srlZ9j+6tPYRTVjy6EsVc7cU3TOzDS9CIymXhZT5EyDUCyPH3fmnvqnfG/e90qx5 6cX8mtZZ0GeOli1SNoSWxr6jtnk3k4tIxG+eWRv5RWfhl8irLMBn1zpxPLAYgCX3meZp 73lx5ZAJFoHYeWxW1Pj65Q2Keq2o8gjwZg1/Ia+nhIPbcclMlaYQskOSwthF/8yQZmYc aLwe/wfcs8lraXS8R0g1FxFPulku6GarmcfWl3enuliqfacpxV5xGlRGOfWBHDAyDTby JTfMqn56PjeSE0/hGr7ewgzvuCKAZABGkT3YRBo+57V4x+OTuzfkpjpzzxRIM25F7FaK S0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=eEEYk/ShToEHO3DpkZSUrgjkBLpUQlN1YAui6u/teYw=; fh=pndOYlRywpyf1i5QffNLR6Ei8g6YgrRjkT+LrHThq9A=; b=lQwHV3ky/bxlr8P5JI02jfa+DfAxDTqOGbCNYeqKlMxLlDUNIIMNR/z1AFN8155FwB i9QcvfODG6I1uhSJb6prWyfzDLMjHwr+xDzGDu45I3i/X4SEJfN5hiRTw52F4qFXqry3 37U9Omr1J0gUZZWIK+xPwBorRqmcFhFEUtfO1HVi0afEzOXTAvtjJWZq/QP7tAwciAew WNgkKDUIxA4q3X6PeOWb7Z1tb2N/MY0AwpeNU7bfKEBaK724sKSWyOSEoT06alosVjWE L7LZ5kKETa5OaHioqSiQlqesJogGdV0IqaM8K/tMmXiyjQVYHxHMRBjThftICzMj/8bX m3uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001b546795669si11147292plk.391.2023.06.29.09.23.22; Thu, 29 Jun 2023 09:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229639AbjF2P7w convert rfc822-to-8bit (ORCPT + 99 others); Thu, 29 Jun 2023 11:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbjF2P7M (ORCPT ); Thu, 29 Jun 2023 11:59:12 -0400 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3DB63595; Thu, 29 Jun 2023 08:58:13 -0700 (PDT) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-991f9148334so24439866b.1; Thu, 29 Jun 2023 08:58:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688054292; x=1690646292; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/qetn1nrmN6G9CR9gXQ9Em61uIidpmKRRe6NZOrRfh0=; b=lNG9G60gMCUko3fblYwJRCr878uyFS69Ao5koexf7EwvMx2rv7Ikf/LjkFxoIQqYLx 8/wiDe1c8pUNpkkBp+QcMVhRI0MkAXcpcSt8EtcSAEV83ZY3kebGIm1bBdkWggr35rl0 gvJ3UJrVZ7WrGxiLZYvED9vPI5CX2aTOeUTo8xbPcdZB0dmnBhPyQZAp+LaQXEv23hWG gmmsm8Qb7njJFuXixyZgQooUodcEGuqlAnzryaqHbjZsrlSMVUhs1C4osXSj4dhkPJcX JcjLPP/ZiPC0yz2z5Fvx3dKIh1X4mLpovKs/GAMZ05P4yrgbiKL98Zjh+03qVdYMuon1 +xgA== X-Gm-Message-State: AC+VfDySib5EMGJK3qw//uA03IHtrxUcJy9upCN0tLaE/Zk1GEGo3PVi fkvQ2wSn84MH65VkGfhrCSU2TT8rPjDiFOoEVg4= X-Received: by 2002:a17:906:6493:b0:987:6960:36c5 with SMTP id e19-20020a170906649300b00987696036c5mr27088527ejm.6.1688054291833; Thu, 29 Jun 2023 08:58:11 -0700 (PDT) MIME-Version: 1.0 References: <20230616165034.3630141-1-michal.wilczynski@intel.com> <20230616165034.3630141-5-michal.wilczynski@intel.com> In-Reply-To: <20230616165034.3630141-5-michal.wilczynski@intel.com> From: "Rafael J. Wysocki" Date: Thu, 29 Jun 2023 17:58:00 +0200 Message-ID: Subject: Re: [PATCH v5 04/10] acpi/video: Move handler installing logic to driver To: Michal Wilczynski Cc: linux-acpi@vger.kernel.org, rafael@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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 16, 2023 at 6:51 PM Michal Wilczynski 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 > Signed-off-by: Michal Wilczynski > --- > 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. > + > 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 >