From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB706C352AA for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388299AbiDLJWB (ORCPT ); Tue, 12 Apr 2022 05:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377938AbiDLHym (ORCPT ); Tue, 12 Apr 2022 03:54:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 774F256209; Tue, 12 Apr 2022 00:32:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2D764B81B58; Tue, 12 Apr 2022 07:32:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2C95C385A5; Tue, 12 Apr 2022 07:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649748725; bh=Q00BETgFTrmU/q7T1FdvzQYcdJLp4PmeOg+OowHQNhQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PTI2mQf0MCbJiTv9DaUxqUVUzksobTkDS5QOT7hjig8DNV+ts93iEQ4mB9j9FyX6C ximBbJ17+6wDLMcqdRTJ+mDCC92LHEZhg3q9a1DlsKXp6fvCoctynGGJtRz6xO8Mby diVfj396JUUs0KEbk/TEKPANJw0M0pt74zA9ZRrUNZuG0dfJEYj0N63YOYXwnvYHXE ui+0HxtqGPFVtNtGu7guF+c1SF8J8Q7F7v91HKhOyFOE1viDWvep6vDTiQ34yumw47 vbNQ7Qh1DS2A4CV73Bj2tw62JDEdMFI/qcV9+OgIdVjTZFJAluMuNTsm+e1Vexb7Ry jB/ToJShnETLw== Date: Tue, 12 Apr 2022 15:32:01 +0800 From: Tzung-Bi Shih To: Fabio Baltieri Cc: Benson Leung , Guenter Roeck , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Lee Jones , Rob Herring , chrome-platform@lists.linux.dev, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/4] drivers: pwm: pwm-cros-ec: add channel type support Message-ID: References: <20220411152114.2165933-1-fabiobaltieri@chromium.org> <20220411152114.2165933-3-fabiobaltieri@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220411152114.2165933-3-fabiobaltieri@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 11, 2022 at 03:21:12PM +0000, Fabio Baltieri wrote: > Add support for EC_PWM_TYPE_DISPLAY_LIGHT and EC_PWM_TYPE_KB_LIGHT pwm > types to the PWM cros_ec_pwm driver. This allows specifying one of these > PWM channel by functionality, and let the EC firmware pick the correct > channel, thus abstracting the hardware implementation from the kernel > driver. > > To use it, define the node with the "google,cros-ec-pwm-type" > compatible. Not sure whether you decide to leave the prefix as is or not[1], just another reminder: to be neat, suggest to remove "drivers: " prefix from the commit title. [1]: https://patchwork.kernel.org/project/chrome-platform/patch/20220331125818.3776912-3-fabiobaltieri@chromium.org/ > +#ifdef CONFIG_OF > +static const struct of_device_id cros_ec_pwm_of_match[] = { > + { > + .compatible = "google,cros-ec-pwm", > + }, > + { > + .compatible = "google,cros-ec-pwm-type", > + .data = OF_CROS_EC_PWM_TYPE, > + }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match); > +#else > +#define cros_ec_pwm_of_match NULL > +#endif > + > static int cros_ec_pwm_probe(struct platform_device *pdev) > { > struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); > struct device *dev = &pdev->dev; > + const struct of_device_id *id; > struct cros_ec_pwm_device *ec_pwm; > struct pwm_chip *chip; > int ret; > @@ -251,17 +312,27 @@ static int cros_ec_pwm_probe(struct platform_device *pdev) > chip = &ec_pwm->chip; > ec_pwm->ec = ec; > > + id = of_match_device(cros_ec_pwm_of_match, dev); > + if (id && id->data == OF_CROS_EC_PWM_TYPE) > + ec_pwm->use_pwm_type = true; > + [...] > -#ifdef CONFIG_OF > -static const struct of_device_id cros_ec_pwm_of_match[] = { > - { .compatible = "google,cros-ec-pwm" }, > - {}, > -}; > -MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match); > -#endif > - Use dev->driver->of_match_table to access the table so that the table declaration doesn't actually need a move. Instead, the helper function of_device_get_match_data() is preferred. Alternatively, it could use of_device_is_compatible(..."google,cros-ec-pwm-type") so that it doesn't need to introduce OF_CROS_EC_PWM_TYPE and reduce some bits. I would prefer this way.