From patchwork Tue Nov 3 18:12:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7546221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4314BEEA4 for ; Tue, 3 Nov 2015 18:15:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21DA020719 for ; Tue, 3 Nov 2015 18:15:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CB9720717 for ; Tue, 3 Nov 2015 18:14:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ztg5F-0005J1-W9; Tue, 03 Nov 2015 18:13:26 +0000 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ztg4h-0004wV-5w for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2015 18:12:53 +0000 Received: by wicfx6 with SMTP id fx6so74823048wic.1 for ; Tue, 03 Nov 2015 10:12:33 -0800 (PST) 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=AXPTJYhpU6umQ9uFu2QemzilfODabun75Nqs1iwznzjWfzKzaPMQYvSRKfU3eXOm7l Qf7QYgdjjSHhHdNjj7BmIvMPvgcAzJlP+ZEzTQtaR5oeYSF4+6FnnH19eMV0yVpuBzZi /e2mFbHGI6IURGunTGFi06C8xIU3ShUMnfuPUpgmbIqfuzxkcHGbEWAOrwzPsxX8ucBT ZnwoaJDKVcBMKiyGuTDnoSAi3j9sKHPYQ6mVByPNMIFFBOEPUcJbGY2jsZysBmkU+6Ks /lEloTxi5yo2xvq1AdiK4C+lDr7taqdtAqRWIOzCR3fp2+YTNIP3ksujzRRCS+EvQpED UH/w== 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=jSbuWJZ4rXi55Pn0og5S4nDtrq+0ogdKxn+oNaZZWprpYQO7TywlnQVSUAksZb4MvL R9lQltaOmbPhMjHphOA5+WAW/s93t82BSFbkmZDDKYunWy/Sduz1lYx0YINq9k5Njkx+ 2FPcElDm+q90lVUUNrU+O2tBlOQ3dL/oOCjMsnxTUN9gI48/xs73HSxDvofIyxBP8MtT vmaUIuyaGntYNn2ffgpoXs/1URfA6z7Ueh/kZ3/cjMkv9NBYdq3zAeyqPduE5j3Y5UH5 6JSmNaTQ5LfrnBkHx8QlBNU1QnmjENHyFsHeA2MiFLq12Ejfur37w6JF0k7MjsjBL7bo c/hQ== X-Gm-Message-State: ALoCoQnK/vzCBTFU1CXy363ab6Zh1MxHYQ6x76RRTUD9GEb8h6uXPxPDCy05dUUTX20biVyZ5vcR X-Received: by 10.194.84.4 with SMTP id u4mr30898577wjy.149.1446574353202; Tue, 03 Nov 2015 10:12:33 -0800 (PST) Received: from new-host-3.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id om1sm28830527wjc.2.2015.11.03.10.12.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Nov 2015 10:12:32 -0800 (PST) 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 Subject: [PATCH v6 5/8] vfio: platform: add compat in vfio_platform_device Date: Tue, 3 Nov 2015 18:12:16 +0000 Message-Id: <1446574339-1843-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446574339-1843-1-git-send-email-eric.auger@linaro.org> References: <1446574339-1843-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151103_101251_461706_9C9E0C09 X-CRM114-Status: GOOD ( 15.29 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, christoffer.dall@linaro.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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