All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@caviumnetworks.com>
To: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Cc: David Daney <ddaney.cavm@gmail.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	linux-mips@linux-mips.org, Sunil Goutham <sgoutham@cavium.com>,
	linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
	David Daney <david.daney@cavium.com>
Subject: Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding.
Date: Fri, 7 Aug 2015 12:43:20 +0200	[thread overview]
Message-ID: <20150807104320.GQ1820@rric.localhost> (raw)
In-Reply-To: <55C467A0.4020601@linaro.org>

On 07.08.15 10:09:04, Tomasz Nowicki wrote:
> On 07.08.2015 02:33, David Daney wrote:

...

> >+#else
> >+
> >+static int bgx_init_acpi_phy(struct bgx *bgx)
> >+{
> >+	return -ENODEV;
> >+}
> >+
> >+#endif /* CONFIG_ACPI */
> >+
> >  #if IS_ENABLED(CONFIG_OF_MDIO)
> >
> >  static int bgx_init_of_phy(struct bgx *bgx)
> >@@ -882,7 +1010,12 @@ static int bgx_init_of_phy(struct bgx *bgx)
> >
> >  static int bgx_init_phy(struct bgx *bgx)
> >  {
> >-	return bgx_init_of_phy(bgx);
> >+	int err = bgx_init_of_phy(bgx);
> >+
> >+	if (err != -ENODEV)
> >+		return err;
> >+
> >+	return bgx_init_acpi_phy(bgx);
> >  }
> >
> 
> If kernel can work with DT and ACPI (both compiled in), it should take only
> one path instead of probing DT and ACPI sequentially. How about:
> 
> @@ -902,10 +925,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct
> pci_device_id *ent)
>  	bgx_vnic[bgx->bgx_id] = bgx;
>  	bgx_get_qlm_mode(bgx);
> 
> -	snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id);
> -	np = of_find_node_by_name(NULL, bgx_sel);
> -	if (np)
> -		bgx_init_of(bgx, np);
> +	err = acpi_disabled ? bgx_init_of_phy(bgx) : bgx_init_acpi_phy(bgx);
> +	if (err)
> +		goto err_enable;
> 
>  	bgx_init_hw(bgx);

I would not pollute bgx_probe() with acpi and dt specifics, and instead
keep bgx_init_phy(). The typical design pattern for this is:

static int bgx_init_phy(struct bgx *bgx)
{
#ifdef CONFIG_ACPI
        if (!acpi_disabled)
                return bgx_init_acpi_phy(bgx);
#endif
        return bgx_init_of_phy(bgx);
}

This adds acpi runtime detection (acpi=no), does not call dt code in
case of acpi, and saves the #else for bgx_init_acpi_phy().

-Robert

WARNING: multiple messages have this Message-ID (diff)
From: Robert Richter <robert.richter@caviumnetworks.com>
To: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Cc: David Daney <ddaney.cavm@gmail.com>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	<linux-mips@linux-mips.org>, Sunil Goutham <sgoutham@cavium.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-acpi@vger.kernel.org>,
	David Daney <david.daney@cavium.com>
Subject: Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding.
Date: Fri, 7 Aug 2015 12:43:20 +0200	[thread overview]
Message-ID: <20150807104320.GQ1820@rric.localhost> (raw)
In-Reply-To: <55C467A0.4020601@linaro.org>

On 07.08.15 10:09:04, Tomasz Nowicki wrote:
> On 07.08.2015 02:33, David Daney wrote:

...

> >+#else
> >+
> >+static int bgx_init_acpi_phy(struct bgx *bgx)
> >+{
> >+	return -ENODEV;
> >+}
> >+
> >+#endif /* CONFIG_ACPI */
> >+
> >  #if IS_ENABLED(CONFIG_OF_MDIO)
> >
> >  static int bgx_init_of_phy(struct bgx *bgx)
> >@@ -882,7 +1010,12 @@ static int bgx_init_of_phy(struct bgx *bgx)
> >
> >  static int bgx_init_phy(struct bgx *bgx)
> >  {
> >-	return bgx_init_of_phy(bgx);
> >+	int err = bgx_init_of_phy(bgx);
> >+
> >+	if (err != -ENODEV)
> >+		return err;
> >+
> >+	return bgx_init_acpi_phy(bgx);
> >  }
> >
> 
> If kernel can work with DT and ACPI (both compiled in), it should take only
> one path instead of probing DT and ACPI sequentially. How about:
> 
> @@ -902,10 +925,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct
> pci_device_id *ent)
>  	bgx_vnic[bgx->bgx_id] = bgx;
>  	bgx_get_qlm_mode(bgx);
> 
> -	snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id);
> -	np = of_find_node_by_name(NULL, bgx_sel);
> -	if (np)
> -		bgx_init_of(bgx, np);
> +	err = acpi_disabled ? bgx_init_of_phy(bgx) : bgx_init_acpi_phy(bgx);
> +	if (err)
> +		goto err_enable;
> 
>  	bgx_init_hw(bgx);

I would not pollute bgx_probe() with acpi and dt specifics, and instead
keep bgx_init_phy(). The typical design pattern for this is:

static int bgx_init_phy(struct bgx *bgx)
{
#ifdef CONFIG_ACPI
        if (!acpi_disabled)
                return bgx_init_acpi_phy(bgx);
#endif
        return bgx_init_of_phy(bgx);
}

This adds acpi runtime detection (acpi=no), does not call dt code in
case of acpi, and saves the #else for bgx_init_acpi_phy().

-Robert

WARNING: multiple messages have this Message-ID (diff)
From: robert.richter@caviumnetworks.com (Robert Richter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding.
Date: Fri, 7 Aug 2015 12:43:20 +0200	[thread overview]
Message-ID: <20150807104320.GQ1820@rric.localhost> (raw)
In-Reply-To: <55C467A0.4020601@linaro.org>

On 07.08.15 10:09:04, Tomasz Nowicki wrote:
> On 07.08.2015 02:33, David Daney wrote:

...

> >+#else
> >+
> >+static int bgx_init_acpi_phy(struct bgx *bgx)
> >+{
> >+	return -ENODEV;
> >+}
> >+
> >+#endif /* CONFIG_ACPI */
> >+
> >  #if IS_ENABLED(CONFIG_OF_MDIO)
> >
> >  static int bgx_init_of_phy(struct bgx *bgx)
> >@@ -882,7 +1010,12 @@ static int bgx_init_of_phy(struct bgx *bgx)
> >
> >  static int bgx_init_phy(struct bgx *bgx)
> >  {
> >-	return bgx_init_of_phy(bgx);
> >+	int err = bgx_init_of_phy(bgx);
> >+
> >+	if (err != -ENODEV)
> >+		return err;
> >+
> >+	return bgx_init_acpi_phy(bgx);
> >  }
> >
> 
> If kernel can work with DT and ACPI (both compiled in), it should take only
> one path instead of probing DT and ACPI sequentially. How about:
> 
> @@ -902,10 +925,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct
> pci_device_id *ent)
>  	bgx_vnic[bgx->bgx_id] = bgx;
>  	bgx_get_qlm_mode(bgx);
> 
> -	snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id);
> -	np = of_find_node_by_name(NULL, bgx_sel);
> -	if (np)
> -		bgx_init_of(bgx, np);
> +	err = acpi_disabled ? bgx_init_of_phy(bgx) : bgx_init_acpi_phy(bgx);
> +	if (err)
> +		goto err_enable;
> 
>  	bgx_init_hw(bgx);

I would not pollute bgx_probe() with acpi and dt specifics, and instead
keep bgx_init_phy(). The typical design pattern for this is:

static int bgx_init_phy(struct bgx *bgx)
{
#ifdef CONFIG_ACPI
        if (!acpi_disabled)
                return bgx_init_acpi_phy(bgx);
#endif
        return bgx_init_of_phy(bgx);
}

This adds acpi runtime detection (acpi=no), does not call dt code in
case of acpi, and saves the #else for bgx_init_acpi_phy().

-Robert

  reply	other threads:[~2015-08-07 10:43 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07  0:33 [PATCH 0/2] net: thunder: Add ACPI support David Daney
2015-08-07  0:33 ` David Daney
2015-08-07  0:33 ` [PATCH 1/2] net: thunder: Factor out DT specific code in BGX David Daney
2015-08-07  0:33   ` David Daney
2015-08-07  0:33 ` [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding David Daney
2015-08-07  0:33   ` David Daney
2015-08-07  8:09   ` Tomasz Nowicki
2015-08-07  8:09     ` Tomasz Nowicki
2015-08-07 10:43     ` Robert Richter [this message]
2015-08-07 10:43       ` Robert Richter
2015-08-07 10:43       ` Robert Richter
2015-08-07 10:52       ` Tomasz Nowicki
2015-08-07 10:52         ` Tomasz Nowicki
2015-08-07 11:56         ` Robert Richter
2015-08-07 11:56           ` Robert Richter
2015-08-07 11:56           ` Robert Richter
2015-08-07 12:42           ` Tomasz Nowicki
2015-08-07 12:42             ` Tomasz Nowicki
2015-08-07 16:40             ` David Daney
2015-08-07 16:40               ` David Daney
2015-08-07 16:40               ` David Daney
2015-08-08 11:26       ` Arnd Bergmann
2015-08-08 11:26         ` Arnd Bergmann
2015-08-07 14:01   ` Mark Rutland
2015-08-07 14:01     ` Mark Rutland
2015-08-07 14:01     ` Mark Rutland
2015-08-07 17:37     ` David Daney
2015-08-07 17:37       ` David Daney
2015-08-07 17:37       ` David Daney
2015-08-07 17:37       ` David Daney
2015-08-07 17:51       ` Mark Rutland
2015-08-07 17:51         ` Mark Rutland
2015-08-07 17:51         ` Mark Rutland
2015-08-07 17:51         ` Mark Rutland
2015-08-08  0:05         ` Rafael J. Wysocki
2015-08-08  0:05           ` Rafael J. Wysocki
2015-08-08  0:05           ` Rafael J. Wysocki
2015-08-08  0:05           ` Rafael J. Wysocki
2015-08-08  0:11           ` David Daney
2015-08-08  0:11             ` David Daney
2015-08-08  0:11             ` David Daney
2015-08-08  0:11             ` David Daney
2015-08-08  0:28             ` Rafael J. Wysocki
2015-08-08  0:28               ` Rafael J. Wysocki
2015-08-08  0:28               ` Rafael J. Wysocki
2015-09-05 20:00               ` _DSD standardization note (WAS: Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding.) Jon Masters
2015-09-05 20:00                 ` Jon Masters
2015-09-05 20:00                 ` Jon Masters
2015-09-08 17:17                 ` David Daney
2015-09-08 17:17                   ` David Daney
2015-09-08 17:17                   ` David Daney
2015-08-07 17:53       ` [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding Mark Rutland
2015-08-07 17:53         ` Mark Rutland
2015-08-07 17:53         ` Mark Rutland
2015-08-07 14:54   ` Graeme Gregory
2015-08-07 14:54     ` Graeme Gregory
2015-08-07 18:14     ` David Daney
2015-08-07 18:14       ` David Daney
2015-08-07 18:14       ` David Daney
2015-08-08  0:32       ` Rafael J. Wysocki
2015-08-08  0:32         ` Rafael J. Wysocki
2015-08-08  0:32         ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150807104320.GQ1820@rric.localhost \
    --to=robert.richter@caviumnetworks.com \
    --cc=davem@davemloft.net \
    --cc=david.daney@cavium.com \
    --cc=ddaney.cavm@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgoutham@cavium.com \
    --cc=tomasz.nowicki@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.