From patchwork Thu Oct 22 09:42:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7464141 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 E49B09F1C3 for ; Thu, 22 Oct 2015 09:44:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC19520996 for ; Thu, 22 Oct 2015 09:44:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 097142085C for ; Thu, 22 Oct 2015 09:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757238AbbJVJoL (ORCPT ); Thu, 22 Oct 2015 05:44:11 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36159 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752443AbbJVJmQ (ORCPT ); Thu, 22 Oct 2015 05:42:16 -0400 Received: by wicfx6 with SMTP id fx6so127282226wic.1 for ; Thu, 22 Oct 2015 02:42:15 -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=sIi9SbbIo46c53gx2eQLrYqxW65Og5G2PI3y+hsSdrE=; b=OmEwYUapvzWQZirWRcF99Duzhdvu59KwGZtHBmSFvuc9lLZ0GRvUWAyY91B9kgjHNk 0MTbYslY1SViBw+NjDD0XETId7jpBWk+FDh8L5LTvPpi7TrkrWlcPx/1r+WmYa11/Tdl 9QKC92bbrKk31jc5+D3qN7T34Sa76X24YihcC14CcoMCxj67SUjay5znGqFtLrCeUN7h BoZgt1kTu16dniR/iwuxf3O+RQkXD82jiuLUc84nOaxMmNa4tKZKCmxFwVSEBnOvn1jj 4OUrHmZ+/MrzFuhXWRPNw1A0iYTJBy3uT+wfkb4/E4qxyxUowYBCwtuE2vBA/gNclUVw tNZg== X-Gm-Message-State: ALoCoQn1mu7tnC8ygRHp7gEGlxq/u5c1+P7DcfLvDYuOhKpRnqC4lFgJCWFRP+xoYRKwx3RWdwLa X-Received: by 10.194.118.102 with SMTP id kl6mr15712510wjb.29.1445506935030; Thu, 22 Oct 2015 02:42:15 -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 lr6sm9376859wic.3.2015.10.22.02.42.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 02:42:14 -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 v2 4/6] vfio: platform: add compat in vfio_platform_device Date: Thu, 22 Oct 2015 11:42:00 +0200 Message-Id: <1445506922-6005-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445506922-6005-1-git-send-email-eric.auger@linaro.org> References: <1445506922-6005-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=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 --- 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 52a4c7b..e7d615f 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -45,16 +45,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); @@ -545,6 +540,12 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, struct iommu_group *group; int ret; + ret = device_property_read_string(dev, "compatible", &vdev->compat); + if (ret) { + pr_err("VFIO: cannot retrieve compat for %s\n", vdev->name); + return -EINVAL; + } + if (!vdev) return -EINVAL; diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 1fb1410..620ee40 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -56,6 +56,7 @@ struct vfio_platform_device { u32 num_irqs; int refcnt; struct mutex igate; + const char *compat; /* * These fields should be filled by the bus specific binder