aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorDavid Kershner <david.kershner@unisys.com>2016-09-19 17:09:34 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-20 07:28:17 -0400
commitebeff0558c0a311f4c5d432c69c32b9502219190 (patch)
treebce32a68103a7a6ae233167aa5c7d633a9395fb6 /drivers/staging
parent97f792ee3cd6f62551f6247ca36492615e26cb5e (diff)
staging: unisys: visorbus: move deviceenabled/disabled store functions
Move the deviceenabled/devicedisabled store functions so that function prototypes can be removed. This caused us to move several of the structures farther down in the file as well. Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David Kershner <david.kershner@unisys.com> Reviewed-by: Tim Sell <Timothy.Sell@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/unisys/visorbus/visorchipset.c418
1 files changed, 205 insertions, 213 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index d3efe75fab32..5603bb65fb67 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -353,59 +353,6 @@ static ssize_t remaining_steps_store(struct device *dev,
353} 353}
354static DEVICE_ATTR_RW(remaining_steps); 354static DEVICE_ATTR_RW(remaining_steps);
355 355
356static ssize_t devicedisabled_store(struct device *dev,
357 struct device_attribute *attr,
358 const char *buf, size_t count);
359static DEVICE_ATTR_WO(devicedisabled);
360
361static ssize_t deviceenabled_store(struct device *dev,
362 struct device_attribute *attr,
363 const char *buf, size_t count);
364static DEVICE_ATTR_WO(deviceenabled);
365
366static struct attribute *visorchipset_install_attrs[] = {
367 &dev_attr_toolaction.attr,
368 &dev_attr_boottotool.attr,
369 &dev_attr_error.attr,
370 &dev_attr_textid.attr,
371 &dev_attr_remaining_steps.attr,
372 NULL
373};
374
375static struct attribute_group visorchipset_install_group = {
376 .name = "install",
377 .attrs = visorchipset_install_attrs
378};
379
380static struct attribute *visorchipset_parahotplug_attrs[] = {
381 &dev_attr_devicedisabled.attr,
382 &dev_attr_deviceenabled.attr,
383 NULL
384};
385
386static struct attribute_group visorchipset_parahotplug_group = {
387 .name = "parahotplug",
388 .attrs = visorchipset_parahotplug_attrs
389};
390
391static const struct attribute_group *visorchipset_dev_groups[] = {
392 &visorchipset_install_group,
393 &visorchipset_parahotplug_group,
394 NULL
395};
396
397static void visorchipset_dev_release(struct device *dev)
398{
399}
400
401/* /sys/devices/platform/visorchipset */
402static struct platform_device visorchipset_platform_device = {
403 .name = "visorchipset",
404 .id = -1,
405 .dev.groups = visorchipset_dev_groups,
406 .dev.release = visorchipset_dev_release,
407};
408
409static uuid_le 356static uuid_le
410parser_id_get(struct parser_context *ctx) 357parser_id_get(struct parser_context *ctx)
411{ 358{
@@ -1185,79 +1132,6 @@ initialize_controlvm_payload(void)
1185 &controlvm_payload_info); 1132 &controlvm_payload_info);
1186} 1133}
1187 1134
1188/**
1189 * visorchipset_chipset_ready() - sends chipset_ready action
1190 *
1191 * Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1192 *
1193 * Return: CONTROLVM_RESP_SUCCESS
1194 */
1195static int
1196visorchipset_chipset_ready(void)
1197{
1198 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
1199 return CONTROLVM_RESP_SUCCESS;
1200}
1201
1202static int
1203visorchipset_chipset_selftest(void)
1204{
1205 char env_selftest[20];
1206 char *envp[] = { env_selftest, NULL };
1207
1208 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
1209 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1210 envp);
1211 return CONTROLVM_RESP_SUCCESS;
1212}
1213
1214/**
1215 * visorchipset_chipset_notready() - sends chipset_notready action
1216 *
1217 * Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1218 *
1219 * Return: CONTROLVM_RESP_SUCCESS
1220 */
1221static int
1222visorchipset_chipset_notready(void)
1223{
1224 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
1225 return CONTROLVM_RESP_SUCCESS;
1226}
1227
1228static void
1229chipset_ready(struct controlvm_message_header *msg_hdr)
1230{
1231 int rc = visorchipset_chipset_ready();
1232
1233 if (rc != CONTROLVM_RESP_SUCCESS)
1234 rc = -rc;
1235 if (msg_hdr->flags.response_expected)
1236 controlvm_respond(msg_hdr, rc);
1237}
1238
1239static void
1240chipset_selftest(struct controlvm_message_header *msg_hdr)
1241{
1242 int rc = visorchipset_chipset_selftest();
1243
1244 if (rc != CONTROLVM_RESP_SUCCESS)
1245 rc = -rc;
1246 if (msg_hdr->flags.response_expected)
1247 controlvm_respond(msg_hdr, rc);
1248}
1249
1250static void
1251chipset_notready(struct controlvm_message_header *msg_hdr)
1252{
1253 int rc = visorchipset_chipset_notready();
1254
1255 if (rc != CONTROLVM_RESP_SUCCESS)
1256 rc = -rc;
1257 if (msg_hdr->flags.response_expected)
1258 controlvm_respond(msg_hdr, rc);
1259}
1260
1261/* 1135/*
1262 * The general parahotplug flow works as follows. The visorchipset 1136 * The general parahotplug flow works as follows. The visorchipset
1263 * driver receives a DEVICE_CHANGESTATE message from Command 1137 * driver receives a DEVICE_CHANGESTATE message from Command
@@ -1335,38 +1209,6 @@ parahotplug_request_destroy(struct parahotplug_request *req)
1335} 1209}
1336 1210
1337/** 1211/**
1338 * parahotplug_request_kickoff() - initiate parahotplug request
1339 * @req: the request to initiate
1340 *
1341 * Cause uevent to run the user level script to do the disable/enable specified
1342 * in the parahotplug_request.
1343 */
1344static void
1345parahotplug_request_kickoff(struct parahotplug_request *req)
1346{
1347 struct controlvm_message_packet *cmd = &req->msg.cmd;
1348 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
1349 env_func[40];
1350 char *envp[] = {
1351 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
1352 };
1353
1354 sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
1355 sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
1356 sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
1357 cmd->device_change_state.state.active);
1358 sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
1359 cmd->device_change_state.bus_no);
1360 sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
1361 cmd->device_change_state.dev_no >> 3);
1362 sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1363 cmd->device_change_state.dev_no & 0x7);
1364
1365 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1366 envp);
1367}
1368
1369/**
1370 * parahotplug_request_complete() - mark request as complete 1212 * parahotplug_request_complete() - mark request as complete
1371 * @id: the id of the request 1213 * @id: the id of the request
1372 * @active: indicates whether the request is assigned to active partition 1214 * @active: indicates whether the request is assigned to active partition
@@ -1411,6 +1253,138 @@ parahotplug_request_complete(int id, u16 active)
1411} 1253}
1412 1254
1413/** 1255/**
1256 * devicedisabled_store() - disables the hotplug device
1257 * @dev: sysfs interface variable not utilized in this function
1258 * @attr: sysfs interface variable not utilized in this function
1259 * @buf: buffer containing the device id
1260 * @count: the size of the buffer
1261 *
1262 * The parahotplug/devicedisabled interface gets called by our support script
1263 * when an SR-IOV device has been shut down. The ID is passed to the script
1264 * and then passed back when the device has been removed.
1265 *
1266 * Return: the size of the buffer for success or negative for error
1267 */
1268static ssize_t devicedisabled_store(struct device *dev,
1269 struct device_attribute *attr,
1270 const char *buf, size_t count)
1271{
1272 unsigned int id;
1273 int err;
1274
1275 if (kstrtouint(buf, 10, &id))
1276 return -EINVAL;
1277
1278 err = parahotplug_request_complete(id, 0);
1279 if (err < 0)
1280 return err;
1281 return count;
1282}
1283static DEVICE_ATTR_WO(devicedisabled);
1284
1285/**
1286 * deviceenabled_store() - enables the hotplug device
1287 * @dev: sysfs interface variable not utilized in this function
1288 * @attr: sysfs interface variable not utilized in this function
1289 * @buf: buffer containing the device id
1290 * @count: the size of the buffer
1291 *
1292 * The parahotplug/deviceenabled interface gets called by our support script
1293 * when an SR-IOV device has been recovered. The ID is passed to the script
1294 * and then passed back when the device has been brought back up.
1295 *
1296 * Return: the size of the buffer for success or negative for error
1297 */
1298static ssize_t deviceenabled_store(struct device *dev,
1299 struct device_attribute *attr,
1300 const char *buf, size_t count)
1301{
1302 unsigned int id;
1303
1304 if (kstrtouint(buf, 10, &id))
1305 return -EINVAL;
1306
1307 parahotplug_request_complete(id, 1);
1308 return count;
1309}
1310static DEVICE_ATTR_WO(deviceenabled);
1311
1312static struct attribute *visorchipset_install_attrs[] = {
1313 &dev_attr_toolaction.attr,
1314 &dev_attr_boottotool.attr,
1315 &dev_attr_error.attr,
1316 &dev_attr_textid.attr,
1317 &dev_attr_remaining_steps.attr,
1318 NULL
1319};
1320
1321static struct attribute_group visorchipset_install_group = {
1322 .name = "install",
1323 .attrs = visorchipset_install_attrs
1324};
1325
1326static struct attribute *visorchipset_parahotplug_attrs[] = {
1327 &dev_attr_devicedisabled.attr,
1328 &dev_attr_deviceenabled.attr,
1329 NULL
1330};
1331
1332static struct attribute_group visorchipset_parahotplug_group = {
1333 .name = "parahotplug",
1334 .attrs = visorchipset_parahotplug_attrs
1335};
1336
1337static const struct attribute_group *visorchipset_dev_groups[] = {
1338 &visorchipset_install_group,
1339 &visorchipset_parahotplug_group,
1340 NULL
1341};
1342
1343static void visorchipset_dev_release(struct device *dev)
1344{
1345}
1346
1347/* /sys/devices/platform/visorchipset */
1348static struct platform_device visorchipset_platform_device = {
1349 .name = "visorchipset",
1350 .id = -1,
1351 .dev.groups = visorchipset_dev_groups,
1352 .dev.release = visorchipset_dev_release,
1353};
1354
1355/**
1356 * parahotplug_request_kickoff() - initiate parahotplug request
1357 * @req: the request to initiate
1358 *
1359 * Cause uevent to run the user level script to do the disable/enable specified
1360 * in the parahotplug_request.
1361 */
1362static void
1363parahotplug_request_kickoff(struct parahotplug_request *req)
1364{
1365 struct controlvm_message_packet *cmd = &req->msg.cmd;
1366 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
1367 env_func[40];
1368 char *envp[] = {
1369 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
1370 };
1371
1372 sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
1373 sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
1374 sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
1375 cmd->device_change_state.state.active);
1376 sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
1377 cmd->device_change_state.bus_no);
1378 sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
1379 cmd->device_change_state.dev_no >> 3);
1380 sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1381 cmd->device_change_state.dev_no & 0x7);
1382
1383 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1384 envp);
1385}
1386
1387/**
1414 * parahotplug_process_message() - enables or disables a PCI device by kicking 1388 * parahotplug_process_message() - enables or disables a PCI device by kicking
1415 * off a udev script 1389 * off a udev script
1416 * @inmsg: the message indicating whether to enable or disable 1390 * @inmsg: the message indicating whether to enable or disable
@@ -1458,6 +1432,79 @@ parahotplug_process_message(struct controlvm_message *inmsg)
1458 } 1432 }
1459} 1433}
1460 1434
1435/**
1436 * visorchipset_chipset_ready() - sends chipset_ready action
1437 *
1438 * Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1439 *
1440 * Return: CONTROLVM_RESP_SUCCESS
1441 */
1442static int
1443visorchipset_chipset_ready(void)
1444{
1445 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
1446 return CONTROLVM_RESP_SUCCESS;
1447}
1448
1449static int
1450visorchipset_chipset_selftest(void)
1451{
1452 char env_selftest[20];
1453 char *envp[] = { env_selftest, NULL };
1454
1455 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
1456 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1457 envp);
1458 return CONTROLVM_RESP_SUCCESS;
1459}
1460
1461/**
1462 * visorchipset_chipset_notready() - sends chipset_notready action
1463 *
1464 * Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1465 *
1466 * Return: CONTROLVM_RESP_SUCCESS
1467 */
1468static int
1469visorchipset_chipset_notready(void)
1470{
1471 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
1472 return CONTROLVM_RESP_SUCCESS;
1473}
1474
1475static void
1476chipset_ready(struct controlvm_message_header *msg_hdr)
1477{
1478 int rc = visorchipset_chipset_ready();
1479
1480 if (rc != CONTROLVM_RESP_SUCCESS)
1481 rc = -rc;
1482 if (msg_hdr->flags.response_expected)
1483 controlvm_respond(msg_hdr, rc);
1484}
1485
1486static void
1487chipset_selftest(struct controlvm_message_header *msg_hdr)
1488{
1489 int rc = visorchipset_chipset_selftest();
1490
1491 if (rc != CONTROLVM_RESP_SUCCESS)
1492 rc = -rc;
1493 if (msg_hdr->flags.response_expected)
1494 controlvm_respond(msg_hdr, rc);
1495}
1496
1497static void
1498chipset_notready(struct controlvm_message_header *msg_hdr)
1499{
1500 int rc = visorchipset_chipset_notready();
1501
1502 if (rc != CONTROLVM_RESP_SUCCESS)
1503 rc = -rc;
1504 if (msg_hdr->flags.response_expected)
1505 controlvm_respond(msg_hdr, rc);
1506}
1507
1461static inline unsigned int 1508static inline unsigned int
1462issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) 1509issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
1463{ 1510{
@@ -1640,61 +1687,6 @@ device_resume_response(struct visor_device *dev_info, int response)
1640 dev_info->pending_msg_hdr = NULL; 1687 dev_info->pending_msg_hdr = NULL;
1641} 1688}
1642 1689
1643/**
1644 * devicedisabled_store() - disables the hotplug device
1645 * @dev: sysfs interface variable not utilized in this function
1646 * @attr: sysfs interface variable not utilized in this function
1647 * @buf: buffer containing the device id
1648 * @count: the size of the buffer
1649 *
1650 * The parahotplug/devicedisabled interface gets called by our support script
1651 * when an SR-IOV device has been shut down. The ID is passed to the script
1652 * and then passed back when the device has been removed.
1653 *
1654 * Return: the size of the buffer for success or negative for error
1655 */
1656static ssize_t devicedisabled_store(struct device *dev,
1657 struct device_attribute *attr,
1658 const char *buf, size_t count)
1659{
1660 unsigned int id;
1661 int err;
1662
1663 if (kstrtouint(buf, 10, &id))
1664 return -EINVAL;
1665
1666 err = parahotplug_request_complete(id, 0);
1667 if (err < 0)
1668 return err;
1669 return count;
1670}
1671
1672/**
1673 * deviceenabled_store() - enables the hotplug device
1674 * @dev: sysfs interface variable not utilized in this function
1675 * @attr: sysfs interface variable not utilized in this function
1676 * @buf: buffer containing the device id
1677 * @count: the size of the buffer
1678 *
1679 * The parahotplug/deviceenabled interface gets called by our support script
1680 * when an SR-IOV device has been recovered. The ID is passed to the script
1681 * and then passed back when the device has been brought back up.
1682 *
1683 * Return: the size of the buffer for success or negative for error
1684 */
1685static ssize_t deviceenabled_store(struct device *dev,
1686 struct device_attribute *attr,
1687 const char *buf, size_t count)
1688{
1689 unsigned int id;
1690
1691 if (kstrtouint(buf, 10, &id))
1692 return -EINVAL;
1693
1694 parahotplug_request_complete(id, 1);
1695 return count;
1696}
1697
1698static int 1690static int
1699visorchipset_mmap(struct file *file, struct vm_area_struct *vma) 1691visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
1700{ 1692{