static void chp_release(struct device *dev) { struct channel_path *cp; cp = to_channelpath(dev); kfree(cp); }
static ssize_t chp_status_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct channel_path *cp = to_channelpath(dev); char cmd[10]; int num_args; int error; num_args = sscanf(buf, "%5s", cmd); if (!num_args) return count; if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) { mutex_lock(&cp->lock); error = s390_vary_chpid(cp->chpid, 1); mutex_unlock(&cp->lock); } else if (!strncasecmp(cmd, "off", 3) || !strcmp(cmd, "0")) { mutex_lock(&cp->lock); error = s390_vary_chpid(cp->chpid, 0); mutex_unlock(&cp->lock); } else error = -EINVAL; return error < 0 ? error : count; }
static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); if (!chp) return 0; return sprintf(buf, "%x\n", chp->desc.desc); }
/* * Files for the channel path entries. */ static ssize_t chp_status_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); if (!chp) return 0; return (chp_get_status(chp->chpid) ? sprintf(buf, "online\n") : sprintf(buf, "offline\n")); }
static ssize_t chp_shared_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); if (!chp) return 0; if (chp->shared == -1) /* channel measurements not available */ return sprintf(buf, "unknown\n"); return sprintf(buf, "%x\n", chp->shared); }
static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); u8 type; mutex_lock(&chp->lock); type = chp->desc.desc; mutex_unlock(&chp->lock); return sprintf(buf, "%x\n", type); }
/* * Files for the channel path entries. */ static ssize_t chp_status_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); int status; mutex_lock(&chp->lock); status = chp->state; mutex_unlock(&chp->lock); return status ? sprintf(buf, "online\n") : sprintf(buf, "offline\n"); }
static ssize_t chp_configure_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *cp; int status; cp = to_channelpath(dev); status = chp_info_get_status(cp->chpid); if (status < 0) return status; return snprintf(buf, PAGE_SIZE, "%d\n", status); }
static ssize_t chp_chid_external_show(struct device *dev, struct device_attribute *attr, char *buf) { struct channel_path *chp = to_channelpath(dev); ssize_t rc; mutex_lock(&chp->lock); if (chp->desc_fmt1.flags & 0x10) rc = sprintf(buf, "%x\n", chp->desc_fmt1.flags & 0x8 ? 1 : 0); else rc = 0; mutex_unlock(&chp->lock); return rc; }
/* * Channel measurement related functions */ static ssize_t chp_measurement_chars_read(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct channel_path *chp; struct device *device; device = container_of(kobj, struct device, kobj); chp = to_channelpath(device); if (!chp->cmg_chars) return 0; return memory_read_from_buffer(buf, count, &off, chp->cmg_chars, sizeof(struct cmg_chars)); }
static ssize_t chp_configure_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct channel_path *cp; int val; char delim; if (sscanf(buf, "%d %c", &val, &delim) != 1) return -EINVAL; if (val != 0 && val != 1) return -EINVAL; cp = to_channelpath(dev); chp_cfg_schedule(cp->chpid, val); cfg_wait_idle(); return count; }
static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct channel_path *chp; struct channel_subsystem *css; struct device *device; unsigned int size; device = container_of(kobj, struct device, kobj); chp = to_channelpath(device); css = to_css(chp->dev.parent); size = sizeof(struct cmg_entry); /* Only allow single reads. */ if (off || count < size) return 0; chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid); count = size; return count; }