For example,
typedef unsigned long long u64;
u64 *dma_mask;
Then how to use printk() to print out a dma_mask variable?
Regards
Jason Xiao
On 6/15/07, jidong xiao <[email protected]> wrote:
> typedef unsigned long long u64;
> u64 *dma_mask;
> Then how to use printk() to print out a dma_mask variable?
In regular printf(), this would be specified by the format "%llu". Try that?
Vegard
On Fri, 15 Jun 2007 17:04:00 +0200 Vegard Nossum wrote:
> On 6/15/07, jidong xiao <[email protected]> wrote:
> > typedef unsigned long long u64;
> > u64 *dma_mask;
> > Then how to use printk() to print out a dma_mask variable?
>
> In regular printf(), this would be specified by the format "%llu". Try that?
and cast dma_mask to (unsigned long long), at least in kernel printk()
calls.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Thanks all.
Is this right?
dev->dev.dma_mask = bus->controller->dma_mask;
printk(KERN_ERR "hey,jason,see,dma_mask is
%llu\n",*(dev->dev.dma_mask));
On 6/15/07, Randy Dunlap <[email protected]> wrote:
> On Fri, 15 Jun 2007 17:04:00 +0200 Vegard Nossum wrote:
>
> > On 6/15/07, jidong xiao <[email protected]> wrote:
> > > typedef unsigned long long u64;
> > > u64 *dma_mask;
> > > Then how to use printk() to print out a dma_mask variable?
> >
> > In regular printf(), this would be specified by the format "%llu". Try that?
>
> and cast dma_mask to (unsigned long long), at least in kernel printk()
> calls.
>
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>
> Is this right?
> dev->dev.dma_mask = bus->controller->dma_mask;
> printk(KERN_ERR "hey,jason,see,dma_mask is
> %llu\n",*(dev->dev.dma_mask));
No, why do you have the '*' -- dma_mask isn't a pointer, is it?
You probably want:
printk(KERN_ERR "hey,jason,see,dma_mask is %llx\n",
(unsigned long long) dev->dev.dma_mask);
(I would use a "%llx" format because masks are much clearer in hex).
The cast to unsigned long long is there because u64 is just unsigned
long on some 64-bit platforms, so you get a warning about the format
not matching on some architectures without the cast.
- R.
dma_mask should be a pointer, I mean, the element in struct device, see below,
struct device {
struct list_head node; /* node in sibling list */
struct list_head bus_list; /* node in bus's list */
struct list_head driver_list;
struct list_head children;
struct device * parent;
struct kobject kobj;
char bus_id[BUS_ID_SIZE]; /* position on parent bus */
struct bus_type * bus; /* type of bus device is on */
struct device_driver *driver; /* which driver has allocated this
device */
void *driver_data; /* data private to the driver */
void *platform_data; /* Platform specific data (e.g. ACPI,
BIOS data relevant to device) */
struct dev_pm_info power;
u32 detach_state; /* State to enter when device is
detached from its driver. */
u64 *dma_mask; /* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */
struct list_head dma_pools; /* dma pools (if dma'ble) */
struct dma_coherent_mem *dma_mem; /* internal for coherent mem
override */
void (*release)(struct device * dev);
};
Regards
Jason Xiao
On 6/16/07, Roland Dreier <[email protected]> wrote:
> > Is this right?
>
> > dev->dev.dma_mask = bus->controller->dma_mask;
> > printk(KERN_ERR "hey,jason,see,dma_mask is
> > %llu\n",*(dev->dev.dma_mask));
>
> No, why do you have the '*' -- dma_mask isn't a pointer, is it?
>
> You probably want:
>
> printk(KERN_ERR "hey,jason,see,dma_mask is %llx\n",
> (unsigned long long) dev->dev.dma_mask);
>
> (I would use a "%llx" format because masks are much clearer in hex).
> The cast to unsigned long long is there because u64 is just unsigned
> long on some 64-bit platforms, so you get a warning about the format
> not matching on some architectures without the cast.
>
> - R.
>
On Jun 16 2007 00:18, jidong xiao wrote:
> dma_mask should be a pointer, I mean, the element in struct device, see
> below,
>
> struct device {
>
> u64 *dma_mask; /* dma mask (if dma'able device) */
Then it's printk("%llx\n", (unsigned long long)*dev->dma_mask);
Jan
--
> dma_mask should be a pointer, I mean, the element in struct device, see below,
Sorry, you're right.
So print it as (unsigned long long) *dev->dma_mask.
- R.
On Fri, 15 Jun 2007 11:41:58 -0700 Roland Dreier <[email protected]> wrote:
>
> > dma_mask should be a pointer, I mean, the element in struct device, see below,
>
> Sorry, you're right.
>
> So print it as (unsigned long long) *dev->dma_mask.
And the reason you need to cast it is because u64 is "unsigned long" on
some architectures and "unsigned long long" on others.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/