Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9136d04f authored by Alexander Curtin's avatar Alexander Curtin Committed by Greg Kroah-Hartman
Browse files

staging: unisys: visorhba: replace functionlike macro with function



The `set_no_disk_inquiry_request` function now uses the correct min
macro. Also I removed an unnecessary conditional.

Get rid of u8 casts, u32 len, and u32 lun (which is actually defined
as a u64 in the scsidev->lun field from whence it originated).

Signed-off-by: default avatarAlexander Curtin <alexander.curtin@unisys.com>
Signed-off-by: default avatarTim Sell <Timothy.Sell@unisys.com>
Signed-off-by: default avatarErik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bddb1531
Loading
Loading
Loading
Loading
+0 −42
Original line number Diff line number Diff line
@@ -253,48 +253,6 @@ struct uiscmdrsp_scsi {
/* SCSI device version for no disk inquiry result */
#define SCSI_SPC2_VER 4		/* indicates SCSI SPC2 (SPC3 is 5) */

/* Windows and Linux want different things for a non-existent lun. So, we'll let
 * caller pass in the peripheral qualifier and type.
 * NOTE:[4] SCSI returns (n-4); so we return length-1-4 or length-5.
 */

#define SET_NO_DISK_INQUIRY_RESULT(buf, len, lun, lun0notpresent, notpresent) \
	do {								\
		memset(buf, 0,						\
		       MINNUM(len,					\
			      (unsigned int)NO_DISK_INQUIRY_RESULT_LEN)); \
		buf[2] = (u8)SCSI_SPC2_VER;				\
		if (lun == 0) {						\
			buf[0] = (u8)lun0notpresent;			\
			buf[3] = (u8)DEV_HISUPPORT;			\
		} else							\
			buf[0] = (u8)notpresent;			\
		buf[4] = (u8)(						\
			MINNUM(len,					\
			       (unsigned int)NO_DISK_INQUIRY_RESULT_LEN) - 5);\
		if (len >= NO_DISK_INQUIRY_RESULT_LEN) {		\
			buf[8] = 'D';					\
			buf[9] = 'E';					\
			buf[10] = 'L';					\
			buf[11] = 'L';					\
			buf[16] = 'P';					\
			buf[17] = 'S';					\
			buf[18] = 'E';					\
			buf[19] = 'U';					\
			buf[20] = 'D';					\
			buf[21] = 'O';					\
			buf[22] = ' ';					\
			buf[23] = 'D';					\
			buf[24] = 'E';					\
			buf[25] = 'V';					\
			buf[26] = 'I';					\
			buf[27] = 'C';					\
			buf[28] = 'E';					\
			buf[30] = ' ';					\
			buf[31] = '.';					\
		}							\
	} while (0)

/* Struct & Defines to support sense information. */

/* The following struct is returned in sensebuf field in uiscmdrsp_scsi.  It is
+22 −4
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ static int visorhba_resume(struct visor_device *dev,

static ssize_t info_debugfs_read(struct file *file, char __user *buf,
				 size_t len, loff_t *offset);
static int set_no_disk_inquiry_result(unsigned char *buf,
				      size_t len, bool is_lun0);
static struct dentry *visorhba_debugfs_dir;
static const struct file_operations debugfs_info_fops = {
	.read = info_debugfs_read,
@@ -772,6 +774,24 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
	}
}

static int set_no_disk_inquiry_result(unsigned char *buf,
				      size_t len, bool is_lun0)
{
	if (!buf || len < NO_DISK_INQUIRY_RESULT_LEN)
		return -EINVAL;
	memset(buf, 0, NO_DISK_INQUIRY_RESULT_LEN);
	buf[2] = SCSI_SPC2_VER;
	if (is_lun0) {
		buf[0] = DEV_DISK_CAPABLE_NOT_PRESENT;
		buf[3] = DEV_HISUPPORT;
	} else {
		buf[0] = DEV_NOT_CAPABLE;
	}
	buf[4] = NO_DISK_INQUIRY_RESULT_LEN - 5;
	strncpy(buf + 8, "DELLPSEUDO DEVICE .", NO_DISK_INQUIRY_RESULT_LEN - 8);
	return 0;
}

/**
 *	do_scsi_nolinuxstat - scsi command didn't have linuxstat
 *	@cmdrsp: response from IOVM
@@ -804,10 +824,8 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
		 * a disk there so we'll present a processor
		 * there.
		 */
		SET_NO_DISK_INQUIRY_RESULT(buf, cmdrsp->scsi.bufflen,
					   scsidev->lun,
					   DEV_DISK_CAPABLE_NOT_PRESENT,
					   DEV_NOT_CAPABLE);
		set_no_disk_inquiry_result(buf, (size_t)cmdrsp->scsi.bufflen,
					   scsidev->lun == 0);

		if (scsi_sg_count(scsicmd) == 0) {
			memcpy(scsi_sglist(scsicmd), buf,