Skip to content

Commit e7ed70e

Browse files
committed
dma-debug: use pr_* instead of printk(KERN_* ...)
The pr_* macros are shorter than the old printk(KERN_ ...) variant. Change the dma-debug code to use the new macros and save a few unnecessary line breaks. If lines don't break the source code can also be grepped more easily. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent c17e2cf commit e7ed70e

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

‎lib/dma-debug.c‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static inline void dump_entry_trace(struct dma_debug_entry *entry)
139139
{
140140
#ifdef CONFIG_STACKTRACE
141141
if (entry) {
142-
printk(KERN_WARNING "Mapped at:\n");
142+
pr_warning("Mapped at:\n");
143143
print_stack_trace(&entry->stacktrace, 0);
144144
}
145145
#endif
@@ -377,8 +377,7 @@ static struct dma_debug_entry *dma_entry_alloc(void)
377377
spin_lock_irqsave(&free_entries_lock, flags);
378378

379379
if (list_empty(&free_entries)) {
380-
printk(KERN_ERR "DMA-API: debugging out of memory "
381-
"- disabling\n");
380+
pr_err("DMA-API: debugging out of memory - disabling\n");
382381
global_disable = true;
383382
goto out;
384383
}
@@ -483,8 +482,7 @@ static int prealloc_memory(u32 num_entries)
483482
num_free_entries = num_entries;
484483
min_free_entries = num_entries;
485484

486-
printk(KERN_INFO "DMA-API: preallocated %d debug entries\n",
487-
num_entries);
485+
pr_info("DMA-API: preallocated %d debug entries\n", num_entries);
488486

489487
return 0;
490488

@@ -534,7 +532,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
534532
* disabled. Since copy_from_user can fault and may sleep we
535533
* need to copy to temporary buffer first
536534
*/
537-
len = min(count, NAME_MAX_LEN - 1);
535+
len = min(count, (size_t)(NAME_MAX_LEN - 1));
538536
if (copy_from_user(buf, userbuf, len))
539537
return -EFAULT;
540538

@@ -557,8 +555,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
557555
* switched off.
558556
*/
559557
if (current_driver_name[0])
560-
printk(KERN_INFO "DMA-API: switching off dma-debug "
561-
"driver filter\n");
558+
pr_info("DMA-API: switching off dma-debug driver filter\n");
562559
current_driver_name[0] = 0;
563560
current_driver = NULL;
564561
goto out_unlock;
@@ -576,8 +573,8 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
576573
current_driver_name[i] = 0;
577574
current_driver = NULL;
578575

579-
printk(KERN_INFO "DMA-API: enable driver filter for driver [%s]\n",
580-
current_driver_name);
576+
pr_info("DMA-API: enable driver filter for driver [%s]\n",
577+
current_driver_name);
581578

582579
out_unlock:
583580
write_unlock_irqrestore(&driver_name_lock, flags);
@@ -594,7 +591,7 @@ static int dma_debug_fs_init(void)
594591
{
595592
dma_debug_dent = debugfs_create_dir("dma-api", NULL);
596593
if (!dma_debug_dent) {
597-
printk(KERN_ERR "DMA-API: can not create debugfs directory\n");
594+
pr_err("DMA-API: can not create debugfs directory\n");
598595
return -ENOMEM;
599596
}
600597

@@ -693,7 +690,7 @@ void dma_debug_add_bus(struct bus_type *bus)
693690

694691
nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
695692
if (nb == NULL) {
696-
printk(KERN_ERR "dma_debug_add_bus: out of memory\n");
693+
pr_err("dma_debug_add_bus: out of memory\n");
697694
return;
698695
}
699696

@@ -718,8 +715,7 @@ void dma_debug_init(u32 num_entries)
718715
}
719716

720717
if (dma_debug_fs_init() != 0) {
721-
printk(KERN_ERR "DMA-API: error creating debugfs entries "
722-
"- disabling\n");
718+
pr_err("DMA-API: error creating debugfs entries - disabling\n");
723719
global_disable = true;
724720

725721
return;
@@ -729,16 +725,15 @@ void dma_debug_init(u32 num_entries)
729725
num_entries = req_entries;
730726

731727
if (prealloc_memory(num_entries) != 0) {
732-
printk(KERN_ERR "DMA-API: debugging out of memory error "
733-
"- disabled\n");
728+
pr_err("DMA-API: debugging out of memory error - disabled\n");
734729
global_disable = true;
735730

736731
return;
737732
}
738733

739734
nr_total_entries = num_free_entries;
740735

741-
printk(KERN_INFO "DMA-API: debugging enabled by kernel config\n");
736+
pr_info("DMA-API: debugging enabled by kernel config\n");
742737
}
743738

744739
static __init int dma_debug_cmdline(char *str)
@@ -747,8 +742,7 @@ static __init int dma_debug_cmdline(char *str)
747742
return -EINVAL;
748743

749744
if (strncmp(str, "off", 3) == 0) {
750-
printk(KERN_INFO "DMA-API: debugging disabled on kernel "
751-
"command line\n");
745+
pr_info("DMA-API: debugging disabled on kernel command line\n");
752746
global_disable = true;
753747
}
754748

@@ -1239,8 +1233,8 @@ static int __init dma_debug_driver_setup(char *str)
12391233
}
12401234

12411235
if (current_driver_name[0])
1242-
printk(KERN_INFO "DMA-API: enable driver filter for "
1243-
"driver [%s]\n", current_driver_name);
1236+
pr_info("DMA-API: enable driver filter for driver [%s]\n",
1237+
current_driver_name);
12441238

12451239

12461240
return 1;

0 commit comments

Comments
 (0)