static ssize_t activate_store()

in core.c [427:469]


static ssize_t activate_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
	struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
	enum nvdimm_fwa_state state;
	bool quiesce;
	ssize_t rc;

	if (!nd_desc->fw_ops)
		return -EOPNOTSUPP;

	if (sysfs_streq(buf, "live"))
		quiesce = false;
	else if (sysfs_streq(buf, "quiesce"))
		quiesce = true;
	else
		return -EINVAL;

	nvdimm_bus_lock(dev);
	state = nd_desc->fw_ops->activate_state(nd_desc);

	switch (state) {
	case NVDIMM_FWA_BUSY:
		rc = -EBUSY;
		break;
	case NVDIMM_FWA_ARMED:
	case NVDIMM_FWA_ARM_OVERFLOW:
		if (quiesce)
			rc = hibernate_quiet_exec(exec_firmware_activate, nd_desc);
		else
			rc = nd_desc->fw_ops->activate(nd_desc);
		break;
	case NVDIMM_FWA_IDLE:
	default:
		rc = -ENXIO;
	}
	nvdimm_bus_unlock(dev);

	if (rc == 0)
		rc = len;
	return rc;
}