Message ID | 20230609154900.43024-4-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1047266vqr; Fri, 9 Jun 2023 09:05:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pREOyjt3mqbQK+uXMN98NSRSEAemju0x/Nt89z02Q8TGWdzVSyrEO9bRhYgqR9QYx+wtC X-Received: by 2002:a17:90a:199:b0:252:94b5:36f1 with SMTP id 25-20020a17090a019900b0025294b536f1mr1258543pjc.27.1686326734981; Fri, 09 Jun 2023 09:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686326734; cv=none; d=google.com; s=arc-20160816; b=AkJ2boK/dLE5sXap9yn1xk/x1k/R5u6sETbfHK+DzLRE+7mNA4oJpBm2qlv6SsPJIt +sRFbi/qNqUCdt5ITmv+8W0bCEcYh8TpFWuy/qnDajKamGSn/kmuP/ZzaJhrWz7uHKzr BVdOj5HjVnU9rdJ2wpTUE9n90Dohf95osMdPGO43f007mn3DkR7tlXXRIluRMkC+ZUv1 ijvfpuvpmiY5Cm7xv48XUepaURjcfNJAZ0hzc1pgIdKhZWpfwGAxYfT47cj9yYI3PyrP t+4TOKg92hus06bP3r0P3Xv9699opPbnZRwMhm4vsdeYDupu3jGIH9HCA7lBsbCUFSuS Zpmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WbpXKQRfnJkfLPYjeuzu5RayFOBqr7pcqk1GahXmh3Y=; b=JixhC+1dUCPflczp8/WiIxyRhoSum2Bai823Z0JCWdD833AAEnIOQBzY5lWsg9F1ES hEBzeh9T2ZkvwVpHyICJCFFJ6u7jFnzpk+xtH/m5u5Fx2e7LORdibd+qPAWJorccJsr7 +Iy25Zmh2f+ZoI76z4akhXE1Cx+uhZkaW3r9EaK/Neid6odG1XLgzSPcZ7p4qeTDAUvF 7tXMtPUJE6ug6lqVGL52kEuHLL/c3LLTLc4zwBZapAS4KVad+Jfz0JTmCZX4Py0wtio1 YTUJtaAhcLSTKM+py2zro3sWMs8t8Hye5g87keBdIcDo/sJ9qe6O2Xm+EqeWrsYqmgJq C/aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ie2msF5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a17090a648900b002534549dac8si4679426pjj.38.2023.06.09.09.05.19; Fri, 09 Jun 2023 09:05:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ie2msF5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241943AbjFIPtR (ORCPT <rfc822;liningstudo@gmail.com> + 99 others); Fri, 9 Jun 2023 11:49:17 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <andriy.shevchenko@linux.intel.com> To: Damien Le Moal <dlemoal@kernel.org>, Serge Semin <Sergey.Semin@baikalelectronics.ru>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Hans de Goede <hdegoede@redhat.com>, Jens Axboe <axboe@kernel.dk>, "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, Daniel Scally <djrscally@gmail.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Sakari Ailus <sakari.ailus@linux.intel.com> 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768241742457779362?= X-GMAIL-MSGID: =?utf-8?q?1768241742457779362?= |
Series |
device property: Introduce device_is_compatible()
|
|
Commit Message
Andy Shevchenko
June 9, 2023, 3:49 p.m. UTC
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 <andriy.shevchenko@linux.intel.com>
---
drivers/ata/ahci_platform.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Hi Andy, On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > 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). You're wrapping the lines well before 75. Why? > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Hi Andy, On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > 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 <andriy.shevchenko@linux.intel.com> > --- > 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 <linux/kernel.h> > +#include <linux/mod_devicetable.h> > #include <linux/module.h> > #include <linux/pm.h> > #include <linux/device.h> > -#include <linux/of_device.h> > #include <linux/platform_device.h> > +#include <linux/property.h> > #include <linux/libata.h> > #include <linux/ahci_platform.h> > -#include <linux/acpi.h> > #include <linux/pci_ids.h> > #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); There are just a handful of users for acpi_device_get_match_data() in the tree. The code could be moved to acpi_fwnode_device_get_match_data() after coverting these. May be out of scope of this set though. > if (!port) > port = &ahci_port_info; >
On Mon, Jun 12, 2023 at 09:06:52AM +0000, Sakari Ailus wrote: > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: ... > > - 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); > > There are just a handful of users for acpi_device_get_match_data() in the > tree. The code could be moved to acpi_fwnode_device_get_match_data() after > coverting these. May be out of scope of this set though. Why do we need that one if we can use device_get_match_data() directly? It will be also flexible in case one of OF code will need something like this (custom info structure for the respective compatible string). That said, I don't think we need to change to acpi_*() whatever.
On Mon, Jun 12, 2023 at 08:02:44AM +0000, Sakari Ailus wrote: > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > > 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). > > You're wrapping the lines well before 75. Why? Didn't pay attention to that much. Is it a problem? Should I send a new version because of that? > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Thank you!
On Mon, Jun 12, 2023 at 06:20:17PM +0300, Andy Shevchenko wrote: > On Mon, Jun 12, 2023 at 08:02:44AM +0000, Sakari Ailus wrote: > > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > > > 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). > > > > You're wrapping the lines well before 75. Why? > > Didn't pay attention to that much. Is it a problem? Should I send a new > version because of that? I guess not. But it's a good practice to wrap at 75 instead.
Hi Andy, On Mon, Jun 12, 2023 at 06:19:22PM +0300, Andy Shevchenko wrote: > On Mon, Jun 12, 2023 at 09:06:52AM +0000, Sakari Ailus wrote: > > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > > ... > > > > - 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); > > > > There are just a handful of users for acpi_device_get_match_data() in the > > tree. The code could be moved to acpi_fwnode_device_get_match_data() after > > coverting these. May be out of scope of this set though. > > Why do we need that one if we can use device_get_match_data() directly? That was what I wanted to point your attention to. ;-) > It will be also flexible in case one of OF code will need something like > this (custom info structure for the respective compatible string). > That said, I don't think we need to change to acpi_*() whatever. I agree.
On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote: > 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). I don't think the driver will get to be fully agnostic after this patch because for instance the ahci_platform_get_resources() method directly uses the OF-available functions, walks over the OF subnodes, touches the OF-properties, etc. So AFAICS in order to be fully OF/ACPI agnostic the entire libahci_platform.o driver needs to be converted too, but it's not trivial at all. Anyway as a start this patch looks good. Reviewed-by: Serge Semin <fancer.lancer@gmail.com> -Serge(y) > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > 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 <linux/kernel.h> > +#include <linux/mod_devicetable.h> > #include <linux/module.h> > #include <linux/pm.h> > #include <linux/device.h> > -#include <linux/of_device.h> > #include <linux/platform_device.h> > +#include <linux/property.h> > #include <linux/libata.h> > #include <linux/ahci_platform.h> > -#include <linux/acpi.h> > #include <linux/pci_ids.h> > #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; > > -- > 2.40.0.1.gaa8946217a0b > >
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 <linux/kernel.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pm.h> #include <linux/device.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/libata.h> #include <linux/ahci_platform.h> -#include <linux/acpi.h> #include <linux/pci_ids.h> #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;