Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp630862ybz; Wed, 29 Apr 2020 06:41:49 -0700 (PDT) X-Google-Smtp-Source: APiQypLE2de1sJ3FcSQpE2CJELsqKk+vrBcM95paYjrBUEtzjqdwRrtmRmDtgNZirHXeQAZi8d3N X-Received: by 2002:a50:c60c:: with SMTP id k12mr2449910edg.111.1588167709300; Wed, 29 Apr 2020 06:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167709; cv=none; d=google.com; s=arc-20160816; b=OZefjJMAbRHP8obGMMIH4Gd7VtMzzujRKwvTK0hYyjTiDxtqf+eKLkp3EEOafASThs +GwNDN9QT+/xi5owbXb95BwL5nBLhUXPLE5KKJwbNACDe1tf9wLzzzlL4IU08tfd3GHj lQUkuID6DLwfqpuCd27pf5Q0U6vB8FLIWBvgzCohi6r1XAY/9NB90HZozbPGiHvICFi0 k8IcwcV9nQOehllODHJGvs9JUmH8EKsZ1KpTXKKNl+zEW1J48ZBbBbTIyfc2V4VXZLRs 3eclHq1HQS/IVoc3fqpzIVelq4fe1ZPkxiikAMubW+fSsRM82P2QbFtJDfRuA+7DOAte NBqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7jodlBtZnGAR7wEmBjwZjV6LwDmS5pFdoJFCuxWFHmY=; b=LVViUIIwZWvWTGFDAGXQ11gNj7yc3X3mil/rvsHBy2w9tN0sYWtTQiedQDNpeIyYw0 cypNoAF7wQv+/x2NnDwqMx5V0qf3gg9B9PAi6Qv7yJZywl0T+1EN31/3fWuka6S6TW9W XHGX16kaEjxqh93/V/enlxkZS+BSKHdpPcAbxBPQfWiHRselbTei3b3FyYHWpbrZ+93l MVpCC3FjN7Kg2+lby4SWADd2ALy941tD67uJ026DM2CudaFtj52geMa/shtijETghWTu sqdY0GOmbuJH75umKNSAe6N/GwM7bBH1HfWYuQ6urWDSY90kWrlDD+2sTjgA4EUhA2n3 xcfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gr24si3926102ejb.162.2020.04.29.06.41.25; Wed, 29 Apr 2020 06:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgD2NjY (ORCPT + 99 others); Wed, 29 Apr 2020 09:39:24 -0400 Received: from 8bytes.org ([81.169.241.247]:40166 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727997AbgD2Nhu (ORCPT ); Wed, 29 Apr 2020 09:37:50 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 49DCAEDB; Wed, 29 Apr 2020 15:37:39 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Jean-Philippe Brucker Cc: Daniel Drake , jonathan.derrick@intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: [PATCH v3 21/34] iommu/msm: Convert to probe/release_device() call-backs Date: Wed, 29 Apr 2020 15:36:59 +0200 Message-Id: <20200429133712.31431-22-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429133712.31431-1-joro@8bytes.org> References: <20200429133712.31431-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Convert the MSM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/msm_iommu.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index 94a6df1bddd6..10cd4db0710a 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -388,43 +388,23 @@ static struct msm_iommu_dev *find_iommu_for_dev(struct device *dev) return ret; } -static int msm_iommu_add_device(struct device *dev) +static struct iommu_device *msm_iommu_probe_device(struct device *dev) { struct msm_iommu_dev *iommu; - struct iommu_group *group; unsigned long flags; spin_lock_irqsave(&msm_iommu_lock, flags); iommu = find_iommu_for_dev(dev); spin_unlock_irqrestore(&msm_iommu_lock, flags); - if (iommu) - iommu_device_link(&iommu->iommu, dev); - else - return -ENODEV; - - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); - - iommu_group_put(group); + if (!iommu) + return ERR_PTR(-ENODEV); - return 0; + return &iommu->iommu; } -static void msm_iommu_remove_device(struct device *dev) +static void msm_iommu_release_device(struct device *dev) { - struct msm_iommu_dev *iommu; - unsigned long flags; - - spin_lock_irqsave(&msm_iommu_lock, flags); - iommu = find_iommu_for_dev(dev); - spin_unlock_irqrestore(&msm_iommu_lock, flags); - - if (iommu) - iommu_device_unlink(&iommu->iommu, dev); - - iommu_group_remove_device(dev); } static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) @@ -708,8 +688,8 @@ static struct iommu_ops msm_iommu_ops = { */ .iotlb_sync = NULL, .iova_to_phys = msm_iommu_iova_to_phys, - .add_device = msm_iommu_add_device, - .remove_device = msm_iommu_remove_device, + .probe_device = msm_iommu_probe_device, + .release_device = msm_iommu_release_device, .device_group = generic_device_group, .pgsize_bitmap = MSM_IOMMU_PGSIZES, .of_xlate = qcom_iommu_of_xlate, -- 2.17.1