From: "Jan Beulich" Subject: [PATCH] linux-2.6.18/scsifront: consolidate printing Date: Fri, 23 Nov 2012 10:46:08 +0000 Message-ID: <50AF620002000078000AACF9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2415D6E0.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part2415D6E0.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Use shost_printk() or dev_err() instead of plain printk(). Signed-off-by: Jan Beulich --- a/drivers/xen/scsifront/scsifront.c +++ b/drivers/xen/scsifront/scsifront.c @@ -30,6 +30,8 @@ =20 #include "common.h" =20 +#define PREFIX(lvl) KERN_##lvl "scsifront: " + static int get_id_from_freelist(struct vscsifrnt_info *info) { unsigned long flags; @@ -108,26 +110,22 @@ irqreturn_t scsifront_intr(int irq, void } =20 =20 -static void scsifront_gnttab_done(struct vscsifrnt_shadow *s, uint32_t = id) +static void scsifront_gnttab_done(struct vscsifrnt_info *info, uint32_t = id) { + struct vscsifrnt_shadow *s =3D &info->shadow[id]; int i; =20 if (s->sc->sc_data_direction =3D=3D DMA_NONE) return; =20 - if (s->nr_segments) { - for (i =3D 0; i < s->nr_segments; i++) { - if (unlikely(gnttab_query_foreign_access( - s->gref[i]) !=3D 0)) { - printk(KERN_ALERT "scsifront: " - "grant still in use by backend.\n")= ; - BUG(); - } - gnttab_end_foreign_access(s->gref[i], 0UL); + for (i =3D 0; i < s->nr_segments; i++) { + if (unlikely(gnttab_query_foreign_access(s->gref[i]) !=3D = 0)) { + shost_printk(PREFIX(ALERT), info->host, + "grant still in use by backend\n"); + BUG(); } + gnttab_end_foreign_access(s->gref[i], 0UL); } - - return; } =20 =20 @@ -144,7 +142,7 @@ static void scsifront_cdb_cmd_done(struc if (sc =3D=3D NULL) BUG(); =20 - scsifront_gnttab_done(&info->shadow[id], id); + scsifront_gnttab_done(info, id); add_id_to_freelist(info, id); =20 sc->result =3D ring_res->rslt; @@ -180,7 +178,7 @@ static void scsifront_sync_cmd_done(stru _add_id_to_freelist(info, id); break; default: - shost_printk(KERN_ERR "scsifront: ", info->host, + shost_printk(PREFIX(ERR), info->host, "bad reset state %d, possibly leaking %u\n", info->shadow[id].rslt_reset, id); break; @@ -272,7 +270,8 @@ static int map_data_for_request(struct v =20 err =3D gnttab_alloc_grant_references(VSCSIIF_SG_TABLESIZE, = &gref_head); if (err) { - printk(KERN_ERR "scsifront: gnttab_alloc_grant_references()= error\n"); + shost_printk(PREFIX(ERR), info->host, + "gnttab_alloc_grant_references() error\n"); return -ENOMEM; } =20 @@ -282,7 +281,8 @@ static int map_data_for_request(struct v nr_pages =3D (sc->request_bufflen + sg[0].offset + = PAGE_SIZE - 1) >> PAGE_SHIFT; =20 if (nr_pages > VSCSIIF_SG_TABLESIZE) { - printk(KERN_ERR "scsifront: Unable to map = request_buffer for command!\n"); + shost_printk(PREFIX(ERR), info->host, + "Unable to map request_buffer for = command!\n"); ref_cnt =3D (-E2BIG); goto big_to_sg; } @@ -369,9 +369,11 @@ static int scsifront_queuecommand(struct uint16_t rqid; =20 /* debug printk to identify more missing scsi commands - printk(KERN_INFO "scsicmd: len=3D%i, 0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,= 0x%x,0x%x,0x%x,0x%x",sc->cmd_len, - sc->cmnd[0],sc->cmnd[1],sc->cmnd[2],sc->cmnd[3],sc->cmnd[4]= , - sc->cmnd[5],sc->cmnd[6],sc->cmnd[7],sc->cmnd[8],sc->cmnd[9]= ); + shost_printk(KERN_INFO "scsicmd: ", sc->device->host, + "len=3D%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x\n", + sc->cmd_len, sc->cmnd[0], sc->cmnd[1], + sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5], + sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]); */ if (RING_FULL(&info->ring)) { goto out_host_busy; --- a/drivers/xen/scsifront/xenbus.c +++ b/drivers/xen/scsifront/xenbus.c @@ -214,7 +214,7 @@ static int scsifront_probe(struct xenbus if (IS_ERR(info->kthread)) { err =3D PTR_ERR(info->kthread); info->kthread =3D NULL; - printk(KERN_ERR "scsifront: kthread start err %d\n", err); + dev_err(&dev->dev, "kthread start err %d\n", err); goto free_sring; } =20 @@ -226,7 +226,7 @@ static int scsifront_probe(struct xenbus =20 err =3D scsi_add_host(host, &dev->dev); if (err) { - printk(KERN_ERR "scsifront: fail to add scsi host %d\n", = err); + dev_err(&dev->dev, "fail to add scsi host %d\n", err); goto free_sring; } =20 @@ -317,7 +317,7 @@ static void scsifront_do_lun_hotplug(str if (device_state =3D=3D XenbusStateInitialised) { sdev =3D scsi_device_lookup(info->host, = chn, tgt, lun); if (sdev) { - printk(KERN_ERR "scsifront: Device = already in use.\n"); + dev_err(&dev->dev, "Device already = in use.\n"); scsi_device_put(sdev); xenbus_printf(XBT_NIL, dev->nodenam= e, state_str, "%d", XenbusStat= eClosed); --=__Part2415D6E0.0__= Content-Type: text/plain; name="xen-scsifront-printing.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-scsifront-printing.patch" scsifront: consolidate printing=0A=0AUse shost_printk() or dev_err() = instead of plain printk().=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/drivers/xen/scsifront/scsifront.c=0A+++ b/drivers/xen/scsifr= ont/scsifront.c=0A@@ -30,6 +30,8 @@=0A =0A #include "common.h"=0A = =0A+#define PREFIX(lvl) KERN_##lvl "scsifront: "=0A+=0A static int = get_id_from_freelist(struct vscsifrnt_info *info)=0A {=0A unsigned = long flags;=0A@@ -108,26 +110,22 @@ irqreturn_t scsifront_intr(int irq, = void=0A }=0A =0A =0A-static void scsifront_gnttab_done(struct vscsifrnt_sha= dow *s, uint32_t id)=0A+static void scsifront_gnttab_done(struct vscsifrnt_= info *info, uint32_t id)=0A {=0A+ struct vscsifrnt_shadow *s =3D = &info->shadow[id];=0A int i;=0A =0A if (s->sc->sc_data_direction = =3D=3D DMA_NONE)=0A return;=0A =0A- if (s->nr_segments) {=0A- = for (i =3D 0; i < s->nr_segments; i++) {=0A- if = (unlikely(gnttab_query_foreign_access(=0A- = s->gref[i]) !=3D 0)) {=0A- printk(KERN_ALERT = "scsifront: "=0A- "grant still in = use by backend.\n");=0A- BUG();=0A- = }=0A- gnttab_end_foreign_access(s->gref[i], = 0UL);=0A+ for (i =3D 0; i < s->nr_segments; i++) {=0A+ if = (unlikely(gnttab_query_foreign_access(s->gref[i]) !=3D 0)) {=0A+ = shost_printk(PREFIX(ALERT), info->host,=0A+ = "grant still in use by backend\n");=0A+ BUG();=0A = }=0A+ gnttab_end_foreign_access(s->gref[i], 0UL);=0A = }=0A-=0A- return;=0A }=0A =0A =0A@@ -144,7 +142,7 @@ static void = scsifront_cdb_cmd_done(struc=0A if (sc =3D=3D NULL)=0A = BUG();=0A =0A- scsifront_gnttab_done(&info->shadow[id], id);=0A+ = scsifront_gnttab_done(info, id);=0A add_id_to_freelist(info, id);=0A = =0A sc->result =3D ring_res->rslt;=0A@@ -180,7 +178,7 @@ static void = scsifront_sync_cmd_done(stru=0A _add_id_to_freelist(info, = id);=0A break;=0A default:=0A- shost_print= k(KERN_ERR "scsifront: ", info->host,=0A+ shost_printk(PREFIX= (ERR), info->host,=0A "bad reset state %d, possibly = leaking %u\n",=0A info->shadow[id].rslt_reset, = id);=0A break;=0A@@ -272,7 +270,8 @@ static int map_data_fo= r_request(struct v=0A =0A err =3D gnttab_alloc_grant_references(VSCSI= IF_SG_TABLESIZE, &gref_head);=0A if (err) {=0A- printk(KERN= _ERR "scsifront: gnttab_alloc_grant_references() error\n");=0A+ = shost_printk(PREFIX(ERR), info->host,=0A+ = "gnttab_alloc_grant_references() error\n");=0A return -ENOMEM;=0A = }=0A =0A@@ -282,7 +281,8 @@ static int map_data_for_request(struct = v=0A nr_pages =3D (sc->request_bufflen + sg[0].offset + = PAGE_SIZE - 1) >> PAGE_SHIFT;=0A =0A if (nr_pages > VSCSIIF_SG_T= ABLESIZE) {=0A- printk(KERN_ERR "scsifront: Unable to map = request_buffer for command!\n");=0A+ shost_printk(PREFIX= (ERR), info->host,=0A+ "Unable to map = request_buffer for command!\n");=0A ref_cnt =3D = (-E2BIG);=0A goto big_to_sg;=0A }=0A@@ = -369,9 +369,11 @@ static int scsifront_queuecommand(struct=0A uint16_t = rqid;=0A =0A /* debug printk to identify more missing scsi commands=0A- = printk(KERN_INFO "scsicmd: len=3D%i, 0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%= x,0x%x,0x%x",sc->cmd_len,=0A- sc->cmnd[0],sc->cmnd[1],sc->cmnd[2]= ,sc->cmnd[3],sc->cmnd[4],=0A- sc->cmnd[5],sc->cmnd[6],sc->cmnd[7]= ,sc->cmnd[8],sc->cmnd[9]);=0A+ shost_printk(KERN_INFO "scsicmd: ", = sc->device->host,=0A+ "len=3D%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,= %#x,%#x,%#x\n",=0A+ sc->cmd_len, sc->cmnd[0], sc->cmnd[1],= =0A+ sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5],=0A= + sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]);= =0A */=0A if (RING_FULL(&info->ring)) {=0A goto = out_host_busy;=0A--- a/drivers/xen/scsifront/xenbus.c=0A+++ b/drivers/xen/s= csifront/xenbus.c=0A@@ -214,7 +214,7 @@ static int scsifront_probe(struct = xenbus=0A if (IS_ERR(info->kthread)) {=0A err =3D = PTR_ERR(info->kthread);=0A info->kthread =3D NULL;=0A- = printk(KERN_ERR "scsifront: kthread start err %d\n", err);=0A+ = dev_err(&dev->dev, "kthread start err %d\n", err);=0A goto = free_sring;=0A }=0A =0A@@ -226,7 +226,7 @@ static int scsifront_probe(stru= ct xenbus=0A =0A err =3D scsi_add_host(host, &dev->dev);=0A if = (err) {=0A- printk(KERN_ERR "scsifront: fail to add scsi host = %d\n", err);=0A+ dev_err(&dev->dev, "fail to add scsi host = %d\n", err);=0A goto free_sring;=0A }=0A =0A@@ -317,7 = +317,7 @@ static void scsifront_do_lun_hotplug(str=0A if = (device_state =3D=3D XenbusStateInitialised) {=0A = sdev =3D scsi_device_lookup(info->host, chn, tgt, lun);=0A = if (sdev) {=0A- printk(KERN_ERR = "scsifront: Device already in use.\n");=0A+ = dev_err(&dev->dev, "Device already in use.\n");=0A = scsi_device_put(sdev);=0A = xenbus_printf(XBT_NIL, dev->nodename,=0A = state_str, "%d", XenbusStateClosed);=0A --=__Part2415D6E0.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part2415D6E0.0__=--