All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "Kershner, David A" <David.Kershner@unisys.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	"Romer, Benjamin M" <Benjamin.Romer@unisys.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"driverdev-devel@linuxdriverproject.org"
	<driverdev-devel@linuxdriverproject.org>,
	"Jes.Sorensen@redhat.com" <Jes.Sorensen@redhat.com>,
	*S-Par-Maintainer <SParMaintainer@unisys.com>
Subject: RE: [PATCH] staging: unisys: Add s-Par visorhba
Date: Wed, 15 Jul 2015 16:53:24 +0000	[thread overview]
Message-ID: <63123ea0c059467c9cb7bd20a6cc2247@US-EXCH13-1.na.uis.unisys.com> (raw)
In-Reply-To: <20150715121617.GE5835@mwanda>



> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Wednesday, July 15, 2015 8:16 AM
> To: Romer, Benjamin M
> Cc: gregkh@linuxfoundation.org; driverdev-devel@linuxdriverproject.org;
> Jes.Sorensen@redhat.com; *S-Par-Maintainer
> Subject: Re: [PATCH] staging: unisys: Add s-Par visorhba
> 
> Since you are redoing this anyway...
> 
> On Mon, Jul 13, 2015 at 02:38:23PM -0400, Benjamin Romer wrote:
> > +	for (vdisk = &devdata->head; vdisk->next; vdisk = vdisk->next) {
> > +		if ((scsidev->channel == vdisk->channel) &&
> > +		    (scsidev->id == vdisk->id) &&
> > +		    (scsidev->lun == vdisk->lun)) {
> > +			if (atomic_read(&vdisk->error_count) <
> > +			    VISORHBA_ERROR_COUNT)
> > +				atomic_inc(&vdisk->error_count);
> > +			else
> > +				atomic_set(&vdisk->ios_threshold,
> > +					   IOS_ERROR_THRESHOLD);
> > +		}
> > +	}
> 
> 
> We do this loop all the time, and we're hitting the 80 character
> limit.  Make it a define.
> 
> #define for_each_vdisk_match(iter, list, match)                 \
> 	for (iter = &list->head; iter->next; iter = iter->next) \
> 		if (iter->channel == match->channel &&          \
> 		    iter->id == match->id &&                    \
> 		    iter->lun == match->lun)
> 
> Btw, avoid using too many parenthesis.  It makes the code harder to read
> and it silences GCC's check for == vs = typos so it can lead to bugs.
> 
> Now the loop looks like:
> 
> 	for_each_vdisk_match(vdisk, devdata, scsidev) {
> 		if (atomic_read(&vdisk->error_count) <
> VISORHBA_ERROR_COUNT)
> 			atomic_inc(&vdisk->error_count);
> 		else
> 			atomic_set(&vdisk->ios_threshold,
> IOS_ERROR_THRESHOLD);
> 
> 	}
> 
> (Written in email client.  Caveat emptor.)

Thanks for the comments and I really like this idea. When I put it in the code, 
I get the following from checkpatch: 

ERROR: Macros with complex values should be enclosed in parentheses
#31: FILE: drivers/staging/unisys/visorhba/visorhba_main.c:157:
+#define for_each_vdisk_match(iter, list, match)                          \
+       for (iter = &list->head; iter->next; iter = iter->next) \
+               if (iter->channel == match->channel &&            \
+                   iter->id == match->id &&                      \
+                   iter->lun == match->lun)

total: 1 errors, 0 warnings, 0 checks, 275 lines checked

Your patch has style problems, please review.

Any ideas what needs to be wrapped to resolved the checkpatch error?

> 
> > +static int
> > +visorhba_queue_command_lck(struct scsi_cmnd *scsicmd,
> > +			   void (*visorhba_cmnd_done)(struct scsi_cmnd *))
> > +{
> > +	struct scsi_device *scsidev = scsicmd->device;
> > +	int insert_location;
> > +	unsigned char op;
> > +	unsigned char *cdb = scsicmd->cmnd;
> > +	struct Scsi_Host *scsihost = scsidev->host;
> > +	struct uiscmdrsp *cmdrsp;
> > +	unsigned int i;
> > +	struct visorhba_devdata *devdata =
> > +		(struct visorhba_devdata *)scsihost->hostdata;
> > +	struct scatterlist *sg = NULL;
> > +	struct scatterlist *sglist = NULL;
> > +	int err = 0;
> > +
> > +	if (devdata->serverdown || devdata->serverchangingstate)
> > +		return SCSI_MLQUEUE_DEVICE_BUSY;
> > +
> > +	cmdrsp = kzalloc(sizeof(*cmdrsp), GFP_ATOMIC);
> > +	if (!cmdrsp)
> > +		return -ENOMEM;
> > +
> > +	/* now saving everything we need from scsi_cmd into cmdrsp
> > +	 * before we queue cmdrsp set type to command - as opposed to
> > +	 * task mgmt
> > +	 */
> > +	cmdrsp->cmdtype = CMD_SCSI_TYPE;
> > +	/* save the pending insertion location. Deletion from pending
> > +	 * will return the scsicmd pointer for completion
> > +	 */
> > +	insert_location =
> > +		add_scsipending_entry(devdata, CMD_SCSI_TYPE, (void
> *)scsicmd);
> > +	if (insert_location != -1) {
> > +		cmdrsp->scsi.scsicmd = (void *)(uintptr_t)insert_location;
> > +	} else {
> > +		kfree(cmdrsp);
> 
> This kfree in the middle of the function is weird.
> 
> > +		return SCSI_MLQUEUE_DEVICE_BUSY;
> > +	}
> 
> The Spar driver tends to have one error label on the end of each
> function and it has had very buggy error handling...  I wrote a google
> plus post on how to do error handling.
> 
> https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
> 
> Instead of trying to match the existing buggy style, just adopt normal
> kernel style.
> 
> regards,
> dan carpenter

  reply	other threads:[~2015-07-15 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13 18:38 [PATCH] staging: unisys: Add s-Par visorhba Benjamin Romer
2015-07-15  1:50 ` Greg KH
2015-07-15 12:16 ` Dan Carpenter
2015-07-15 16:53   ` Kershner, David A [this message]
2015-07-15 18:34     ` Dan Carpenter
2015-07-15 19:48     ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63123ea0c059467c9cb7bd20a6cc2247@US-EXCH13-1.na.uis.unisys.com \
    --to=david.kershner@unisys.com \
    --cc=Benjamin.Romer@unisys.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=SParMaintainer@unisys.com \
    --cc=dan.carpenter@oracle.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.