staging: vme_user: Remove printk's & clean up log messages
v3 cover staging: vme_user: Remove printk's & clean up log messages
Staging driver vme_user has a bunch of printk() calls in vme.c which triggers checkpatch warnings. Remove all printk's by either changing them to the appropriate logging mechanism i.e dev_err()/dev_warn() or by dropping the unneeded printk's.
Also, clean up the messages further by using __func__ in the string instead of function names.
This patchset fixes all checkpatch warnings like:
WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then
dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
&
WARNING: Prefer using '"%s...", __func__' to using 'vme_lm_get',
this function's name, in a string
Patches must be applied in order.
Changes in v3:
1. Patch 1: Use only dev_err() to replace printk(). v2 replaced some of the printk's using pr_err(). Leave the calls as printk's. New patches added in v3 handle these printk's.
(as per feedback from [email protected])
2. Added Patch 3: Remove unneeded printk.
(suggested by [email protected])
3. Added Patch 4: Remove NULL-checks for bridge device & resource. Corresponding printk's(part of the check blocks) are removed too. (as per feedback from [email protected])
4. Added Patch 5: Replace printk with dev_err() in vme_check_window() Since vme_check_window() doesn't have access to bridge device, pass the bridge pointer to it.
(suggested by [email protected])
5. Edit cover letter subject & body according to patches added in v3.
Changes in v2:
1. Correct "cleanup" to "clean up" in cover letter. (as per feedback
from [email protected])
2. Patch 1: Change the pr_*() calls used to replace printk's in v1 to dev_*() wherever possible, as it adds more context to the messages. (as per feedback from [email protected] & [email protected])
Soumya Negi (5):
staging: vme_user: Replace printk() with dev_*()
staging: vme_user: Use __func__ instead of function name
staging: vme_user: Remove printk() in find_bridge()
staging: vme_user: Remove NULL-checks
staging: vme_user: Use dev_err() in vme_check_window()
drivers/staging/vme_user/vme.c | 222 ++++++++++++++++----------------- drivers/staging/vme_user/vme.h | 4 +- 2 files changed, 108 insertions(+), 118 deletions(-)
Signature · 1 line
2.42.0
PATCH v3 1/5 staging: vme_user: Replace printk() with dev_*()
vme.c uses printk() to log messages. To improve and standardize message formatting, use logging mechanisms dev_err()/dev_warn() instead. Retain the printk log levels of the messages during replacement.
Issue found by checkpatch.pl
--- drivers/staging/vme_user/vme.c | 175 +++++++++++++++++++-------------- 1 file changed, 99 insertions(+), 76 deletions(-)
drivers/staging/vme_user/vme.c +99 -76
@@ -100,8 +100,9 @@ void *vme_alloc_consistent(struct vme_resource *resource, size_t size, }if (!bridge->alloc_consistent) { -printk (KERN_ERR "alloc_consistent not supported by bridge %s\n" , - bridge->name); +dev_err (bridge->parent, +"alloc_consistent not supported by bridge %s\n" , + bridge->name);return NULL ; }
@@ -140,8 +141,9 @@ void vme_free_consistent(struct vme_resource *resource, size_t size, }if (!bridge->free_consistent) { -printk (KERN_ERR "free_consistent not supported by bridge %s\n" , - bridge->name); +dev_err (bridge->parent, +"free_consistent not supported by bridge %s\n" , + bridge->name);return ; }
@@ -161,6 +163,7 @@ EXPORT_SYMBOL(vme_free_consistent);*/ size_t vme_get_size (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);int enabled, retval;unsigned long long base, size;dma_addr_t buf_base;
@@ -184,7 +187,7 @@ size_t vme_get_size(struct vme_resource *resource)case VME_DMA :return 0 ;default : -printk (KERN_ERR "Unknown resource type\n" ); +dev_err (bridge->parent,"Unknown resource type\n" );return 0 ; } }
@@ -288,14 +291,15 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address, bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" ); goto err_bus; }/* Loop through slave resources */ list_for_each_entry (slave_image, &bridge->slave_resources, list) {if (!slave_image) { -printk (KERN_ERR "Registered NULL Slave resource\n" ); +dev_err (bridge->parent, +"Registered NULL Slave resource\n" );continue ; }
@@ -362,20 +366,20 @@ int vme_slave_set(struct vme_resource *resource, int enabled,int retval;if (resource->type !=VME_SLAVE ) { -printk (KERN_ERR "Not a slave resource\n" ); +dev_err (bridge->parent,"Not a slave resource\n" );return -EINVAL ; } image = list_entry(resource->entry, struct vme_slave_resource, list);if (!bridge->slave_set) { -printk (KERN_ERR "Function not supported\n" ); +dev_err (bridge->parent,"Function not supported\n" );return -ENOSYS ; }if (!(((image->address_attr & aspace) == aspace) && ((image->cycle_attr & cycle) == cycle))) { -printk (KERN_ERR "Invalid attributes\n" ); +dev_err (bridge->parent,"Invalid attributes\n" );return -EINVAL ; }
@@ -411,14 +415,14 @@ int vme_slave_get(struct vme_resource *resource, int *enabled,struct vme_slave_resource *image;if (resource->type !=VME_SLAVE ) { -printk (KERN_ERR "Not a slave resource\n" ); +dev_err (bridge->parent,"Not a slave resource\n" );return -EINVAL ; } image = list_entry(resource->entry, struct vme_slave_resource, list);if (!bridge->slave_get) { -printk (KERN_ERR "vme_slave_get not supported\n" ); +dev_err (bridge->parent,"vme_slave_get not supported\n" );return -EINVAL ; }
@@ -435,24 +439,25 @@ EXPORT_SYMBOL(vme_slave_get);*/ void vme_slave_free (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_slave_resource *slave_image;if (resource->type !=VME_SLAVE ) { -printk (KERN_ERR "Not a slave resource\n" ); +dev_err (bridge->parent,"Not a slave resource\n" );return ; } slave_image = list_entry(resource->entry, struct vme_slave_resource, list);if (!slave_image) { -printk (KERN_ERR "Can't find slave resource\n" ); +dev_err (bridge->parent,"Can't find slave resource\n" );return ; }/* Unlock image */ mutex_lock (&slave_image->mtx);if (slave_image->locked ==0 ) -printk (KERN_ERR "Image is already free\n" ); +dev_err (bridge->parent,"Image is already free\n" ); slave_image->locked =0 ;mutex_unlock (&slave_image->mtx);
@@ -484,14 +489,15 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address, bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" ); goto err_bus; }/* Loop through master resources */ list_for_each_entry (master_image, &bridge->master_resources, list) {if (!master_image) { -printk (KERN_WARNING "Registered NULL master resource\n" ); +dev_warn (bridge->parent, +"Registered NULL master resource\n" );continue ; }
@@ -511,7 +517,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,/* Check to see if we found a resource */ if (!allocated_image) { -printk (KERN_ERR "Can't find a suitable resource\n" ); +dev_err (&vdev->dev,"Can't find a suitable resource\n" ); goto err_image; }
@@ -561,21 +567,21 @@ int vme_master_set(struct vme_resource *resource, int enabled,int retval;if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; } image = list_entry(resource->entry, struct vme_master_resource, list);if (!bridge->master_set) { -printk (KERN_WARNING "vme_master_set not supported\n" ); +dev_warn (bridge->parent,"vme_master_set not supported\n" );return -EINVAL ; }if (!(((image->address_attr & aspace) == aspace) && ((image->cycle_attr & cycle) == cycle) && ((image->width_attr & dwidth) == dwidth))) { -printk (KERN_WARNING "Invalid attributes\n" ); +dev_warn (bridge->parent,"Invalid attributes\n" );return -EINVAL ; }
@@ -611,14 +617,14 @@ int vme_master_get(struct vme_resource *resource, int *enabled,struct vme_master_resource *image;if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; } image = list_entry(resource->entry, struct vme_master_resource, list);if (!bridge->master_get) { -printk (KERN_WARNING "%s not supported\n" , __func__); +dev_warn (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -650,12 +656,13 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,size_t length;if (!bridge->master_read) { -printk (KERN_WARNING "Reading from resource not supported\n" ); +dev_warn (bridge->parent, +"Reading from resource not supported\n" );return -EINVAL ; }if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; }
@@ -664,7 +671,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count, length =vme_get_size (resource);if (offset > length) { -printk (KERN_WARNING "Invalid Offset\n" ); +dev_warn (bridge->parent,"Invalid Offset\n" );return -EFAULT ; }
@@ -698,12 +705,12 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf,size_t length;if (!bridge->master_write) { -printk (KERN_WARNING "Writing to resource not supported\n" ); +dev_warn (bridge->parent,"Writing to resource not supported\n" );return -EINVAL ; }if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; }
@@ -712,7 +719,7 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf, length =vme_get_size (resource);if (offset > length) { -printk (KERN_WARNING "Invalid Offset\n" ); +dev_warn (bridge->parent,"Invalid Offset\n" );return -EFAULT ; }
@@ -749,12 +756,12 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,struct vme_master_resource *image;if (!bridge->master_rmw) { -printk (KERN_WARNING "Writing to resource not supported\n" ); +dev_warn (bridge->parent,"Writing to resource not supported\n" );return -EINVAL ; }if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; }
@@ -777,12 +784,13 @@ EXPORT_SYMBOL(vme_master_rmw);*/ int vme_master_mmap (struct vme_resource *resource,struct vm_area_struct *vma) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_master_resource *image;phys_addr_t phys_addr;unsigned long vma_size;if (resource->type !=VME_MASTER ) { -pr_err ("Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return -EINVAL ; }
@@ -791,7 +799,7 @@ int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma) vma_size = vma->vm_end - vma->vm_start;if (phys_addr + vma_size > image->bus_resource.end +1 ) { -pr_err ("Map size cannot exceed the window size\n" ); +dev_err (bridge->parent,"Map size cannot exceed the window size\n" );return -EFAULT ; }
@@ -809,24 +817,25 @@ EXPORT_SYMBOL(vme_master_mmap);*/ void vme_master_free (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_master_resource *master_image;if (resource->type !=VME_MASTER ) { -printk (KERN_ERR "Not a master resource\n" ); +dev_err (bridge->parent,"Not a master resource\n" );return ; } master_image = list_entry(resource->entry, struct vme_master_resource, list);if (!master_image) { -printk (KERN_ERR "Can't find master resource\n" ); +dev_err (bridge->parent,"Can't find master resource\n" );return ; }/* Unlock image */ spin_lock (&master_image->lock);if (master_image->locked ==0 ) -printk (KERN_ERR "Image is already free\n" ); +dev_err (bridge->parent,"Image is already free\n" ); master_image->locked =0 ;spin_unlock (&master_image->lock);
@@ -854,18 +863,19 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)struct vme_resource *resource =NULL ;/* XXX Not checking resource attributes */ -printk (KERN_ERR "No VME resource Attribute tests done\n" ); +dev_err (&vdev->dev,"No VME resource Attribute tests done\n" ); bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" ); goto err_bus; }/* Loop through DMA resources */ list_for_each_entry (dma_ctrlr, &bridge->dma_resources, list) {if (!dma_ctrlr) { -printk (KERN_ERR "Registered NULL DMA resource\n" ); +dev_err (bridge->parent, +"Registered NULL DMA resource\n" );continue ; }
@@ -917,10 +927,11 @@ EXPORT_SYMBOL(vme_dma_request);*/ struct vme_dma_list *vme_new_dma_list (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_dma_list *dma_list;if (resource->type !=VME_DMA ) { -printk (KERN_ERR "Not a DMA resource\n" ); +dev_err (bridge->parent,"Not a DMA resource\n" );return NULL ; }
@@ -1098,12 +1109,13 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,int retval;if (!bridge->dma_list_add) { -printk (KERN_WARNING "Link List DMA generation not supported\n" ); +dev_warn (bridge->parent, +"Link List DMA generation not supported\n" );return -EINVAL ; }if (!mutex_trylock (&list->mtx)) { -printk (KERN_ERR "Link List already submitted\n" ); +dev_err (bridge->parent,"Link List already submitted\n" );return -EINVAL ; }
@@ -1131,7 +1143,8 @@ int vme_dma_list_exec(struct vme_dma_list *list)int retval;if (!bridge->dma_list_exec) { -printk (KERN_ERR "Link List DMA execution not supported\n" ); +dev_err (bridge->parent, +"Link List DMA execution not supported\n" );return -EINVAL ; }
@@ -1160,12 +1173,13 @@ int vme_dma_list_free(struct vme_dma_list *list)int retval;if (!bridge->dma_list_empty) { -printk (KERN_WARNING "Emptying of Link Lists not supported\n" ); +dev_warn (bridge->parent, +"Emptying of Link Lists not supported\n" );return -EINVAL ; }if (!mutex_trylock (&list->mtx)) { -printk (KERN_ERR "Link List in use\n" ); +dev_err (bridge->parent,"Link List in use\n" );return -EBUSY ; }
@@ -1175,7 +1189,7 @@ int vme_dma_list_free(struct vme_dma_list *list)*/ retval = bridge->dma_list_empty (list);if (retval) { -printk (KERN_ERR "Unable to empty link-list entries\n" ); +dev_err (bridge->parent,"Unable to empty link-list entries\n" );mutex_unlock (&list->mtx);return retval; }
@@ -1197,22 +1211,24 @@ EXPORT_SYMBOL(vme_dma_list_free);*/ int vme_dma_free (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_dma_resource *ctrlr;if (resource->type !=VME_DMA ) { -printk (KERN_ERR "Not a DMA resource\n" ); +dev_err (bridge->parent,"Not a DMA resource\n" );return -EINVAL ; } ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);if (!mutex_trylock (&ctrlr->mtx)) { -printk (KERN_ERR "Resource busy, can't free\n" ); +dev_err (bridge->parent,"Resource busy, can't free\n" );return -EBUSY ; }if (!(list_empty (&ctrlr->pending) &&list_empty (&ctrlr->running))) { -printk (KERN_WARNING "Resource still processing transfers\n" ); +dev_warn (bridge->parent, +"Resource still processing transfers\n" );mutex_unlock (&ctrlr->mtx);return -EBUSY ; }
@@ -1290,8 +1306,9 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)if (call)call (level, statid, priv_data);else -printk (KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n" , - level, statid); +dev_warn (bridge->parent, +"Spurious VME interrupt, level:%x, vector:%x\n" , level, + statid); }EXPORT_SYMBOL (vme_irq_handler);
@@ -1319,17 +1336,18 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid, bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" );return -EINVAL ; }if ((level <1 ) || (level >7 )) { -printk (KERN_ERR "Invalid interrupt level\n" ); +dev_err (bridge->parent,"Invalid interrupt level\n" );return -EINVAL ; }if (!bridge->irq_set) { -printk (KERN_ERR "Configuring interrupts not supported\n" ); +dev_err (bridge->parent, +"Configuring interrupts not supported\n" );return -EINVAL ; }
@@ -1337,7 +1355,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,if (bridge->irq[level -1 ].callback[statid].func) {mutex_unlock (&bridge->irq_mtx); -printk (KERN_WARNING "VME Interrupt already taken\n" ); +dev_warn (bridge->parent,"VME Interrupt already taken\n" );return -EBUSY ; }
@@ -1368,17 +1386,18 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid) bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" );return ; }if ((level <1 ) || (level >7 )) { -printk (KERN_ERR "Invalid interrupt level\n" ); +dev_err (bridge->parent,"Invalid interrupt level\n" );return ; }if (!bridge->irq_set) { -printk (KERN_ERR "Configuring interrupts not supported\n" ); +dev_err (bridge->parent, +"Configuring interrupts not supported\n" );return ; }
@@ -1415,17 +1434,18 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid) bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" );return -EINVAL ; }if ((level <1 ) || (level >7 )) { -printk (KERN_WARNING "Invalid interrupt level\n" ); +dev_warn (bridge->parent,"Invalid interrupt level\n" );return -EINVAL ; }if (!bridge->irq_generate) { -printk (KERN_WARNING "Interrupt generation not supported\n" ); +dev_warn (bridge->parent, +"Interrupt generation not supported\n" );return -EINVAL ; }
@@ -1452,14 +1472,15 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev) bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" ); goto err_bus; }/* Loop through LM resources */ list_for_each_entry (lm, &bridge->lm_resources, list) {if (!lm) { -printk (KERN_ERR "Registered NULL Location Monitor resource\n" ); +dev_err (bridge->parent, +"Registered NULL Location Monitor resource\n" );continue ; }
@@ -1511,10 +1532,11 @@ EXPORT_SYMBOL(vme_lm_request);*/ int vme_lm_count (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return -EINVAL ; }
@@ -1545,14 +1567,14 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return -EINVAL ; } lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_set) { -printk (KERN_ERR "vme_lm_set not supported\n" ); +dev_err (bridge->parent,"vme_lm_set not supported\n" );return -EINVAL ; }
@@ -1581,14 +1603,14 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return -EINVAL ; } lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_get) { -printk (KERN_ERR "vme_lm_get not supported\n" ); +dev_err (bridge->parent,"vme_lm_get not supported\n" );return -EINVAL ; }
@@ -1618,14 +1640,14 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return -EINVAL ; } lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_attach) { -printk (KERN_ERR "vme_lm_attach not supported\n" ); +dev_err (bridge->parent,"vme_lm_attach not supported\n" );return -EINVAL ; }
@@ -1651,14 +1673,14 @@ int vme_lm_detach(struct vme_resource *resource, int monitor)struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return -EINVAL ; } lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_detach) { -printk (KERN_ERR "vme_lm_detach not supported\n" ); +dev_err (bridge->parent,"vme_lm_detach not supported\n" );return -EINVAL ; }
@@ -1680,10 +1702,11 @@ EXPORT_SYMBOL(vme_lm_detach);*/ void vme_lm_free (struct vme_resource *resource) { +struct vme_bridge *bridge =find_bridge (resource);struct vme_lm_resource *lm;if (resource->type !=VME_LM ) { -printk (KERN_ERR "Not a Location Monitor resource\n" ); +dev_err (bridge->parent,"Not a Location Monitor resource\n" );return ; }
@@ -1720,12 +1743,12 @@ int vme_slot_num(struct vme_dev *vdev) bridge = vdev->bridge;if (!bridge) { -printk (KERN_ERR "Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" );return -EINVAL ; }if (!bridge->slot_get) { -printk (KERN_WARNING "vme_slot_num not supported\n" ); +dev_warn (bridge->parent,"vme_slot_num not supported\n" );return -EINVAL ; }
@@ -1748,7 +1771,7 @@ int vme_bus_num(struct vme_dev *vdev) bridge = vdev->bridge;if (!bridge) { -pr_err ("Can't find VME bus\n" ); +dev_err (&vdev->dev,"Can't find VME bus\n" );return -EINVAL ; }
Signature · 1 line
2.42.0
PATCH v3 2/5 staging: vme_user: Use __func__ instead of function name
In reply to Soumya NegiReplace function names in message strings with __func__ to fix all checkpatch warnings like:
WARNING: Prefer using '"%s...", __func__' to using 'vme_lm_get',
this function's name, in a string
--- drivers/staging/vme_user/vme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/vme_user/vme.c +7 -7
@@ -422,7 +422,7 @@ int vme_slave_get(struct vme_resource *resource, int *enabled, image = list_entry(resource->entry, struct vme_slave_resource, list);if (!bridge->slave_get) { -dev_err (bridge->parent,"vme_slave_get not supported\n" ); +dev_err (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -574,7 +574,7 @@ int vme_master_set(struct vme_resource *resource, int enabled, image = list_entry(resource->entry, struct vme_master_resource, list);if (!bridge->master_set) { -dev_warn (bridge->parent,"vme_master_set not supported\n" ); +dev_warn (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -1574,7 +1574,7 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base, lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_set) { -dev_err (bridge->parent,"vme_lm_set not supported\n" ); +dev_err (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -1610,7 +1610,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base, lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_get) { -dev_err (bridge->parent,"vme_lm_get not supported\n" ); +dev_err (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -1647,7 +1647,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor, lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_attach) { -dev_err (bridge->parent,"vme_lm_attach not supported\n" ); +dev_err (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -1680,7 +1680,7 @@ int vme_lm_detach(struct vme_resource *resource, int monitor) lm = list_entry(resource->entry, struct vme_lm_resource, list);if (!bridge->lm_detach) { -dev_err (bridge->parent,"vme_lm_detach not supported\n" ); +dev_err (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
@@ -1748,7 +1748,7 @@ int vme_slot_num(struct vme_dev *vdev) }if (!bridge->slot_get) { -dev_warn (bridge->parent,"vme_slot_num not supported\n" ); +dev_warn (bridge->parent,"%s not supported\n" , __func__);return -EINVAL ; }
Signature · 1 line
2.42.0
PATCH v3 3/5 staging: vme_user: Remove printk() in find_bridge()
In reply to Soumya NegiDon't log error message in find_bridge(). The printk() triggers a checkpatch warning:
WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then
dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
It can't be replaced by dev_err() & using pr_err() is not helpful as it doesn't give much context to the user. It is better to remove it.
--- drivers/staging/vme_user/vme.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/vme_user/vme.c +0 -1
@@ -62,7 +62,6 @@ static struct vme_bridge *find_bridge(struct vme_resource *resource) return list_entry(resource->entry, struct vme_lm_resource, list)->parent;default : -printk (KERN_ERR "Unknown resource type\n" );return NULL ; } }
Signature · 1 line
2.42.0
PATCH v3 4/5 staging: vme_user: Remove NULL-checks
In reply to Soumya NegiDon't check for empty bridge device & resource in vme_alloc_consistent() & vme_free_consistent() since they can not be NULL. Both the VME bridge device and the VME resource that are used in these functions are set at probe time.
--- drivers/staging/vme_user/vme.c | 36 ++-------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-)
drivers/staging/vme_user/vme.c +2 -34
@@ -80,23 +80,7 @@ static struct vme_bridge *find_bridge(struct vme_resource *resource)void *vme_alloc_consistent (struct vme_resource *resource,size_t size,dma_addr_t *dma) { -struct vme_bridge *bridge; - -if (!resource) { -printk (KERN_ERR "No resource\n" ); -return NULL ; - } - - bridge =find_bridge (resource); -if (!bridge) { -printk (KERN_ERR "Can't find bridge\n" ); -return NULL ; - } - -if (!bridge->parent) { -printk (KERN_ERR "Dev entry NULL for bridge %s\n" , bridge->name); -return NULL ; - } +struct vme_bridge *bridge =find_bridge (resource);if (!bridge->alloc_consistent) { dev_err(bridge->parent,
@@ -121,23 +105,7 @@ EXPORT_SYMBOL(vme_alloc_consistent);void vme_free_consistent (struct vme_resource *resource,size_t size,void *vaddr,dma_addr_t dma) { -struct vme_bridge *bridge; - -if (!resource) { -printk (KERN_ERR "No resource\n" ); -return ; - } - - bridge =find_bridge (resource); -if (!bridge) { -printk (KERN_ERR "Can't find bridge\n" ); -return ; - } - -if (!bridge->parent) { -printk (KERN_ERR "Dev entry NULL for bridge %s\n" , bridge->name); -return ; - } +struct vme_bridge *bridge =find_bridge (resource);if (!bridge->free_consistent) { dev_err(bridge->parent,
Signature · 1 line
2.42.0
PATCH v3 5/5 staging: vme_user: Use dev_err() in vme_check_window()
In reply to Soumya Negivme_check_window() uses printk() for logging error message. This leads to the following checkpatch warning:
WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then
dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
Use dev_err() instead. Pass VME bridge device to vme_check_window() so that the error message can be logged with the bridge device context.
--- drivers/staging/vme_user/vme.c | 10 +++++----- drivers/staging/vme_user/vme.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/vme_user/vme.c +5 -5
@@ -160,8 +160,8 @@ size_t vme_get_size(struct vme_resource *resource) }EXPORT_SYMBOL (vme_get_size); -int vme_check_window (u32 aspace,unsigned long long vme_base, -unsigned long long size) +int vme_check_window (struct vme_bridge *bridge,u32 aspace, +unsigned long long vme_base,unsigned long long size) {int retval =0 ;
@@ -195,7 +195,7 @@ int vme_check_window(u32 aspace, unsigned long long vme_base,/* User Defined */ break ;default : -printk (KERN_ERR "Invalid address space\n" ); +dev_err (bridge->parent,"Invalid address space\n" ); retval = -EINVAL ;break ; }
@@ -350,7 +350,7 @@ int vme_slave_set(struct vme_resource *resource, int enabled,return -EINVAL ; } - retval =vme_check_window (aspace, vme_base, size); + retval =vme_check_window (bridge, aspace, vme_base, size);if (retval)return retval;
@@ -552,7 +552,7 @@ int vme_master_set(struct vme_resource *resource, int enabled,return -EINVAL ; } - retval =vme_check_window (aspace, vme_base, size); + retval =vme_check_window (bridge, aspace, vme_base, size);if (retval)return retval;
drivers/staging/vme_user/vme.h +2 -2
@@ -133,8 +133,8 @@ void vme_free_consistent(struct vme_resource *, size_t, void *, dma_addr_t);size_t vme_get_size (struct vme_resource *); -int vme_check_window (u32 aspace,unsigned long long vme_base, -unsigned long long size); +int vme_check_window (struct vme_bridge *bridge,u32 aspace, +unsigned long long vme_base,unsigned long long size);struct vme_resource *vme_slave_request (struct vme_dev *,u32 ,u32 ); int vme_slave_set(struct vme_resource *, int, unsigned long long,
Signature · 1 line
2.42.0
kernel test robot
build botRe: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*()
In reply to Soumya Negikernel test robot noticed the following build warnings:
Hi Soumya,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Soumya-Negi/staging-vme_user-Replace-printk-with-dev_/20231020-095619 base: staging/staging-testing patch link: https://lore.kernel.org/r/a36a0b839f9c21efe1f2df6f9272ae882fd04fb8.1697763267.git.soumya.negi97%40gmail.com patch subject: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*() reproduce: (https://download.01.org/0day-ci/archive/20231020/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
# many are suggestions rather than must-fix
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_slave_get', this function's name, in a string #118: FILE: drivers/staging/vme_user/vme.c:425:
+ dev_err(bridge->parent, "vme_slave_get not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_master_set', this function's name, in a string #191: FILE: drivers/staging/vme_user/vme.c:577:
+ dev_warn(bridge->parent, "vme_master_set not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_lm_set', this function's name, in a string #583: FILE: drivers/staging/vme_user/vme.c:1577:
+ dev_err(bridge->parent, "vme_lm_set not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_lm_get', this function's name, in a string #600: FILE: drivers/staging/vme_user/vme.c:1613:
+ dev_err(bridge->parent, "vme_lm_get not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_lm_attach', this function's name, in a string #617: FILE: drivers/staging/vme_user/vme.c:1650:
+ dev_err(bridge->parent, "vme_lm_attach not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_lm_detach', this function's name, in a string #634: FILE: drivers/staging/vme_user/vme.c:1683:
+ dev_err(bridge->parent, "vme_lm_detach not supported\n");
WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'vme_slot_num', this function's name, in a string #662: FILE: drivers/staging/vme_user/vme.c:1751:
+ dev_warn(bridge->parent, "vme_slot_num not supported\n");
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*()
Quoted 50 lines · kernel test robot
Hi Soumya,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Soumya-Negi/staging-vme_user-Replace-printk-with-dev_/20231020-095619 base: staging/staging-testing patch link: https://lore.kernel.org/r/a36a0b839f9c21efe1f2df6f9272ae882fd04fb8.1697763267.git.soumya.negi97%40gmail.com patch subject: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*() reproduce: (https://download.01.org/0day-ci/archive/20231020/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/# many are suggestions rather than must-fixWARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slave_get', this function's name, in a string #118: FILE:drivers/staging/vme_user/vme.c:425:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_slave_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_master_set', this function's name, in a string #191: FILE:drivers/staging/vme_user/vme.c:577:drivers/staging/vme_user/vme.c +1
-0+dev_warn (bridge->parent,"vme_master_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_set', this function's name, in a string #583: FILE:drivers/staging/vme_user/vme.c:1577:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_get', this function's name, in a string #600: FILE:drivers/staging/vme_user/vme.c:1613:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_attach', this function's name, in a string #617: FILE:drivers/staging/vme_user/vme.c:1650:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_attach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_detach', this function's name, in a string #634: FILE:drivers/staging/vme_user/vme.c:1683:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_detach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slot_num', this function's name, in a string #662: FILE:drivers/staging/vme_user/vme.c:1751:drivers/staging/vme_user/vme.c +1
-0+dev_warn (bridge->parent,"vme_slot_num not supported\n" );Signature · 3 lines
-- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi,
There are changes being made in stages. This patch is replacing printk() to dev_err() while keeping the message string unchanged. The function names embedded are removed from the message strings by using __func__ in the next patch of this patchset:
"[PATCH v3 2/5] staging: vme_user: Use __func__ instead of function name"
And the warnings go away.
Should the tags suggested by this bot be added to [PATCH v3 2/5] in this case?
Thanks,
Soumya
Re: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*()
Quoted 59 lines · Soumya Negi
Quoted 48 lines · kernel test robot
Hi Soumya,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Soumya-Negi/staging-vme_user-Replace-printk-with-dev_/20231020-095619 base: staging/staging-testing patch link: https://lore.kernel.org/r/a36a0b839f9c21efe1f2df6f9272ae882fd04fb8.1697763267.git.soumya.negi97%40gmail.com patch subject: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*() reproduce: (https://download.01.org/0day-ci/archive/20231020/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/# many are suggestions rather than must-fixWARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slave_get', this function's name, in a string #118: FILE:drivers/staging/vme_user/vme.c:425:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_slave_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_master_set', this function's name, in a string #191: FILE:drivers/staging/vme_user/vme.c:577:drivers/staging/vme_user/vme.c +1
-0+dev_warn (bridge->parent,"vme_master_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_set', this function's name, in a string #583: FILE:drivers/staging/vme_user/vme.c:1577:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_get', this function's name, in a string #600: FILE:drivers/staging/vme_user/vme.c:1613:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_attach', this function's name, in a string #617: FILE:drivers/staging/vme_user/vme.c:1650:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_attach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_detach', this function's name, in a string #634: FILE:drivers/staging/vme_user/vme.c:1683:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_detach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slot_num', this function's name, in a string #662: FILE:drivers/staging/vme_user/vme.c:1751:drivers/staging/vme_user/vme.c +1
-1+dev_warn (bridge->parent,"vme_slot_num not supported\n" ); --Quoted 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wikiHi,
There are changes being made in stages. This patch is replacing
printk()todev_err()while keeping the message string unchanged. The function names embedded are removed from the message strings by using__func__in the next patch of this patchset:
Quoted 6 lines
"[PATCH v3 2/5] staging:
vme_user: Use__func__instead of function name"And the warnings go away.
Should the tags suggested by this bot be added to [PATCH v3 2/5] in this case?
I think you can just ignore the bot completely in this case, because you already made the changes.
julia
Greg Kroah-Hartman
maintainerRe: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*()
Quoted 65 lines · Julia Lawall
Quoted 61 lines · Soumya Negi
Quoted 48 lines · kernel test robot
Hi Soumya,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Soumya-Negi/staging-vme_user-Replace-printk-with-dev_/20231020-095619 base: staging/staging-testing patch link: https://lore.kernel.org/r/a36a0b839f9c21efe1f2df6f9272ae882fd04fb8.1697763267.git.soumya.negi97%40gmail.com patch subject: [PATCH v3 1/5] staging: vme_user: Replace printk() with dev_*() reproduce: (https://download.01.org/0day-ci/archive/20231020/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/# many are suggestions rather than must-fixWARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slave_get', this function's name, in a string #118: FILE:drivers/staging/vme_user/vme.c:425:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_slave_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_master_set', this function's name, in a string #191: FILE:drivers/staging/vme_user/vme.c:577:drivers/staging/vme_user/vme.c +1
-0+dev_warn (bridge->parent,"vme_master_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_set', this function's name, in a string #583: FILE:drivers/staging/vme_user/vme.c:1577:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_set not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_get', this function's name, in a string #600: FILE:drivers/staging/vme_user/vme.c:1613:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_get not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_attach', this function's name, in a string #617: FILE:drivers/staging/vme_user/vme.c:1650:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_attach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_lm_detach', this function's name, in a string #634: FILE:drivers/staging/vme_user/vme.c:1683:drivers/staging/vme_user/vme.c +1
-0+dev_err (bridge->parent,"vme_lm_detach not supported\n" );WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...",
__func__' to using 'vme_slot_num', this function's name, in a string #662: FILE:drivers/staging/vme_user/vme.c:1751:drivers/staging/vme_user/vme.c +1
-1+dev_warn (bridge->parent,"vme_slot_num not supported\n" ); --Quoted 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wikiHi,
There are changes being made in stages. This patch is replacing
printk()todev_err()while keeping the message string unchanged. The function names embedded are removed from the message strings by using__func__in the next patch of this patchset:"[PATCH v3 2/5] staging:
vme_user: Use__func__instead of function name"
Quoted 7 lines
Quoted 4 lines
And the warnings go away.
Should the tags suggested by this bot be added to [PATCH v3 2/5] in this case?
I think you can just ignore the bot completely in this case, because you already made the changes.
Agreed, this is safe to ignore, thanks.
greg k-h