Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp637057imm; Wed, 23 May 2018 03:05:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqzMcfoA1OrShSYuKqwTZtBT6FVm+LYhv5bWuUrYCFY35rYSQyfMW71lSm2K5PWnZxpPU/6 X-Received: by 2002:a62:8d51:: with SMTP id z78-v6mr2232121pfd.69.1527069946774; Wed, 23 May 2018 03:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527069946; cv=none; d=google.com; s=arc-20160816; b=oLgfW7km1rp6jR+K4pDYALeqJkLb2+SI5pVokdnzLQoRYs3TfhFryFQ1ehytsLyeQ2 Q3aVjCnbVZSsfJZycTgYYaJ/0L7NWF5eCfSISLcctEBFN9OCNDxReAbAu1/vo0EnC3XL GYK8m15ZodWRdQa01jwunT1ceWSYSEoArz/xXM8oJVjrU4ybwO+l26A3NVoqZAE9g+FL MQRM1a/0oMOeFfQ5ACoKlAAG76KnFzGuriJNTrmm0EkBP0/T7TFdzHunGRwXw9gGkFym lDbUbWgAB+Tr8BZD+NLMmCusdqPGHMWCXDwQDt6qr8wDjcaPpn4EB37hRZmiztHv6Mi+ b4Gg== 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=ApnjMPCHKMSm5b31DR18RE1xfR0fvkWInmrs7KAVKq8=; b=rVIMsJTMkvbuQZgvRs+lEXHw2TkXUtecjpx0mctHLiN1AHQ9ARD+N+W+8ydqHzaVES ROvRSJ3iVtjD1skIMtXRxuUG8GkcoOykC8TQ9/pG7jOxgz4TVDSgZuNMRZHEOSnwuMQd XzCJO2nM2LJp8xEt4MMBd4O5EsM8RsdTIQPvQFjb7ohJkc7fu/S3i/bFQJJjBNN0M7Um Yej7vGLw4JecSNLasWJRfNNsUe/duExMduoRwPVZcHSF0xLEdDN1sUJj6Bk4FbQx7Arl j93/eaZSWzFpn7MYyA6E7nRiNyZ9+X3lBqTGQzignftB+EhjJh9Z16m+FJYPhO0b+13p nwDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k2zHTCal; 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 q66-v6si18346178pfi.235.2018.05.23.03.05.32; Wed, 23 May 2018 03:05:46 -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=k2zHTCal; 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 S932357AbeEWKDX (ORCPT + 99 others); Wed, 23 May 2018 06:03:23 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:44786 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932228AbeEWKDT (ORCPT ); Wed, 23 May 2018 06:03:19 -0400 Received: by mail-pg0-f68.google.com with SMTP id c22-v6so8527974pgn.11 for ; Wed, 23 May 2018 03:03:19 -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=ApnjMPCHKMSm5b31DR18RE1xfR0fvkWInmrs7KAVKq8=; b=k2zHTCalrrMVqvzCtKEKiQq4rroDdluuLEfQ5EtlyUOIjrVfzUdqQXPfnB/ZixmriG a1CTYL5x1IuzggyYieVT6DAmiqqU9ZWjhZ3Ctv6JxzvHpZpZR3gFO4mWa0xfCrlQwBZ7 FF7FSDuLdr8+MIJHBp8uQ/vhlScRH4pPhWk9A= 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=ApnjMPCHKMSm5b31DR18RE1xfR0fvkWInmrs7KAVKq8=; b=ktGMHYnHGOax9IHKiBlPV7KvmoNt6sIO6Zls3FUg5fM5FBZ13QXhQ8z0mA6U65iGjq rXIwBP6Qu0Bkw/D5ktTT6iKuBqpGVrNINFbsiYKZhHcDMKOlxC10bt5JNw7VMHn0LH+M kRx5Ncp6u7kGiuTXMBWlZSCztKlZ7a8PFYIA/fOzLICETG2yQRxNQvRMRUUyF7o4l9WU mTZtYoM8Afi0EmP7xMNioFW8nIop7OHjMlR+66ySUEJDjlJ16MGp7ljGQHV9Dh7IP/Pi zBeQ1rIwbvHJnWiVAEnG8oFjmVI2bE22HWkQqTyhEnDjv7W6NDiZWrKdBUKPyk0kN78P 7YIg== X-Gm-Message-State: ALKqPweOViUI2G0cRHIwOCvrpZDcDNykMJeu8ulq9um1Dg3DxkZFnYAe EHhrqS2832Buh5yLbkGXcN/yTg== X-Received: by 2002:a63:69c3:: with SMTP id e186-v6mr1777274pgc.353.1527069799339; Wed, 23 May 2018 03:03:19 -0700 (PDT) Received: from localhost ([122.167.129.138]) by smtp.gmail.com with ESMTPSA id 5-v6sm33742629pfx.140.2018.05.23.03.03.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 03:03:18 -0700 (PDT) Date: Wed, 23 May 2018 15:33:16 +0530 From: Viresh Kumar To: Ilia Lin Cc: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, robh@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 1/2] cpufreq: Add Kryo CPU scaling driver Message-ID: <20180523100316.27m4epl7deitfrnt@vireshk-i7> References: <1527068454-28921-1-git-send-email-ilialin@codeaurora.org> <1527068454-28921-2-git-send-email-ilialin@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527068454-28921-2-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 On 23-05-18, 12:40, Ilia Lin wrote: > In Certain QCOM SoCs like apq8096 and msm8996 that have KRYO processors, > the CPU frequency subset and voltage value of each OPP varies > based on the silicon variant in use. Qualcomm Process Voltage Scaling Tables > defines the voltage and frequency value based on the msm-id in SMEM > and speedbin blown in the efuse combination. > The qcom-cpufreq-kryo driver reads the msm-id and efuse value from the SoC > to provide the OPP framework with required information. > This is used to determine the voltage and frequency value for each OPP of > operating-points-v2 table when it is parsed by the OPP framework. > > Signed-off-by: Ilia Lin Well I gave you an Ack and you should have kept it here :( > +static int __init qcom_cpufreq_kryo_driver_init(void) > +{ > + struct opp_table *opp_tables[NR_CPUS] = {0}; > + enum _msm8996_version msm8996_version; > + struct nvmem_cell *speedbin_nvmem; > + struct platform_device *pdev; > + struct device_node *np; > + struct device *cpu_dev; > + unsigned cpu; > + u8 *speedbin; > + u32 versions; > + size_t len; > + int ret; > + > + cpu_dev = get_cpu_device(0); > + if (NULL == cpu_dev) > + return -ENODEV; > + > + msm8996_version = qcom_cpufreq_kryo_get_msm_id(); > + if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { > + dev_err(cpu_dev, "Not Snapdragon 820/821!"); > + return -ENODEV; > + } > + > + np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); > + if (IS_ERR(np)) > + return PTR_ERR(np); > + > + if (!of_device_is_compatible(np, "operating-points-v2-kryo-cpu")) { > + ret = -ENOENT; > + goto free_np; As Russell pointed out, drop this goto here and write: of_node_put(np); return -ENOENT; } > + } > + > + speedbin_nvmem = of_nvmem_cell_get(np, NULL); And do the same here unconditionally as you don't need to use np anymore, i.e. of_node_put(np); > + if (IS_ERR(speedbin_nvmem)) { > + ret = PTR_ERR(speedbin_nvmem); > + dev_err(cpu_dev, "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; > + } > + > + for_each_possible_cpu(cpu) { > + cpu_dev = get_cpu_device(cpu); > + if (NULL == cpu_dev) { > + ret = -ENODEV; > + goto free_opp; > + } > + > + opp_tables[cpu] = dev_pm_opp_set_supported_hw(cpu_dev, > + &versions, 1); > + if (IS_ERR(opp_tables[cpu])) { > + ret = PTR_ERR(opp_tables[cpu]); > + dev_err(cpu_dev, "Failed to set supported hardware\n"); > + goto free_opp; > + } > + } > + > + pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0); > + if (!IS_ERR(pdev)) > + return 0; > + > + ret = PTR_ERR(pdev); > + dev_err(cpu_dev, "Failed to register platform device\n"); > + > +free_opp: > + for_each_possible_cpu(cpu) { > + if (IS_ERR_OR_NULL(opp_tables[cpu])) > + break; > + dev_pm_opp_put_supported_hw(opp_tables[cpu]); > + } > +free_np: > + of_node_put(np); And then you can remove the label and above statement. > + > + 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