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: Eric Auger X-Patchwork-Id: 7473481 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 726779F71A for ; Fri, 23 Oct 2015 15:47:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 916532086D for ; Fri, 23 Oct 2015 15:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A00C1208A7 for ; Fri, 23 Oct 2015 15:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbbJWPrn (ORCPT ); Fri, 23 Oct 2015 11:47:43 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:34081 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbbJWPrl (ORCPT ); Fri, 23 Oct 2015 11:47:41 -0400 Received: by wikq8 with SMTP id q8so82732432wik.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=hois/mDu4nZgxEq0PXhrQMpz/00THSMg26crSyUVbi/qLs9SimZfWfKxe0e216luUs wljRibbptIsTo8VgefYkEL85vSi+Hhn6237OZqbmZj3Qnfb07jNmhfPFKbgW/HbOWf06 7u+9DS+Z+eqlDF+ND+XhLhMDwbFj3gEUoNbjFJqIgzjvHOW4hTO0vTept7fGci/eNzZJ 3RbJmEo3n437DrnjUzaCsGPpiNS/+x0OCrnSzsHEqm+3yW8VQ2VAcj+faZMVzFlznXzW 12rKqspR+o4KfG0yv+Pj+A/RSrQ6kEX3Xi/i6SvHAe/u/9NWXg0WXJ/g9HC9HpYhIkEl RpEA== X-Gm-Message-State: ALoCoQkEiSdXylRbYg9YIvHtolMck5MFNeytTkv/BSs3zPSzL1AR1wSnv3VjLbzwkUkcqXH6vsCG X-Received: by 10.180.77.7 with SMTP id o7mr5373174wiw.84.1445615260370; Fri, 23 Oct 2015 08:47:40 -0700 (PDT) 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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