From patchwork Fri Jun 9 15:48:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 691216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF29DC83005 for ; Fri, 9 Jun 2023 15:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241909AbjFIPtJ (ORCPT ); Fri, 9 Jun 2023 11:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241887AbjFIPtG (ORCPT ); Fri, 9 Jun 2023 11:49:06 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 488953588; Fri, 9 Jun 2023 08:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686325742; x=1717861742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ddxTpj08Ejw4GJ1aZ/q3t7SQimsuCWBX6xQNszlNeHQ=; b=eCKd0B4RlSOHajFQm7yURBo++R3ju1OPoVztpf5dAXgkKWR+29JCOKpQ aSYKVwQFkXXAhWd7ria6TcYcUqZt0IfpqUn+9wUIA0AMMHFmzVOIVkMJ+ ml4uLHc1WJOFs7TbyGaWyq2hnoLWeP9zTZS0OM+WnOOM1QGsVGfvJrYQx 2Aqj6tI9wi3INeoKrI5CTTntwTt422j1Vp+AyD5OXuFE9GzZP7HgBAlDg dI+Z2bgxsCPkP0qUNOAn5Ej+ldzQTjSpqjsQ5C9zKOZUOVUWSYHj0o01E X/EHKvVZ3jMe49+qX1614bEiqbeKJDvsXiJRrx5z0RuAF6Vg/y0KCL5Rm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="423504360" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="423504360" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:48:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="854785636" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="854785636" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Jun 2023 08:48:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 591A016A; Fri, 9 Jun 2023 18:49:02 +0300 (EEST) From: Andy Shevchenko To: Damien Le Moal , Serge Semin , Andy Shevchenko , Greg Kroah-Hartman , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Hans de Goede , Jens Axboe , "Rafael J. Wysocki" , Len Brown , Daniel Scally , Heikki Krogerus , Sakari Ailus Subject: [PATCH v2 1/3] ACPI: Move ACPI_DEVICE_CLASS() to mod_devicetable.h Date: Fri, 9 Jun 2023 18:48:58 +0300 Message-Id: <20230609154900.43024-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> References: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The data type of struct acpi_device_id is defined in the mod_devicetable.h. It's suboptimal to require user with the almost agnostic code to include acpi.h solely for the macro that affects the data type defined elsewhere. Taking into account the above and for the sake of consistency move ACPI_DEVICE_CLASS() to mod_devicetable.h. Note, that with CONFIG_ACPI=n the ID table will be filed with data but it does not really matter because either it won't be used, or won't be compiled in some cases (when guarded by respective ifdeffery). Signed-off-by: Andy Shevchenko Acked-by: Rafael J. Wysocki --- include/linux/acpi.h | 14 -------------- include/linux/mod_devicetable.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d41a05d68166..640f1c07c894 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -70,19 +70,6 @@ static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode) kfree(fwnode); } -/** - * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with - * the PCI-defined class-code information - * - * @_cls : the class, subclass, prog-if triple for this device - * @_msk : the class mask for this device - * - * This macro is used to create a struct acpi_device_id that matches a - * specific PCI class. The .id and .driver_data fields will be left - * initialized with the default value. - */ -#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk), - static inline bool has_acpi_companion(struct device *dev) { return is_acpi_device_node(dev->fwnode); @@ -782,7 +769,6 @@ const char *acpi_get_subsystem_id(acpi_handle handle); #define ACPI_COMPANION_SET(dev, adev) do { } while (0) #define ACPI_HANDLE(dev) (NULL) #define ACPI_HANDLE_FWNODE(fwnode) (NULL) -#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0), #include diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index ccaaeda792c0..486747518aae 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -221,6 +221,19 @@ struct acpi_device_id { __u32 cls_msk; }; +/** + * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with + * the PCI-defined class-code information + * + * @_cls : the class, subclass, prog-if triple for this device + * @_msk : the class mask for this device + * + * This macro is used to create a struct acpi_device_id that matches a + * specific PCI class. The .id and .driver_data fields will be left + * initialized with the default value. + */ +#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk), + #define PNP_ID_LEN 8 #define PNP_MAX_DEVICES 8 From patchwork Fri Jun 9 15:48:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 690933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51EE8C7EE2E for ; Fri, 9 Jun 2023 15:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241897AbjFIPtI (ORCPT ); Fri, 9 Jun 2023 11:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241902AbjFIPtG (ORCPT ); Fri, 9 Jun 2023 11:49:06 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6270C358C; Fri, 9 Jun 2023 08:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686325742; x=1717861742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y+zkYbO5YK9WS+hVnRuiIYSGEwkKq9bB3JyPjPdLmHk=; b=SLyf/6tP4qRceqWuqNm70aTe0Pj2DCHDbVpxvpYL94IzfUzgoYkhORav cyD4SMTCpfhRYM0k/y4/vbdw7HLu6ZImwikcKDFGuEfJDAYAX4I3i4/eG AZMYlVnnYq91XXg/8CYWcuHmqi84zuY7CxqwTfERje3i1Ci3HkwARqbHd OcX5K59R6lWstq388Xey6h+eyT+jVy55g83Skb+/xc/AlOMPLYhrtjL28 7wOkpNYcD71zvODFTCWkgenWPqlg/pLcN8wtMV/lpKFGrxv0gIiBfxOdM adLzXQU05+yh6Tqr+Q9YHlEZagDQQZKdYayvU77GfZqi5lfcKs/hnchl7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="423504368" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="423504368" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:48:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="854785637" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="854785637" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Jun 2023 08:48:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5E97534F; Fri, 9 Jun 2023 18:49:02 +0300 (EEST) From: Andy Shevchenko To: Damien Le Moal , Serge Semin , Andy Shevchenko , Greg Kroah-Hartman , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Hans de Goede , Jens Axboe , "Rafael J. Wysocki" , Len Brown , Daniel Scally , Heikki Krogerus , Sakari Ailus Subject: [PATCH v2 2/3] device property: Implement device_is_compatible() Date: Fri, 9 Jun 2023 18:48:59 +0300 Message-Id: <20230609154900.43024-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> References: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Some users want to use the struct device pointer to see if the device is compatible in terms of Open Firmware specifications, i.e. if it has a 'compatible' property and it matches to the given value. Provide inline helper for the users. Signed-off-by: Andy Shevchenko --- include/linux/property.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/property.h b/include/linux/property.h index 695053c60306..0222b77dd75c 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -85,6 +85,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char return fwnode_property_match_string(fwnode, "compatible", compat) >= 0; } +/** + * device_is_compatible - match 'compatible' property of the device with a given string + * @dev: Pointer to the struct device + * @compat: The string to match 'compatible' property with + * + * Returns: true if matches, otherwise false. + */ +static inline bool device_is_compatible(const struct device *dev, const char *compat) +{ + return fwnode_device_is_compatible(dev_fwnode(dev), compat); +} + int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, const char *prop, const char *nargs_prop, unsigned int nargs, unsigned int index, From patchwork Fri Jun 9 15:49:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 690932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 981B8C8300C for ; Fri, 9 Jun 2023 15:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241925AbjFIPtN (ORCPT ); Fri, 9 Jun 2023 11:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241912AbjFIPtH (ORCPT ); Fri, 9 Jun 2023 11:49:07 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E61B359D; Fri, 9 Jun 2023 08:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686325745; x=1717861745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MMOQJvuhySW3Bx7Au361jmZr/o23ev6AN5VhmCppLTM=; b=Ie2msF5MXRteANZb70tjW4p6r6eyuRT5e9m6Lf9DQoGlYkjExid3er1A c41k4uo8VH+o9BdnJBZYKINtPCZbgD6X+RoUMEvtVTz6yCsrjcon3KG/a KloaGbrrI+JSGOPP0v3AocQTUSgiVYQj2m332J1Fy0TQph4FhVkZFYwQQ BTyd5VLBuIt1o4SF2V2V+Tpz2KOtfPOzKwaTB5ZGZ8jKQwEYy5aA1r58L jCV9AmfxBYN1l/3dpCMfWiG4vMXMO1QUqQO8MPbMsS/FYZx0yd93qU9mo JrOo3XAUcv6WoWRXXMNngB26geF8zmvcqxhvJzSPBx/BEAgZ8Fg8Rhvmh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="423504375" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="423504375" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:48:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="854785638" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="854785638" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Jun 2023 08:48:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7310765E; Fri, 9 Jun 2023 18:49:02 +0300 (EEST) From: Andy Shevchenko To: Damien Le Moal , Serge Semin , Andy Shevchenko , Greg Kroah-Hartman , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Hans de Goede , Jens Axboe , "Rafael J. Wysocki" , Len Brown , Daniel Scally , Heikki Krogerus , Sakari Ailus Subject: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI Date: Fri, 9 Jun 2023 18:49:00 +0300 Message-Id: <20230609154900.43024-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> References: <20230609154900.43024-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org With the help of a new device_is_compatible() make the driver code agnostic to the OF/ACPI. This makes it neater. As a side effect the header inclusions is corrected (seems mod_devicetable.h was implicitly included). Signed-off-by: Andy Shevchenko Reviewed-by: Sakari Ailus --- drivers/ata/ahci_platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index ab30c7138d73..81fc63f6b008 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -9,14 +9,14 @@ */ #include +#include #include #include #include -#include #include +#include #include #include -#include #include #include "ahci.h" @@ -56,10 +56,10 @@ static int ahci_probe(struct platform_device *pdev) if (rc) return rc; - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) + if (device_is_compatible(dev, "hisilicon,hisi-ahci")) hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; - port = acpi_device_get_match_data(dev); + port = device_get_match_data(dev); if (!port) port = &ahci_port_info;