Re: [Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
On 2015/3/6 20:50, Joe Perches wrote: On Fri, 2015-03-06 at 17:33 +0800, Chentao (Boby) wrote: #ifdef pr_fmt #undef pr_fmt #endif #define pr_fmt(fmt) xen-pvscsi: fmt No, just use add #define pr_fmt(fmt) xen-pvscsi: fmt before the first #include. The #ifdef/#undef/#endif isn't necessary. Then replace all DPRINTK with pr_debug. Yes on this one. Thanks very much, Joe. . ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
On 2015/3/5 0:32, Joe Perches wrote: On Wed, 2015-03-04 at 18:32 +, Tao Chen wrote: Defined the string of {xen-pvscsi: } as DRV_PFX, then use it in the pr sentences and DPRINTK. Also fixed up some comments just as eliminate redundant white spaces and format the code. These will make the code easier to read. It'd probaby be better just to use pr_fmt before any include and remove all the DRV_PRV uses #define pr_fmt(fmt) xen-pvscsi: fmt diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c [] @@ -69,8 +69,10 @@ #include xen/interface/grant_table.h #include xen/interface/io/vscsiif.h +#define DRV_PFX xen-pvscsi: #define DPRINTK(_f, _a...)\ - pr_debug((file=%s, line=%d) _f, __FILE__ , __LINE__ , ## _a) + pr_debug(DRV_PFX (file=%s, line=%d) _f,\ + __FILE__ , __LINE__ , ## _a) I'd also remove DPRINTK and just use pr_debug directly as dynamic_debug can emit file and line as desired. Joe, your suggested code is like below #ifdef pr_fmt #undef pr_fmt #endif #define pr_fmt(fmt) xen-pvscsi: fmt Then replace all DPRINTK with pr_debug. Am I right? @@ -84,7 +86,7 @@ struct ids_tuple { struct v2p_entry { struct ids_tuple v; /* translate from */ - struct scsiback_tpg *tpg; /* translate to */ + struct scsiback_tpg *tpg; /* translate to */ superfluous change. . I'm sorry, I made a mistake here. I will modify it in my next patch. Thanks, Joe. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
On 2015/3/4 18:34, David Vrabel wrote: On 04/03/15 18:32, Tao Chen wrote: Defined the string of {xen-pvscsi: } as DRV_PFX, then use it in the pr sentences and DPRINTK. Also fixed up some comments just as eliminate redundant white spaces and format the code. These will make the code easier to read. I have already said you needed to use: #define pr_fmt(fmt) to do this. David . David, I'm sorry because I didn't read your reply in time. I will accept your advice in my next patch. Many thanks to you. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
On Wed, 2015-03-04 at 18:32 +, Tao Chen wrote: Defined the string of {xen-pvscsi: } as DRV_PFX, then use it in the pr sentences and DPRINTK. Also fixed up some comments just as eliminate redundant white spaces and format the code. These will make the code easier to read. It'd probaby be better just to use pr_fmt before any include and remove all the DRV_PRV uses #define pr_fmt(fmt) xen-pvscsi: fmt diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c [] @@ -69,8 +69,10 @@ #include xen/interface/grant_table.h #include xen/interface/io/vscsiif.h +#define DRV_PFX xen-pvscsi: #define DPRINTK(_f, _a...) \ - pr_debug((file=%s, line=%d) _f, __FILE__ , __LINE__ , ## _a) + pr_debug(DRV_PFX (file=%s, line=%d) _f, \ + __FILE__ , __LINE__ , ## _a) I'd also remove DPRINTK and just use pr_debug directly as dynamic_debug can emit file and line as desired. @@ -84,7 +86,7 @@ struct ids_tuple { struct v2p_entry { struct ids_tuple v; /* translate from */ - struct scsiback_tpg *tpg; /* translate to */ + struct scsiback_tpg *tpg; /* translate to */ superfluous change. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
On 04/03/15 18:32, Tao Chen wrote: Defined the string of {xen-pvscsi: } as DRV_PFX, then use it in the pr sentences and DPRINTK. Also fixed up some comments just as eliminate redundant white spaces and format the code. These will make the code easier to read. I have already said you needed to use: #define pr_fmt(fmt) to do this. David ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
[Xen-devel] [PATCH v2] xen-scsiback: use DRV_PFX in the pr macros and DPRINTK
Defined the string of {xen-pvscsi: } as DRV_PFX, then use it in the pr sentences and DPRINTK. Also fixed up some comments just as eliminate redundant white spaces and format the code. These will make the code easier to read. Signed-off-by: Tao Chen boby.c...@huawei.com --- drivers/xen/xen-scsiback.c | 70 -- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 9faca6a..7cc18e9 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -69,8 +69,10 @@ #include xen/interface/grant_table.h #include xen/interface/io/vscsiif.h +#define DRV_PFX xen-pvscsi: #define DPRINTK(_f, _a...) \ - pr_debug((file=%s, line=%d) _f, __FILE__ , __LINE__ , ## _a) + pr_debug(DRV_PFX (file=%s, line=%d) _f, \ + __FILE__ , __LINE__ , ## _a) #define VSCSI_VERSION v0.1 #define VSCSI_NAMELEN 32 @@ -84,7 +86,7 @@ struct ids_tuple { struct v2p_entry { struct ids_tuple v; /* translate from */ - struct scsiback_tpg *tpg; /* translate to */ + struct scsiback_tpg *tpg; /* translate to */ unsigned int lun; struct kref kref; struct list_head l; @@ -271,7 +273,7 @@ static void scsiback_print_status(char *sense_buffer, int errors, { struct scsiback_tpg *tpg = pending_req-v2p-tpg; - pr_err(xen-pvscsi[%s:%d] cmnd[0]=%02x - st=%02x msg=%02x host=%02x drv=%02x\n, + pr_err(DRV_PFX [%s:%d] cmnd[0]=%02x - st=%02x msg=%02x host=%02x drv=%02x\n, tpg-tport-tport_name, pending_req-v2p-lun, pending_req-cmnd[0], status_byte(errors), msg_byte(errors), host_byte(errors), driver_byte(errors)); @@ -427,7 +429,7 @@ static int scsiback_gnttab_data_map_batch(struct gnttab_map_grant_ref *map, BUG_ON(err); for (i = 0; i cnt; i++) { if (unlikely(map[i].status != GNTST_okay)) { - pr_err(xen-pvscsi: invalid buffer -- could not remap it\n); + pr_err(DRV_PFX invalid buffer -- could not remap it\n); map[i].handle = SCSIBACK_INVALID_HANDLE; err = -ENOMEM; } else { @@ -449,7 +451,7 @@ static int scsiback_gnttab_data_map_list(struct vscsibk_pend *pending_req, for (i = 0; i cnt; i++) { if (get_free_page(pg + mapcount)) { put_free_pages(pg, mapcount); - pr_err(xen-pvscsi: no grant page\n); + pr_err(DRV_PFX no grant page\n); return -ENOMEM; } gnttab_set_map_op(map[mapcount], vaddr_page(pg[mapcount]), @@ -492,7 +494,7 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req, return 0; if (nr_segments VSCSIIF_SG_TABLESIZE) { - DPRINTK(xen-pvscsi: invalid parameter nr_seg = %d\n, + DPRINTK(invalid parameter nr_seg = %d\n, ring_req-nr_segments); return -EINVAL; } @@ -516,13 +518,13 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req, nr_segments += n_segs; } if (nr_segments SG_ALL) { - DPRINTK(xen-pvscsi: invalid nr_seg = %d\n, + DPRINTK(invalid nr_seg = %d\n, nr_segments); return -EINVAL; } } - /* free of (sgl) in fast_flush_area()*/ + /* free of (sgl) in fast_flush_area() */ pending_req-sgl = kmalloc_array(nr_segments, sizeof(struct scatterlist), GFP_KERNEL); if (!pending_req-sgl) @@ -679,7 +681,7 @@ static int prepare_pending_reqs(struct vscsibk_info *info, v2p = scsiback_do_translation(info, vir); if (!v2p) { pending_req-v2p = NULL; - DPRINTK(xen-pvscsi: doesn't exist.\n); + DPRINTK(doesn't exist.\n); return -ENODEV; } pending_req-v2p = v2p; @@ -690,14 +692,14 @@ static int prepare_pending_reqs(struct vscsibk_info *info, (pending_req-sc_data_direction != DMA_TO_DEVICE) (pending_req-sc_data_direction != DMA_FROM_DEVICE) (pending_req-sc_data_direction != DMA_NONE)) { - DPRINTK(xen-pvscsi: invalid parameter data_dir = %d\n, + DPRINTK(invalid parameter data_dir = %d\n, pending_req-sc_data_direction); return -EINVAL; } pending_req-cmd_len = ring_req-cmd_len; if (pending_req-cmd_len VSCSIIF_MAX_COMMAND_SIZE) { - DPRINTK(xen-pvscsi: invalid parameter cmd_len = %d\n, + DPRINTK(invalid parameter cmd_len =