Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3428164imm; Mon, 6 Aug 2018 04:45:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFqz7vTj9JrQ0rNkfmT9tRHqe1qoK4NQ1rw6HILL6WzajzVlgmxokmFDTJXnR6K9Cgrsik X-Received: by 2002:a17:902:bf44:: with SMTP id u4-v6mr13888547pls.84.1533555938909; Mon, 06 Aug 2018 04:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533555938; cv=none; d=google.com; s=arc-20160816; b=WF1mzV+sPxjwLnk5Yv3OSRAtj/wjamHzpWYjmMkFJ+ILjU/ZtdGtUMSGBdYKNg0p0/ BzAq67dlZVcLWMWY4vNCzp9ATfg99KBmnV060UUErHlL/rIwQhVP2BDEYhcV+0lCeWk+ prucBOAl53ojFvJ7qk+2dTpWtX5LJSa2fSBRAFVCVZX5WBMwBD9Taw7tb/ZDhBShWisC 2M+y3ECpIOxHEQPnaqo5WM2pMoUU09vgbU4/414Coxy6g3PTSGAZZ81Sy80uEkoSL5vG gp9lq7FLPkyiLSyjRbHW+7qIGCiPj37hHyIVBIL10TOmbp5bI6NvIDKqjaEBZCoESSn6 8YLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RW8Zi3sWb31J5SfhpToLKZ1iep0tNeBzDRJm8ZA4oeI=; b=Z/tGawl4m8zmf+DWezj32naP5mErMOzdnb3FYcGhLgsXlOqzpNfOk7e2qI1zWrcyy6 r8WVRC8mn8b4OCIgWiAIPv6xylwrgwlM5w5fEmE5rYSFkSe43f0OZ6jhJEm8SrDSUSWZ MJkvmf7q3fqFmjxSfxh0DoQmDX7AXbqlPLGpzUCU0rtUc35qjN1eFUu/x+g3DvcUK3mr 1uOaZ92qMri27D5SIPo9jn9srJHqRiz+AVfiCBnRdhtTAksPaulhAVlrPP9fqi2XzWJn 9kXxOfKbl2Xdx18MCbu9K7G4m2c4wk0J4pUnh9mJGjXunlzQVyUHarp9Em+dyMFq3FVN QCPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EMdEtpa+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9-v6si12194954pgi.493.2018.08.06.04.45.24; Mon, 06 Aug 2018 04:45:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EMdEtpa+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730679AbeHFNwI (ORCPT + 99 others); Mon, 6 Aug 2018 09:52:08 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34344 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727109AbeHFNwI (ORCPT ); Mon, 6 Aug 2018 09:52:08 -0400 Received: by mail-oi0-f65.google.com with SMTP id 13-v6so21614332ois.1 for ; Mon, 06 Aug 2018 04:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RW8Zi3sWb31J5SfhpToLKZ1iep0tNeBzDRJm8ZA4oeI=; b=EMdEtpa+fvLTVBzD7ys/MHbVHLTCVt38yPrwlOlZZJtbM5cuNhFN+GgN3BqvPGtHJT 6azrhBk+GTULih8qnQdsA47HN31R8AX/3ebC/dgI3luG215lxY+fU7oxTaNAo0pBtXq4 oNp+bqQHdju+fpKoUiVGuIruRyxN5ZkQ93PbI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RW8Zi3sWb31J5SfhpToLKZ1iep0tNeBzDRJm8ZA4oeI=; b=gdp1snoAXCnFwSafkJNM+4eg0eweLxVr2nYadZ5rUVDNsyqF6MbhgcflFANn4uEtPk CavXEdVhot2Hd+myC/LGwvFP34jQFPI5srhTSfYJEax2L0C0dsDW1eAq/bGkkzS2DMu3 2ktnk3uIjzMIKgEhmeRzJmXN6+5vvRusmJyQz+qCTcvw6ID4SRiY6APeHMjKPsuwQqD1 IMjuh8MxxkXEkxQfnpiP4zF/G7LwRmvWin748xayLy6nLKhKTHwE3MeUEyni4C8KHbdV 7K06qKR0k8/De2AdOsBrPP6R8aGQ1HuVoehGBoF8o7pmKIt5lYEqcuuOUC15YMU12JuX qIHQ== X-Gm-Message-State: AOUpUlFAK8UHfJ1rNnwbLPakWFDGs6y0u+NUoblPOYsijP33ClxKf0F5 8YBOcueSxG14ArcyJxIsOY+vC8hLGuAVO9tBv8biOg== X-Received: by 2002:aca:c5:: with SMTP id 188-v6mr13581724oia.128.1533555805894; Mon, 06 Aug 2018 04:43:25 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:237a:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 04:43:25 -0700 (PDT) In-Reply-To: References: <3d7e8701-d92b-9f51-befa-a585b5957488@gmail.com> From: Baolin Wang Date: Mon, 6 Aug 2018 19:43:25 +0800 Message-ID: Subject: Re: [PATCH v4 1/2] leds: core: Introduce LED pattern trigger To: Jacek Anaszewski Cc: Pavel Machek , rteysseyre@gmail.com, Bjorn Andersson , Mark Brown , Linux LED Subsystem , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacek, On 6 August 2018 at 19:41, Jacek Anaszewski wrote: > Hi Baolin, > > On 08/06/2018 03:53 AM, Baolin Wang wrote: >> Hi Jacek, > [...] >>>> +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-pattern >>>> @@ -0,0 +1,21 @@ >>>> +What: /sys/class/leds//pattern >>>> +Date: August 2018 >>>> +KernelVersion: 4.19 >>>> +Description: >>>> + Specify a pattern for the LED, for LED hardware that support >>>> + altering the brightness as a function of time. >>>> + >>>> + The pattern is given by a series of tuples, of brightness and >>>> + duration (ms). The LED is expected to traverse the series and >>>> + each brightness value for the specified duration. Duration of >>>> + 0 means brightness should immediately change to new value. >>>> + >>>> + The format of the pattern values should be: >>>> + "brightness_1 duration_1 brightness_2 duration_2 brightness_3 >>>> + duration_3 ...". >>>> + >>>> +What: /sys/class/leds//repeat >>>> +Date: August 2018 >>>> +KernelVersion: 4.19 >>>> +Description: >>>> + Specify a pattern repeat number. 0 means repeat indefinitely. >>> >>> In current implementation this file on read returns the number >>> of remaining repeat intervals. I'd add that to this description. >> >> I saw Pavel's comments that he did not suggest do this. So I will keep >> the original description? > > Yes, please report always the original value. Sure. Thanks. > > [...] >>>> +static ssize_t pattern_trig_store_repeat(struct device *dev, >>>> + struct device_attribute *attr, >>>> + const char *buf, size_t count) >>>> +{ >>>> + struct led_classdev *led_cdev = dev_get_drvdata(dev); >>>> + struct pattern_trig_data *data = led_cdev->trigger_data; >>>> + unsigned long res; >>>> + int err; >>>> + >>>> + err = kstrtoul(buf, 10, &res); >>>> + if (err) >>>> + return err; >>>> + >>>> + if (!led_cdev->pattern_set) >>>> + del_timer_sync(&data->timer); >>> >>> Is there a reason for not having this check under mutex? >> >> We will hold the mutex in pattern_trig_timer_function(), so if we do >> del_timer_sync() under the mutex protection, we may meet dead-lock >> issue. Moreover, the del_timer_sync() will make sure deactivating one >> timer is safe. > > Ack. > > -- > Best regards, > Jacek Anaszewski -- Baolin Wang Best Regards