Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5613825ybl; Tue, 10 Dec 2019 08:45:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzxokYHz0TQ8AwiXpahUk89F3T2kbvIU00XYGVr4zw+Vs/2872ebek2mWgqUgOn+TaikMY4 X-Received: by 2002:a05:6808:9a2:: with SMTP id e2mr4887999oig.1.1575996301738; Tue, 10 Dec 2019 08:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575996301; cv=none; d=google.com; s=arc-20160816; b=M0el1QEPvJ2nuoGIJ6mpZAq+5GYAFoKkgz1i9QFXG2dV0yb7yecs7WThkcsG0EAlCv ZGDEtyDlH+okrPI/JHRZBrpkGmMTB8lFekVQqp4scYpewS4JitEsGr2jWvKbKsbgczXr VqP7AZz5xS74DEwZT70rl9M9XsaOCKaqXvx89VDtx7PAdamP6He31cxfehE52mh1qOvd AQCuWq40CHONJzR5wrknZNIiHq5CzenPtxo6zFSojjx7exaKnjp9Xn2O2QvDZtR0qnkd pvv3VSMQGgIR4IWZTorPPu2self4WKmBldUL339M5+xiJLrfb/msyLktYTpTiqzXmxg5 WIyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wsWFQ3Z6EFYQnpUSOkIidynsctL0yAXSVPN00DmSMSU=; b=FCPR2p93HhDKKFiDVn2mh8YKMFCQrN2YY2erO1jF04IjksXx2FoSs5wVBJrc6qNqkk LXw3+DmiAmJIqTscy4hkXHC5D/s8TzTzEa9nPtYgww9UTP7SED+pYsJgkI0yBO+yzl0x XRkXO1VGWRVufUPBsJooyYCNB7RHSBJ8K7Sn6eZiJu8jeik3EPehkX3Kvs2tEvKB6zRc WGypfpeho+rolBbKCd9fwsRrr73QP1NwhT9ey1jGosOhTlpCTWKzwWGGOEVFk/lcPoDr mKF40al4c/iDXm6ejKZ6H5GVpVPitLQ7OXbAUn6NeWSFQ9WfqX1Ufcq+hHN4ct3DfXJ8 /qew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="RR/KqD97"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21si2350705ote.320.2019.12.10.08.44.49; Tue, 10 Dec 2019 08:45:01 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="RR/KqD97"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727899AbfLJQmt (ORCPT + 99 others); Tue, 10 Dec 2019 11:42:49 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37236 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727764AbfLJQmT (ORCPT ); Tue, 10 Dec 2019 11:42:19 -0500 Received: by mail-pl1-f195.google.com with SMTP id c23so95716plz.4; Tue, 10 Dec 2019 08:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wsWFQ3Z6EFYQnpUSOkIidynsctL0yAXSVPN00DmSMSU=; b=RR/KqD97Nx8ISod240BNcDjZXFkKcI0DWk6K49ikM67NadPyaq/H7rGl6G2+dg3NR3 I3TIpjyFvX4cpzLkwPah6kiozSbk9KCqHuMx/Fk3e591bY3CYakTWJi7rhrjbKXZo+mV Bbw75Qxxamx9g58hQ/77KwRR5HzA9VfOUJAnO3fTGP3rZtxKjveJ18GIphcY9+v+yWkx RZ1L2Zo4AGUp1eNeFegOfY4nDPAVdBsbX0ycAu3xI6R+Hvj5Kn+xbs5OLkqhr5AxCgye l15W5iS8fEMJ3tRJIkMo2lOio0gK8NfjmU5/L2DYvo9Nb+EkofqJ0goGjt2Up4t+B/Ed jbsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wsWFQ3Z6EFYQnpUSOkIidynsctL0yAXSVPN00DmSMSU=; b=UIf+Xafjt6+JCL5Xe+M8BgAwtAU8EVUgEY48SPJo8g04qR2HWDmmpX+gLcAxbSe5zh IipqHbAZANMhwsDQaYq+3yHXW6eKH1YRieSA4Do7MXgM6B/l4UnlzobR7Wvrix8kAIK0 Km7IvAq7juBkueBUbO7g4u26iZVyRIl+ChTim+EFAm5KyXWsj0SiZ1oA2sFiOrWqwxYe 7ZOxu5yRJ22cn5QpzDGKJ9wAxbA+zA157yLpCtdef4G1DUJTNzxaPcKPeA8lQj0gHu15 e3h7FF7t4UD/f77HVtCQ/J9Cc2kPlTdD9fze1VeuTNmXeWwZDFtSLodbWRE2dqnRlgHx 29uQ== X-Gm-Message-State: APjAAAXgN/9zN5Qa5GzAmNgGiLJ3dE9uM7l+5f957IiGUPAR6IOgKush soQ5Sj3Ib9FtoDjq1VecBkE= X-Received: by 2002:a17:90a:6346:: with SMTP id v6mr6310012pjs.51.1575996138248; Tue, 10 Dec 2019 08:42:18 -0800 (PST) Received: from localhost.localdomain (c-67-165-113-11.hsd1.wa.comcast.net. [67.165.113.11]) by smtp.gmail.com with ESMTPSA id j38sm4034634pgj.27.2019.12.10.08.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 08:42:17 -0800 (PST) From: Andrey Smirnov To: Daniel Lezcano Cc: Andrey Smirnov , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 06/12] thermal: qoriq: Pass data to qoriq_tmu_calibration() directly Date: Tue, 10 Dec 2019 08:41:47 -0800 Message-Id: <20191210164153.10463-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191210164153.10463-1-andrew.smirnov@gmail.com> References: <20191210164153.10463-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can simplify error cleanup code if instead of passing a "struct platform_device *" to qoriq_tmu_calibration() and deriving a bunch of pointers from it, we pass those pointers directly. This way we won't be force to call platform_set_drvdata() as early in qoriq_tmu_probe() and need to have "platform_set_drvdata(pdev, NULL);" in error path. Signed-off-by: Andrey Smirnov Reviewed-by: Daniel Lezcano Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index f024ac68e2ed..de8c9cd115aa 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -201,23 +201,23 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, return 0; } -static int qoriq_tmu_calibration(struct platform_device *pdev) +static int qoriq_tmu_calibration(struct device *dev, + struct qoriq_tmu_data *data) { int i, val, len; u32 range[4]; const u32 *calibration; - struct device_node *np = pdev->dev.of_node; - struct qoriq_tmu_data *data = platform_get_drvdata(pdev); + struct device_node *np = dev->of_node; len = of_property_count_u32_elems(np, "fsl,tmu-range"); if (len < 0 || len > 4) { - dev_err(&pdev->dev, "invalid range data.\n"); + dev_err(dev, "invalid range data.\n"); return len; } val = of_property_read_u32_array(np, "fsl,tmu-range", range, len); if (val != 0) { - dev_err(&pdev->dev, "failed to read range data.\n"); + dev_err(dev, "failed to read range data.\n"); return val; } @@ -227,7 +227,7 @@ static int qoriq_tmu_calibration(struct platform_device *pdev) calibration = of_get_property(np, "fsl,tmu-calibration", &len); if (calibration == NULL || len % 8) { - dev_err(&pdev->dev, "invalid calibration data.\n"); + dev_err(dev, "invalid calibration data.\n"); return -ENODEV; } @@ -271,8 +271,6 @@ static int qoriq_tmu_probe(struct platform_device *pdev) if (!data) return -ENOMEM; - platform_set_drvdata(pdev, data); - data->little_endian = of_property_read_bool(np, "little-endian"); data->regs = devm_platform_ioremap_resource(pdev, 0); @@ -299,7 +297,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev) qoriq_tmu_init_device(data); /* TMU initialization */ - ret = qoriq_tmu_calibration(pdev); /* TMU calibration */ + ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */ if (ret < 0) goto err; @@ -310,11 +308,12 @@ static int qoriq_tmu_probe(struct platform_device *pdev) goto err; } + platform_set_drvdata(pdev, data); + return 0; err: clk_disable_unprepare(data->clk); - platform_set_drvdata(pdev, NULL); return ret; } -- 2.21.0