From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_NEOMUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39BF9C10F0E for ; Wed, 10 Apr 2019 03:24:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08AC92133D for ; Wed, 10 Apr 2019 03:24:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NaJPYmBF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ij5G/oNb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08AC92133D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RLmhzWpSFA0L8KmRXUomxj5EA20w/F9NF6Uwxx2S/1k=; b=NaJPYmBFtOrXJp G0WDVTSSEv3qlmBxAtg2u5dMfZKiOMSYDaORBEPITL5OGMk3oV61fRS9WTFIuFZfvGBE4WeDKoYrW qQlmGvTPrfToWXFuSsJRc610VLYzh3hSgWfQtdt4C1sArLLnM5+9guHuPKDlbzPCY6nNG3BDfwGXF zGj8HK650YaBRR6/v4teSIbYr5UqKAOYKQ7z3f+KFVmT9kBRJOCkVDaQe45rR9e3EVNoHT6j7sXRW u5RzCGYA+O+Sn/ljnFBgvDVY1xJ05nzl0THZxR7urnSoNUEtLIoJTwN7E/pq18e59nc+krbH8MWKK JIu6D7N4k0n02MYyAIag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hE3qP-00060v-Jy; Wed, 10 Apr 2019 03:24:13 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hE3qM-00060X-PC for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2019 03:24:12 +0000 Received: by mail-pl1-x642.google.com with SMTP id a96so483882pla.6 for ; Tue, 09 Apr 2019 20:24:09 -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=fDaB7AQBQgFAqrLsrjcQE4bi+tzImk9oc4UlfpH5iRQ=; b=ij5G/oNb95eXSsD1S1NKcpDLAzxltRjzkS2vNxx91dTvZMCLJ8UGUYbYp8D/QOEzlt mFEM1HjvQcEddXUwos41AXju6J7szB6Q2piB/JoLbGyI149Mw7NIz838E/2kj4QPSJpK e8C7+1jFHlYUcsjVLZyLH5fWMyaImWWIMPmgigXgBah+v64bM5LkksDsEVolBoeQTc78 ckVyp/McmqDVAFuwEZkXRyRw/kpmnBkF90UDcZVCY+TiZ++PiRDJ1iCifzIF4hIIly6l aSdwrk8xITYyrySxD13fcKVdzufZ+5IhNQzXwZhwchRJ4Fzfmn25RtN62g4iG9Oz7izY 7xXg== 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=fDaB7AQBQgFAqrLsrjcQE4bi+tzImk9oc4UlfpH5iRQ=; b=F+YE2X85eUPgXL2q2J/wMyodbQZhrJEXhQBsllYGrDXdlK1Pk6DYUBG513KfqZl0cD u3adntT+DRvzCZLCcXkzIj2f2P2BVNurvoQP8FPkiGJj9KidkrZ9Jr9o0aeCsPrVuUQr gULLAuaSLZAtsS1nLOqnQTc8nCBDDXQJ4YxgBx60wd7MegJZPAzhnCFHvmjezRO5YAzu 8HRNlg5Nr6JUozLGFXiLnlaqfBM8Ug/RGaMMGHQxcRb41hPSyntK0sCsX7rsoBDqrqJq 9PU3s/xk2MCblt/2YDOL4ZrrAVJZfmqqJOG1ORQAz0XUzfvDKzyR6FZq9fj6THTDLjPP B9zQ== X-Gm-Message-State: APjAAAXAZlUGRlbQdWQXvlovM/eyUvqgfbICCpWMERD5TFCjnTsQ9TtX pfUbL+AOhd6/QArde7todHTfbw== X-Google-Smtp-Source: APXvYqy4WqxmeDHzZvbtNMMhHMZKHov4Nr0cvDcxQD92LS5by/92IhrsIw9zJiVxeD3QvXTnFVK+uQ== X-Received: by 2002:a17:902:184:: with SMTP id b4mr20220942plb.26.1554866649145; Tue, 09 Apr 2019 20:24:09 -0700 (PDT) Received: from localhost ([122.166.139.136]) by smtp.gmail.com with ESMTPSA id l10sm25158503pfc.46.2019.04.09.20.24.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 20:24:06 -0700 (PDT) Date: Wed, 10 Apr 2019 08:54:04 +0530 From: Viresh Kumar To: Yangtao Li Subject: Re: [PATCH v2 1/2] cpufreq: Add sunxi nvmem based CPU scaling driver Message-ID: <20190410032404.eskk4qxbsws6fbec@vireshk-i7> References: <20190409172558.18778-1-tiny.windzz@gmail.com> <20190409172558.18778-2-tiny.windzz@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190409172558.18778-2-tiny.windzz@gmail.com> User-Agent: NeoMutt/20180323-120-3dd1ac X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_202410_848688_56FA6415 X-CRM114-Status: GOOD ( 15.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, mark.rutland@arm.com, linux-pm@vger.kernel.org, maxime.ripard@bootlin.com, vireshk@kernel.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, sboyd@kernel.org, wens@csie.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, davem@davemloft.net, devicetree@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 09-04-19, 13:25, Yangtao Li wrote: > +static const struct sunxi_cpufreq_soc_data sun50i_h6_data = { > + .efuse_xlate = sun50i_efuse_xlate, > + .nvmem_mask = 0x7, > + .nvmem_shift = 5, > +}; > + > +static const struct of_device_id sunxi_cpufreq_match_list[] = { > + { .compatible = "allwinner,sun50i-h6", .data = &sun50i_h6_data }, > + {} > +}; > + > +static const struct of_device_id *sunxi_cpufreq_match_node(void) > +{ > + struct device_node *np; > + const struct of_device_id *match; > + > + np = of_find_node_by_path("/"); > + match = of_match_node(sunxi_cpufreq_match_list, np); > + of_node_put(np); > + > + return match; > +} > + Above code can be placed just above sunxi_cpufreq_init(), if you ... > +static int sunxi_cpufreq_nvmem_probe(struct platform_device *pdev) > +{ > + const struct sunxi_cpufreq_soc_data *soc_data; > + struct opp_table **opp_tables; > + const struct of_device_id *match; > + char name[MAX_NAME_LEN]; > + unsigned int cpu; > + u32 speed = 0; > + int ret; > + > + opp_tables = kcalloc(num_possible_cpus(), sizeof(*opp_tables), > + GFP_KERNEL); > + if (!opp_tables) > + return -ENOMEM; > + > + match = sunxi_cpufreq_match_node(); ... avoid this and ... > + soc_data = match->data; > + if (!soc_data) > + return -EINVAL; > + > + ret = sunxi_cpufreq_get_efuse(soc_data, &speed); > + if (ret) > + return ret; > + > + snprintf(name, MAX_NAME_LEN, "speed%d", speed); > + > + for_each_possible_cpu(cpu) { > + struct device *cpu_dev = get_cpu_device(cpu); > + > + if (NULL == cpu_dev) { > + ret = -ENODEV; > + goto free_opp; > + } > + > + opp_tables[cpu] = dev_pm_opp_set_prop_name(cpu_dev, name); > + if (IS_ERR(opp_tables[cpu])) { > + ret = PTR_ERR(opp_tables[cpu]); > + pr_err("Failed to set prop name\n"); > + goto free_opp; > + } > + } > + > + cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, > + NULL, 0); > + if (!IS_ERR(cpufreq_dt_pdev)) { > + platform_set_drvdata(pdev, opp_tables); > + return 0; > + } > + > + ret = PTR_ERR(cpufreq_dt_pdev); > + pr_err("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_prop_name(opp_tables[cpu]); > + } > + kfree(opp_tables); > + > + return ret; > +} > + > +static int sunxi_cpufreq_nvmem_remove(struct platform_device *pdev) > +{ > + struct opp_table **opp_tables = platform_get_drvdata(pdev); > + unsigned int cpu; > + > + platform_device_unregister(cpufreq_dt_pdev); > + > + for_each_possible_cpu(cpu) > + dev_pm_opp_put_prop_name(opp_tables[cpu]); > + > + kfree(opp_tables); > + > + return 0; > +} > + > +static struct platform_driver sunxi_cpufreq_driver = { > + .probe = sunxi_cpufreq_nvmem_probe, > + .remove = sunxi_cpufreq_nvmem_remove, > + .driver = { > + .name = "sunxi-cpufreq-nvmem", > + }, > +}; > + > +/* > + * Since the driver depends on nvmem drivers, which may return EPROBE_DEFER, > + * all the real activity is done in the probe, which may be defered as well. > + * The init here is only registering the driver and the platform device. > + */ > +static int __init sunxi_cpufreq_init(void) > +{ > + const struct of_device_id *match; > + int ret; > + > + match = sunxi_cpufreq_match_node(); > + if (!match) > + return -ENODEV; > + > + ret = platform_driver_register(&sunxi_cpufreq_driver); > + if (unlikely(ret < 0)) > + return ret; > + > + sunxi_cpufreq_pdev = platform_device_register_simple( > + "sunxi-cpufreq-nvmem", -1, NULL, 0); ... pass match->data as platform device's data here.. > + ret = PTR_ERR_OR_ZERO(sunxi_cpufreq_pdev); > + if (0 == ret) > + return 0; > + > + platform_driver_unregister(&sunxi_cpufreq_driver); > + return ret; > +} > +module_init(sunxi_cpufreq_init); > + > +static void __exit sunxi_cpufreq_exit(void) > +{ > + platform_device_unregister(sunxi_cpufreq_pdev); > + platform_driver_unregister(&sunxi_cpufreq_driver); > +} > +module_exit(sunxi_cpufreq_exit); > + > +MODULE_DESCRIPTION("Sunxi cpufreq driver"); > +MODULE_LICENSE("GPL v2"); > -- > 2.17.0 -- viresh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel