Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1149547yba; Thu, 16 May 2019 15:25:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzf7A+gitkf4cKDGFB1jCVATez5sgYssJgmmPNLL57r/Kl+sRf376Yws7a2Dfjh0WakJ9+9 X-Received: by 2002:a17:902:e7:: with SMTP id a94mr28321424pla.182.1558045528832; Thu, 16 May 2019 15:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558045528; cv=none; d=google.com; s=arc-20160816; b=IFfkNMovMEKpNCgivdIATWTfUO0hfKpJNSmDsLM8EublNLLOgCOPeqNXxd06Ig+K6M xDKYm3daAK3fKsVivKEANJQ8KO8JwKDnDZZIP3hktcYL24S5el6r9QEjWV86zbN8O4ke X9svB6kdguwjoOgtd8lvbubflbDxikVltE4bcCqmFXbsMlSgOPIPpi231HtQd6ZQ7MuY 5bdVRXBY6TsH8g1bLYOma3HQU9QZ8kbL71ZoxHrQiY8y6fFPPcqGymQ810dMLH0yXAJl pHrPB7KKFMoinhW5kea/Z0zsaa2lh/4o9z38WDhW7Y5VbkQJf0xuyOB8H9JWED9kqevn 2HRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=82QFDdDTnVFsSaJHksjPUZz4PNhhT3EIMZ6ZtPpx4UE=; b=adWDdOhSeZlIkGiVXbLAR/V3CE0TtHpBalcE/AH2PIEkKv3eAtAGuz6KNHZDX58eEh o1L7XoiyUkXYcEOlzS2lVPdOhnfNE1856bO/AqX6344JkHQmSIwAJi3EItmZDqSKwUrc lx4c0vlSSt7s0RZeBdqR5qZ9wNpHP2H62NH7qACnO63Za9fxjs5CgPfovEAlVu2fLbt3 ftbEnPWsepHfYMJ0pp5VIx8/zxYivA7h1V16Wap/5Ixs25iaSvxbKjnKc1iqJH92iHuh mqwvHzEY6msyjXHP4w319nX3CbdH0M9kDnBOvZtx0OK3Ni5NnvrbybXKrcubv3ab5pGy 3hwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b="E3leZ/bq"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si5871639plo.363.2019.05.16.15.25.13; Thu, 16 May 2019 15:25:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b="E3leZ/bq"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbfEPVLy (ORCPT + 99 others); Thu, 16 May 2019 17:11:54 -0400 Received: from vps.xff.cz ([195.181.215.36]:39694 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbfEPVLy (ORCPT ); Thu, 16 May 2019 17:11:54 -0400 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 Cc: 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 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.