Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1944415imm; Sun, 15 Jul 2018 22:13:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLw2R8Kg/W+SuvIuczX5OYIiYMjFy+dFjMOG353Ds7BAtXetu/eLx0uo391XZ7AoO84Jhu X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr16713168pfc.256.1531717989393; Sun, 15 Jul 2018 22:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531717989; cv=none; d=google.com; s=arc-20160816; b=xF5RRdywIdvnuABk4QHnKT03L1uBhkT9smBU5UM7mPNqxcvC4YJwy6K7XqAXiuvZ9c c7Lbdgnc2ZfMS/nJvJMzAJ1GASh5Vuwamltpecc7Y+BiFamu1eHYLAXxzW/C3zFzsacn SIyN83/65girUCCg7Ly7xn6lbltyAFAk7rbxxYwhF8QhZO7SQLVgbhsyYZJ2yGgYZsXI 5JMtT5tsqxRW/Y1HEpoyANhVivGVpK8b3zCG4kIDrFZ3+Dkv+WpHi2KVeKaE7Jux7/JV XeRdJilV7qePsCiE15mMPuNqHo5XSK+TBwFP+/K17t82COGlB1xESx2S2bCW6YC1zIQK 9Hzg== 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=QgkMnEFIxJGAje2UsBQPMQ+CWvoYqiNzv1pFlMeT8HQ=; b=aRzRNjD2WfDIXUM2tDngW4gCPXo61uTg1j6WImX75zDhNTYeaCbSBLWWKtg0bbZ8vd 079htAxdFWo5EWsvffBJOpDbo/jK/Vjwi8LOpc+6cjeeAniuHLQho6o46wp3/vVtSRg4 mgMQauWBDW+khoSkH0eP20+cEwATLpwDN0DXuGFnogCXe+Pft628au3alTGmFX9SSJdm soOnZ0kYZcfibsz/A+Zr8pxTQgGlJL2KlsrZQ8UTm1Ffn1W0Kia6c/AKHrnRU1eDOB5c /MPcN+5zFj6UFSiZFa6xvI3i/4MLdduGutCP+6rbj91P8UDBgAkLveoseKcsZBe9xj+N QH9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LM3k4IiQ; 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 o22-v6si2690417pgk.534.2018.07.15.22.12.54; Sun, 15 Jul 2018 22:13:09 -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=LM3k4IiQ; 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 S1727298AbeGPFh4 (ORCPT + 99 others); Mon, 16 Jul 2018 01:37:56 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45673 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbeGPFhz (ORCPT ); Mon, 16 Jul 2018 01:37:55 -0400 Received: by mail-pf0-f195.google.com with SMTP id i26-v6so14293046pfo.12 for ; Sun, 15 Jul 2018 22:12:22 -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=QgkMnEFIxJGAje2UsBQPMQ+CWvoYqiNzv1pFlMeT8HQ=; b=LM3k4IiQLn9/Z83NtCuYPKzdH/6S7TBi+yQW04HtoYVGe+dqTxS/fEw3tdB8sZTSZL bKUizRlWWy/kQn5UGtRKaip035f7wsNmHP8HXdvpkwxsIXSI+EG2AZhL8JisLa28eofI SDCFSyvgjzqGr5KnDYBGTJawKnOJmdXwNuV2k= 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=QgkMnEFIxJGAje2UsBQPMQ+CWvoYqiNzv1pFlMeT8HQ=; b=iuX7GyG7blkr6Dmy/k2jPha07lRb7ZBNrjHJhp1l2uzU0yHYUNQxm9CEX9a8FkV0iY 6AK96IUWZN6dCmXpWuXcSNClbJo3YObSDw2zRJmSa8GxOHsce8p942QvYUfaVLO6fGgW 2yJ2DUf8XiZbcPmvxACM2ZW5OzlLhjU6edo55CSIjtJXrL3JQTkJL5P6+acEo9/WwRyh 7FIJplryJDUw0DJ/MI8HFIIl3P5RmeuUXwrwx8blidhyDF7SclY6aaPRfrx5o2X0Z6cb gGc4gGy8woDCZZJUkGZXv8TxhZd/BEcuL49zq/MF+kFdCJFDltA+ZAmcE9Hn6+c5fGbw QzZg== X-Gm-Message-State: AOUpUlFFV/jPEbnhwgpfLNBSZVzcrUAUPnia/66pIpT+vq/aaio2/7A7 u9RC/YDHJDBucNML1Tm32PyJmw== X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr13252094pgv.307.1531717941736; Sun, 15 Jul 2018 22:12:21 -0700 (PDT) Received: from localhost ([122.171.235.75]) by smtp.gmail.com with ESMTPSA id s90-v6sm36204890pfa.178.2018.07.15.22.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jul 2018 22:12:21 -0700 (PDT) Date: Mon, 16 Jul 2018 10:42:19 +0530 From: Viresh Kumar To: Taniya Das Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Stephen Boyd , Rajendra Nayak , Amit Nischal , devicetree@vger.kernel.org, robh@kernel.org, skannan@codeaurora.org, amit.kucheria@linaro.org, evgreen@google.com Subject: Re: [PATCH v5 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver Message-ID: <20180716051219.36rdvxux3lz3rjed@vireshk-i7> References: <1531418745-19742-1-git-send-email-tdas@codeaurora.org> <1531418745-19742-3-git-send-email-tdas@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1531418745-19742-3-git-send-email-tdas@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 12-07-18, 23:35, Taniya Das wrote: > +static int qcom_cpu_resources_init(struct platform_device *pdev, > + struct device_node *np, unsigned int cpu) > +{ > + struct cpufreq_qcom *c; > + struct resource res; > + struct device *dev = &pdev->dev; > + unsigned int offset, cpu_r; > + int ret; > + > + c = devm_kzalloc(dev, sizeof(*c), GFP_KERNEL); > + if (!c) > + return -ENOMEM; > + > + c->reg_offset = of_device_get_match_data(&pdev->dev); > + if (!c->reg_offset) > + return -EINVAL; > + > + if (of_address_to_resource(np, 0, &res)) > + return -ENOMEM; > + > + c->base = devm_ioremap(dev, res.start, resource_size(&res)); > + if (!c->base) { > + dev_err(dev, "Unable to map %s base\n", np->name); > + return -ENOMEM; > + } > + > + offset = c->reg_offset[REG_ENABLE]; > + > + /* HW should be in enabled state to proceed */ > + if (!(readl_relaxed(c->base + offset) & 0x1)) { > + dev_err(dev, "%s cpufreq hardware not enabled\n", np->name); > + return -ENODEV; > + } > + > + ret = qcom_get_related_cpus(np, &c->related_cpus); > + if (ret) { > + dev_err(dev, "%s failed to get related CPUs\n", np->name); > + return ret; > + } > + > + c->max_cores = cpumask_weight(&c->related_cpus); > + if (!c->max_cores) > + return -ENOENT; > + > + ret = qcom_read_lut(pdev, c); > + if (ret) { > + dev_err(dev, "%s failed to read LUT\n", np->name); > + return ret; > + } > + > + qcom_freq_domain_map[cpu] = c; > + > + /* Related CPUs to keep a single copy */ > + cpu_r = cpumask_first(&c->related_cpus); > + if (cpu != cpu_r) { > + qcom_freq_domain_map[cpu] = qcom_freq_domain_map[cpu_r]; > + devm_kfree(dev, c); > + } Sorry about missing this, you have actually worked on my comments. But I think this isn't the clever way of doing it. You allocate the structures, fill everything and then finally free them because we were related. Why can't we have similar check at the top of this routine and skip everything then ? -- viresh