Commit 93a84565 authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman
Browse files

staging: unisys: refactor ULTRA_check_channel_client()



Rename the function ULTRA_check_channel_client() to
spar_check_channel_client(), and fix CamelCase parameter names:

pChannel => ch
expectedTypeGuid => expected_uuid
channelName => chname
expectedMinBytes => expected_min_bytes
expectedVersionId => expected_version
expectedSignature => expected_signature

Rename macros that use spar_check_channel_client:

ULTRA_CONTROLVM_CHANNEL_OK_CLIENT => SPAR_CONTROLVM_CHANNEL_OK_CLIENT
ULTRA_VHBA_CHANNEL_OK_CLIENT => SPAR_VHBA_CHANNEL_OK_CLIENT
ULTRA_VNIC_CHANNEL_OK_CLIENT => SPAR_VNIC_CHANNEL_OK_CLIENT
ULTRA_VSWITCH_CHANNEL_OK_CLIENT => SPAR_VSWITCH_CHANNEL_OK_CLIENT
ULTRA_VBUS_CHANNEL_OK_CLIENT => SPAR_VBUS_CHANNEL_OK_CLIENT

Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 153cf710
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -43,17 +43,16 @@
 * Return value:
 * 1 if the insertion succeeds, 0 if the queue was full.
 */
unsigned char
visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
		    void *pSignal)
unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
				 void *sig)
{
	void __iomem *psignal;
	unsigned int head, tail, nof;

	struct signal_queue_header __iomem *pqhdr =
	    (struct signal_queue_header __iomem *)
		((char __iomem *) pChannel + readq(&pChannel->ch_space_offset))
		+ Queue;
		((char __iomem *) ch + readq(&ch->ch_space_offset))
		+ queue;

	/* capture current head and tail */
	head = readl(&pqhdr->head);
@@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
	 */
	psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
		(head * readl(&pqhdr->signal_size));
	memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size));
	memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));

	mb(); /* channel synch */
	writel(head, &pqhdr->head);
@@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
	writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
	return 1;
}
EXPORT_SYMBOL_GPL(visor_signal_insert);
EXPORT_SYMBOL_GPL(spar_signal_insert);

/*
 * Routine Description:
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue,
	unsigned long flags;

	spin_lock_irqsave(lock, flags);
	result = visor_signal_insert(pChannel, Queue, pSignal);
	result = spar_signal_insert(pChannel, Queue, pSignal);
	spin_unlock_irqrestore(lock, flags);
	return result;
}
+29 −53
Original line number Diff line number Diff line
@@ -289,89 +289,65 @@ struct signal_queue_header {
 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
 */
static inline int
ULTRA_check_channel_client(void __iomem *pChannel,
			   uuid_le expectedTypeGuid,
			   char *channelName,
			   u64 expectedMinBytes,
			   u32 expectedVersionId,
			   u64 expectedSignature,
			   char *fileName, int lineNumber, void *logCtx)
spar_check_channel_client(void __iomem *ch,
			  uuid_le expected_uuid,
			  char *chname,
			  u64 expected_min_bytes,
			  u32 expected_version,
			  u64 expected_signature)
{
	if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) {
	if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
		uuid_le guid;

		memcpy_fromio(&guid,
			&((struct channel_header __iomem *)(pChannel))->chtype,
			      &((struct channel_header __iomem *)(ch))->chtype,
			      sizeof(guid));
		/* caller wants us to verify type GUID */
		if (uuid_le_cmp(guid, expectedTypeGuid) != 0) {
		if (uuid_le_cmp(guid, expected_uuid) != 0) {
			pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
			       channelName, &expectedTypeGuid,
			       &expectedTypeGuid, &guid);
			       chname, &expected_uuid,
			       &expected_uuid, &guid);
			return 0;
		}
	}
	if (expectedMinBytes > 0) {	/* caller wants us to verify
	if (expected_min_bytes > 0) {	/* caller wants us to verify
					 * channel size */
		unsigned long long bytes =
				readq(&((struct channel_header __iomem *)
					(pChannel))->size);
		if (bytes < expectedMinBytes) {
					(ch))->size);
		if (bytes < expected_min_bytes) {
			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
			       channelName, &expectedTypeGuid,
			       (unsigned long long)expectedMinBytes, bytes);
			       chname, &expected_uuid,
			       (unsigned long long)expected_min_bytes, bytes);
			return 0;
		}
	}
	if (expectedVersionId > 0) {	/* caller wants us to verify
	if (expected_version > 0) {	/* caller wants us to verify
					 * channel version */
		unsigned long ver = readl(&((struct channel_header __iomem *)
				    (pChannel))->version_id);
		if (ver != expectedVersionId) {
				    (ch))->version_id);
		if (ver != expected_version) {
			pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
			       channelName, &expectedTypeGuid,
			       (unsigned long)expectedVersionId, ver);
			       chname, &expected_uuid,
			       (unsigned long)expected_version, ver);
			return 0;
		}
	}
	if (expectedSignature > 0) {	/* caller wants us to verify
	if (expected_signature > 0) {	/* caller wants us to verify
					 * channel signature */
		unsigned long long sig =
				readq(&((struct channel_header __iomem *)
					(pChannel))->signature);
		if (sig != expectedSignature) {
					(ch))->signature);
		if (sig != expected_signature) {
			pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
			       channelName, &expectedTypeGuid,
			       expectedSignature, sig);
			       chname, &expected_uuid,
			       expected_signature, sig);
			return 0;
		}
	}
	return 1;
}

/* Generic function useful for validating any type of channel when it is about
 * to be initialized by the server of the channel.
 * Note that <logCtx> is only needed for callers in the EFI environment, and
 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
 */
static inline int
ULTRA_check_channel_server(uuid_le typeGuid,
			   char *channelName,
			   u64 expectedMinBytes,
			   u64 actualBytes,
			   char *fileName, int lineNumber, void *logCtx)
{
	if (expectedMinBytes > 0)	/* caller wants us to verify
					 * channel size */
		if (actualBytes < expectedMinBytes) {
			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
			       channelName, &typeGuid, expectedMinBytes,
			       actualBytes);
			return 0;
		}
	return 1;
}

/* Given a file pathname <s> (with '/' or '\' separating directory nodes),
 * returns a pointer to the beginning of a node within that pathname such
 * that the number of nodes from that pointer to the end of the string is
@@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id)
* full.
*/

unsigned char visor_signal_insert(struct channel_header __iomem *pChannel,
				  u32 Queue, void *pSignal);
unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
				 void *sig);

/*
* Routine Description:
+7 −13
Original line number Diff line number Diff line
@@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
* channel struct withOUT needing to increment this. */
#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1

#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx)           \
	(ULTRA_check_channel_client(pChannel, \
#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel)           \
	(spar_check_channel_client(pChannel, \
				   UltraControlvmChannelProtocolGuid, \
				   "controlvm", \
				   sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
				   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE, \
		__FILE__, __LINE__, logCtx))
#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes, logCtx)        \
	(ULTRA_check_channel_server(UltraControlvmChannelProtocolGuid,	\
				    "controlvm",			\
				    sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
				    actualBytes, __FILE__, __LINE__, logCtx))
				   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))

#define MY_DEVICE_INDEX 0
#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
+2 −3
Original line number Diff line number Diff line
@@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid =
#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2

#define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx)			\
	(ULTRA_check_channel_client(pChannel,				\
	(spar_check_channel_client(pChannel,				\
				    UltraDiagChannelProtocolGuid,	\
				    "diag",				\
				    sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
				    ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
				    ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \
				    __FILE__, __LINE__, logCtx))
				    ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx)		\
	(ULTRA_check_channel_server(UltraDiagChannelProtocolGuid,	\
				    "diag",				\
Loading