/** * zfcp_sysfs_port_failed_store - failed state of port * @dev: pointer to belonging device * @buf: pointer to input buffer * @count: number of bytes in buffer * * Store function of the "failed" attribute of a port. * If a "0" gets written to "failed", error recovery will be * started for the belonging port. */ static ssize_t zfcp_sysfs_port_failed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct zfcp_port *port; unsigned int val; char *endp; int retval = 0; down(&zfcp_data.config_sema); port = dev_get_drvdata(dev); if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status)) { retval = -EBUSY; goto out; } val = simple_strtoul(buf, &endp, 0); if (((endp + 1) < (buf + count)) || (val != 0)) { retval = -EINVAL; goto out; } zfcp_erp_modify_port_status(port, ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED); zfcp_erp_wait(port->adapter); out: up(&zfcp_data.config_sema); return retval ? retval : (ssize_t) count; }
/** * zfcp_sysfs_port_add_store - add a port to sysfs tree * @dev: pointer to belonging device * @buf: pointer to input buffer * @count: number of bytes in buffer * * Store function of the "port_add" attribute of an adapter. */ static ssize_t zfcp_sysfs_port_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { wwn_t wwpn; char *endp; struct zfcp_adapter *adapter; struct zfcp_port *port; int retval = -EINVAL; down(&zfcp_data.config_sema); adapter = dev_get_drvdata(dev); if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status)) { retval = -EBUSY; goto out; } wwpn = simple_strtoull(buf, &endp, 0); if ((endp + 1) < (buf + count)) goto out; port = zfcp_port_enqueue(adapter, wwpn, 0, 0); if (!port) goto out; retval = 0; zfcp_erp_port_reopen(port, 0); zfcp_erp_wait(port->adapter); zfcp_port_put(port); out: up(&zfcp_data.config_sema); return retval ? retval : (ssize_t) count; }
static ssize_t zfcp_sysfs_port_failed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); unsigned long val; if (strict_strtoul(buf, 0, &val) || val != 0) return -EINVAL; zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING); zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2"); zfcp_erp_wait(port->adapter); return count; }
/** * zfcp_erp_port_shutdown - Shutdown port * @port: Port to shut down. * @clear: Status flags to clear. * @id: Id for debug trace event. * @ref: Reference for debug trace event. */ void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *id, void *ref) { int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; zfcp_erp_port_reopen(port, clear | flags, id, ref); }