lkml.org 
[lkml]   [2012]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] LDT - Linux Driver Template
From
On Tue, Nov 13, 2012 at 9:01 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> +#define pr_debug_hex(h) pr_debug("%s:%d %s %s = 0x%lX\n", \
>> + __file__, __LINE__, __func__, #h, (long int)h)
>
> This is not needed at all, just use the proper printk() attribute.

Macro above allows tidy tracing code:

pr_debug_hex(ioread8(port_ptr + UART_IER));
pr_debug_hex(ioread8(port_ptr + UART_IIR));
pr_debug_hex(ioread8(port_ptr + UART_FCR));
pr_debug_hex(ioread8(port_ptr + UART_LCR));
pr_debug_hex(ioread8(port_ptr + UART_MCR));
pr_debug_hex(ioread8(port_ptr + UART_LSR));
pr_debug_hex(ioread8(port_ptr + UART_MSR));

Without that macro, code above should be rewritten with pr_debug (or printk) as:

pr_debug("UART_IER=0x%02X\n", ioread8(port_ptr + UART_IER));
pr_debug("UART_IIR=0x%02X\n", ioread8(port_ptr + UART_IIR));
pr_debug("UART_FCR=0x%02X\n", ioread8(port_ptr + UART_FCR));
pr_debug("UART_LCR=0x%02X\n", ioread8(port_ptr + UART_LCR));
pr_debug("UART_MCR=0x%02X\n", ioread8(port_ptr + UART_MCR));
pr_debug("UART_LSR=0x%02X\n", ioread8(port_ptr + UART_LSR));
pr_debug("UART_MSR=0x%02X\n", ioread8(port_ptr + UART_MSR));

That is less readable and less supportable.

I prefer the fist case.

Actually I use a lot shorter macro:
#define traceh(h) printk("%s = 0x%lX\n", #h, (long int)h)

What is you opinion? Which method is better?
Thank you.


\
 
 \ /
  Last update: 2012-11-14 01:21    [W:0.068 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site