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 X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_DISCARD,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6236C04AAF for ; Thu, 16 May 2019 21:12:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 885152082E for ; Thu, 16 May 2019 21:12:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F8J0RCQN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=megous.com header.i=@megous.com header.b="E3leZ/bq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 885152082E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=megous.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CFo5BXttn4+8nTKWouZORvJKwml2OfdHiAKcC83Y4CY=; b=F8J0RCQNl/18fz HHf/oWvaxCb4gaZm0BjtnOs0imqQ7C/U/D0hn1Bib5BtjhscZ1cJ1J6PuE4ebVwtGD6jkMD9mngtK wdE/6SiVRiPEMyVhBIDbWw2lniYXSr8bb2GbHEFI2nLEzDPvE9BoE4mgIX0/jXthf3/vI5y7rQfwB Mh0yr8NSy3oiszVUkpRbtXPQlSArY850fLfhq798EmS1N7kEWwKKRlpFIVci+mX7GNRjXCYmhSMoG Fws8qnTzLQ5Hhp22vLRsQZ6fI0pLjSc0uRcrD6f6D7XXTEWRTgITyR+JNls6I77t+kTBk5VzWK/zD E3yzGbnf+jq5tl7QkQpg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRNfS-0000E1-6M; Thu, 16 May 2019 21:11:58 +0000 Received: from vps.xff.cz ([195.181.215.36]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRNfO-0000DZ-LR for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2019 21:11:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1558041111; bh=UWj0YrD5goghSNEmjJRSGrmoJDVqz/hOGHbwFS3q6Qs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E3leZ/bqG3v4DiQd1HKgqnMfkAa7iAxPpIzoIlBCCQj3c66wJJ6OgdrtNC5DtmCNa Cp3h0aZBMHwlX3d5eNFGjc6m7TcqfiXv5VMD65SoK/sQmsXpRcKtskw2OjsUYtitVD 0Im+OWUvLKknjoD+fI/QT1jHkX0x9EXUhozhOCzw= Date: Thu, 16 May 2019 23:11:51 +0200 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Frank Lee Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6 Message-ID: <20190516211151.qwac53shdjhlwj4p@core.my.home> Mail-Followup-To: Frank Lee , Maxime Ripard , Mark Rutland , Daniel Lezcano , catalin.marinas@arm.com, will.deacon@arm.com, bjorn.andersson@linaro.org, Mauro Carvalho Chehab , paulmck@linux.ibm.com, stefan.wahren@i2se.com, Linux PM , Chen-Yu Tsai , Jagan Teki , Andy Gross , rui.zhang@intel.com, devicetree@vger.kernel.org, marc.w.gonzalez@free.fr, Eduardo Valentin , enric.balletbo@collabora.com, robh+dt@kernel.org, Jonathan.Cameron@huawei.com, Linux ARM , Greg Kroah-Hartman , Linux Kernel Mailing List , olof@lixom.net, David Miller References: <20190512082614.9045-1-tiny.windzz@gmail.com> <20190512082614.9045-3-tiny.windzz@gmail.com> <20190512133930.t5txssl7mou2gljt@flea> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190516_141155_209403_D1F5714E X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Maxime Ripard , catalin.marinas@arm.com, will.deacon@arm.com, bjorn.andersson@linaro.org, marc.w.gonzalez@free.fr, Mauro Carvalho Chehab , paulmck@linux.ibm.com, stefan.wahren@i2se.com, Daniel Lezcano , Chen-Yu Tsai , Jagan Teki , Andy Gross , rui.zhang@intel.com, devicetree@vger.kernel.org, Linux PM , Eduardo Valentin , olof@lixom.net, robh+dt@kernel.org, Jonathan.Cameron@huawei.com, Linux ARM , Greg Kroah-Hartman , Linux Kernel Mailing List , enric.balletbo@collabora.com, David Miller Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, On Fri, May 17, 2019 at 01:51:56AM +0800, Frank Lee wrote: > > > +static int tsens_probe(struct platform_device *pdev) > > > +{ > > > + struct tsens_device *tmdev; > > > + struct device *dev = &pdev->dev; > > > + int ret; > > > + > > > + tmdev = devm_kzalloc(dev, sizeof(*tmdev), GFP_KERNEL); > > > + if (!tmdev) > > > + return -ENOMEM; > > > + > > > + tmdev->dev = dev; > > > + tmdev->chip = of_device_get_match_data(&pdev->dev); > > > + if (!tmdev->chip) > > > + return -EINVAL; > > > + > > > + ret = tsens_init(tmdev); > > > + if (ret) > > > + return ret; > > > + > > > + ret = tsens_register(tmdev); > > > + if (ret) > > > + return ret; > > > + > > > + ret = tmdev->chip->enable(tmdev); > > > + if (ret) > > > + return ret; > > > > > > + platform_set_drvdata(pdev, tmdev); > > > > Your registration should be the very last thing you do. Otherwise, you > > have a small window where the get_temp callback can be called, but the > > driver will not be functional yet. > No. Anyway, ths data qcquisition is ms level. Tz code can change in the future, and call the get_temp callback during registration, and this would break. It's better to be correct, than make dangerous assumptions. So platform_set_drvdata should be done somewhere prior to init_resource. Enable should be after register though. Because otherwise you may be calling tz update on non-registered tz from an interrupt handler. > > > + return ret; > > > +} > > > + regards, o. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel