Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp563466pxk; Fri, 11 Sep 2020 14:26:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7XydhmQ1o5NDSIZpoUjrke6j5OU9oCfNAsuyaasERCel5+MjYkgDG3mYQ0inrd4aJjyJj X-Received: by 2002:a05:6402:228c:: with SMTP id cw12mr4759888edb.174.1599859571686; Fri, 11 Sep 2020 14:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599859571; cv=none; d=google.com; s=arc-20160816; b=CFdhVW+ooPprjUgOYYeTTS6afmIMftkI1HZywP/SjSs77uqMqqORPGyS4Eqr8gxjl3 vkIHG4pJBp7Q7wf9125Zaf3JrUW7YD1A7zlbOc5/K2mpUGBBHws2hLtasepJtwc1+SXW IXoMOyisxBh5311/v34eyT5+f5iokquat7I0Bkr0FPFm6OfcSa+pV0e64/U/fd9q/YoN gtmg+mANQh16Fg829Dmr9P7577OxMfc5L4nB9rjwi6tVnJn29b4O2nOYat5rQVM+lCAv qNea1qJHaBiZ0WlEqQZXOKL1X/jbdt56zg0ce3O6cDRPpT5zdl7Ex33QoxbO8mE5bS4+ E3ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=AdOFtW4+OTIfp7Vou5995FqSxqsP8JuVzsLCHo5nrGw=; b=GvLnDZjARnIP1jTQdAJaRTcijudj8/IARDVHNHHjD9lCvLWTqMNuRzQoV6ZY6lJ4+T 7EIALnPEe2FJzq/B3GsYD2EqeBJIgpegehBXzn/Vxav+ED4bHRKuWk02biTw4+/UGvq+ 8It+CrgFLCt0jZAS0NkAugd1ZCuRbZYYMMAF38ZDCSxo+dej1KNQ1Uk342mZqb77KfPp Uokf2KUPn63dMr0jBaC6bKmTBYPLnd6n3aE/e9SZYFA3tF/E2Tu/oElYL+dicOkNMsfY NhLjoM9NrS84bLuQbMK0kASGarfH4gFb/Qpz8fPUtDxOG+YD3q8JktKBjoZTx/XPQt3m VGfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iwx2YXfA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r14si659394edb.14.2020.09.11.14.25.48; Fri, 11 Sep 2020 14:26:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iwx2YXfA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725873AbgIKVVn (ORCPT + 99 others); Fri, 11 Sep 2020 17:21:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgIKVVg (ORCPT ); Fri, 11 Sep 2020 17:21:36 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74181C061573; Fri, 11 Sep 2020 14:21:36 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id j2so820488eds.9; Fri, 11 Sep 2020 14:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=AdOFtW4+OTIfp7Vou5995FqSxqsP8JuVzsLCHo5nrGw=; b=iwx2YXfAln6p3+zUP1hzFoV8htJuprZmjPd2GMeVHLV95xIUBZ0d5kbG/zN0idAJZR CW420ks8syqWX+2MiN9x1egEJbYq6ia6v6uBT4Mn6BGQZ501QvqklbRxxbPomAkdHG2s VH+TyXl/AifpbFN2iDgXavo7b2SXiy9kbQOo4LdGoT2SYQdx87zlsOnUkH/a2RyziGnq q17UG/ZDvz+FSf5JCOpBjuiSczlBwJz7ESoPAjKHsFu2nvXFV1CDhOSEHk+tgaIamwow hEMXayvrrYu7sm1LSaOfY6zeTQiaYSQ2n0owQeMkDo3DKVSa/naw+QHhfeyBS502+0QX CCSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=AdOFtW4+OTIfp7Vou5995FqSxqsP8JuVzsLCHo5nrGw=; b=EA9lkMLKoFy6y8HFTFjoApDrYTu/805hzooA9ukspGzlfMnCIeATcm9KrNq5YmJTMr IZDF6LF7cZ8tWCpGdNQgXLNv8MjFlWrDO3r7+sHebSB9HoNzUHBFtnkULC+y3QRhe+31 nIbHUNqUVCjDpCp/CmY7yf7Ad3IXhMN61s+Jq5kak4M9DhY8Izz4G7HMGItdKATAzjHL luvwmk/6eGBTYo8zaeKOzPHJPrICsE0p4GyRYw14HHeClpIZ1hpkNDMkRe89giGlLGOt XdzASL13yCv2qlrsVBko5b5y67ymqGSmDQejVaSHr8wAaL0cHU77fN5gty6+ZF7Q1I51 q1Lg== X-Gm-Message-State: AOAM530uhhUK+kZ9NLCiAxkxw+5yg3IxOu3U+DaNcF8btUrNwGyHJdtL cJ1/qSn9ysZXmMkKWyknLOY= X-Received: by 2002:aa7:d296:: with SMTP id w22mr4581288edq.327.1599859295171; Fri, 11 Sep 2020 14:21:35 -0700 (PDT) Received: from ?IPv6:2a01:110f:b59:fd00:e953:3254:5e71:3177? ([2a01:110f:b59:fd00:e953:3254:5e71:3177]) by smtp.gmail.com with ESMTPSA id z18sm2200844ejb.92.2020.09.11.14.21.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 14:21:34 -0700 (PDT) Subject: Re: [PATCH v3 1/2] leds: mt6360: Add LED driver for MT6360 To: Gene Chen , Pavel Machek Cc: robh+dt@kernel.org, Matthias Brugger , Dan Murphy , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Gene Chen , Wilma.Wu@mediatek.com, shufan_lee@richtek.com, cy_huang@richtek.com, benjamin.chao@mediatek.com References: <1599474459-20853-1-git-send-email-gene.chen.richtek@gmail.com> <1599474459-20853-2-git-send-email-gene.chen.richtek@gmail.com> <559a568e-3a2e-33c6-43aa-547a18f8e26b@gmail.com> <20200911070503.GA9818@amd> From: Jacek Anaszewski Message-ID: <7e67c8f7-7f79-72f8-05bc-022ed0655a3f@gmail.com> Date: Fri, 11 Sep 2020 23:21:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/11/20 1:24 AM, Gene Chen wrote: > Pavel Machek 於 2020年9月11日 週五 下午3:05寫道: >> >> Hi! >> >>>> +{ >>>> + struct mt6360_led *led = container_of(lcdev, struct mt6360_led, flash.led_cdev); >>>> + struct mt6360_priv *priv = led->priv; >>>> + u32 enable_mask = MT6360_TORCHEN_MASK | MT6360_FLCSEN_MASK(led->led_no); >>>> + u32 val = (level) ? MT6360_FLCSEN_MASK(led->led_no) : 0; >>>> + u32 prev = priv->fled_torch_used, curr; >>>> + int ret; >>>> + >>>> + dev_dbg(lcdev->dev, "[%d] brightness %d\n", led->led_no, level); >>>> + if (priv->fled_strobe_used) { >>>> + dev_warn(lcdev->dev, "Please disable strobe first [%d]\n", priv->fled_strobe_used); >>> >>> Doesn't hardware handle that? IOW, what happens when you have enabled >>> both torch and flash? If flash just overrides torch mode, than you >>> should not prevent enabling torch in this case. >> >> Yep, this is strange/confusing... and was reason why I asked for not >> supporting strobe from sysfs. >> >> Could I get you to remove code you are not commenting at when >> reviewing? >> > > MT6360 FLED register define is STROBE_EN/TORCH_EN/CS1/CS2 (current > source) 4 bits. > The STROBE_EN/TORCH_EN is shared by FLED1 and FLED2. > If I want to enable FLED1 torch mode, I set TORCH_EN and CS1 > If I want to enable FLED2 strobe mode, I set STROBE_EN and CS2 > For example I set FLED1 torch, then I set FLED2 strobe. > When I set FLED2 strobe, I will see the strobe current is FLED2 add > FLED1 current which is not I want. > So I need disable FLED1 torch first. > Considering every circumstances is complicated when share same H/W > logic control. > And the other problem is torch mode switch to strobe mode needs ramp > time because strobe and torch mode can't be co-exist. Thank you for the explanation. So we have to keep your guards but I would return -EBUSY instead of -EINVAL. This would be also consistent with what drivers/media/v4l2-core/v4l2-flash-led-class.c does in its v4l2_flash_s_ctrl(), case V4L2_CID_FLASH_STROBE - it returns -EBUSY if __software_strobe_mode_inactive() returns false. The advantage of V4L2 Flash interface is that it has LED_MODE that can be set to torch or flash, but in LED subsystem we don't have the counterpart. -- Best regards, Jacek Anaszewski