Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp380753rwb; Wed, 10 Aug 2022 09:40:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6DvFGJOtPjHbEDglKT3eF9AbdLgJZaoZmUQkqyidpB03qIiWx5pNHqEKuM7prgSokvCQNs X-Received: by 2002:a17:907:97cb:b0:731:6d1:13fa with SMTP id js11-20020a17090797cb00b0073106d113famr16069634ejc.375.1660149647305; Wed, 10 Aug 2022 09:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660149647; cv=none; d=google.com; s=arc-20160816; b=RH9zX/x89Ap0zk18G/9n3FMzPccf3h2V+pdCVCWbczeeR3tXsKUtJBCVdXb/EWYyh8 PsGTKdmM4hATe/eK22A/RlOW2LpB/5Vr9JWDgRn4XeIZKjdU/051OtU1nRY70LyyzwSv uDawPUzQIKKKADjlZZEb2rIN6wV0xaVXEzRRfXQN20fAw4CtMZUwQNP17r8Utx2qwxxq MtGUELf7UgcIYofjk4CtlqSfQieQ2On/1XUz/DkNdoq4Ck0+DiD+Byd9DGO+WnW+93to oXQFN5SbYu1dUGKePbkgmu3MD+Y+BK/ZHxSY/uIdO1leY7mHMOrWApVtnaeWKAF1w/uh gPnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=G+lB7bfJh9cLvMr6zyz2T1QXwEjwEqv5VT0AGLxmyMM=; b=vHzaUmFYZvhWH6nMzgyq7f1Bl0T4thsMPRPeBUiIujOKCL9i6yQXAJgEX5BHAbq3vV LoDxArCjEI3ysIFeWAenUblt6gIMZfDqYq/pT9nEgDtaOWASVESxrQinZXRWdA0/nsVr kuLHYckfooVU3NW3XoDWqfDog8bRtY7CCiSrH8CKMVLAxssxkl3JXOo37HUxiozBwCST UtPn0aQqSdjQEs0W4kRhyvNgWhyOLJ7kux3Cegw05kT4/xGRbFj8dZTRswlC8UbJV/KW ka1ZW6cyk9LzfD6RfWUBbgakpNZHQlQfAfH/fefd2gtUZSKdNs240yiAQNDeqBMJW2It GMCQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf38-20020a1709077f2600b00730551afa8esi5026348ejc.885.2022.08.10.09.40.19; Wed, 10 Aug 2022 09:40:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232738AbiHJQY3 (ORCPT + 99 others); Wed, 10 Aug 2022 12:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbiHJQYB (ORCPT ); Wed, 10 Aug 2022 12:24:01 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3E980F6D; Wed, 10 Aug 2022 09:23:58 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id b1d2a683a77102d0; Wed, 10 Aug 2022 18:23:56 +0200 Received: from kreacher.localnet (unknown [213.134.187.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 24A4066CF1C; Wed, 10 Aug 2022 18:23:56 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Andy Shevchenko , Linux PM Subject: [PATCH v1 3/5] ACPI: scan: Rearrange initialization of ACPI device objects Date: Wed, 10 Aug 2022 18:16:33 +0200 Message-ID: <1828627.tdWV9SEqCh@kreacher> In-Reply-To: <12036348.O9o76ZdvQC@kreacher> References: <12036348.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.187.55 X-CLIENT-HOSTNAME: 213.134.187.55 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegvddgleejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrddukeejrdehheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukeejrdehhedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhn vghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Rafael J. Wysocki The initialization of ACPI device objects is split between acpi_init_device_object() and __acpi_device_add() that initializes the dev field in struct acpi_device. The "release" function pointer is passed to __acpi_device_add() for this reason. However, that split is artificial and all of the initialization can be carried out by acpi_init_device_object(), so rearrange the code to that end. In particular, make acpi_init_device_object() take the "release" pointer as an argument, along with the "type" which is related to it, instead of __acpi_device_add(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/internal.h | 5 ++--- drivers/acpi/power.c | 5 +++-- drivers/acpi/scan.c | 27 ++++++++++++++------------- 3 files changed, 19 insertions(+), 18 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -673,8 +673,7 @@ static void acpi_store_pld_crc(struct ac ACPI_FREE(pld); } -static int __acpi_device_add(struct acpi_device *device, - void (*release)(struct device *)) +static int __acpi_device_add(struct acpi_device *device) { struct acpi_device_bus_id *acpi_device_bus_id; int result; @@ -730,11 +729,6 @@ static int __acpi_device_add(struct acpi mutex_unlock(&acpi_device_lock); - if (device->parent) - device->dev.parent = &device->parent->dev; - - device->dev.bus = &acpi_bus_type; - device->dev.release = release; result = device_add(&device->dev); if (result) { dev_err(&device->dev, "Error registering device\n"); @@ -761,7 +755,7 @@ err_unlock: return result; } -int acpi_device_add(struct acpi_device *adev, void (*release)(struct device *)) +int acpi_device_add(struct acpi_device *adev) { int ret; @@ -769,7 +763,7 @@ int acpi_device_add(struct acpi_device * if (ret) return ret; - return __acpi_device_add(adev, release); + return __acpi_device_add(adev); } /* -------------------------------------------------------------------------- @@ -1776,12 +1770,19 @@ static bool acpi_device_enumeration_by_p } void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, - int type) + int type, void (*release)(struct device *)) { + struct acpi_device *parent = acpi_find_parent_acpi_dev(handle); + INIT_LIST_HEAD(&device->pnp.ids); device->device_type = type; device->handle = handle; - device->parent = acpi_find_parent_acpi_dev(handle); + if (parent) { + device->parent = parent; + device->dev.parent = &parent->dev; + } + device->dev.release = release; + device->dev.bus = &acpi_bus_type; fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); acpi_set_device_status(device, ACPI_STA_DEFAULT); acpi_device_get_busid(device); @@ -1835,7 +1836,7 @@ static int acpi_add_single_object(struct if (!device) return -ENOMEM; - acpi_init_device_object(device, handle, type); + acpi_init_device_object(device, handle, type, acpi_device_release); /* * Getting the status is delayed till here so that we can call * acpi_bus_get_status() and use its quirk handling. Note that @@ -1865,7 +1866,7 @@ static int acpi_add_single_object(struct mutex_unlock(&acpi_dep_list_lock); if (!result) - result = __acpi_device_add(device, acpi_device_release); + result = __acpi_device_add(device); if (result) { acpi_device_release(&device->dev); Index: linux-pm/drivers/acpi/internal.h =================================================================== --- linux-pm.orig/drivers/acpi/internal.h +++ linux-pm/drivers/acpi/internal.h @@ -102,10 +102,9 @@ struct acpi_device_bus_id { struct list_head node; }; -int acpi_device_add(struct acpi_device *device, - void (*release)(struct device *)); void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, - int type); + int type, void (*release)(struct device *)); +int acpi_device_add(struct acpi_device *device); int acpi_device_setup_files(struct acpi_device *dev); void acpi_device_remove_files(struct acpi_device *dev); void acpi_device_add_finalize(struct acpi_device *device); Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -944,7 +944,8 @@ struct acpi_device *acpi_add_power_resou return NULL; device = &resource->device; - acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER); + acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, + acpi_release_power_resource); mutex_init(&resource->resource_lock); INIT_LIST_HEAD(&resource->list_node); INIT_LIST_HEAD(&resource->dependents); @@ -968,7 +969,7 @@ struct acpi_device *acpi_add_power_resou pr_info("%s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); device->flags.match_driver = true; - result = acpi_device_add(device, acpi_release_power_resource); + result = acpi_device_add(device); if (result) goto err;