From patchwork Mon Mar 25 12:32:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602006 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 7E5FA1420A0; Mon, 25 Mar 2024 12:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370096; cv=none; b=k0PIcoAK24+DraWRIXSPw3RIrxJdX56WL5Eks1eB1hTiV9JBh41G29V2oqxVrRMwk4gdGuygIrNezKOYgtt/mYOJcn0frEgTt3a4XYJID+hD2xqwdTiFmMIaLiePwtauOfN1mVWgBv00K5EgzkKK/+YLs6s2gkHw5fEuga+cHWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370096; c=relaxed/simple; bh=oJ6UBa3Usaa6uDF3+sd8tBSCjSHUcPsUvLsqUUXSaOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VWutS63XYne7pKEgqsxyiNaeP51fP9/rGOCCdYsifNPpO9b8K3oFmA5nIx3Nq1DgsyGV9l8bW8qqSQQ2i9cu60KQpveiwmxt37y1MDCWUCcYlAaHxSR24shNabyzIiJydJZuNwQ87JKhiS9/EBs+F6wyXeiJ9I2BQbO9PfbqGKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mJVwpKJj; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mJVwpKJj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370094; x=1742906094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oJ6UBa3Usaa6uDF3+sd8tBSCjSHUcPsUvLsqUUXSaOY=; b=mJVwpKJjl2bV7iItVpVg30iw86jEvsCbsIYT0QOjA/SGozVCyA7L2ZnC YuhyuL2S0ydlmg0zp/Z5B5vidHiTEr+dB8YnlwZbjm9MxFzPE4tklwJGr 3xzq9IrZ3u7MxLBjSd6xi4vx3JNPwoNaVRrGQz9w39EgJXp6F3nmwHEw/ 0GB7oMHJvqMuIIyOeXhT7kICcqD0VS9nJ4KzME29AxWCiPdc8lvjKnFHc 923nKI2OuUK2g+xB6GTecYweJKHdkdPrF2LUy36/4G7AX1DE9uE+E2jV9 jK6mS4nRTRMXVt9X+CQbLxfaOb9vmdozV+pGQ/G2/hyCUPNvoLMh+BPhq A==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549691" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549691" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070331" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070331" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id ABC32101; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 1/7] ACPI: bus: Make container_of() no-op where it makes sense Date: Mon, 25 Mar 2024 14:32:57 +0200 Message-ID: <20240325123444.3031851-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move list head node to be the first member in a few data structures in order to make container_of() no-op at compile time. On x86_64 with a custom (default + a few dozens of drivers enabled) configuration: add/remove: 0/0 grow/shrink: 5/12 up/down: 21/-124 (-103) ... Total: Before=39924675, After=39924572, chg -0.00% Signed-off-by: Andy Shevchenko --- include/acpi/acpi_bus.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 5de954e2b18a..cdee38ef9ba5 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -124,8 +124,8 @@ static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile( } struct acpi_scan_handler { - const struct acpi_device_id *ids; struct list_head list_node; + const struct acpi_device_id *ids; bool (*match)(const char *idstr, const struct acpi_device_id **matchid); int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id); void (*detach)(struct acpi_device *dev); @@ -269,6 +269,7 @@ struct acpi_device_power_flags { }; struct acpi_device_power_state { + struct list_head resources; /* Power resources referenced */ struct { u8 valid:1; u8 explicit_set:1; /* _PSx present? */ @@ -276,7 +277,6 @@ struct acpi_device_power_state { } flags; int power; /* % Power (compared to D0) */ int latency; /* Dx->D0 time (microseconds) */ - struct list_head resources; /* Power resources referenced */ }; struct acpi_device_power { @@ -342,16 +342,16 @@ struct acpi_device_wakeup { }; struct acpi_device_physical_node { - unsigned int node_id; struct list_head node; + unsigned int node_id; struct device *dev; bool put_online:1; }; struct acpi_device_properties { + struct list_head list; const guid_t *guid; union acpi_object *properties; - struct list_head list; void **bufs; }; @@ -488,12 +488,12 @@ struct acpi_device { /* Non-device subnode */ struct acpi_data_node { + struct list_head sibling; const char *name; acpi_handle handle; struct fwnode_handle fwnode; struct fwnode_handle *parent; struct acpi_device_data data; - struct list_head sibling; struct kobject kobj; struct completion kobj_done; }; From patchwork Mon Mar 25 12:32:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602005 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 EA438140364; Mon, 25 Mar 2024 12:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370095; cv=none; b=bKMOJZr720ZLhNq9xB1dE3t3tOz14swiVpz4WAeUjYi+6Z4CSwU2BkbgNNSaAoBBEvCctIhruFuMRqxR8xDodc8DuwwOJtdG2tIGp36lAlhnW/txMvoY4zcRv9+JThJxBvmZv0d5N/yfE/CFsV4fWt6DKCOUHg05zv7eZlTVjZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370095; c=relaxed/simple; bh=biGNLvjZxsnLB/YZsxsoQQ4aRn4EP/9IpoXiUDXO3iE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6KYYI7phU8whxbVwwus1NkeYB4d8oDdHLE1Omq477wyc1j5aDCovOsTejvlpdvJsqZyPN8D+fXg2gH0DJsdxsI+xld6ThbBC7u5Enw5JQwJuRGvWVTkyeE0GEQq2OYSxY6ngrCYHYwNl6AK7fKeOBqwRxxi3yvObF2bguWPWIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=et2XpH8p; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="et2XpH8p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370094; x=1742906094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=biGNLvjZxsnLB/YZsxsoQQ4aRn4EP/9IpoXiUDXO3iE=; b=et2XpH8pfxksdOIy0CJkHtsBEMcD6uC7vKhqhATluMWy0bt2F0ZrR4b1 E8fzL6BxJomf/jJHTA/xnZgobgJrUq1l0yDZjDoN6JzGeBSMXsgdi6GeS TNZ1Ki7ndwIn6PgCclW5wasI4SAlred5WdHqv28uiBLg6n9FC5Ruwnlrs K7yQxHfvKqROPr81GMd6aOMm2Uz4+/Jmb2AWh1AiVWUG16aIdwKg52EOk ryenLXS6Bo43WM0ez3VY2ZWqKqjHa6rG3Fi6FZ3lBErbLkD7IqjZdM7fY 20OfJuyOgdnnVEhcjeeeOAQeejL9q1NN606h+QM2866Tv79v92Axw/2nD g==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549694" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549694" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070333" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070333" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD3852CA; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 2/7] ACPI: bus: Don't use "proxy" headers Date: Mon, 25 Mar 2024 14:32:58 +0200 Message-ID: <20240325123444.3031851-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update header inclusions to follow IWYU (Include What You Use) principle. Signed-off-by: Andy Shevchenko --- include/acpi/acpi_bus.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index cdee38ef9ba5..acb62d1d3306 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -9,8 +9,13 @@ #ifndef __ACPI_BUS_H__ #define __ACPI_BUS_H__ +#include +#include #include +#include +#include #include +#include struct acpi_handle_list { u32 count; From patchwork Mon Mar 25 12:32:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602003 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 2278D13EFE8; Mon, 25 Mar 2024 12:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370093; cv=none; b=u9G9IWk1PXRHKAT4Ef9FqhJ2cM+FfnIrIE0JPaZIltTJX7G7qABWUj1wpNKvZyeF62mGg1YHPQeo/hGyrjjYF0xH61GuI0AqePYIEWqaKgtidFNuYr1dw5REAnopDr8CnC/S+LUHwoiNwgBjVkXWFPAx8ajsS8LKahy6kHnq/B0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370093; c=relaxed/simple; bh=xP4F0Dzs6Z1vnbHfWvIrP7rhalwxftEshnlKle1DX1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q11OYOjc3OQp0LuImSL0KZIaTuzs3fLVKWwaWTCwS+Z3kw/KKJvhlpaJKu2cy9yUMkxRsDjdreTDz0Y4RkIWJ+PCWUq9tx0IQkwMAtTirD6VdeNCBHbOjC/9CjPtktXkqXMdgta8mEcrevhD5/4MRunUT8gIDZbMl7Pil9Oj0fY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mB8PtC8y; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mB8PtC8y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370092; x=1742906092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xP4F0Dzs6Z1vnbHfWvIrP7rhalwxftEshnlKle1DX1g=; b=mB8PtC8yFYJkM7RBxnYkvDfDbuRu2ZYh0a5ivwjJkB6pgdAxNcPu+iEU WYpVk1JbRyx1JCSQTj0Zqo5LxE30CNf/GASWYo+YucJl6+AKpcYZCposw BH9SLSxvwEzBmMuJxVN+w/9deY2zVI3QvZnd+ZgoqLuRMc45Jfl+mi7mC 5JO7LS+TmsedGVxsb+njleLg4+s9qcmwgNXqR5UojECb11DepYRI74i4u KKKE10flNpMmRtuPVti1s8kQDCy8KL4AR6a2QMT5OHTqV0IEnBlhnZ9QD Zhck8Jl/GH84NyBIUoLsCtpwHCVy5+HQluBYgqHH/6zdlYWJNTBY5FFqQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549685" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549685" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070327" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070327" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C4A14233; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 3/7] ACPI: scan: Replace infinite for-loop with finite while-loop Date: Mon, 25 Mar 2024 14:32:59 +0200 Message-ID: <20240325123444.3031851-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The infinite loops is harder to understand (as one has to go over the body in order to find main exit conditional) and it's more verbose than usual approach with a while-loop. Note, we may not use list_for_each_entry_safe() as there is locking involved and the saved pointer may become invalid behind our back. Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 7c157bf92695..5e4118970285 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -530,15 +530,10 @@ static DEFINE_MUTEX(acpi_device_del_lock); static void acpi_device_del_work_fn(struct work_struct *work_not_used) { - for (;;) { - struct acpi_device *adev; + struct acpi_device *adev; - mutex_lock(&acpi_device_del_lock); - - if (list_empty(&acpi_device_del_list)) { - mutex_unlock(&acpi_device_del_lock); - break; - } + mutex_lock(&acpi_device_del_lock); + while (!list_empty(&acpi_device_del_list)) { adev = list_first_entry(&acpi_device_del_list, struct acpi_device, del_list); list_del(&adev->del_list); @@ -555,7 +550,10 @@ static void acpi_device_del_work_fn(struct work_struct *work_not_used) */ acpi_power_transition(adev, ACPI_STATE_D3_COLD); acpi_dev_put(adev); + + mutex_lock(&acpi_device_del_lock); } + mutex_unlock(&acpi_device_del_lock); } /** From patchwork Mon Mar 25 12:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602007 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 1DDFC1428FC; Mon, 25 Mar 2024 12:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370096; cv=none; b=oZQoIXGPFXQ90bFEaSVDN0ZN33loLqdYWHFMOP4CjKop/wK0OzjvW3nLCRnYjTc7V3vqraUThbnRHguhycI51Jj2DK4jS/XI15QPOXHfTUkJNkY+0NNLzvm3z6DFCJ/yrmjnOGWP2ANXcyQJ01WfA/F/Znerqr2kVcRXp/ntglg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370096; c=relaxed/simple; bh=2QqcFaZw9ZOboSMWLp4Lpq84CkXZHQ0XhXntHOHAUGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RmaMi1KDeBUOGdJY3rX8NF4jAz/8PmGOOeknqiPU0ba2nMpum8JGSRwDFErbWA2+eTSssgmQNNcaFB9cuHEI/JuODi2vT4CiPZmS6x8m8nZd3tfwwO8HppQ7/FyWrUiV2gcMjhOwLoMSzovlYOo4YEDKKLPI85ZlVqleU/SUNeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GYyAhHMx; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GYyAhHMx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370095; x=1742906095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2QqcFaZw9ZOboSMWLp4Lpq84CkXZHQ0XhXntHOHAUGY=; b=GYyAhHMxV055L1UCDKEB8y4ZmDUxuHh/ai1uKJ4RWWmg/qtdTyQcq98q 3OO4YJkTpg6h86MgT/nGgGN/Skm2/KuFum51+zOTcqHBPZqoMQZUCEH4X AMNi7swuesMvjyw/plmptWZ8doBcQcXCineCV+IY55HcZFTkuB0/MB9u7 syWxA1weR6Ppl2jhmA3eD2zvS4n3fGfjk9Wni7hyzcydiySA6JcbvUxAo 6FUAuSGBactS1dvCrx6WiZpNyWZh7p0rkuclK4M3xyvXGd18NQoHzNuk9 JK0Odytz8VSaKqq3sB+psU6Bah6dnNoFThyLXK55sQSqXOPJxOjCt9bxz w==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549697" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549697" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070335" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070335" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D7FDB484; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 4/7] ACPI: scan: Use list_first_entry_or_null() in acpi_device_hid() Date: Mon, 25 Mar 2024 14:33:00 +0200 Message-ID: <20240325123444.3031851-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To replace list_empty() + list_first_entry() pair to simplify code. Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5e4118970285..f5581d3701f1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1296,10 +1296,10 @@ const char *acpi_device_hid(struct acpi_device *device) { struct acpi_hardware_id *hid; - if (list_empty(&device->pnp.ids)) + hid = list_first_entry_or_null(&device->pnp.ids, struct acpi_hardware_id, list); + if (!hid) return dummy_hid; - hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); return hid->id; } EXPORT_SYMBOL(acpi_device_hid); From patchwork Mon Mar 25 12:33:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602008 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 9BBF61448EA; Mon, 25 Mar 2024 12:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370097; cv=none; b=fc6AcfrsxcQhqTKQyTAcC8SkrDnAlaVHuF70F1LuG8pAr8DDjr+Ee5mbqlf2QxKbyK6+Tc3DvJ6t6r2y5SPbgSEPt1J/U8G6/WKBCoZ3J/0JFGGQpikP3GdS0J2XugdHUuUBkmHCjTKHV00rfqNi9IPCvMHO93EORtxgF53KiCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370097; c=relaxed/simple; bh=kYaSqMOPeljRP3bQrvr/dBmRA0QEYgsB0ELeJUX3x+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=thdFkKmXIiZS593OalDuSJJ7PNRrckbq7ZtiIr3CnK7q1Rw6ux+Y83jJfhk0B2pr5lUN+2ebATth/UurSCGPfFj9dpcL0J1EhwTa3WZ7V0Ip5SELGCW6REeFpNjemZjA6tmKnkADZ59s6aA+8fpswBuAG1iNN0X+5HN19I0plyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=canUxtjf; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="canUxtjf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370095; x=1742906095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kYaSqMOPeljRP3bQrvr/dBmRA0QEYgsB0ELeJUX3x+g=; b=canUxtjfMtCALu+bCpdwnlMPgEvhJ9nysXWgTkdXwk9bKX0f9/KSropi Wdak0rlevy68mSEJjTy786blrlaLVc8sZp9dpcycOqnVyrx4C9kfTa1Tp kmJZjKIwAVYq53Iaxy+PyxOHdyyPHehvrZ3P+NusuP3yFXqsre5TcrQMn 70Vg+1+rT8ZOtKxrAJDiPvrGUgzKh/n1CDod1AsEL/nPg3qLu8hnyMy+q +Hs15g7dGxeaMsnp7GA+Puo8XQ2nEuf/CFO5df1hgD/r0/RGq4UClwVtG jY4D41QWppPNEjmGv+cl7PL93pUo5K7sHlnZeljM/qtykST+FDVi92KlZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549703" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549703" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070340" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070340" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DCC693C5; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 5/7] ACPI: scan: Move misleading comment to acpi_dma_configure_id() Date: Mon, 25 Mar 2024 14:33:01 +0200 Message-ID: <20240325123444.3031851-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The acpi_iommu_configure_id() implementation has a misleading comment since after it the flow does something different to what it states. Move the commit to the caller and with that unshadow the error code inside acpi_iommu_configure_id(). Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index f5581d3701f1..b2785a036a68 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1623,12 +1623,11 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) if (!err && dev->bus) err = iommu_probe_device(dev); - /* Ignore all other errors apart from EPROBE_DEFER */ - if (err == -EPROBE_DEFER) { + if (err == -EPROBE_DEFER) return err; - } else if (err) { + if (err) { dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); - return -ENODEV; + return err; } if (!acpi_iommu_fwspec_ops(dev)) return -ENODEV; @@ -1669,13 +1668,14 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, acpi_arch_dma_setup(dev); + /* Ignore all other errors apart from EPROBE_DEFER */ ret = acpi_iommu_configure_id(dev, input_id); if (ret == -EPROBE_DEFER) return -EPROBE_DEFER; /* * Historically this routine doesn't fail driver probing due to errors - * in acpi_iommu_configure_id() + * in acpi_iommu_configure_id(). */ arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); From patchwork Mon Mar 25 12:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602009 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 3D22D146A8B; Mon, 25 Mar 2024 12:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370097; cv=none; b=Qqs+ZOaOVubKT4e9iSz+uqlYoRonD4iJMLOt/4djdxJa5lb7jSh30T1I9eqyaF3umNSjTkruY/KC2mv9ws1Y50Rb2sc246cWWUibbMlPSeVDms54a9DHbqVb6SrMQtrd3LOH1zQpPdsVgQcHMNfXcqbg08ygVG/tsli8aAsRI5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370097; c=relaxed/simple; bh=90eQ8H9NeVyKRfnXGj9oSY32Oak16lSvywalPic9hkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gh/1udhLijKMYwx5NQn1Zayx3XVFLbT6BsuBmVaZ3Lv549CQ4E4Pdxt8C/bH2YD44YgnyF5eX3guz6EoFVx2wH8cy0OfmZYVEOvUnkcbiXj2cqyEi6pyrNX4VjmMOK7eRjyHKjw7Gix7Ggr//y7nuJCXLBJIV9PRI2SwKUqCAic= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DjevTs3M; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DjevTs3M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370096; x=1742906096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=90eQ8H9NeVyKRfnXGj9oSY32Oak16lSvywalPic9hkA=; b=DjevTs3MYG+E+Huf+t2BOqld0Ak4KIxElfWzEOGphxUrE6tSnhF8nZHS Sd3BvhOj7uVDhACWTEqCNYDLCknIk/w0m1Kde+YWmymMHznlWpL8NqHAu 5CxfpDE3hvqmj2a+vX2DVVEcjaqRLiPH3j3ZVTfI+/OCleOX5LYY4s1vG vSmXBNrCKp8Q+RJV9SHg/GolYUh0c1ICH52iVFNQnnvUsWrRlSYJ5LR4Y GIjzD7L7G0jubu0D4eAsg5D381Ix15qCr5mTNGk41UkEgkS070+JfNNwa cDuBoh9nfk/ZG2eMW9JvAGlzXHo5gVl90cw+/r7z9zgG3zHHczDnvp4hd w==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549707" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549707" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070342" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070342" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F1090524; Mon, 25 Mar 2024 14:34:46 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 6/7] ACPI: scan: Use standard error checking pattern Date: Mon, 25 Mar 2024 14:33:02 +0200 Message-ID: <20240325123444.3031851-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Check for an error and return it as it's the usual way to handle this. Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index b2785a036a68..45f7ec3b6548 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1579,12 +1579,13 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id, struct fwnode_handle *fwnode, const struct iommu_ops *ops) { - int ret = iommu_fwspec_init(dev, fwnode, ops); + int ret; - if (!ret) - ret = iommu_fwspec_add_ids(dev, &id, 1); + ret = iommu_fwspec_init(dev, fwnode, ops); + if (ret) + return ret; - return ret; + return iommu_fwspec_add_ids(dev, &id, 1); } static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev) From patchwork Mon Mar 25 12:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13602010 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 D5588149DFA; Mon, 25 Mar 2024 12:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370099; cv=none; b=JFr/Oet9+mwdwbgLoMfl+ssUhfGurvMsKttJYvzxiNOplR0homQV9bYl2B5jhzpErcydkYArBBEulauLA4okujYyspJo/QLvmccQsUh1DfWXJKCGUka0/4GWcQpmqM9DaiYZedLAIH687E2O/zFixGNzNgcbFj9c45GIzfsdQZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370099; c=relaxed/simple; bh=WSEkVBdORAODjRrcbYfVLEM4QYPG1G7EGlAISHGvqxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JMqznptl5w8MJeCPVRcT0XnN+mcrjijQ/fY9X8a0stWMgFBgapfzJvoS5oAReJA8no5zYXgmYU10ftOSjD078rXMd/MaMny0wnCdmZ5Mf7Brkb/7DFCfZalPlLMUYg+lr2Vw8hBr0fpoUV46fyYMsF2AyV30ESyAh3/I0XWsQA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dXCjXhY1; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dXCjXhY1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711370097; x=1742906097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WSEkVBdORAODjRrcbYfVLEM4QYPG1G7EGlAISHGvqxU=; b=dXCjXhY10Rx6rXx/QKKZcWW9aF1Yob3zmPE+PrnCymsIn6sJgKqtYgPM ye9kHZurEufb3LOiuJP9kW8u8Js09rwIPh4w4Awa2w5M1HO6VpICVAlnH wMb2Ko9U5I4z5KaolCSwAG2F/soHiluYnkP+aIFhAVDsEHXRDxYmYMkJK APSP/N02ZNKdw+4LVn7ucdTiQHqqFQSEtGznNxplZCh25ePikUI3TIVzu 6BJ1RFl4/7MW0152hKyoj7k6vnB9vfH1SIsN0AtGTKZZR7fuD0GUK8TFK Wzy8bh5F6tV8NjfyOouYfmjb5B/07BeINNeowM0hRA6YRcZP5ocAGDTbE A==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6549711" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="6549711" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 05:34:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070344" X-IronPort-AV: E=Sophos;i="6.07,153,1708416000"; d="scan'208";a="937070344" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 05:34:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 02AFD5A8; Mon, 25 Mar 2024 14:34:47 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Cc: "Rafael J. Wysocki" , Len Brown , Robert Moore Subject: [PATCH v1 7/7] ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members Date: Mon, 25 Mar 2024 14:33:03 +0200 Message-ID: <20240325123444.3031851-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> References: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Follow the struct acpi_device_ops approach and introduce typedef:s for the members. It makes code less verbose and more particular on what parameters we take or types we use. Signed-off-by: Andy Shevchenko --- drivers/acpi/dock.c | 48 +++++++++++++++-------------------------- drivers/acpi/scan.c | 5 ++--- include/acpi/acpi_bus.h | 13 ++++++----- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index a7c00ef78086..34affbda295e 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -88,43 +88,29 @@ static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event, enum dock_callback_type cb_type) { struct acpi_device *adev = dd->adev; + acpi_hp_fixup fixup = NULL; + acpi_hp_uevent uevent = NULL; + acpi_hp_notify notify = NULL; acpi_lock_hp_context(); - if (!adev->hp) - goto out; - - if (cb_type == DOCK_CALL_FIXUP) { - void (*fixup)(struct acpi_device *); - - fixup = adev->hp->fixup; - if (fixup) { - acpi_unlock_hp_context(); - fixup(adev); - return; - } - } else if (cb_type == DOCK_CALL_UEVENT) { - void (*uevent)(struct acpi_device *, u32); - - uevent = adev->hp->uevent; - if (uevent) { - acpi_unlock_hp_context(); - uevent(adev, event); - return; - } - } else { - int (*notify)(struct acpi_device *, u32); - - notify = adev->hp->notify; - if (notify) { - acpi_unlock_hp_context(); - notify(adev, event); - return; - } + if (adev->hp) { + if (cb_type == DOCK_CALL_FIXUP) + fixup = adev->hp->fixup; + else if (cb_type == DOCK_CALL_UEVENT) + uevent = adev->hp->uevent; + else + notify = adev->hp->notify; } - out: acpi_unlock_hp_context(); + + if (fixup) + fixup(adev); + else if (uevent) + uevent(adev, event); + else if (notify) + notify(adev, event); } static struct dock_station *find_dock_station(acpi_handle handle) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 45f7ec3b6548..534cb15351f5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -73,8 +73,7 @@ void acpi_unlock_hp_context(void) void acpi_initialize_hp_context(struct acpi_device *adev, struct acpi_hotplug_context *hp, - int (*notify)(struct acpi_device *, u32), - void (*uevent)(struct acpi_device *, u32)) + acpi_hp_notify notify, acpi_hp_uevent uevent) { acpi_lock_hp_context(); hp->notify = notify; @@ -428,7 +427,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src) } else if (adev->flags.hotplug_notify) { error = acpi_generic_hotplug_event(adev, src); } else { - int (*notify)(struct acpi_device *, u32); + acpi_hp_notify notify; acpi_lock_hp_context(); notify = adev->hp ? adev->hp->notify : NULL; diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index acb62d1d3306..6aa0d8a1de79 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -144,11 +144,15 @@ struct acpi_scan_handler { * -------------------- */ +typedef int (*acpi_hp_notify) (struct acpi_device *, u32); +typedef void (*acpi_hp_uevent) (struct acpi_device *, u32); +typedef void (*acpi_hp_fixup) (struct acpi_device *); + struct acpi_hotplug_context { struct acpi_device *self; - int (*notify)(struct acpi_device *, u32); - void (*uevent)(struct acpi_device *, u32); - void (*fixup)(struct acpi_device *); + acpi_hp_notify notify; + acpi_hp_uevent uevent; + acpi_hp_fixup fixup; }; /* @@ -583,8 +587,7 @@ static inline void acpi_set_hp_context(struct acpi_device *adev, void acpi_initialize_hp_context(struct acpi_device *adev, struct acpi_hotplug_context *hp, - int (*notify)(struct acpi_device *, u32), - void (*uevent)(struct acpi_device *, u32)); + acpi_hp_notify notify, acpi_hp_uevent uevent); /* acpi_device.dev.bus == &acpi_bus_type */ extern const struct bus_type acpi_bus_type;