Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3277423lfo; Mon, 23 May 2022 00:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8UTtDj7cU2Ea3mIPKVuEn17ijFGHDQFM+30co/YztDpTefyonyh7I5c67cfmWvMNJlr6W X-Received: by 2002:a17:902:a406:b0:161:1642:692f with SMTP id p6-20020a170902a40600b001611642692fmr21488590plq.134.1653291064078; Mon, 23 May 2022 00:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291064; cv=none; d=google.com; s=arc-20160816; b=Qrhe8V5GWgAVeQmoWVI0T639O3YDLySTJbFYViTkXLTHQssTwgEVDgJYp3gRtHyetO nZBvTZ6NCEScwYoYTRAN6ZjsxgOpq9Jfwh21Cc+WMI3TbeeipCgRDDTuHOgV8lJ08GYt nVPOxD05SFc4F1FuYmN1lWiyuZDR3FETawrhPrySdWyMcro4Ghx9P3BQru+cTMcdVBBm 2EAvmN4JMJYPtIieWtyoNlcmjyz8HoJ1XAIoN3Bmfcc3uv7R6+yGXe90Awyr7saiWKIR 4J5wE6dsdieR2geY3whsSd5usA5KS/VXLjb+/1hzaeyiYGND5h2DsfgVF5HDzUfGylDu eBqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aXa2uAZUA/pVzM2Y8Si5QF6N4wK8ejJ5LGByvpm0CYM=; b=eJzVOMMqv5gP5xGWLFjwfYUzayTTLiuGvpJFCzb6cL7WCRKl0mPOTHPqrg/640IeoO D0r5TgEqu781xDy6Q0UT9uVeqv1W4/BXtrP+AXPeZBYj4zSd+cXYmLmNG4uoYf0cQmwp 1BOuaJPt/Qv2j2F2H12l72x9u0ie55ADBlzu2/JtmHDRoJLn5VDVARpWMX/o/wGMP93Q SiY0xAeJ1QaZ1/BxqzTQHSgHXMVRnX6XJE8BiAkvquEN0xqMlcXmVRnbA68vAMHfw/o9 wILaxNlyD9/ISSWjOU7jRs7B1/ZWW0Rx/N9m02Mfaa2rApf11waJkG86xEto1y3cmGHx NR1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DMwCVIFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j70-20020a638049000000b003fa247b3520si5682145pgd.444.2022.05.23.00.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:31:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DMwCVIFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0651366A8; Sun, 22 May 2022 23:42:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245224AbiETExb (ORCPT + 99 others); Fri, 20 May 2022 00:53:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345466AbiETEx1 (ORCPT ); Fri, 20 May 2022 00:53:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96BE514ACA9; Thu, 19 May 2022 21:53:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C5C061D3D; Fri, 20 May 2022 04:53:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73763C385A9; Fri, 20 May 2022 04:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653022403; bh=APGPDdy5nqlALidXofvxDcr/grRV+XFXUdq+7hIgFnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DMwCVIFwPEg43th+Ec07N5q1FIq7SvUByh3BajNgz7VUy4ECUHHdgiUhKE6xuOkNh q0Y28OIeHsmPc/ir6DY44uQ+5+TG+Rjcypu/mLzFw9wgV/dBKNyhwWOZH1oEbGqVaa RCSAhy6b4NBNuk/Lp1pBqoUfAx9wvyQ43+3YtTJAXIZAcpAMSmOXuRA7S8P0XvCdPW WoyMnB03t5mpdbs9+DoCac5+CztvI0ob3/F0unW7gFkKMaXNLcmmWJDhxGLRkaiF+F ckqlOcZZ3x56i32XoahQMSzi2TXcf/xtaR8YUdotQ9hlF+GolZY/ggmvnw+W5w5fiQ tjazeBW1uq9Ow== Date: Fri, 20 May 2022 12:53:20 +0800 From: Tzung-Bi Shih To: Matthias Kaehlcke Cc: bleung@chromium.org, groeck@chromium.org, robh+dt@kernel.org, chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend Message-ID: References: <20220321085547.1162312-1-tzungbi@kernel.org> <20220321085547.1162312-6-tzungbi@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 03:40:21PM -0700, Matthias Kaehlcke wrote: > On Mon, Mar 21, 2022 at 04:55:47PM +0800, Tzung-Bi Shih wrote: > > +struct keyboard_led_private { > > Why 'private', isn't this more a 'cros_ec_kdb_bl' or similar? It is just drvdata. I would prefer to keep the original prefix "keyboard_led_" if you wouldn't have strong opinion. > > +static int > > +keyboard_led_set_brightness_blocking_ec_pwm(struct led_classdev *cdev, > > + enum led_brightness brightness) > > nit: since there is only a blocking version of .set_brightness you could omit > 'blocking' in the function name. Ack, will fix it in next version. > > + struct { > > + struct cros_ec_command msg; > > + struct ec_params_pwm_set_keyboard_backlight params; > > + } __packed buf; > > + struct ec_params_pwm_set_keyboard_backlight *params = &buf.params; > > + struct cros_ec_command *msg = &buf.msg; > > + struct keyboard_led_private *private = > > + container_of(cdev, struct keyboard_led_private, cdev); > > + > > + memset(&buf, 0, sizeof(buf)); > > + > > + msg->version = 0; > > not strictly needed since you do the memset above, I guess it's > fine to keep the assignment if you want to be explicit about the > version. Ack, let's remove them in next version. > > +static int keyboard_led_init_ec_pwm(struct platform_device *pdev) > > +{ > > + struct keyboard_led_private *private = platform_get_drvdata(pdev); > > + > > + private->ec = dev_get_drvdata(pdev->dev.parent); > > + if (!private->ec) { > > + dev_err(&pdev->dev, "no parent EC device\n"); > > + return -EINVAL; > > + } > > The only thing this 'init' function does is assigning private->ec. Wouldn't > it be clearer to do this directly in probe() from where callback is called? > It could be with the condition that the device as a DT node. No. The probe() isn't aware of the device is from ACPI or OF. > Is it actually possible that the keyboard backlight device gets instantiated > if there is no EC parent? It shouldn't be but just in case. > > +static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = { > > + .init = keyboard_led_init_ec_pwm_null, > > Is this really needed? > > keyboard_led_probe() checks if .init is assigned before invoking the callback: > > if (drvdata->init) { > error = drvdata->init(pdev); > > The whole 'else' branch could be eliminated if .of_match_table of the driver > only is assigned when CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM is set. IMO that > would preferable over creating 'stubs'. CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM and CONFIG_OF are independent. The stubs were created to avoid compile errors if CONFIG_OF=y but CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM=n. However, I just realized it could also have compile errors if CONFIG_OF=n and CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM=y. The `keyboard_led_drvdata_ec_pwm` is unused. In any case, I agree with you. Let's remove the stubs in next version. I would use __maybe_unused for some of them.