static ssize_t attr_torch_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct lm3561_drv_data *data = dev_get_drvdata(dev); unsigned long enable; int result; result = strict_strtoul(buf, 10, &enable); if (result) { dev_err(&data->client->dev, "%s(): strtoul failed, result=%d\n", __func__, result); return -EINVAL; } if (1 < enable) { dev_err(&data->client->dev, "%s(): 1 < enable, enable=%lu\n", __func__, enable); return -EINVAL; } result = lm3561_torch_mode(data, (unsigned)enable); if (result) return result; return size; }
static ssize_t attr_torch_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct lm3561_drv_data *data = dev_get_drvdata(dev); unsigned long enable; int result; result = strict_strtoul(buf, 10, &enable); if (result) { dev_err(&data->client->dev, "%s(): strtoul failed, result=%d\n", __func__, result); return -EINVAL; } if (1 < enable) { dev_err(&data->client->dev, "%s(): 1 < enable, enable=%lu\n", __func__, enable); return -EINVAL; } if (enable && data->on_duty == DUTY_ON_TORCH) { dev_dbg(&data->client->dev, "%s: already enabled\n", __func__); return size; } result = pm_enable_lock(data); if (result) goto err; result = lm3561_torch_mode(data, (unsigned)enable); data->on_duty = !result && enable ? DUTY_ON_TORCH : DUTY_ON_NOTHING; if (!data->on_duty) { pm_runtime_mark_last_busy(&data->client->dev); pm_runtime_put_autosuspend(&data->client->dev); } err: mutex_unlock(&data->lock); return result ? result : size; }