Commit 246e0cd0 authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman

staging: unisys: refactor VISORCHIPSET_DEVICE_INFO

Remove the typedef and use struct visorchipset_device_info instead. Fix
CamelCase names:

busNo => bus_no
devNo => dev_no
devInstGuid => dev_inst_guid
chanInfo => chan_info
Reserved1 => reserved1
Reserved2 => reserved2
switchNo => switch_no
internalPortNo => internal_port_no
pendingMsgHdr => pending_msg_hdr
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9b1caee7
...@@ -75,30 +75,30 @@ struct visorchipset_channel_info { ...@@ -75,30 +75,30 @@ struct visorchipset_channel_info {
* visorchipset_get_client_device_info() or * visorchipset_get_client_device_info() or
* visorchipset_get_server_device_info(). * visorchipset_get_server_device_info().
*/ */
typedef struct { struct visorchipset_device_info {
struct list_head entry; struct list_head entry;
u32 busNo; u32 bus_no;
u32 devNo; u32 dev_no;
uuid_le devInstGuid; uuid_le dev_inst_uuid;
struct visorchipset_state state; struct visorchipset_state state;
struct visorchipset_channel_info chanInfo; struct visorchipset_channel_info chan_info;
u32 Reserved1; /* control_vm_id */ u32 reserved1; /* control_vm_id */
u64 Reserved2; u64 reserved2;
u32 switchNo; /* when devState.attached==1 */ u32 switch_no; /* when devState.attached==1 */
u32 internalPortNo; /* when devState.attached==1 */ u32 internal_port_no; /* when devState.attached==1 */
struct controlvm_message_header pendingMsgHdr; /* CONTROLVM_MESSAGE */ struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
/** For private use by the bus driver */ /** For private use by the bus driver */
void *bus_driver_context; void *bus_driver_context;
} VISORCHIPSET_DEVICE_INFO; };
static inline VISORCHIPSET_DEVICE_INFO * static inline struct visorchipset_device_info *
finddevice(struct list_head *list, u32 busNo, u32 devNo) finddevice(struct list_head *list, u32 busNo, u32 devNo)
{ {
VISORCHIPSET_DEVICE_INFO *p; struct visorchipset_device_info *p;
list_for_each_entry(p, list, entry) { list_for_each_entry(p, list, entry) {
if (p->busNo == busNo && p->devNo == devNo) if (p->bus_no == busNo && p->dev_no == devNo)
return p; return p;
} }
return NULL; return NULL;
...@@ -106,10 +106,10 @@ finddevice(struct list_head *list, u32 busNo, u32 devNo) ...@@ -106,10 +106,10 @@ finddevice(struct list_head *list, u32 busNo, u32 devNo)
static inline void delbusdevices(struct list_head *list, u32 busNo) static inline void delbusdevices(struct list_head *list, u32 busNo)
{ {
VISORCHIPSET_DEVICE_INFO *p, *tmp; struct visorchipset_device_info *p, *tmp;
list_for_each_entry_safe(p, tmp, list, entry) { list_for_each_entry_safe(p, tmp, list, entry) {
if (p->busNo == busNo) { if (p->bus_no == busNo) {
list_del(&p->entry); list_del(&p->entry);
kfree(p); kfree(p);
} }
...@@ -274,7 +274,7 @@ void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response); ...@@ -274,7 +274,7 @@ void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response);
BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo); BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo);
BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, BOOL visorchipset_get_device_info(ulong busNo, ulong devNo,
VISORCHIPSET_DEVICE_INFO *devInfo); struct visorchipset_device_info *devInfo);
BOOL visorchipset_get_switch_info(ulong switchNo, BOOL visorchipset_get_switch_info(ulong switchNo,
VISORCHIPSET_SWITCH_INFO *switchInfo); VISORCHIPSET_SWITCH_INFO *switchInfo);
BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo,
......
...@@ -561,10 +561,11 @@ busInfo_clear(void *v) ...@@ -561,10 +561,11 @@ busInfo_clear(void *v)
static void static void
devInfo_clear(void *v) devInfo_clear(void *v)
{ {
VISORCHIPSET_DEVICE_INFO *p = (VISORCHIPSET_DEVICE_INFO *) (v); struct visorchipset_device_info *p =
(struct visorchipset_device_info *)(v);
p->state.created = 0; p->state.created = 0;
memset(p, 0, sizeof(VISORCHIPSET_DEVICE_INFO)); memset(p, 0, sizeof(struct visorchipset_device_info));
} }
static u8 static u8
...@@ -638,7 +639,7 @@ static void ...@@ -638,7 +639,7 @@ static void
cleanup_controlvm_structures(void) cleanup_controlvm_structures(void)
{ {
VISORCHIPSET_BUS_INFO *bi, *tmp_bi; VISORCHIPSET_BUS_INFO *bi, *tmp_bi;
VISORCHIPSET_DEVICE_INFO *di, *tmp_di; struct visorchipset_device_info *di, *tmp_di;
list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) { list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) {
busInfo_clear(bi); busInfo_clear(bi);
...@@ -865,7 +866,7 @@ device_changestate_responder(enum controlvm_id cmdId, ...@@ -865,7 +866,7 @@ device_changestate_responder(enum controlvm_id cmdId,
ulong busNo, ulong devNo, int response, ulong busNo, ulong devNo, int response,
struct spar_segment_state responseState) struct spar_segment_state responseState)
{ {
VISORCHIPSET_DEVICE_INFO *p = NULL; struct visorchipset_device_info *p = NULL;
struct controlvm_message outmsg; struct controlvm_message outmsg;
p = finddevice(&DevInfoList, busNo, devNo); p = finddevice(&DevInfoList, busNo, devNo);
...@@ -873,16 +874,16 @@ device_changestate_responder(enum controlvm_id cmdId, ...@@ -873,16 +874,16 @@ device_changestate_responder(enum controlvm_id cmdId,
LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
return; return;
} }
if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { if (p->pending_msg_hdr.id == CONTROLVM_INVALID) {
LOGERR("device_responder no pending msg"); LOGERR("device_responder no pending msg");
return; /* no controlvm response needed */ return; /* no controlvm response needed */
} }
if (p->pendingMsgHdr.id != cmdId) { if (p->pending_msg_hdr.id != cmdId) {
LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id);
return; return;
} }
controlvm_init_response(&outmsg, &p->pendingMsgHdr, response); controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
outmsg.cmd.device_change_state.bus_no = busNo; outmsg.cmd.device_change_state.bus_no = busNo;
outmsg.cmd.device_change_state.dev_no = devNo; outmsg.cmd.device_change_state.dev_no = devNo;
...@@ -894,14 +895,14 @@ device_changestate_responder(enum controlvm_id cmdId, ...@@ -894,14 +895,14 @@ device_changestate_responder(enum controlvm_id cmdId,
return; return;
} }
p->pendingMsgHdr.id = CONTROLVM_INVALID; p->pending_msg_hdr.id = CONTROLVM_INVALID;
} }
static void static void
device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
int response) int response)
{ {
VISORCHIPSET_DEVICE_INFO *p = NULL; struct visorchipset_device_info *p = NULL;
BOOL need_clear = FALSE; BOOL need_clear = FALSE;
p = finddevice(&DevInfoList, busNo, devNo); p = finddevice(&DevInfoList, busNo, devNo);
...@@ -916,16 +917,16 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, ...@@ -916,16 +917,16 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
need_clear = TRUE; need_clear = TRUE;
} }
if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { if (p->pending_msg_hdr.id == CONTROLVM_INVALID) {
LOGERR("device_responder no pending msg"); LOGERR("device_responder no pending msg");
return; /* no controlvm response needed */ return; /* no controlvm response needed */
} }
if (p->pendingMsgHdr.id != (u32) cmdId) { if (p->pending_msg_hdr.id != (u32) cmdId) {
LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id);
return; return;
} }
controlvm_respond(&p->pendingMsgHdr, response); controlvm_respond(&p->pending_msg_hdr, response);
p->pendingMsgHdr.id = CONTROLVM_INVALID; p->pending_msg_hdr.id = CONTROLVM_INVALID;
if (need_clear) if (need_clear)
devInfo_clear(p); devInfo_clear(p);
} }
...@@ -1005,7 +1006,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, ...@@ -1005,7 +1006,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL; VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL;
BOOL notified = FALSE; BOOL notified = FALSE;
VISORCHIPSET_DEVICE_INFO *pDevInfo = struct visorchipset_device_info *pDevInfo =
finddevice(&DevInfoList, busNo, devNo); finddevice(&DevInfoList, busNo, devNo);
char *envp[] = { char *envp[] = {
"SPARSP_DIAGPOOL_PAUSED_STATE = 1", "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
...@@ -1021,10 +1022,10 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, ...@@ -1021,10 +1022,10 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
else else
notifiers = &BusDev_Client_Notifiers; notifiers = &BusDev_Client_Notifiers;
if (needResponse) { if (needResponse) {
memcpy(&pDevInfo->pendingMsgHdr, msgHdr, memcpy(&pDevInfo->pending_msg_hdr, msgHdr,
sizeof(struct controlvm_message_header)); sizeof(struct controlvm_message_header));
} else } else
pDevInfo->pendingMsgHdr.id = CONTROLVM_INVALID; pDevInfo->pending_msg_hdr.id = CONTROLVM_INVALID;
down(&NotifierLock); down(&NotifierLock);
if (response >= 0) { if (response >= 0) {
...@@ -1234,7 +1235,7 @@ my_device_create(struct controlvm_message *inmsg) ...@@ -1234,7 +1235,7 @@ my_device_create(struct controlvm_message *inmsg)
struct controlvm_message_packet *cmd = &inmsg->cmd; struct controlvm_message_packet *cmd = &inmsg->cmd;
ulong busNo = cmd->create_device.bus_no; ulong busNo = cmd->create_device.bus_no;
ulong devNo = cmd->create_device.dev_no; ulong devNo = cmd->create_device.dev_no;
VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; struct visorchipset_device_info *pDevInfo = NULL;
VISORCHIPSET_BUS_INFO *pBusInfo = NULL; VISORCHIPSET_BUS_INFO *pBusInfo = NULL;
int rc = CONTROLVM_RESP_SUCCESS; int rc = CONTROLVM_RESP_SUCCESS;
...@@ -1264,7 +1265,7 @@ my_device_create(struct controlvm_message *inmsg) ...@@ -1264,7 +1265,7 @@ my_device_create(struct controlvm_message *inmsg)
rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
goto Away; goto Away;
} }
pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL); pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL);
if (pDevInfo == NULL) { if (pDevInfo == NULL) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
busNo, devNo); busNo, devNo);
...@@ -1275,27 +1276,27 @@ my_device_create(struct controlvm_message *inmsg) ...@@ -1275,27 +1276,27 @@ my_device_create(struct controlvm_message *inmsg)
} }
INIT_LIST_HEAD(&pDevInfo->entry); INIT_LIST_HEAD(&pDevInfo->entry);
pDevInfo->busNo = busNo; pDevInfo->bus_no = busNo;
pDevInfo->devNo = devNo; pDevInfo->dev_no = devNo;
pDevInfo->devInstGuid = cmd->create_device.dev_inst_uuid; pDevInfo->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo,
POSTCODE_SEVERITY_INFO); POSTCODE_SEVERITY_INFO);
if (inmsg->hdr.flags.test_message == 1) if (inmsg->hdr.flags.test_message == 1)
pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALTEST; pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST;
else else
pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALPHYSICAL; pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
pDevInfo->chanInfo.channel_addr = cmd->create_device.channel_addr; pDevInfo->chan_info.channel_addr = cmd->create_device.channel_addr;
pDevInfo->chanInfo.n_channel_bytes = cmd->create_device.channel_bytes; pDevInfo->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
pDevInfo->chanInfo.channel_type_uuid = pDevInfo->chan_info.channel_type_uuid =
cmd->create_device.data_type_uuid; cmd->create_device.data_type_uuid;
pDevInfo->chanInfo.intr = cmd->create_device.intr; pDevInfo->chan_info.intr = cmd->create_device.intr;
list_add(&pDevInfo->entry, &DevInfoList); list_add(&pDevInfo->entry, &DevInfoList);
POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo,
POSTCODE_SEVERITY_INFO); POSTCODE_SEVERITY_INFO);
Away: Away:
/* get the bus and devNo for DiagPool channel */ /* get the bus and devNo for DiagPool channel */
if (is_diagpool_channel(pDevInfo->chanInfo.channel_type_uuid)) { if (is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) {
g_diagpoolBusNo = busNo; g_diagpoolBusNo = busNo;
g_diagpoolDevNo = devNo; g_diagpoolDevNo = devNo;
LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu",
...@@ -1304,7 +1305,7 @@ my_device_create(struct controlvm_message *inmsg) ...@@ -1304,7 +1305,7 @@ my_device_create(struct controlvm_message *inmsg)
device_epilog(busNo, devNo, segment_state_running, device_epilog(busNo, devNo, segment_state_running,
CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
inmsg->hdr.flags.response_expected == 1, inmsg->hdr.flags.response_expected == 1,
FOR_VISORBUS(pDevInfo->chanInfo.channel_type_uuid)); FOR_VISORBUS(pDevInfo->chan_info.channel_type_uuid));
} }
static void static void
...@@ -1314,7 +1315,7 @@ my_device_changestate(struct controlvm_message *inmsg) ...@@ -1314,7 +1315,7 @@ my_device_changestate(struct controlvm_message *inmsg)
ulong busNo = cmd->device_change_state.bus_no; ulong busNo = cmd->device_change_state.bus_no;
ulong devNo = cmd->device_change_state.dev_no; ulong devNo = cmd->device_change_state.dev_no;
struct spar_segment_state state = cmd->device_change_state.state; struct spar_segment_state state = cmd->device_change_state.state;
VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; struct visorchipset_device_info *pDevInfo = NULL;
int rc = CONTROLVM_RESP_SUCCESS; int rc = CONTROLVM_RESP_SUCCESS;
pDevInfo = finddevice(&DevInfoList, busNo, devNo); pDevInfo = finddevice(&DevInfoList, busNo, devNo);
...@@ -1339,7 +1340,7 @@ my_device_changestate(struct controlvm_message *inmsg) ...@@ -1339,7 +1340,7 @@ my_device_changestate(struct controlvm_message *inmsg)
&inmsg->hdr, rc, &inmsg->hdr, rc,
inmsg->hdr.flags.response_expected == 1, inmsg->hdr.flags.response_expected == 1,
FOR_VISORBUS( FOR_VISORBUS(
pDevInfo->chanInfo.channel_type_uuid)); pDevInfo->chan_info.channel_type_uuid));
} }
static void static void
...@@ -1348,7 +1349,7 @@ my_device_destroy(struct controlvm_message *inmsg) ...@@ -1348,7 +1349,7 @@ my_device_destroy(struct controlvm_message *inmsg)
struct controlvm_message_packet *cmd = &inmsg->cmd; struct controlvm_message_packet *cmd = &inmsg->cmd;
ulong busNo = cmd->destroy_device.bus_no; ulong busNo = cmd->destroy_device.bus_no;
ulong devNo = cmd->destroy_device.dev_no; ulong devNo = cmd->destroy_device.dev_no;
VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; struct visorchipset_device_info *pDevInfo = NULL;
int rc = CONTROLVM_RESP_SUCCESS; int rc = CONTROLVM_RESP_SUCCESS;
pDevInfo = finddevice(&DevInfoList, busNo, devNo); pDevInfo = finddevice(&DevInfoList, busNo, devNo);
...@@ -1370,7 +1371,7 @@ my_device_destroy(struct controlvm_message *inmsg) ...@@ -1370,7 +1371,7 @@ my_device_destroy(struct controlvm_message *inmsg)
CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
inmsg->hdr.flags.response_expected == 1, inmsg->hdr.flags.response_expected == 1,
FOR_VISORBUS( FOR_VISORBUS(
pDevInfo->chanInfo.channel_type_uuid)); pDevInfo->chan_info.channel_type_uuid));
} }
/* When provided with the physical address of the controlvm channel /* When provided with the physical address of the controlvm channel
...@@ -2228,7 +2229,7 @@ EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); ...@@ -2228,7 +2229,7 @@ EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
BOOL BOOL
visorchipset_get_device_info(ulong busNo, ulong devNo, visorchipset_get_device_info(ulong busNo, ulong devNo,
VISORCHIPSET_DEVICE_INFO *devInfo) struct visorchipset_device_info *devInfo)
{ {
void *p = finddevice(&DevInfoList, busNo, devNo); void *p = finddevice(&DevInfoList, busNo, devNo);
...@@ -2236,7 +2237,7 @@ visorchipset_get_device_info(ulong busNo, ulong devNo, ...@@ -2236,7 +2237,7 @@ visorchipset_get_device_info(ulong busNo, ulong devNo,
LOGERR("(%lu,%lu) failed", busNo, devNo); LOGERR("(%lu,%lu) failed", busNo, devNo);
return FALSE; return FALSE;
} }
memcpy(devInfo, p, sizeof(VISORCHIPSET_DEVICE_INFO)); memcpy(devInfo, p, sizeof(struct visorchipset_device_info));
return TRUE; return TRUE;
} }
EXPORT_SYMBOL_GPL(visorchipset_get_device_info); EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
...@@ -2244,7 +2245,8 @@ EXPORT_SYMBOL_GPL(visorchipset_get_device_info); ...@@ -2244,7 +2245,8 @@ EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
BOOL BOOL
visorchipset_set_device_context(ulong busNo, ulong devNo, void *context) visorchipset_set_device_context(ulong busNo, ulong devNo, void *context)
{ {
VISORCHIPSET_DEVICE_INFO *p = finddevice(&DevInfoList, busNo, devNo); struct visorchipset_device_info *p =
finddevice(&DevInfoList, busNo, devNo);
if (!p) { if (!p) {
LOGERR("(%lu,%lu) failed", busNo, devNo); LOGERR("(%lu,%lu) failed", busNo, devNo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment