Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp586457ybz; Wed, 15 Apr 2020 14:35:43 -0700 (PDT) X-Google-Smtp-Source: APiQypIEEQl7sH2BfHOz1qToWzY7+hChE5lpYD5lKjgmi6NUZjx1NuZPqShSiS6+5V4JIsRt6X3p X-Received: by 2002:aa7:d0c7:: with SMTP id u7mr13872744edo.206.1586986543035; Wed, 15 Apr 2020 14:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986543; cv=none; d=google.com; s=arc-20160816; b=UPn0g65RxvnEWb0DK5qa1KvvA1d7WXn3KebRCC0XWmmELorW+7W5K17YHQefKuZto9 L6tyozCzxLLPyC3dU7Z5pzNoUzNrDy4oMgWenQRZdjOMpasvQeB/GVTvjFe2Bq046ror 0+LF21i14MRyfg90xFulwpbF+VEpvAbybejJw2MGVsZUeIYfoLWipmhq4YptvoK8raCT mn6CisUUgk8OvIP9/oB5XBWoIXKiF8RE89zLX8w9a1i0oXbfQ9x/W0AomwbE1+D0B2hB x9bdd1Zk/1HT/7wPfPfwgK+pdyGRqWAQUjuw+fTJWRv92a1utqozw9fqx5KphwG0OYug CrbA== 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=tBM90ug8dReFUk/0mF17YDyp6x5pBNMkMLHmgIm7lsg=; b=VnqsfrpKEiMFjzKqyaHaFjE8sz1brW6DVi+C0/mHITniKffCFhpLIv8QacNk3K6sOv 4G0ExOW44BrCm8wRRqAZMQzGUIQwV68ryOxYJKhxcuMNlIqDTWpYkqNGORfdHXGU/MgQ GvFRUh9OXCLoYmVpZHKWfAfxBBMa6dO/hAAlO9/6PjkNPEPboutmEObH7wpiu1jw1Pk0 t04PXflB1c/zHXN7DDkI1KLY/nLiEClajySVJUqkdhmH6Grl3CDpOTqe9gIe99EWM51C CsJ6HZT2ruQQysTBrCG/1AKcDm/EMx9UoD7OMV6iF4WMYUQhFVb2Dk4YDmdgAzq00iwN rjiQ== 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 z90si4629134ede.477.2020.04.15.14.35.19; Wed, 15 Apr 2020 14:35:43 -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 S1731236AbgDNNVf (ORCPT + 99 others); Tue, 14 Apr 2020 09:21:35 -0400 Received: from 8bytes.org ([81.169.241.247]:35392 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502768AbgDNNQH (ORCPT ); Tue, 14 Apr 2020 09:16:07 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 3FB4A736; Tue, 14 Apr 2020 15:15:56 +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: 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 v2 25/33] iommu/rockchip: Convert to probe/release_device() call-backs Date: Tue, 14 Apr 2020 15:15:34 +0200 Message-Id: <20200414131542.25608-26-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200414131542.25608-1-joro@8bytes.org> References: <20200414131542.25608-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 Rockchip 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/rockchip-iommu.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index b33cdd5aad81..d25c2486ca07 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1054,40 +1054,28 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) kfree(rk_domain); } -static int rk_iommu_add_device(struct device *dev) +static struct iommu_device *rk_iommu_probe_device(struct device *dev) { - struct iommu_group *group; - struct rk_iommu *iommu; struct rk_iommudata *data; + struct rk_iommu *iommu; data = dev->archdata.iommu; if (!data) - return -ENODEV; + return ERR_PTR(-ENODEV); iommu = rk_iommu_from_dev(dev); - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); - iommu_group_put(group); - - iommu_device_link(&iommu->iommu, dev); data->link = device_link_add(dev, iommu->dev, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME); - return 0; + return &iommu->iommu; } -static void rk_iommu_remove_device(struct device *dev) +static void rk_iommu_release_device(struct device *dev) { - struct rk_iommu *iommu; struct rk_iommudata *data = dev->archdata.iommu; - iommu = rk_iommu_from_dev(dev); - device_link_del(data->link); - iommu_device_unlink(&iommu->iommu, dev); - iommu_group_remove_device(dev); } static struct iommu_group *rk_iommu_device_group(struct device *dev) @@ -1126,8 +1114,8 @@ static const struct iommu_ops rk_iommu_ops = { .detach_dev = rk_iommu_detach_device, .map = rk_iommu_map, .unmap = rk_iommu_unmap, - .add_device = rk_iommu_add_device, - .remove_device = rk_iommu_remove_device, + .probe_device = rk_iommu_probe_device, + .release_device = rk_iommu_release_device, .iova_to_phys = rk_iommu_iova_to_phys, .device_group = rk_iommu_device_group, .pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP, -- 2.17.1