From patchwork Thu May 22 18:02:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 4225411 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 426D0BF90B for ; Thu, 22 May 2014 18:05:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 753FC2037E for ; Thu, 22 May 2014 18:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87509201DC for ; Thu, 22 May 2014 18:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbaEVSC6 (ORCPT ); Thu, 22 May 2014 14:02:58 -0400 Received: from mga02.intel.com ([134.134.136.20]:51899 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752415AbaEVSC4 (ORCPT ); Thu, 22 May 2014 14:02:56 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 22 May 2014 11:02:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,888,1392192000"; d="scan'208";a="516171723" Received: from unknown (HELO rzhang1-toshiba.ccr.corp.intel.com) ([10.255.20.115]) by orsmga001.jf.intel.com with ESMTP; 22 May 2014 11:02:53 -0700 From: Zhang Rui To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bhelgaas@google.com, matthew.garrett@nebula.com, rafael.j.wysocki@intel.com, dmitry.torokhov@gmail.com, mika.westerberg@linux.intel.com, Zhang Rui Subject: [PATCH V7 05/11] ACPI: allow scan handlers without .attach() callback Date: Fri, 23 May 2014 02:02:27 +0800 Message-Id: <1400781753-2682-6-git-send-email-rui.zhang@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400781753-2682-1-git-send-email-rui.zhang@intel.com> References: <1400781753-2682-1-git-send-email-rui.zhang@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Devices that can be attached to scan handlers, are kind of different from the others, because they are known that some special actions should be taken. But we do not mark this difference when the configurable scan handlers are compiled out. This is harmless currently, but it will be when we want to take some common actions to the other "non-special" devices, which will be done in a later patch. This patch makes .attach() of the acpi scan handler optional. So that the configurable scan handlers can provide NULL .attach() callback when not supported. Signed-off-by: Zhang Rui --- drivers/acpi/scan.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c82ab73..e9c2f6f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -84,7 +84,7 @@ EXPORT_SYMBOL_GPL(acpi_initialize_hp_context); int acpi_scan_add_handler(struct acpi_scan_handler *handler) { - if (!handler || !handler->attach) + if (!handler) return -EINVAL; list_add_tail(&handler->list_node, &acpi_scan_handlers_list); @@ -2066,6 +2066,12 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, return AE_OK; } +static int acpi_scan_handler_dummy_attach(struct acpi_device *device, + const struct acpi_device_id *devid) +{ + return 1; +} + static int acpi_scan_attach_handler(struct acpi_device *device) { struct acpi_hardware_id *hwid; @@ -2078,7 +2084,10 @@ static int acpi_scan_attach_handler(struct acpi_device *device) handler = acpi_scan_match_handler(hwid->id, &devid); if (handler) { device->handler = handler; - ret = handler->attach(device, devid); + if (handler->attach) + ret = handler->attach(device, devid); + else + ret = acpi_scan_handler_dummy_attach(device, devid); if (ret > 0) break;