linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to printk unsigned long long variable?
@ 2007-06-15 14:59 jidong xiao
  2007-06-15 15:04 ` Vegard Nossum
  0 siblings, 1 reply; 9+ messages in thread
From: jidong xiao @ 2007-06-15 14:59 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 14:59 How to printk unsigned long long variable? jidong xiao
@ 2007-06-15 15:04 ` Vegard Nossum
  2007-06-15 15:33   ` Randy Dunlap
  0 siblings, 1 reply; 9+ messages in thread
From: Vegard Nossum @ 2007-06-15 15:04 UTC (permalink / raw)
  To: jidong xiao; +Cc: linux-kernel

On 6/15/07, jidong xiao <jidong.xiao@gmail.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 15:04 ` Vegard Nossum
@ 2007-06-15 15:33   ` Randy Dunlap
  2007-06-15 15:39     ` jidong xiao
  0 siblings, 1 reply; 9+ messages in thread
From: Randy Dunlap @ 2007-06-15 15:33 UTC (permalink / raw)
  To: Vegard Nossum; +Cc: jidong xiao, linux-kernel

On Fri, 15 Jun 2007 17:04:00 +0200 Vegard Nossum wrote:

> On 6/15/07, jidong xiao <jidong.xiao@gmail.com> 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 ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 15:33   ` Randy Dunlap
@ 2007-06-15 15:39     ` jidong xiao
  2007-06-15 16:14       ` Roland Dreier
  0 siblings, 1 reply; 9+ messages in thread
From: jidong xiao @ 2007-06-15 15:39 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Vegard Nossum, linux-kernel

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 <randy.dunlap@oracle.com> wrote:
> On Fri, 15 Jun 2007 17:04:00 +0200 Vegard Nossum wrote:
>
> > On 6/15/07, jidong xiao <jidong.xiao@gmail.com> 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 ***
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 15:39     ` jidong xiao
@ 2007-06-15 16:14       ` Roland Dreier
  2007-06-15 16:18         ` jidong xiao
  0 siblings, 1 reply; 9+ messages in thread
From: Roland Dreier @ 2007-06-15 16:14 UTC (permalink / raw)
  To: jidong xiao; +Cc: Randy Dunlap, Vegard Nossum, linux-kernel

 > 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 16:14       ` Roland Dreier
@ 2007-06-15 16:18         ` jidong xiao
  2007-06-15 16:29           ` Jan Engelhardt
  2007-06-15 18:41           ` Roland Dreier
  0 siblings, 2 replies; 9+ messages in thread
From: jidong xiao @ 2007-06-15 16:18 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Randy Dunlap, Vegard Nossum, linux-kernel

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 <rdreier@cisco.com> 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.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 16:18         ` jidong xiao
@ 2007-06-15 16:29           ` Jan Engelhardt
  2007-06-15 18:41           ` Roland Dreier
  1 sibling, 0 replies; 9+ messages in thread
From: Jan Engelhardt @ 2007-06-15 16:29 UTC (permalink / raw)
  To: jidong xiao; +Cc: Roland Dreier, Randy Dunlap, Vegard Nossum, linux-kernel


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
-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 16:18         ` jidong xiao
  2007-06-15 16:29           ` Jan Engelhardt
@ 2007-06-15 18:41           ` Roland Dreier
  2007-06-17  6:55             ` Stephen Rothwell
  1 sibling, 1 reply; 9+ messages in thread
From: Roland Dreier @ 2007-06-15 18:41 UTC (permalink / raw)
  To: jidong xiao; +Cc: Randy Dunlap, Vegard Nossum, linux-kernel

 > 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to printk unsigned long long variable?
  2007-06-15 18:41           ` Roland Dreier
@ 2007-06-17  6:55             ` Stephen Rothwell
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Rothwell @ 2007-06-17  6:55 UTC (permalink / raw)
  To: Roland Dreier; +Cc: jidong xiao, Randy Dunlap, Vegard Nossum, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

On Fri, 15 Jun 2007 11:41:58 -0700 Roland Dreier <rdreier@cisco.com> 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                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-06-17  6:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-15 14:59 How to printk unsigned long long variable? jidong xiao
2007-06-15 15:04 ` Vegard Nossum
2007-06-15 15:33   ` Randy Dunlap
2007-06-15 15:39     ` jidong xiao
2007-06-15 16:14       ` Roland Dreier
2007-06-15 16:18         ` jidong xiao
2007-06-15 16:29           ` Jan Engelhardt
2007-06-15 18:41           ` Roland Dreier
2007-06-17  6:55             ` Stephen Rothwell

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).