From patchwork Tue Jul 3 09:22:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 10503567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1CCD5602BC for ; Tue, 3 Jul 2018 09:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC5428A4C for ; Tue, 3 Jul 2018 09:23:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F417528A4D; Tue, 3 Jul 2018 09:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EFD928A4A for ; Tue, 3 Jul 2018 09:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933649AbeGCJXA (ORCPT ); Tue, 3 Jul 2018 05:23:00 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:40646 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933633AbeGCJW7 (ORCPT ); Tue, 3 Jul 2018 05:22:59 -0400 Received: by mail-qt0-f196.google.com with SMTP id h4-v6so930165qtj.7 for ; Tue, 03 Jul 2018 02:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=6Iu7TZ1mb769VLJMGzyuXq8+1crxGus9llCmVOXsn3A=; b=UjIgmeJvug3McynvszMzkLeEq3SxImAeNxRVwU5yiDIBO96XWaeVRbtmpWeHoswxD8 9vIZlJziupUty474wG+woIF0psJjconMWRLN7AdWhhmiA8nh1X051CElMbfoMgT3C1lN qEJUxQANXmtCoTuLu8y/h28hjn7ohUK1QJ5FA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6Iu7TZ1mb769VLJMGzyuXq8+1crxGus9llCmVOXsn3A=; b=PiJ2GQPTk307YGXYvYpYJUOUq82BrLG+qkolYjh4IHaoZR0n3+FiDihzv+uskK3/DT CKUnFHH0245/nUej8wqY5hER9UDgSbjVX0NyWA+JA3X2syZHL0+/Zs4AvR6jQ36NCrUh +RwvgC0irMOZjX8gtrQbfRh9zYT5nYeIuAYiEQ0pIMVpmuPDr9CkUSumzir1h7owV4g5 XwIBHXCgT6ha9vDgp9ZcSUpUpG+6ub9NyQTto9s7dFCx1dsgGLRxtAXIypvcTBuc8O2w RP0W3npGEeKN0RXpatvg+ybGIaqaeaLzHHMi15+KAv+9K3+4DV6qPBVYbxyT1Pe51PXb riOw== X-Gm-Message-State: APt69E2ILhWw/Xb1W4QWoYgitJPHtNwY8vBQMp/Vv+xrzgv94DkVfmCF OqYVMahq1maIVaN+tw/wqev7Zg== X-Google-Smtp-Source: AAOMgpfuVsu4cUc5lEHSPPV4yJVZIflVbRHhOjuT5MAfaY85buPTtZ2SshPbjgIa80eA/+I1fSB6YA== X-Received: by 2002:a0c:b40c:: with SMTP id u12-v6mr3632356qve.58.1530609778385; Tue, 03 Jul 2018 02:22:58 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k10-v6sm417856qtm.6.2018.07.03.02.22.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Jul 2018 02:22:57 -0700 (PDT) From: Srinath Mannam To: rafael@kernel.org, lenb@kernel.org, andy.shevchenko@gmail.com Cc: ray.jui@broadcom.com, vladimir.olovyannikov@broadcom.com, vikram.prakash@broadcom.com, scott.branden@broadcom.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [RFC PATCH] ACPI: bus: match of_device_id using acpi device Date: Tue, 3 Jul 2018 14:52:40 +0530 Message-Id: <1530609760-8919-1-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch provides a function, to get of_device_id after matching with ACPI device _DSD object compatible property in the case driver does not contain acpi_device_id list and driver probe called for ACPI device ID PRP0001 with compatible property match with of_device_id compatible. Signed-off-by: Srinath Mannam --- drivers/acpi/bus.c | 23 +++++++++++++++++++++++ include/linux/acpi.h | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 84b4a62..e676bf7 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -830,6 +830,29 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, } EXPORT_SYMBOL_GPL(acpi_match_device); +/** + * acpi_match_of_device_id - Match a struct device in given of_device_id list + * @ids: Array of struct of_device_id object to match against. + * @dev: The device structure to match. + * + * Check if @dev has a valid ACPI handle and if there is a struct acpi_device + * object for that handle and use that object to match against a given list of + * device IDs. + * + * Return a pointer to the first matching ID on success or %NULL on failure. + */ +const +struct of_device_id *acpi_match_of_device_id(const struct of_device_id *ids, + const struct device *dev) +{ + const struct of_device_id *id = NULL; + + __acpi_match_device(acpi_companion_match(dev), NULL, ids, NULL, &id); + return id; +} +EXPORT_SYMBOL_GPL(acpi_match_of_device_id); + + const void *acpi_device_get_match_data(const struct device *dev) { const struct acpi_device_id *match; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4b35a66..2f24800 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -589,6 +589,10 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, const struct device *dev); +const +struct of_device_id *acpi_match_of_device_id(const struct of_device_id *ids, + const struct device *dev); + const void *acpi_device_get_match_data(const struct device *dev); extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv); @@ -775,6 +779,12 @@ static inline const struct acpi_device_id *acpi_match_device( return NULL; } +static inline const struct of_device_id *acpi_match_of_device_id( + const struct of_device_id *ids, const struct device *dev) +{ + return NULL; +} + static inline const void *acpi_device_get_match_data(const struct device *dev) { return NULL;