Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp247568iob; Mon, 2 May 2022 18:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDyjAgLd4JqJOYMRPAscJLOwT0jPoGyrF/PKOFKKUnKq4MduX0UY++WykVGpEdfqODtnGV X-Received: by 2002:a63:2b05:0:b0:3c2:3ed1:5fa9 with SMTP id r5-20020a632b05000000b003c23ed15fa9mr4560873pgr.220.1651541248637; Mon, 02 May 2022 18:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651541248; cv=none; d=google.com; s=arc-20160816; b=hBfhcURw8TwVvkwgYmpbNBnjVh/z0EwbBqQg8vXNBDRbn4bshagdVwKedu4/8JcCDc VfA7fhgoFbSdFdQD6tTiPyd3ala+EwttMIWNDWnh5hNzsXKDBuZWMPMewLuYIOW3+E/b Uz92nWzi6hY5BheH04rRpGJGYGGFj4rZ4XYAlH95UDgm4JoOSKexq/xNwx/16YaNKgio pL8af970lAViAUC0KxF6RjWvuPsa/0OMZbpCfA++2ZkK/gTGiU5UxWL3BgSxxBIfMQIA N6HlHPEan18zT04ekQEgiZe2vzuL0FzaEhCURAaZCoLktO4LQxEscXvLtWmWBRWeiCcU AZ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :message-id:user-agent:references:in-reply-to:subject:cc:to:from :date:mime-version; bh=ld75ly6s95ye3tdiZ0IdzznGk0xydBBcAtOVtzZcf28=; b=yKcjjsB+xwm7W+55RNRPnW97V/gvmQOA/rzlqGVq0k+SqPQwwjlpARbyNo62G4p7uO 7f2XTDf902ZsxI0eqlDrL7f4VkY+pkpPcONq52pY+P7wDIs8wV3YZlHIa7/KUeHrbyUA 4Oo+YiQJA/ZU2SmfyfUwnKvR/m682od2/srRZzimixQ6u7SLHlBO/5LaRtraaUYnmoEv /JhdecjtQeZWQ3ou5BylKa9VOs0I8G8BazrGWAKLcosN0O7BETWinsdXhL3pzpoYOKnC sWlqCt2d8U+Rq2ZKhenx06WSu20eRfV73tkEbY8vfjOTAFwKqc8I0Z9mo35iW9YmmV8L IMCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bg6-20020a056a02010600b003ab339bb2c2si17265225pgb.145.2022.05.02.18.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:27:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46A666A428; Mon, 2 May 2022 18:06:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233624AbiEBX0U (ORCPT + 99 others); Mon, 2 May 2022 19:26:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234103AbiEBXZH (ORCPT ); Mon, 2 May 2022 19:25:07 -0400 Received: from skyrocket.fabmicro.ru (skyrocket.fabmicro.ru [217.116.57.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E042647 for ; Mon, 2 May 2022 16:21:36 -0700 (PDT) Received: from mail.fabmicro.ru (skyrocket.fabmicro.ru [217.116.57.130]) by skyrocket.fabmicro.ru (8.14.9/8.14.9) with ESMTP id 242NK3ij032574; Mon, 2 May 2022 23:20:03 GMT (envelope-from rz@fabmicro.ru) MIME-Version: 1.0 Date: Tue, 03 May 2022 04:20:03 +0500 From: Ruslan Zalata To: Jonathan Cameron Cc: Guenter Roeck , Jean Delvare , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v2] hwmon: (sun4i-lradc) Add driver for LRADC found on Allwinner A13/A20 SoC In-Reply-To: <20220429142412.00001e43@Huawei.com> References: <20220428210906.29527-1-rz@fabmicro.ru> <20220429142412.00001e43@Huawei.com> User-Agent: Roundcube Webmail/1.4.3 Message-ID: X-Sender: rz@fabmicro.ru Organization: Fabmicro, LLC. Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Jonathan, Thank you for pointing to DEFINE_SIMPLE_DEV_PM_OPS macros, will use it. --- Regards, Ruslan. Fabmicro, LLC. On 2022-04-29 18:24, Jonathan Cameron wrote: > On Thu, 28 Apr 2022 14:30:06 -0700 > Guenter Roeck wrote: > >> On 4/28/22 14:09, Ruslan Zalata wrote: >> > Some Allwinner SoCs like A13, A20 or T2 are equipped with two-channel >> > low rate (6 bit) ADC that is often used for extra keys. There's a driver >> > for that already implementing standard input device, but it has these >> > limitations: 1) it cannot be used for general ADC data equisition, and >> >> acquisition >> >> > 2) it uses only one LRADC channel of two available. >> > >> > This driver provides basic hwmon interface to both channels of LRADC on >> > such Allwinner SoCs. >> > >> > Signed-off-by: Ruslan Zalata >> >> Ok, next phase of review. >> > > One thing noticed whilst randomly glancing at this patch. > > >> > +#ifdef CONFIG_PM >> > +static int sun4i_lradc_resume(struct device *dev) >> > +{ >> > + struct sun4i_lradc_data *lradc = dev_get_drvdata(dev); >> > + >> > + return sun4i_lradc_start(lradc); >> > +} >> > + >> > +static int sun4i_lradc_suspend(struct device *dev) >> > +{ >> > + struct sun4i_lradc_data *lradc = dev_get_drvdata(dev); >> > + >> > + sun4i_lradc_stop(lradc); >> > + return 0; >> > +} >> > + >> > +#define SUN4I_LRADC_DEV_PM_OPS (&sun4i_lradc_dev_pm_ops) >> > +#else >> > +#define SUN4I_LRADC_DEV_PM_OPS NULL >> > +#endif /* CONFIG_PM */ >> > + >> > +static const struct dev_pm_ops sun4i_lradc_dev_pm_ops = { > > We have much better infrastructure for this these days. > > Take a look at DEFINE_SIMPLE_DEV_PM_OPS() > and pm_sleep_ptr() > > Those two in combination will let you get rid of all the ifdef stuff > here by letting the compiler remove the unused code automatically. > >> > + .suspend = sun4i_lradc_suspend, >> > + .resume = sun4i_lradc_resume, >> > +}; >> > + >> > +static const struct of_device_id sun4i_lradc_of_match[] = { >> > + { .compatible = "allwinner,sun4i-a10-lradc-keys", .data = &variant_sun4i_a10_lradc}, >> > + { /* sentinel */ } >> > +}; >> > +MODULE_DEVICE_TABLE(of, sun4i_lradc_of_match); >> > + >> > +static struct platform_driver sun4i_lradc_driver = { >> > + .driver = { >> > + .name = "sun4i-lradc-hwmon", >> > + .of_match_table = of_match_ptr(sun4i_lradc_of_match), >> > + .pm = SUN4I_LRADC_DEV_PM_OPS, >> > + }, >> > + .probe = sun4i_lradc_probe, >> > +}; >> > + >> > +module_platform_driver(sun4i_lradc_driver); >> > + >> > +MODULE_DESCRIPTION("Allwinner A13/A20 LRADC hwmon driver"); >> > +MODULE_AUTHOR("Ruslan Zalata "); >> > +MODULE_LICENSE("GPL"); >> > +No empty line at end, please >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel