From patchwork Wed Oct 28 13:02:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 55673 Delivered-To: patches@linaro.org Received: by 10.112.61.134 with SMTP id p6csp106349lbr; Wed, 28 Oct 2015 06:03:05 -0700 (PDT) X-Received: by 10.180.76.240 with SMTP id n16mr2611820wiw.11.1446037378160; Wed, 28 Oct 2015 06:02:58 -0700 (PDT) Return-Path: Received: from mail-wi0-x22f.google.com (mail-wi0-x22f.google.com. [2a00:1450:400c:c05::22f]) by mx.google.com with ESMTPS id ce3si6194009wib.67.2015.10.28.06.02.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Oct 2015 06:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c05::22f as permitted sender) client-ip=2a00:1450:400c:c05::22f; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c05::22f as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by wicll6 with SMTP id ll6so11668611wic.1 for ; Wed, 28 Oct 2015 06:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NH6A1ghj1g05g5CwpfKe1ICLYf2OjeUugPiL71Gv/Uc=; b=Vdvll4kDsbVRe0BcQUPFpwe2AGAVoLEX+vnS71IYAAAb4NwqWl2akmuMEx4YffOUnb tfUPOpFqvvA23tLGsXyWafC9CMCuKgFXNfh4b/TNl9bPhns/jOOIujQ3yII9HcnP/Wha HmpYpMWbKJgAXW0G2kaHDWGhzdvawh4XY9bksMS9aA2OG7SIdrNj8huMWwg1WTfZaYFv HbiMDqNcWhVZJm36sdBuxky0VFZo4CftM6ALSpgQRARNLJ4cADBR6FiB9Wt45XgW5bT1 pYzU0LznHHgF7sXpinLFdl6ue7tknhseyWKLKyHVDNTvvHzMFemJD11P6Fs6pwD7Rj91 /gCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NH6A1ghj1g05g5CwpfKe1ICLYf2OjeUugPiL71Gv/Uc=; b=VcObZiYPVkDLuMPAFXbOnl7GUx54UOyIl7XaHsQ0vl8YHv/i0mERqKezSL4xEgpZOV 1BKCzSGponigI3E5u3UXhcdbtxEGnpYeFzfHiloztV4TupwJ7g6VeUYNz4uSZtvL4ZUm 7XuG24NqH2NnUkWxQ5r73pnz3EwZk0GwzL0kFxp4IaExTTcgd/LYWiebmMf7OXJMnkMz Z9xJx3nM9KI1ofhCiOtTzZfzBILWAUZs8VFlY8rP5+IEzlYLl6kK/9WY0vUjrN0TXCE+ IPejqC4LWmia9eJqFU1b/mUEtzmDLIoCZI/jQgeyakMruLRrNWzG+UtH/oUUw8XeYLYM rD0w== X-Gm-Message-State: ALoCoQklOv2eEMv+UF6ZTGVPZUzK+wkY0Oo15cIpDfyxhNvmJOIXe5MJrZJzLa2m+WxVQ0U52nfH X-Received: by 10.194.2.5 with SMTP id 5mr61255878wjq.153.1446037377966; Wed, 28 Oct 2015 06:02:57 -0700 (PDT) Return-Path: Received: from new-host-2.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id gl9sm49894196wjb.10.2015.10.28.06.02.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 06:02:56 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v5 5/7] vfio: platform: add compat in vfio_platform_device Date: Wed, 28 Oct 2015 13:02:36 +0000 Message-Id: <1446037358-2079-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446037358-2079-1-git-send-email-eric.auger@linaro.org> References: <1446037358-2079-1-git-send-email-eric.auger@linaro.org> Let's retrieve the compatibility string on probe and store it in the vfio_platform_device struct Signed-off-by: Eric Auger --- v2 -> v3: - populate compat after vdev check --- drivers/vfio/platform/vfio_platform_common.c | 15 ++++++++------- drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 3b7e52c..f2d41a0 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -41,16 +41,11 @@ static const struct vfio_platform_reset_combo reset_lookup_table[] = { static void vfio_platform_get_reset(struct vfio_platform_device *vdev, struct device *dev) { - const char *compat; int (*reset)(struct vfio_platform_device *); - int ret, i; - - ret = device_property_read_string(dev, "compatible", &compat); - if (ret) - return; + int i; for (i = 0 ; i < ARRAY_SIZE(reset_lookup_table); i++) { - if (!strcmp(reset_lookup_table[i].compat, compat)) { + if (!strcmp(reset_lookup_table[i].compat, vdev->compat)) { request_module(reset_lookup_table[i].module_name); reset = __symbol_get( reset_lookup_table[i].reset_function_name); @@ -544,6 +539,12 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, if (!vdev) return -EINVAL; + ret = device_property_read_string(dev, "compatible", &vdev->compat); + if (ret) { + pr_err("VFIO: cannot retrieve compat for %s\n", vdev->name); + return -EINVAL; + } + group = iommu_group_get(dev); if (!group) { pr_err("VFIO: No IOMMU group for device %s\n", vdev->name); diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index fd262be..415310f 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -57,6 +57,7 @@ struct vfio_platform_device { int refcnt; struct mutex igate; struct module *parent_module; + const char *compat; /* * These fields should be filled by the bus specific binder