From: Peng Fan <B51431@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/4] dm: introduce dev_get_addr interface
Date: Fri, 6 Feb 2015 14:44:02 +0800 [thread overview]
Message-ID: <54D462B2.3070509@freescale.com> (raw)
In-Reply-To: <CAPnjgZ1+abwDi7aATRMTVaB4NyAfF6JO28KRmqc4aRi2pZen4A@mail.gmail.com>
Hi, Simon
On 1/23/2015 5:25 AM, Simon Glass wrote:
> Hi,
>
> On 21 January 2015 at 04:09, Peng Fan <Peng.Fan@freescale.com> wrote:
>> Abstracting dev_get_addr can improve drivers that want to
>> get device's address.
>>
>> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>> ---
>> drivers/core/device.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>> index 963b16f..0ba5c76 100644
>> --- a/drivers/core/device.c
>> +++ b/drivers/core/device.c
>> @@ -12,6 +12,7 @@
>> #include <common.h>
>> #include <fdtdec.h>
>> #include <malloc.h>
>> +#include <libfdt.h>
>> #include <dm/device.h>
>> #include <dm/device-internal.h>
>> #include <dm/lists.h>
>> @@ -390,3 +391,21 @@ ulong dev_get_of_data(struct udevice *dev)
>> {
>> return dev->of_id->data;
>> }
>> +
>> +#ifdef CONFIG_OF_CONTROL
>> +void *dev_get_addr(struct udevice *dev)
> My approach so far has been to use a ulong for the device address
> (e.g. in platform data) and only use a pointer when we know the type
> (e.g. struct disp_ctlr *), typically in driver-private data.
>
> So do you think it would be better to return FDT_ADDR_T_NONE?
Sorry for the long time delay to reply.
Do you agree this way using ulong as the return type?
"
#ifdef CONFIG_OF_CONTROL
unsigned long dev_get_addr(struct udevice *dev)
{
fdt_addr_t addr;
addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
return addr;
}
#else
unsigned long dev_get_addr(struct udevice *dev)
{
return FDT_ADDR_T_NONE;
}
#endif
"
Is it better to move this piece of code to include/dm/device.h and using
static inline prototype? or put them still in driver/core/device.c?
>> +{
>> + fdt_addr_t addr;
>> +
>> + addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
>> + if (addr == FDT_ADDR_T_NONE)
>> + return NULL;
>> + else
>> + return (void *)addr;
>> +}
>> +#else
>> +void *dev_get_addr(struct udevice *dev)
>> +{
>> + return NULL;
>> +}
>> +#endif
>> --
>> 1.8.4
>>
>>
> Regards,
> Simon
Thanks,
Peng.
next prev parent reply other threads:[~2015-02-06 6:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-21 11:09 [U-Boot] [PATCH v3 0/4] dm:gpio:mxc add DT support Peng Fan
2015-01-21 11:09 ` [U-Boot] [PATCH v3 1/4] dm: introduce dev_get_addr interface Peng Fan
2015-01-21 11:58 ` Igor Grinberg
2015-01-22 21:25 ` Simon Glass
2015-02-06 6:44 ` Peng Fan [this message]
2015-02-06 15:45 ` Simon Glass
2015-01-21 11:09 ` [U-Boot] [PATCH v3 2/4] dm: add dev_get_addr prototype Peng Fan
2015-01-21 11:59 ` Igor Grinberg
2015-01-21 11:09 ` [U-Boot] [PATCH v3 3/4] dm:gpio:mxc add a bank_index entry in platdata Peng Fan
2015-01-21 12:01 ` Igor Grinberg
2015-01-22 21:27 ` Simon Glass
2015-01-21 11:09 ` [U-Boot] [PATCH v3 4/4] dm:gpio:mxc add DT support Peng Fan
2015-01-22 1:06 ` Peng Fan
2015-01-22 8:38 ` Igor Grinberg
2015-01-22 18:56 ` Peng Fan
2015-01-22 21:26 ` Simon Glass
2015-01-24 14:34 ` Peng Fan
2015-01-26 13:38 ` Simon Glass
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=54D462B2.3070509@freescale.com \
--to=b51431@freescale.com \
--cc=u-boot@lists.denx.de \
/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