static ssize_t set_brightness2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct nvshield_led *led = usb_get_intfdata(intf); unsigned long brightness_val; unsigned int edp_state; if (!kstrtoul(buf, 10, &brightness_val)) { if (led->pwm_enabled) led->brightness[LED_TOUCH] = (unsigned char)brightness_val; else { if (brightness_val <= 20) led->brightness[LED_TOUCH] = (unsigned char)LED_MIN_BRIGHTNESS; else led->brightness[LED_TOUCH] = (unsigned char)LED_MAX_BRIGHTNESS; } edp_state = compute_edp_state(brightness_val, led->brightness[LED_NVBUTTON]); if (edp_state > sysedp_get_state(led->sysedpc)) { sysedp_set_state(led->sysedpc, edp_state); send_command(led, LED_TOUCH); } else { send_command(led, LED_TOUCH); sysedp_set_state(led->sysedpc, edp_state); } } return count; }
static ssize_t state_store(struct sysedp_consumer *c, const char *s, size_t count) { unsigned int new_state; if (sscanf(s, "%u", &new_state) != 1) return -EINVAL; sysedp_set_state(c, new_state); return count; }
static void oc_throttle_alarm(struct sysedp_reactive_capping_platform_data *h) { mutex_lock(&h->mutex); h->cur_capping_mw += h->step_alarm_mw; h->cur_capping_mw = min(h->cur_capping_mw, h->max_capping_mw); cancel_delayed_work(&h->work); sysedp_set_state(&h->sysedpc, count_state(h->cur_capping_mw)); schedule_delayed_work(&h->work, msecs_to_jiffies(h->relax_ms)); mutex_unlock(&h->mutex); }
static void oc_throttle_work(struct work_struct *work) { struct sysedp_reactive_capping_platform_data *h; h = container_of(to_delayed_work(work), struct sysedp_reactive_capping_platform_data, work); mutex_lock(&h->mutex); h->cur_capping_mw -= h->step_relax_mw; h->cur_capping_mw = max(h->cur_capping_mw, 0); sysedp_set_state(&h->sysedpc, count_state(h->cur_capping_mw)); if (h->cur_capping_mw) schedule_delayed_work(&h->work, msecs_to_jiffies(h->relax_ms)); mutex_unlock(&h->mutex); }