From patchwork Wed Oct 25 11:18:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 737902 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6945273D1 for ; Wed, 25 Oct 2023 11:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PQ2gxTkg" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C1A116; Wed, 25 Oct 2023 04:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232715; x=1729768715; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=556kuxWLablNck66gh7gdlu265PifGuIbT7//kLJcU0=; b=PQ2gxTkgRv1JEXE3SYXlvvu8hgwQQ/lXs5FBeYhOZW71zsD3ZgKVJlDH I62vzLjBuEJOzEXFkhIGEXpp2iO2ACSXtjPQ/d93AF9rkGLpzYLUlrTyz JXLoOABNATlnvgZsa3BejPjKy3ABqmMgh4pFA6RHwGZGiKpgeLhi6agOH steKGGNFfQeE8f7CGH96Na/x3MsnicSoKHdrgG74+zg+l8KTzhd86vZFc 56TpkZjGRtZQXnbv0KLHMJJ0HgmB2qq2bntpjwsCoB9o0oKUOn0Ee4/pE WSrM7L/IxZxYq05DT7sLGeYTTCoel2P/q3l+XodLpY9vWYqBB8JD8LQ0E Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154615" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154615" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425086" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425086" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:18 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski , Andy Shevchenko Subject: [PATCH v1 1/6] ACPI: acpi_video: Remove unnecessary checks Date: Wed, 25 Oct 2023 14:18:01 +0300 Message-ID: <20231025111806.2416524-2-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove unnecessary checks for NULL for variables that can't be NULL at the point they're checked for it. Reviewed-by: Andy Shevchenko Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 0b7a01f38b65..c14b44f99e35 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1027,9 +1027,6 @@ static int acpi_video_bus_check(struct acpi_video_bus *video) acpi_status status = -ENOENT; struct pci_dev *dev; - if (!video) - return -EINVAL; - dev = acpi_get_pci_dev(video->device->handle); if (!dev) return -ENODEV; @@ -2087,13 +2084,7 @@ static int acpi_video_bus_add(struct acpi_device *device) static void acpi_video_bus_remove(struct acpi_device *device) { - struct acpi_video_bus *video = NULL; - - - if (!device || !acpi_driver_data(device)) - return; - - video = acpi_driver_data(device); + struct acpi_video_bus *video = acpi_driver_data(device); acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); From patchwork Wed Oct 25 11:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 738381 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6EAF273CD for ; Wed, 25 Oct 2023 11:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i29CdDs5" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84B28AC; Wed, 25 Oct 2023 04:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232715; x=1729768715; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FBsgi0f5RSq42TrQbFfpfnW/pY1sLDlris71usgmqQw=; b=i29CdDs5hpEiGQ/o5KOI6Wm9I0jbG2aDGpKTdb/rAf5+GG0afbO6lXg3 mtAKKFgjCPl3DTXkVA4J+2JvYRZZgRmCFv9GdDq9bmctwbgmLWSt6yq2Q pgWQi3Ccr22gRJ1ioXRUuFkXnynSeX/K+hybVdxkjrjh0aFCDwo2KM1c7 bGTZDzSHx8U1Aq9eWXvmicNCnmVMQzz+6bFpXePI4BaYVAZ1pDg96bYoR Mt7Fu3wmCJDdNSQH6q5eSUXZW00oevyJf8bPVKG4elutc7leXjZPOu/JX laGefowj6zkSvTEQ01QNzMtZTj/KlfxFaBonTvhGyEPmfjnzJZowfvooc A==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154626" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154626" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425094" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425094" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:20 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 2/6] ACPI: acpi_video: Use yes_or_no helper instead of ternary operator Date: Wed, 25 Oct 2023 14:18:02 +0300 Message-ID: <20231025111806.2416524-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use string helper, instead of manually computing "yes" or "no" using ternary operator. Suggested-by: Andy Shevchenko Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index c14b44f99e35..e17474949bbb 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -2032,9 +2032,9 @@ static int acpi_video_bus_add(struct acpi_device *device) pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n", ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), - video->flags.multihead ? "yes" : "no", - video->flags.rom ? "yes" : "no", - video->flags.post ? "yes" : "no"); + str_yes_no(video->flags.multihead), + str_yes_no(video->flags.rom), + str_yes_no(video->flags.post)); mutex_lock(&video_list_lock); list_add_tail(&video->entry, &video_bus_head); mutex_unlock(&video_list_lock); From patchwork Wed Oct 25 11:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 738380 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4AE626E19 for ; Wed, 25 Oct 2023 11:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XVnH2i6y" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEF50137; Wed, 25 Oct 2023 04:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232716; x=1729768716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GGWBLv1O7SHoGXNqpswjaidLqIzwApROs0cSW0Fp2r8=; b=XVnH2i6yhtAz/hY4hA0WS3OjmJbRC8Vi1L0e9WESRTIgx0xzGyvQdSdh ICZoR7QVgZJ6oduA7tWm0bpO4sTbbpAfBMgkSam53mK0peLfQIWRQGoLs iO/p6RBo/+BcI3Mi0NcR460Rm90FzkfA5vROZNb2Y3lUwFRBAt7O7JxGH udpKh6LqZS/++FPM9jZ8kpueie9omX0N52aLVeUeFTYWsSkBWdByDq+Hz QKsxaG+A604I67LIaXT918sT78A5daxmWE5GrIuH/26N5A9wV1JLFx+XD SlHwU92WkvO9x0PBbqlZMe8Hx8lsU+vC0jkY0RHBi19pa5FPc0UJqRroO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154628" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154628" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425103" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425103" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:22 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 3/6] ACPI: acpi_video: Remove unnecessary driver_data clear Date: Wed, 25 Oct 2023 14:18:03 +0300 Message-ID: <20231025111806.2416524-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 0d16710146a1 ("ACPI: bus: Set driver_data to NULL every time .add() fails") introduced clearing driver_data every time probe fails, so it's not necessary to clear it in the probe() callback. Remove NULL assignment to driver_data in error path in acpi_video_bus_add(). Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index e17474949bbb..0c93b0ef0feb 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -2077,7 +2077,6 @@ static int acpi_video_bus_add(struct acpi_device *device) kfree(video->attached_array); err_free_video: kfree(video); - device->driver_data = NULL; return error; } From patchwork Wed Oct 25 11:18:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 737901 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F758273CD for ; Wed, 25 Oct 2023 11:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iYD+r70B" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 274AD18A; Wed, 25 Oct 2023 04:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232717; x=1729768717; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kk6qAnA8TIEab1NEc+P02lCCwI8ZDSv7ghqU2ChGxeA=; b=iYD+r70BDOhEoz17qQZVQ3vDaqsUiJUyQrrIfo7X0VnZa8bkZRa6PZzE 4HJNJmxX24BW769qbhPjMDZJcKFsAHTGJpE/rcnJQhOdWCDVBMaggtv+R WeEIDEyw6TjsAqU0xseEHkRv2Orrb6eLtpjreShNB/pPghE5RKk32A3HE Zq5PXq4GvISz3Izfae0zk2IeSwEbxevnf21J94f4PMrfCVBBcP5NvxFzx 5etnzotPIEg2EuOoksTC5jOv3ZPkPDugpob/CRNcJ9556C2NNoplaigqu wrxlDRdgWdjTPinMkLdr0u/UaBtaR9uA9IsCz3VPUb+0nh02/In5T1+nx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154631" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154631" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425117" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425117" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:24 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 4/6] ACPI: acpi_video: Replace acpi_driver with platform_driver Date: Wed, 25 Oct 2023 14:18:04 +0300 Message-ID: <20231025111806.2416524-5-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The acpi_video driver uses struct acpi_driver to register itself while it would be more logically consistent to use struct platform_driver for this purpose, because the corresponding platform device is present and the role of struct acpi_device is to amend the other bus types. ACPI devices are not meant to be used as proper representation of hardware entities, but to collect information on those hardware entities provided by the platform firmware. Use struct platform_driver for registering the acpi_video driver. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 0c93b0ef0feb..5b9fb3374a2e 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -75,8 +76,8 @@ static int register_count; static DEFINE_MUTEX(register_count_mutex); 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 int acpi_video_bus_probe(struct platform_device *pdev); +static void acpi_video_bus_remove(struct platform_device *pdev); static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data); /* @@ -97,14 +98,13 @@ static const struct acpi_device_id video_device_ids[] = { }; MODULE_DEVICE_TABLE(acpi, video_device_ids); -static struct acpi_driver acpi_video_bus = { - .name = "video", - .class = ACPI_VIDEO_CLASS, - .ids = video_device_ids, - .ops = { - .add = acpi_video_bus_add, - .remove = acpi_video_bus_remove, - }, +static struct platform_driver acpi_video_bus = { + .probe = acpi_video_bus_probe, + .remove_new = acpi_video_bus_remove, + .driver = { + .name = "video", + .acpi_match_table = video_device_ids, + }, }; struct acpi_video_bus_flags { @@ -1525,8 +1525,8 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_device *device = data; - struct acpi_video_bus *video = acpi_driver_data(device); + struct acpi_video_bus *video = data; + struct acpi_device *device = video->device; struct input_dev *input; int keycode = 0; @@ -1969,8 +1969,9 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) static int instance; -static int acpi_video_bus_add(struct acpi_device *device) +static int acpi_video_bus_probe(struct platform_device *pdev) { + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); struct acpi_video_bus *video; bool auto_detect; int error; @@ -2010,7 +2011,7 @@ static int acpi_video_bus_add(struct acpi_device *device) video->device = device; strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); - device->driver_data = video; + platform_set_drvdata(pdev, video); acpi_video_bus_find_cap(video); error = acpi_video_bus_check(video); @@ -2059,7 +2060,7 @@ static int acpi_video_bus_add(struct acpi_device *device) goto err_del; error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, - acpi_video_bus_notify, device); + acpi_video_bus_notify, video); if (error) goto err_remove; @@ -2081,11 +2082,11 @@ static int acpi_video_bus_add(struct acpi_device *device) return error; } -static void acpi_video_bus_remove(struct acpi_device *device) +static void acpi_video_bus_remove(struct platform_device *pdev) { - struct acpi_video_bus *video = acpi_driver_data(device); + struct acpi_video_bus *video = platform_get_drvdata(pdev); - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, + acpi_dev_remove_notify_handler(video->device, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); mutex_lock(&video_list_lock); @@ -2200,7 +2201,7 @@ int acpi_video_register(void) dmi_check_system(video_dmi_table); - ret = acpi_bus_register_driver(&acpi_video_bus); + ret = platform_driver_register(&acpi_video_bus); if (ret) goto leave; @@ -2220,7 +2221,7 @@ void acpi_video_unregister(void) { mutex_lock(®ister_count_mutex); if (register_count) { - acpi_bus_unregister_driver(&acpi_video_bus); + platform_driver_unregister(&acpi_video_bus); register_count = 0; may_report_brightness_keys = false; } From patchwork Wed Oct 25 11:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 738379 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15D51273D6 for ; Wed, 25 Oct 2023 11:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YMPxpEXU" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26277186; Wed, 25 Oct 2023 04:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232717; x=1729768717; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZnEsI21T+BVIgOU+yWrQFs6Jq1f1Hh4Po/SFx2T8n10=; b=YMPxpEXUr1TQoE1HGFxTmvRZ9oXwYLg6mbK1e6QuqrIeh+lXwAp2Heqk y0h/5V3oVwsZZQE8xmpT9z/y2sE8AirxcwApfc3Fyg/LipsdWh5x5Z6u6 UUrAUr/WKYJJiS48msyHzWaXMdKJ296MntleByd8z6I23u/Etztc6gpwL HiiDf639iEOcS7X74Jb8QAY7oRvCtErkqCCTmy3xeTUxqm5PUd/k4OiFI sEbDTGf2xnOpBAtNUYzjUeMeMwhjYPQhaA0Jta12kBw0bJoGI8CG54FCY MpbpbZPIIKDTtDX1UxT2rcJTmtywXi2ekiSkk+QMhd1DurNGRfbO+re1w w==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154634" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154634" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425130" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425130" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:26 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 5/6] ACPI: acpi_video: Rename ACPI device instances from device to adev Date: Wed, 25 Oct 2023 14:18:05 +0300 Message-ID: <20231025111806.2416524-6-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since transformation from ACPI driver to platform driver there are two devices on which the driver operates - ACPI device and platform device. For the sake of reader this calls for the distinction in their naming, to avoid confusion. Rename relevant ACPI devices to adev, as corresponding platform devices are called pdev. Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 5b9fb3374a2e..bfc7f51a527d 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1526,7 +1526,7 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) { struct acpi_video_bus *video = data; - struct acpi_device *device = video->device; + struct acpi_device *adev = video->device; struct input_dev *input; int keycode = 0; @@ -1559,12 +1559,12 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) break; default: - acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", + acpi_handle_debug(adev->handle, "Unsupported event [0x%x]\n", event); break; } - if (acpi_notifier_call_chain(device, event, 0)) + if (acpi_notifier_call_chain(adev, event, 0)) /* Something vetoed the keypress. */ keycode = 0; @@ -1971,16 +1971,16 @@ static int instance; static int acpi_video_bus_probe(struct platform_device *pdev) { - struct acpi_device *device = ACPI_COMPANION(&pdev->dev); + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); struct acpi_video_bus *video; bool auto_detect; int error; acpi_status status; status = acpi_walk_namespace(ACPI_TYPE_DEVICE, - acpi_dev_parent(device)->handle, 1, - acpi_video_bus_match, NULL, - device, NULL); + acpi_dev_parent(adev)->handle, 1, + acpi_video_bus_match, NULL, + adev, NULL); if (status == AE_ALREADY_EXISTS) { pr_info(FW_BUG "Duplicate ACPI video bus devices for the" @@ -1996,21 +1996,21 @@ static int acpi_video_bus_probe(struct platform_device *pdev) return -ENOMEM; /* a hack to fix the duplicate name "VID" problem on T61 */ - if (!strcmp(device->pnp.bus_id, "VID")) { + if (!strcmp(adev->pnp.bus_id, "VID")) { if (instance) - device->pnp.bus_id[3] = '0' + instance; + adev->pnp.bus_id[3] = '0' + instance; instance++; } /* a hack to fix the duplicate name "VGA" problem on Pa 3553 */ - if (!strcmp(device->pnp.bus_id, "VGA")) { + if (!strcmp(adev->pnp.bus_id, "VGA")) { if (instance) - device->pnp.bus_id[3] = '0' + instance; + adev->pnp.bus_id[3] = '0' + instance; instance++; } - video->device = device; - strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); - strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); + video->device = adev; + strcpy(acpi_device_name(adev), ACPI_VIDEO_BUS_NAME); + strcpy(acpi_device_class(adev), ACPI_VIDEO_CLASS); platform_set_drvdata(pdev, video); acpi_video_bus_find_cap(video); @@ -2021,7 +2021,7 @@ static int acpi_video_bus_probe(struct platform_device *pdev) mutex_init(&video->device_list_lock); INIT_LIST_HEAD(&video->video_device_list); - error = acpi_video_bus_get_devices(video, device); + error = acpi_video_bus_get_devices(video, adev); if (error) goto err_put_video; @@ -2029,10 +2029,10 @@ static int acpi_video_bus_probe(struct platform_device *pdev) * HP ZBook Fury 16 G10 requires ACPI video's child devices have _PS0 * evaluated to have functional panel brightness control. */ - acpi_device_fix_up_power_extended(device); + acpi_device_fix_up_power_extended(adev); pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n", - ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), + ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(adev), str_yes_no(video->flags.multihead), str_yes_no(video->flags.rom), str_yes_no(video->flags.post)); @@ -2059,7 +2059,7 @@ static int acpi_video_bus_probe(struct platform_device *pdev) if (error) goto err_del; - error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, + error = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video); if (error) goto err_remove; From patchwork Wed Oct 25 11:18:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 737900 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E901273D1 for ; Wed, 25 Oct 2023 11:18:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eh9Gv0dT" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2EE18E; Wed, 25 Oct 2023 04:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698232718; x=1729768718; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zxS//e/ZqjIB0NhbIBluRHpqaStKqMVqrAs7nUrO30A=; b=eh9Gv0dTUI1E0jFNHkSYABwrN+ihY+6BYLLbG5iBBlZwxgJTt1ST2VuX Q2J2j5uLjkwfuhj/ewWJMPu03pgshcH6ozOb2FCxXwnk0Z4yHQYBW1+pe UFmwrpicpCe9CqyV2zbjzlDbCJX8RSWMrgJeUMfN8vyX4xA/1RPVbT1pl Gt87B8Amnf7ZYt+oUPFS9sPS+7rX8fGukFfNJESG1Cm+Za4vfkx5cLO1w QIcgKGaepK+J/OBwJPJYj2UEjfggL6qDy5LI+IJYw/LsAkeFL7QaCMib/ 5t/dOYdtdif0BYkfABZMDBecNHUj2hAuXvAP73jATyhs0RXmSWfNZSLRK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="391154641" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="391154641" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="762425139" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="762425139" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 04:18:28 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 6/6] ACPI: acpi_video: Fix holes in acpi_video_bus Date: Wed, 25 Oct 2023 14:18:06 +0300 Message-ID: <20231025111806.2416524-7-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025111806.2416524-1-michal.wilczynski@intel.com> References: <20231025111806.2416524-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As identified by 'pahole' utility there are holes in acpi_video_bus struct. Rearrange elements to get rid of the holes. Put elements biggest in size first, and one-byte elements later. Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index bfc7f51a527d..1e10d5b748b2 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -155,19 +155,19 @@ struct acpi_video_enumerated_device { struct acpi_video_bus { struct acpi_device *device; + struct acpi_video_enumerated_device *attached_array; + struct list_head video_device_list; + struct mutex device_list_lock; /* protects video_device_list */ + struct list_head entry; + struct input_dev *input; + struct notifier_block pm_nb; bool backlight_registered; u8 dos_setting; - struct acpi_video_enumerated_device *attached_array; u8 attached_count; u8 child_count; struct acpi_video_bus_cap cap; struct acpi_video_bus_flags flags; - struct list_head video_device_list; - struct mutex device_list_lock; /* protects video_device_list */ - struct list_head entry; - struct input_dev *input; char phys[32]; /* for input device */ - struct notifier_block pm_nb; }; struct acpi_video_device_flags {