devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Jean-Jacques Hiblot
	<jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Gregory Clement
	<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v3 2/2] dt: platform driver: Fill the resources before probe and defer if needed
Date: Wed, 23 Apr 2014 18:38:54 +0100	[thread overview]
Message-ID: <20140423173854.GI24070@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <53556AF1.2030608-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Mon, Apr 21, 2014 at 02:01:05PM -0500, Rob Herring wrote:
> Ah, right. Except for those drivers you need to work with deferred probe
> would have to use platform_get_irq. That fact makes this solution quite
> a bit easier.
> 
> Something like this is what you had in mind?

The below is what I had in mind... :)  This moves it to the right place
for deferred probing to work - the alternative is we need some way to
"register" a device which can't be probed immediately, track it's
resources, have some way for it to be notified when those resources
become available (or poll for them becoming available... eg at the
same time as the deferred probing trigger) and then make it properly
available to drivers.  That brings up all sorts of questions about
whether it should be registered in sysfs, what if another device with
the same name comes along, etc.

So the solution below is very much a simple and nice solution to the
problem - it makes full use of our existing infrastructure to deal with
the problem.

> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index e714709..5b47210 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -13,6 +13,7 @@
>  #include <linux/string.h>
>  #include <linux/platform_device.h>
>  #include <linux/of_device.h>
> +#include <linux/of_irq.h>
>  #include <linux/module.h>
>  #include <linux/init.h>
>  #include <linux/dma-mapping.h>
> @@ -87,7 +88,11 @@ int platform_get_irq(struct platform_device *dev,
> unsigned int num)
>  		return -ENXIO;
>  	return dev->archdata.irqs[num];
>  #else
> -	struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num);
> +	struct resource *r;
> +	if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node)
> +		return of_irq_get(dev->dev.of_node, num);
> +
> +	r = platform_get_resource(dev, IORESOURCE_IRQ, num);
> 
>  	return r ? r->start : -ENXIO;
>  #endif
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 7d3184f..30449ad 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -400,6 +400,26 @@ int of_irq_to_resource(struct device_node *dev, int
> index, struct resource *r)
>  EXPORT_SYMBOL_GPL(of_irq_to_resource);
> 
>  /**
> + * of_irq_get - Decode a node's IRQ and return it as a Linux irq number
> + * @dev: pointer to device tree node
> + * @index: zero-based index of the irq
> + *
> + * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
> + * is not yet created.
> + *
> + */
> +int of_irq_get(struct device_node *dev, int index)
> +{
> +	int irq = irq_of_parse_and_map(dev, index);
> +
> +	if (!irq && of_find_irq_domain(dev, index) == NULL)
> +		return -EPROBE_DEFER;
> +
> +	return irq;
> +}
> +EXPORT_SYMBOL_GPL(of_irq_get);
> +
> +/**
>   * of_irq_count - Count the number of IRQs a node uses
>   * @dev: pointer to device tree node
>   */

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-04-23 17:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  9:57 [PATCH] dt: platform driver: Fill the resources before probe and defer if needed Jean-Jacques Hiblot
2014-02-13 10:06 ` Jean-Jacques Hiblot
2014-02-18 20:22 ` Greg KH
2014-02-18 22:34   ` Grant Likely
2014-02-20 15:30 ` Grant Likely
2014-02-21 13:18   ` [PATCH v2] " Jean-Jacques Hiblot
     [not found]     ` <1392988720-20976-1-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2014-02-21 15:37       ` Strashko, Grygorii
2014-02-21 16:22         ` Jean-Jacques Hiblot
2014-02-27 16:43           ` Jean-Jacques Hiblot
2014-03-08  7:32             ` Grant Likely
2014-02-27 15:01       ` Ludovic Desroches
2014-03-08  7:37       ` Grant Likely
     [not found]         ` <20140308073758.DA63FC408EC-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-03-08 11:59           ` Russell King - ARM Linux
2014-03-17 11:07         ` Jean-Jacques Hiblot
     [not found]   ` < 1392988720-20976-1-git-send-email-jjhiblot@traphandler.com>
     [not found]     ` < 902E09E6452B0E43903E4F2D568737AB0B9D2959@DFRE01.ent.ti.com>
     [not found]       ` < CACh+v5MPTx6nwVj1s3krntJqQ6DMTQ2hQ93Hc+rRNAuFa9+qPw@mail.gmail.com>
     [not found]     ` <20140308073758 .DA63FC408EC@trevor.secretlab.ca>
     [not found]       ` < CACh+v5P=tcc-h_9r7Btwyu+jWjwH2ocmW4VCgDYqY7VMWsHuOA@mail.gmail.com>
     [not found]         ` <CACh+v5P=tcc-h_9r7Btwyu+jWjwH2ocmW4VCgDYqY7VMWsHuOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-17 14:24           ` Grant Likely
2014-03-17 15:20             ` Jean-Jacques Hiblot
     [not found]         ` < 20140317142443.A2447C40A85@trevor.secretlab.ca>
     [not found]           ` < CACh+v5M+0+C2JJwLqcp6erWa81kt=j1HucHiE52ufj1SO9F75w@mail.gmail.com>
     [not found]             ` <CACh+v5M+0+C2JJwLqcp6erWa81kt=j1HucHiE52ufj1SO9F75w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-20 16:11               ` Grant Likely
     [not found]                 ` <20140320161118.B7075C4067A-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-03-21 14:46                   ` [PATCH v3 0/2] " Jean-Jacques Hiblot
     [not found]                     ` <1395413185-29763-1-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2014-03-21 14:46                       ` [PATCH v3 1/2] of: irq: Added of_find_irq_domain() to get the domain of an irq Jean-Jacques Hiblot
2014-03-21 14:46                     ` [PATCH v3 2/2] dt: platform driver: Fill the resources before probe and defer if needed Jean-Jacques Hiblot
2014-04-11 17:28                       ` Rob Herring
     [not found]                         ` <CAL_Jsq+aU+rs28gV=Gesb_-Dy6Ht7zuKrRA6_hmqp94Uun23Yg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-18 20:52                           ` Tony Lindgren
     [not found]                             ` <20140418205213.GA21823-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-04-18 21:39                               ` Rob Herring
     [not found]                                 ` <CAL_JsqJvVvo6R-qNXxur7wiZERKbi52xyKoWnmzJTfKS2iKK7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-18 21:58                                   ` Tony Lindgren
     [not found]                                     ` <20140418215848.GD21823-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-04-18 23:03                                       ` Russell King - ARM Linux
     [not found]                                         ` <20140418230335.GI24070-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-04-18 23:24                                           ` Tony Lindgren
2014-04-21 13:47                                             ` Rob Herring
     [not found]                                               ` <CAL_JsqLvLTJwgsB-m0W72WxSUoTV4ubMdvM_a784J4k2eiK9AQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-21 15:54                                                 ` Tony Lindgren
     [not found]                                                   ` <20140421155424.GD23945-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-04-21 19:01                                                     ` Rob Herring
     [not found]                                                       ` <53556AF1.2030608-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-21 20:25                                                         ` Tony Lindgren
     [not found]                                                           ` <20140421202546.GA26554-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-04-22  3:05                                                             ` Tony Lindgren
2014-04-22  4:57                                                               ` Tony Lindgren
     [not found]                                                                 ` <20140422045730.GC26554-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-04-23 22:03                                                                   ` Rob Herring
2014-04-23 17:38                                                         ` Russell King - ARM Linux [this message]
2014-04-23 15:02                                               ` Grant Likely

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=20140423173854.GI24070@n2100.arm.linux.org.uk \
    --to=linux-lfz/pmaqli7xmaaqvzeohq@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).