Rename spar_check_channel_server() to spar_check_channel_server(), remove unused parameters fileName, lineNumber, and logCtx, update references to the function and remove unused parameters in macros that call it, and fix CamelCase names: typeGuid => typeuuid channelName => name expectedMinBytes => expected_min_bytes actualBytes => actual_bytes Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx> --- .../unisys/common-spar/include/channels/channel.h | 20 ++++++++++++++++++++ .../common-spar/include/channels/controlvmchannel.h | 5 +++++ .../common-spar/include/channels/diagchannel.h | 10 +++++----- .../unisys/common-spar/include/channels/iochannel.h | 11 ++++++++++- .../common-spar/include/channels/vbuschannel.h | 6 ++++++ 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 865d9a4..6fb6e5b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -348,6 +348,26 @@ spar_check_channel_client(void __iomem *ch, 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 spar_check_channel_server(uuid_le typeuuid, char *name, + u64 expected_min_bytes, + u64 actual_bytes) +{ + if (expected_min_bytes > 0) /* caller wants us to verify + * channel size */ + if (actual_bytes < expected_min_bytes) { + pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n", + name, &typeuuid, expected_min_bytes, + actual_bytes); + 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 diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 9a7531f..ce601ae 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -52,6 +52,11 @@ static const uuid_le UltraControlvmChannelProtocolGuid = sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraControlvmChannelProtocolGuid, \ + "controlvm", \ + sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ + actualBytes)) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 97451ba..4132642 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -65,11 +65,11 @@ static const uuid_le UltraDiagChannelProtocolGuid = sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \ - "diag", \ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ - actualBytes, __FILE__, __LINE__, logCtx)) +#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraDiagChannelProtocolGuid, \ + "diag", \ + sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ + actualBytes)) #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ #define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info * accompanying event... */ diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index f5fd542..b1f4a47 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -65,17 +65,26 @@ "vhba", MIN_IO_CHANNEL_SIZE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(spar_vhba_channel_protocol_uuid, \ + "vhba", MIN_IO_CHANNEL_SIZE, actualBytes)) #define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(spar_vnic_channel_protocol_uuid, \ + "vnic", MIN_IO_CHANNEL_SIZE, actualBytes)) #define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ "vswitch", MIN_IO_CHANNEL_SIZE, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE)) - +#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraVswitchChannelProtocolGuid, \ + "vswitch", MIN_IO_CHANNEL_SIZE, \ + actualBytes)) /* * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 7b32aa9..9329e28 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -51,6 +51,12 @@ static const uuid_le UltraVbusChannelProtocolGuid = ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ +#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraVbusChannelProtocolGuid, \ + "vbus", \ + sizeof(struct ultra_vbus_channel_protocol),\ + actualBytes)) + #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ typedef struct _ULTRA_VBUS_HEADERINFO { u32 structBytes; /* size of this struct in bytes */ -- 1.9.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel