From patchwork Fri Jun 9 15:25:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 691218 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 02E35C87FDD for ; Fri, 9 Jun 2023 15:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241313AbjFIPZT (ORCPT ); Fri, 9 Jun 2023 11:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241534AbjFIPZO (ORCPT ); Fri, 9 Jun 2023 11:25:14 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E3335B6; Fri, 9 Jun 2023 08:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686324312; x=1717860312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ddxTpj08Ejw4GJ1aZ/q3t7SQimsuCWBX6xQNszlNeHQ=; b=T7elnzfw5GNCpdj814oiTP4sXUn15CIhuOZrvPuXj2CXEQilvra4glah 0aIm6LjToxvgY2hYOHBpeo7+L/c9v7IWZEkm1sTZEWg3Qy4GubakXi0Mv ooibK2NV3Tbr9ZcF1//M5l69iYP2Dx5J4Qdx6l3sBRrrDiMZoAyfXGo+B OkxBnPlgA5ZVtK3ucVCms5YrPhkJD4wLmbQwLwpW5bolPxGIyPaTEvPSx E9RD8nl0t5sYTNq9RkhvhTV93TeG9Bj1uLpZaDIzJAgqaUxv7/ZsJOpbD d57nNgA6tgGxq/cyV/B/2geZsL10h9U7SJQhOW4ShluqsLEgARW8QROdZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="357623180" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="357623180" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:25:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="775532601" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="775532601" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 09 Jun 2023 08:25:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 681CD16A; Fri, 9 Jun 2023 18:25:14 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , Damien Le Moal , 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 v1 1/3] ACPI: Move ACPI_DEVICE_CLASS() to mod_devicetable.h Date: Fri, 9 Jun 2023 18:25:05 +0300 Message-Id: <20230609152507.77649-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609152507.77649-1-andriy.shevchenko@linux.intel.com> References: <20230609152507.77649-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 --- 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:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 690935 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 CF5E6C7EE25 for ; Fri, 9 Jun 2023 15:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238814AbjFIPZR (ORCPT ); Fri, 9 Jun 2023 11:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241524AbjFIPZO (ORCPT ); Fri, 9 Jun 2023 11:25:14 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA7235BE; Fri, 9 Jun 2023 08:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686324312; x=1717860312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zHjAgdVUBB0uVbkIgjmznv/ebWgxcQFRvgnhOx3Y82k=; b=I+FqyP3fmtGL4UXWxvjPPrf9JOsNIpmpUW9m1LAw6sEfXXeA8ozKYWoZ JdIHBK0hk/rUEpEr+ARuCSGYVrF3wkIqVio6sdTnnyzq1W9/w487hFQbq tdFdiV4ni06do0qWWXo1s3y+5/Qs0ag+wY/IQgdvg3S+t7hjmimLxy52j 1i/LT1IgLiHvDDGnasWAJbg29t7pXryHqEbmdGTvLTyKCQanIl0hrdDkq HGGxtVO2j9q6HHwJSqvagur/UXJv1xS1tVFf2J4l3VaY8pyYVhcerU/QI 9Bp3GnDqo9AOr2aZBxBZ22TuNZ6uWVTsCsiJ6YJqTpo/4+s8OE1GJX5ne w==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="357623195" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="357623195" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:25:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="775532602" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="775532602" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 09 Jun 2023 08:25:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7760E56D; Fri, 9 Jun 2023 18:25:14 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , Damien Le Moal , 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 v1 2/3] device property: Implement device_is_compatible() Date: Fri, 9 Jun 2023 18:25:06 +0300 Message-Id: <20230609152507.77649-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609152507.77649-1-andriy.shevchenko@linux.intel.com> References: <20230609152507.77649-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. Provide inline helpers for them. Signed-off-by: Andy Shevchenko --- include/linux/property.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/property.h b/include/linux/property.h index 695053c60306..8de2c707818a 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -85,6 +85,11 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char return fwnode_property_match_string(fwnode, "compatible", compat) >= 0; } +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:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 690934 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 84B6DC7EE2F for ; Fri, 9 Jun 2023 15:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241537AbjFIPZU (ORCPT ); Fri, 9 Jun 2023 11:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241495AbjFIPZP (ORCPT ); Fri, 9 Jun 2023 11:25:15 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CBE3A94; Fri, 9 Jun 2023 08:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686324313; x=1717860313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JiZcSEh6wtKIXhWUTQdPeLqGPLC1Yi/N2wixH2YZSZk=; b=EJa5g5PiePvyG4IjnlFH/h6ujKDStd8TMIcJR4jrVlONViWLjRAavmSu 0HQr7P4KV3vEsJIOKC0dfh8eWea2H4DXym4+NS8f3yJ15kssP7F3AHugi uR1gYcPFns+X6af04g89PpjhIZPCFZeRerTo6Q26gKyBQgH1lRhjyWFI4 ug8XT6IMjbfZ85Sq+CIE0DFEo0ROTfGVxZYlGzspc5Hl/RREamd7tLYZ6 gSrR5H3Aqn2lIWZp/9r25QOz8gEeo+rSrdBv1nAPJoA9EaAniEkLMi+LP 7wTq2bjWiKy+E66GKFbF7YVSYbuOAgC7FOfjTv+EiTOlAaIG9vKc9R4Bt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="357623189" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="357623189" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 08:25:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="775532603" X-IronPort-AV: E=Sophos;i="6.00,229,1681196400"; d="scan'208";a="775532603" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 09 Jun 2023 08:25:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7D70D34F; Fri, 9 Jun 2023 18:25:14 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , Damien Le Moal , 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 v1 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI Date: Fri, 9 Jun 2023 18:25:07 +0300 Message-Id: <20230609152507.77649-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230609152507.77649-1-andriy.shevchenko@linux.intel.com> References: <20230609152507.77649-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 --- drivers/ata/ahci_platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index ab30c7138d73..71a18344a0c8 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -12,11 +12,11 @@ #include #include #include -#include +#include +#include #include #include #include -#include #include #include "ahci.h" @@ -56,7 +56,7 @@ 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);