static ssize_t baseband_xmm_onoff(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int pwr; int size; struct platform_device *device = to_platform_device(dev); mutex_lock(&xmm_onoff_mutex); pr_debug("%s\n", __func__); /* check input */ if (buf == NULL) { pr_err("%s: buf NULL\n", __func__); mutex_unlock(&xmm_onoff_mutex); return -EINVAL; } pr_debug("%s: count=%d\n", __func__, count); /* parse input */ size = sscanf(buf, "%d", &pwr); if (size != 1) { pr_err("%s: size=%d -EINVAL\n", __func__, size); mutex_unlock(&xmm_onoff_mutex); return -EINVAL; } if (power_onoff == pwr) { pr_err("%s: Ignored, due to same CP power state(%d)\n", __func__, power_onoff); mutex_unlock(&xmm_onoff_mutex); return -EINVAL; } power_onoff = pwr; pr_debug("%s power_onoff=%d\n", __func__, power_onoff); if (power_onoff == 0) baseband_xmm_power_off(device); else if (power_onoff == 1) baseband_xmm_power_on(device); mutex_unlock(&xmm_onoff_mutex); return count; }
static ssize_t store_nml_reset_modem(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int state; struct platform_device *device = to_platform_device(dev); sscanf(buf, "%d", &state); pr_info("++ nml_reset_modem ++\n"); if (state > 0) { baseband_xmm_power_off(device); msleep(50); baseband_xmm_power_on(device); modem_reset_flag = 1; } pr_info("-- nml_reset_modem --\n"); return count; }