Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5008267imm; Tue, 12 Jun 2018 00:39:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIjClblNgcJbrcAi8X48umpnnLOWFtmi6H/ETiomfC2rbd3dQ6ShKgGuUtYt4RWrBEYy+VZ X-Received: by 2002:a62:3c15:: with SMTP id j21-v6mr2661490pfa.7.1528789192939; Tue, 12 Jun 2018 00:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528789192; cv=none; d=google.com; s=arc-20160816; b=aSnXVAyKxT13J2WQBWjmuByv9u2609wglcMIOks7ydoNddqeVzITUCWYlXBokd9ha5 gqDXveYsAYU4MA0ihaJ7McLkIV9ssQl0IQAAJcxpbH0ivNtSM2vxlwbF3ku/QzBlQPWW BXjKp3KN6rj3fWFd1ZcfOYFr8OutbVktqa2rFkmDqcan6gRx89ScYJ8XyVgKZBW1g2+B lmeYKkqPay38dNs3fST3ziw1IWFqnSAc4AccSEoE1SYyXpneo21dbv/EP3O91vCI5gKG nA8UzAPuYHHO8OecCD/mePQr8BiGLGUvqG25DbSmr0+9oME039rwKfLvioChxiYBewop KLhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=LyL49EB3rTTx7ntP4Mea49HKY5BzLbJOFBp8jPFPBAA=; b=1DCTdJRtGl23udFwnBy6LdJamnxBX8a7UMC8b5+cX6h+t1CzFEXktEYWAQDzfOX43v h5CO0j12ox80qANQ+U+M/DPzHoCXPCSybNxvy3FLurcXGpqIKFvGTn+bsW583yiOeagV TJ+ugTewNJtAphV7y3NpXcoBanBCUaSwvNYxcDSXrckC6ZLcIF1FLxG450BLa6L/NeIz 0JRuHDkgSRcOS7OUdrSUmLAhWTKVTH7SG+QebaOQZtvHdUyyllRj9q5DBx2fZTrjgwl9 8W79ItQMs3APCTg+yq48OOIKmaN/2KsmusN5Tw6U+VgMdzl6UQ37wQcDcQ2I/yXb4FzM VIyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1CE2PMi; 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 m2-v6si237704pgs.349.2018.06.12.00.39.38; Tue, 12 Jun 2018 00:39:52 -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=L1CE2PMi; 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 S933327AbeFLHjL (ORCPT + 99 others); Tue, 12 Jun 2018 03:39:11 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:45517 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933243AbeFLHjJ (ORCPT ); Tue, 12 Jun 2018 03:39:09 -0400 Received: by mail-io0-f195.google.com with SMTP id l25-v6so26900262ioh.12 for ; Tue, 12 Jun 2018 00:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LyL49EB3rTTx7ntP4Mea49HKY5BzLbJOFBp8jPFPBAA=; b=L1CE2PMi0uLhKu83cNtA4K+uTT0dTzQfCg/PFEzCE9cKtJzewd1bcnDqg4UFiVzgaf 0ViadJMq6yReqWzIBK1CTeVPa3qxmHN7MOgI9LOf3mRZXRchO5f7JRhXXXvggN07/QHo 6M/99A3OoL5mkT2p0Z9CcMuax0dau1XYXCWco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LyL49EB3rTTx7ntP4Mea49HKY5BzLbJOFBp8jPFPBAA=; b=dyIPkFN1aidDZqRPHzlExt4FOA4NKlEZnFA8XZAdKPCqJe+XgGE9P/dGFcQC+UkefT OkOx+UzwFstbtdRBtR5toqPoDhtxqdxYU5itkjHEYfXUe2RoXZ7G6+hqlW5e1mhg2VU3 4U2bJ4RCArLY+jubjIWbTEeJIy/4lvMoOK9PwcVOUC5LMqAJsjTKwVo0HT8FxYi14cqm BRXr6LcUA0ljLRk7SPoFI0oK+nFKoUcDRniMJe1/Nk1M41pWz/9erjz84bzt66f+zC6i VMgOKo2iRh27vPhieP+zPIPcgnpK7H6ROCUHD5NO5qoMunY4gWCmPcDi08TpDhLFKN8D 9gSw== X-Gm-Message-State: APt69E0r0aX6IJ3/44ox9Xm61ZQ566L0m/HWaRWRgTzh3ekRSX/ap3oZ nZfGiTMhJ/lFcbvAcNgz2xXGT3VbbCDM2nps72VndA== X-Received: by 2002:a6b:1410:: with SMTP id 16-v6mr2211774iou.218.1528789149203; Tue, 12 Jun 2018 00:39:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:c054:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 00:39:08 -0700 (PDT) In-Reply-To: <20180612044052.4402-3-rnayak@codeaurora.org> References: <20180612044052.4402-1-rnayak@codeaurora.org> <20180612044052.4402-3-rnayak@codeaurora.org> From: Ulf Hansson Date: Tue, 12 Jun 2018 09:39:08 +0200 Message-ID: Subject: Re: [PATCH v3 2/7] soc: qcom: rpmpd: Add a Power domain driver to model corners To: Rajendra Nayak Cc: Viresh Kumar , Stephen Boyd , Andy Gross , collinsd@codeaurora.org, devicetree@vger.kernel.org, linux-arm-msm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > +static int rpmpd_probe(struct platform_device *pdev) > +{ > + int i; > + size_t num; > + struct genpd_onecell_data *data; > + struct qcom_smd_rpm *rpm; > + struct rpmpd **rpmpds; > + const struct rpmpd_desc *desc; > + > + rpm = dev_get_drvdata(pdev->dev.parent); > + if (!rpm) { > + dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n"); > + return -ENODEV; > + } > + > + desc = of_device_get_match_data(&pdev->dev); > + if (!desc) > + return -EINVAL; > + > + rpmpds = desc->rpmpds; > + num = desc->num_pds; > + > + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains), > + GFP_KERNEL); > + data->num_domains = num; > + > + for (i = 0; i < num; i++) { > + if (!rpmpds[i]) { > + dev_warn(&pdev->dev, "rpmpds[] with empty entry at index=%d\n", > + i); > + continue; > + } > + > + rpmpds[i]->rpm = rpm; > + rpmpds[i]->pd.power_off = rpmpd_power_off; > + rpmpds[i]->pd.power_on = rpmpd_power_on; > + pm_genpd_init(&rpmpds[i]->pd, NULL, true); > + > + data->domains[i] = &rpmpds[i]->pd; > + } > + > + return of_genpd_add_provider_onecell(pdev->dev.of_node, data); > +} > + > +static int rpmpd_remove(struct platform_device *pdev) > +{ > + of_genpd_del_provider(pdev->dev.of_node); In principle what you need, additionally to the above, is something like this: while (!IS_ERR(of_genpd_remove_last(pdev->dev.of_node)); Then in the ->probe() function, use dev_set_drvdata() to store the pointers for the allocated data, such you can use dev_get_drvdata() to get them back here to kfree() them. However, running the ->remove() path for this driver doesn't really make sense. As we can't remove a genpd that has devices attached to it anyways. Perhaps make this a built in driver, if possible? [...] Reviewed-by: Ulf Hansson Kind regards Uffe