From patchwork Fri Oct 23 15:47:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 55498 Delivered-To: patches@linaro.org Received: by 10.55.75.214 with SMTP id y205csp1169991qka; Fri, 23 Oct 2015 08:48:42 -0700 (PDT) X-Received: by 10.194.234.70 with SMTP id uc6mr5545086wjc.42.1445615260582; Fri, 23 Oct 2015 08:47:40 -0700 (PDT) Return-Path: Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com. [209.85.212.169]) by mx.google.com with ESMTPS id w6si5744581wia.98.2015.10.23.08.47.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2015 08:47:40 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.169 as permitted sender) smtp.mailfrom=eric.auger@linaro.org Received: by wicfx6 with SMTP id fx6so37063479wic.1 for ; Fri, 23 Oct 2015 08:47:40 -0700 (PDT) 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=m+Ik/eenL4I462gQu0Cq3iYQcwFgKfo/RrNt734nWWBhgUj7Lwrg96V0lvoPT3+gsV n493aCCwJIUI3IWpBdeFspeqUGWO9p1qHEdYjcK8SxfwmLAcz0LUvxQ/jz4MPcs8yQAm 3MLFiAeDefeVVRovVG8DYnkZo+1kl+76PyKoMFmmdeHtcjfhx7Wb5CkF2yjpYxHmWepW 6b1mmqIQvEMbhTLsfYaITeGZYeUc1m0tU983hsfz0d6mJ9E/Pq1K7AEZ+Ho0qeVfy01y cHDMw6WIiNeaQMETGjQFJgMxtVQVNJITNGFan0zaFukl3Xcqhnv6dYO/2Fn9OVV8M4HA PEUw== X-Gm-Message-State: ALoCoQmd2ZafIaBmxvcKzjSR4PHzfqlfRwgJ/2R/DydaYN4A4oFv+5bzia5g29cyCh9E1rWxjAyd X-Received: by 10.180.77.7 with SMTP id o7mr5373174wiw.84.1445615260370; Fri, 23 Oct 2015 08:47:40 -0700 (PDT) Return-Path: Received: from gnx2579.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id i3sm3388471wij.9.2015.10.23.08.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2015 08:47:39 -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 v4 5/7] vfio: platform: add compat in vfio_platform_device Date: Fri, 23 Oct 2015 17:47:23 +0200 Message-Id: <1445615245-31124-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445615245-31124-1-git-send-email-eric.auger@linaro.org> References: <1445615245-31124-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