Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp7224382imm; Sun, 20 May 2018 22:05:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqYllxVGVzY9q6VEdoQ5mTtojiq+4UsiQQ5l76uNDdxcX5hD5ukQiUEMqCMu/1sFrHhRFcy X-Received: by 2002:a17:902:b946:: with SMTP id h6-v6mr19531071pls.3.1526879128768; Sun, 20 May 2018 22:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526879128; cv=none; d=google.com; s=arc-20160816; b=LdyeYCv0Jlt16619EkaTm1rJpsnrfdCbWa0EpwfscB1GHpKVj/UVlXiRCSF//Dktl9 UJ+5/95bydR5fT+sdpSy2o98jTJVsL7di0XgT8IVOeycLT4T9VesLFzylthwpbCT4S64 bOgamyATeXnzlPVD+8r4EtCFVy0PF2v9Hnq2b7E55IIyNMEstsCw7jcfBavS0+6CCiOo WerNNgi2CZ7I3iw689XrrBL/gIyXQihIJvl/S3UWhbcDDYFSVm5R9bUVgGtRCD27WO9w oCiUp/5murK68AGvJsZnRgoVy4XbLSpv8Om2Sb15+Oc6RmRG5k1Nv5URMABv0GXLZ1Ve XLsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=pOpdlHJR8iBk2NxNnKhJuXZdF6B2KqL7h7wzbiduZ+U=; b=bTkleIvi952m5h9mywrbwXaf5gnyLd/KxZ2CZN5RbxjCv80BWdZWcaWU11ovMS7XcN Bg/UzCwFrHKcK+JDPgpJuydTgrXlbFfp6MNuXg+XArjp7fUkHiM39RVxVolMKca31Pcz gTZUNrF4nnXxyYDWTSEdlrqPow2hDYxRCaIeYX3beVuC7HtwvA44kJUO+2mUZAsl5kwM +ZnzGLNgxit9ug8j/01MJZ4Mvqg4BNyOPAmSYHg8Fz1bpaW/dePjLO46a1W8quFXBoYG 9FxJ/kG7XqHUppPT5VbLDuSyhXKsurBx4hvcaDrHAPJml4Xoql+D17PHmiaDU1DLYaPG EWjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iACf80la; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a81-v6si13575821pfg.200.2018.05.20.22.05.13; Sun, 20 May 2018 22:05: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=@linaro.org header.s=google header.b=iACf80la; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751007AbeEUFFA (ORCPT + 99 others); Mon, 21 May 2018 01:05:00 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44975 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbeEUFE4 (ORCPT ); Mon, 21 May 2018 01:04:56 -0400 Received: by mail-pl0-f67.google.com with SMTP id e6-v6so8057474plt.11 for ; Sun, 20 May 2018 22:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pOpdlHJR8iBk2NxNnKhJuXZdF6B2KqL7h7wzbiduZ+U=; b=iACf80laMeZxLQf/CUzB5kXo0uDAaKTw7CGb3irlVhRwWrkK9gduGr7z/0MnKcU5EP O3vqZobP53qrUt0eYLwB7o9Neoghl8Sl5ytfNizEmb8PlhW8urgAt0GlNPtfEDjusZwm x8AOHZPZ6t8C5VylsUgcgC45jyrnaKs8rQB0k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pOpdlHJR8iBk2NxNnKhJuXZdF6B2KqL7h7wzbiduZ+U=; b=PQYHHIGjQ1231LPPWMFSqPfM9bNQyD7/UpTkAYd0h/rlfWw4sWVD1xe7YiT/VxHHsH m6zQ6n4R//AqucKQr+Bp7Q3OUPWJCrl+5ATDl34DcbScESxEzBIeaXEvMT06MazF7oRd IG5NPxPV5xfB3/xuYQFVYOknYC+QWWZw6C7bW7q5V3Kh/2+B5HkjE/rn4Qm1qj5PJgU7 eRfFm1cuiHMis0YX/vTrRMfxgyi1JE19iA9B4cVDPqjbjfnHAeAkYh66Yd8FDxz5dWLQ pZiB/+Xk8t4DLmce5gC+BLECmEeoxl4N6cHclXfQWbK0e7GIawENPz2ggFVhTX5CsO+B 9DaA== X-Gm-Message-State: ALKqPwdKzLJTK0X09zlE4QNWJL8P1WWj6jJya4jlKmYBBwN7XwHpKW3R f0xfqN+l/mCgxVQnmw7IhCxbzQ== X-Received: by 2002:a17:902:7149:: with SMTP id u9-v6mr18848491plm.356.1526879096218; Sun, 20 May 2018 22:04:56 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id x2-v6sm18473040pgc.53.2018.05.20.22.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 May 2018 22:04:55 -0700 (PDT) Date: Mon, 21 May 2018 10:34:53 +0530 From: Viresh Kumar To: Ilia Lin Cc: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, mark.rutland@arm.com, nm@ti.com, lgirdwood@gmail.com, broonie@kernel.org, andy.gross@linaro.org, david.brown@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rnayak@codeaurora.org, amit.kucheria@linaro.org, nicolas.dechesne@linaro.org, celster@codeaurora.org, tfinkel@codeaurora.org Subject: Re: [PATCH] cpufreq: Add Kryo CPU scaling driver Message-ID: <20180521050453.vls3fe6fyake4dhk@vireshk-i7> References: <1526555955-29960-11-git-send-email-ilialin@codeaurora.org> <1526729701-8589-1-git-send-email-ilialin@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1526729701-8589-1-git-send-email-ilialin@codeaurora.org> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org More comments after Russell's reply. On 19-05-18, 14:35, Ilia Lin wrote: > +static int __init qcom_cpufreq_kryo_driver_init(void) > +{ > + struct device *cpu_dev_silver, *cpu_dev_gold; > + struct opp_table *opp_silver, *opp_gold; > + enum _msm8996_version msm8996_version; > + struct nvmem_cell *speedbin_nvmem; > + struct platform_device *pdev; > + struct device_node *np; > + u8 *speedbin; > + u32 versions; > + size_t len; > + int ret; > + > + cpu_dev_silver = get_cpu_device(SILVER_LEAD); > + if (IS_ERR_OR_NULL(cpu_dev_silver)) get_cpu_device() returns only NULL on error. > + return PTR_ERR(cpu_dev_silver); > + > + cpu_dev_gold = get_cpu_device(SILVER_LEAD); > + if (IS_ERR_OR_NULL(cpu_dev_gold)) > + return PTR_ERR(cpu_dev_gold); > + > + msm8996_version = qcom_cpufreq_kryo_get_msm_id(); > + if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { > + dev_err(cpu_dev_silver, "Not Snapdragon 820/821!"); > + return -ENODEV; > + } > + > + np = dev_pm_opp_of_get_opp_desc_node(cpu_dev_silver); > + if (IS_ERR_OR_NULL(np)) same here. > + return PTR_ERR(np); > + > + if (!of_device_is_compatible(np, "operating-points-v2-kryo-cpu")) { > + ret = -ENOENT; > + goto free_np; > + } > + > + speedbin_nvmem = of_nvmem_cell_get(np, NULL); > + if (IS_ERR(speedbin_nvmem)) { > + ret = PTR_ERR(speedbin_nvmem); > + dev_err(cpu_dev_silver, "Could not get nvmem cell: %d\n", ret); > + goto free_np; > + } > + > + speedbin = nvmem_cell_read(speedbin_nvmem, &len); > + nvmem_cell_put(speedbin_nvmem); > + > + switch (msm8996_version) { > + case MSM8996_V3: > + versions = 1 << (unsigned int)(*speedbin); > + break; > + case MSM8996_SG: > + versions = 1 << ((unsigned int)(*speedbin) + 4); > + break; > + default: > + BUG(); > + break; > + } > + > + opp_silver = dev_pm_opp_set_supported_hw(cpu_dev_silver,&versions,1); > + if (IS_ERR(opp_silver)) { > + dev_err(cpu_dev_silver, "Failed to set supported hardware\n"); > + ret = PTR_ERR(opp_silver); > + goto free_np; > + } > + > + opp_gold = dev_pm_opp_set_supported_hw(cpu_dev_gold,&versions,1); > + if (IS_ERR(opp_gold)) { > + dev_err(cpu_dev_gold, "Failed to set supported hardware\n"); > + ret = PTR_ERR(opp_gold); > + goto free_opp_silver; > + } > + > + pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0); and this only returns ERR_PTR() on error. > + if (!IS_ERR_OR_NULL(pdev)) > + return 0; > + > + ret = PTR_ERR(pdev); > + dev_err(cpu_dev_silver, "Failed to register platform device\n"); > + dev_pm_opp_put_supported_hw(opp_gold); > + > +free_opp_silver: > + dev_pm_opp_put_supported_hw(opp_silver); > + > +free_np: > + of_node_put(np); > + > + return ret; > +} > +late_initcall(qcom_cpufreq_kryo_driver_init); > + > +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Kryo CPUfreq driver"); > +MODULE_LICENSE("GPL v2"); > -- > 1.9.1 -- viresh