Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2755022imj; Mon, 18 Feb 2019 11:34:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IZO0OzqKjYaJ1mFl475/OVEKMDnLOfv0bc0+6i/b4yQWcfAm4To4rmHKDHJ1/mPLe08QQaR X-Received: by 2002:a65:5844:: with SMTP id s4mr20024467pgr.77.1550518475926; Mon, 18 Feb 2019 11:34:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550518475; cv=none; d=google.com; s=arc-20160816; b=r8Y9PO9WLvdB7a4tldOuvGqLIMdkOG9/cbRYUqKOukqZ9BPuyKbii2vRhqEQWP+vAZ 50NpGCq0vjINd7jfuxoWMaOA07J3WwwUbBYJwdYc0H1Ah3ayaAFtz6VLpyyfmz/69XXu N98QiwU+K6x1+qztBkcwuHaUMPc1npR8u3VgpwE6j+kzzaqSsxbn/vvGQtiD/Ne+DZIo NHaB4+QslBUEihHcNjXFNiysO4RGcZzFlmWyvtUUhki1MZghn3hMcHD7HcOJjkahS7ei r6or6000Ay7sMNq1MZ7kQQhC8+RElAbKk+uHrGMXer3AryclHZy5ZOdUYfTV0fZBkwxE u54Q== 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=jc/u/VuNKfP8g2qvvHU2FxhsXY6Y2Hqv0zrQmbupw/s=; b=AoxsGLcsOMEcXp/PMS9Dd2cG8+D3rEaZHAPOXGnp/NuLKOkr8inpRijS8CA/YbOcGr smjwMq+cxu3FOy4LuOn1j/SACLGSEtwFdaN46tl++eTdcIONKvzdUxoidApRP/tXfw8z Y4+wD/eYaZGMAWylUan3YEpEGuSa1N4NDvV+9cGaUmQSU5i+8+yxWJIyEJaFe/O2y6ah uDQPDpLmnFy/x6zb5cibZZHTRg86vviAjoJ5IcwaBRRrz9eRZ4aZ5zsmPzIcscx4kvOw XOyiwAdnVKaO4nKobyyo6mdfc9z+caJ/gUV3HX9srbswzcri8Fzi9RFfLAjYo09ASPIf /H2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YHzWjj0w; 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 b9si2956643pgt.390.2019.02.18.11.34.20; Mon, 18 Feb 2019 11:34:35 -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=YHzWjj0w; 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 S1728977AbfBRTMw (ORCPT + 99 others); Mon, 18 Feb 2019 14:12:52 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35844 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbfBRTMG (ORCPT ); Mon, 18 Feb 2019 14:12:06 -0500 Received: by mail-pl1-f195.google.com with SMTP id g9so9193714plo.3; Mon, 18 Feb 2019 11:12:06 -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=jc/u/VuNKfP8g2qvvHU2FxhsXY6Y2Hqv0zrQmbupw/s=; b=YHzWjj0wVwV11iaUNXTj+NPB2YpyyuXkUVX2Pvp4oy8Gk7ifkFKKRy+3RmgnbVlLOs NwX+tS4mWW4yIWPrGIiSIEH0JaNj51UJclX6SlVa+ineTYnRJHY6fNGXBK8qmc77lgwE wqxsgDypBba/ZF5uzgc4YMsmmU3t8+D1oq66bB9Wq5JqTcbAGHeJjhe0ZIB8gqD8f4xX xdcIST/kjt3drYfa7CTbyRuati15W+dU0b/JqeUhON2Y4cWcS+xwrBRZEEXOm2lq6Bw2 GjDmmjL07Z3O2iWqD0lO3cuSmGLbJiiKBAOylPZE5iF7DGp+PN77iNizmGgynlH+LNBB jHig== 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=jc/u/VuNKfP8g2qvvHU2FxhsXY6Y2Hqv0zrQmbupw/s=; b=E0DWzWmDihRATupSwN/oKDIAyUo+JE/0mT9ecOCS+loXmDbHLFN1Bof7OOuTwANpDD J2lXy3MMzaICRB7PxbT1kMBKVoTG5+p+NtzSgQIxEIdQnIMNDsjbXl2V+8x093NDmbcI nZcUV2FXiRNlaeQIkKayvon5l/ycFQ0CSnAQRFeNEa5u3e4CorxVnkx14cijCuLQMXpz NVEXDR9a5xwYqFq1oc8CU6T6FQpuJ9CWBjpVlGCGocb1e/opdV+X5QUdFHQoXqiT7Ibp ZHGyEZtQbNICg0FIiv4qliDYLeVwskwhDjZKBRZdcFnEu4zUuRE5vPjEUAJY172NguQf //iA== X-Gm-Message-State: AHQUAuYzdbbLNZ3dV6XPD0lDCdDMidNtmUOnfGyldABtXkVq0aY9g7WJ 2saMWWzQfv0J4YJdeEIv/i3dfDfb X-Received: by 2002:a17:902:298a:: with SMTP id h10mr26992694plb.312.1550517125360; Mon, 18 Feb 2019 11:12:05 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id t12sm33189727pgq.68.2019.02.18.11.12.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 11:12:04 -0800 (PST) From: Andrey Smirnov To: linux-pm@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Lucas Stach , Zhang Rui , Eduardo Valentin , Daniel Lezcano , linux-imx@nxp.com, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] thermal: qoriq: Don't pass platform_device to qoriq_tmu_calibration() Date: Mon, 18 Feb 2019 11:11:33 -0800 Message-Id: <20190218191141.3729-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218191141.3729-1-andrew.smirnov@gmail.com> References: <20190218191141.3729-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 consequently would be able to drop the "err_iomap" error path. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index c24629b1b8c2..9bae001e8264 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -131,16 +131,16 @@ static int qoriq_tmu_get_sensor_id(void) return id; } -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; if (of_property_read_u32_array(np, "fsl,tmu-range", range, 4)) { - dev_err(&pdev->dev, "missing calibration range.\n"); + dev_err(dev, "missing calibration range.\n"); return -ENODEV; } @@ -152,7 +152,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; } @@ -195,27 +195,23 @@ 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->sensor_id = qoriq_tmu_get_sensor_id(); if (data->sensor_id < 0) { dev_err(dev, "Failed to get sensor id\n"); - ret = -ENODEV; - goto err_iomap; + return -ENODEV; } data->regs = of_iomap(np, 0); if (!data->regs) { dev_err(dev, "Failed to get memory region\n"); - ret = -ENODEV; - goto err_iomap; + return -ENODEV; } 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_tmu; @@ -229,6 +225,8 @@ static int qoriq_tmu_probe(struct platform_device *pdev) goto err_tmu; } + platform_set_drvdata(pdev, data); + /* Enable monitoring */ site = 0x1 << (15 - data->sensor_id); tmu_write(data, site | TMR_ME | TMR_ALPF, &data->regs->tmr); @@ -238,9 +236,6 @@ static int qoriq_tmu_probe(struct platform_device *pdev) err_tmu: iounmap(data->regs); -err_iomap: - platform_set_drvdata(pdev, NULL); - return ret; } -- 2.20.1