/** * boottime_set - Set function for sysfs attribute boottime * @dev: the &struct device * @attr: device attributes * @buf: buffer that contains new attribute value * @count: size of buffer */ static ssize_t boottime_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct cmd_ds_mesh_config cmd; uint32_t datum; int ret; memset(&cmd, 0, sizeof(cmd)); ret = sscanf(buf, "%d", &datum); if ((ret != 1) || (datum > 255)) return -EINVAL; /* A too small boot time will result in the device booting into * standalone (no-host) mode before the host can take control of it, * so the change will be hard to revert. This may be a desired * feature (e.g to configure a very fast boot time for devices that * will not be attached to a host), but dangerous. So I'm enforcing a * lower limit of 20 seconds: remove and recompile the driver if this * does not work for you. */ datum = (datum < 20) ? 20 : datum; cmd.data[0] = datum; cmd.length = cpu_to_le16(sizeof(uint8_t)); ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_BOOTTIME); if (ret) return ret; return strlen(buf); }
/** * capability_set - Set function for sysfs attribute capability * @dev: the &struct device * @attr: device attributes * @buf: buffer that contains new attribute value * @count: size of buffer */ static ssize_t capability_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct cmd_ds_mesh_config cmd; struct mrvl_mesh_defaults defs; struct mrvl_meshie *ie; struct lbs_private *priv = to_net_dev(dev)->ml_priv; uint32_t datum; int ret; memset(&cmd, 0, sizeof(cmd)); ret = sscanf(buf, "%d", &datum); if ((ret != 1) || (datum > 255)) return -EINVAL; /* fetch all other Information Element parameters */ ret = mesh_get_default_parameters(dev, &defs); cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); /* transfer IE elements */ ie = (struct mrvl_meshie *) &cmd.data[0]; memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); /* update value */ ie->val.mesh_capability = datum; ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_MESH_IE); if (ret) return ret; return strlen(buf); }
static ssize_t boottime_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct cmd_ds_mesh_config cmd; uint32_t datum; int ret; memset(&cmd, 0, sizeof(cmd)); ret = sscanf(buf, "%d", &datum); if ((ret != 1) || (datum > 255)) return -EINVAL; /* */ datum = (datum < 20) ? 20 : datum; cmd.data[0] = datum; cmd.length = cpu_to_le16(sizeof(uint8_t)); ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_BOOTTIME); if (ret) return ret; return strlen(buf); }
static int mesh_get_default_parameters(struct device *dev, struct mrvl_mesh_defaults *defs) { struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct cmd_ds_mesh_config cmd; int ret; memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET, CMD_TYPE_MESH_GET_DEFAULTS); if (ret) return -EOPNOTSUPP; memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults)); return 0; }
/** * channel_set - Set function for sysfs attribute channel * @dev: the &struct device * @attr: device attributes * @buf: buffer that contains new attribute value * @count: size of buffer */ static ssize_t channel_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct cmd_ds_mesh_config cmd; uint32_t datum; int ret; memset(&cmd, 0, sizeof(cmd)); ret = sscanf(buf, "%d", &datum); if (ret != 1 || datum < 1 || datum > 11) return -EINVAL; *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum); cmd.length = cpu_to_le16(sizeof(uint16_t)); ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_DEF_CHANNEL); if (ret) return ret; return strlen(buf); }
/** * @brief Set function for sysfs attribute bootflag */ static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lbs_private *priv = to_net_dev(dev)->priv; struct cmd_ds_mesh_config cmd; uint32_t datum; int ret; memset(&cmd, 0, sizeof(cmd)); ret = sscanf(buf, "%x", &datum); if (ret != 1) return -EINVAL; *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum); cmd.length = cpu_to_le16(sizeof(uint32_t)); ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_BOOTFLAG); if (ret) return ret; return strlen(buf); }
/** * mesh_id_set - Set function for sysfs attribute mesh_id * @dev: the &struct device * @attr: device attributes * @buf: buffer that contains new attribute value * @count: size of buffer */ static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct cmd_ds_mesh_config cmd; struct mrvl_mesh_defaults defs; struct mrvl_meshie *ie; struct lbs_private *priv = to_net_dev(dev)->ml_priv; int len; int ret; if (count < 2 || count > IEEE80211_MAX_SSID_LEN + 1) return -EINVAL; memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); ie = (struct mrvl_meshie *) &cmd.data[0]; /* fetch all other Information Element parameters */ ret = mesh_get_default_parameters(dev, &defs); cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); /* transfer IE elements */ memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); len = count - 1; memcpy(ie->val.mesh_id, buf, len); /* SSID len */ ie->val.mesh_id_len = len; /* IE len */ ie->len = sizeof(struct mrvl_meshie_val) - IEEE80211_MAX_SSID_LEN + len; ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, CMD_TYPE_MESH_SET_MESH_IE); if (ret) return ret; return strlen(buf); }