From patchwork Sun Oct 18 16:00:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 55176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 3EB2E22F11 for ; Sun, 18 Oct 2015 16:00:44 +0000 (UTC) Received: by wibhd5 with SMTP id hd5sf530302wib.0 for ; Sun, 18 Oct 2015 09:00:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=VX6qqein7kVLHp58/0CSn5idIaxf8UVt2YALWh9PzK0=; b=mD69Jpqwk8ltD6TyMcQdQgrysAZmicLMq6MEESfZA/RqWxgb8nY9a6eI/Da4+KBLsi e7ofT/4V1W26u9DbMYRt7g/N2gtrAzppekMej2k1Oz8cgWeHUAakW116xh5VHnzzYJNd epK9q55AzzCIzHumkbcGY5Ae/JPGdtfLN0+DhC4m0SA+VoRKu53CQHtW6Q1UPfhdCzi7 73nO9QpsebZERFmYuySGaIgyiefkFlHLDjDUqlp3Wuf29pyEd6d6urho42sUsHSuUyRt F62IIqVc8roext/EY9LYgBsVAA1ADq0lqZ/bYpLo4XksM9DuyVrmx8ackpGIUgCQaFus jJDA== X-Gm-Message-State: ALoCoQlLXoc4d8Z9S871QmDwi+acQWCCjWJUt80HDlClwPqNHZAbcnBJH+T/zF6KO2fB87JWWubr X-Received: by 10.112.150.229 with SMTP id ul5mr5936333lbb.2.1445184043223; Sun, 18 Oct 2015 09:00:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.43.135 with SMTP id r129ls505331lfr.93.gmail; Sun, 18 Oct 2015 09:00:43 -0700 (PDT) X-Received: by 10.25.22.149 with SMTP id 21mr7124070lfw.8.1445184043080; Sun, 18 Oct 2015 09:00:43 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id az8si19721213lbc.148.2015.10.18.09.00.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 09:00:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbcao8 with SMTP id ao8so126362756lbc.3 for ; Sun, 18 Oct 2015 09:00:43 -0700 (PDT) X-Received: by 10.112.163.131 with SMTP id yi3mr12402367lbb.36.1445184042956; Sun, 18 Oct 2015 09:00:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1033798lbq; Sun, 18 Oct 2015 09:00:42 -0700 (PDT) X-Received: by 10.180.219.106 with SMTP id pn10mr16595233wic.56.1445184042266; Sun, 18 Oct 2015 09:00:42 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com. [209.85.212.179]) by mx.google.com with ESMTPS id mu9si17166434wib.28.2015.10.18.09.00.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 09:00:42 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.179 as permitted sender) client-ip=209.85.212.179; Received: by wikq8 with SMTP id q8so20935012wik.1 for ; Sun, 18 Oct 2015 09:00:42 -0700 (PDT) X-Received: by 10.180.93.133 with SMTP id cu5mr14906865wib.49.1445184042091; Sun, 18 Oct 2015 09:00:42 -0700 (PDT) Received: from gnx2579.st.com. ([78.232.41.119]) by smtp.gmail.com with ESMTPSA id jd7sm34740323wjb.19.2015.10.18.09.00.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 09:00:40 -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 1/4] vfio: platform: add capability to register a reset function Date: Sun, 18 Oct 2015 18:00:12 +0200 Message-Id: <1445184015-24414-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445184015-24414-1-git-send-email-eric.auger@linaro.org> References: <1445184015-24414-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In preparation for subsequent changes in reset function lookup, lets introduce a dynamic list of reset combos (compat string, reset module, reset function). The list can be populated/voided with two new functions, vfio_platform_register/unregister_reset. Those are not yet used in this patch. Signed-off-by: Eric Auger --- drivers/vfio/platform/vfio_platform_common.c | 55 +++++++++++++++++++++++++++ drivers/vfio/platform/vfio_platform_private.h | 14 +++++++ 2 files changed, 69 insertions(+) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index e43efb5..d36afc9 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -23,6 +23,8 @@ #include "vfio_platform_private.h" +struct list_head reset_list; +LIST_HEAD(reset_list); static DEFINE_MUTEX(driver_lock); static const struct vfio_platform_reset_combo reset_lookup_table[] = { @@ -573,3 +575,56 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) return vdev; } EXPORT_SYMBOL_GPL(vfio_platform_remove_common); + +int vfio_platform_register_reset(struct module *reset_owner, char *compat, + vfio_platform_reset_fn_t reset) +{ + struct vfio_platform_reset_node *node, *iter; + bool found = false; + + list_for_each_entry(iter, &reset_list, link) { + if (!strcmp(iter->compat, compat)) { + found = true; + break; + } + } + if (found) + return -EINVAL; + + node = kmalloc(sizeof(*node), GFP_KERNEL); + if (!node) + return -ENOMEM; + + node->compat = kstrdup(compat, GFP_KERNEL); + if (!node->compat) + return -ENOMEM; + + node->owner = reset_owner; + node->reset = reset; + + list_add(&node->link, &reset_list); + return 0; +} +EXPORT_SYMBOL_GPL(vfio_platform_register_reset); + +int vfio_platform_unregister_reset(char *compat) +{ + struct vfio_platform_reset_node *iter; + bool found = false; + + list_for_each_entry(iter, &reset_list, link) { + if (!strcmp(iter->compat, compat)) { + found = true; + break; + } + } + if (!found) + return -EINVAL; + + list_del(&iter->link); + kfree(iter->compat); + kfree(iter); + return 0; +} +EXPORT_SYMBOL_GPL(vfio_platform_unregister_reset); + diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 1c9b3d5..17323f0 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -76,6 +76,15 @@ struct vfio_platform_reset_combo { const char *module_name; }; +typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev); + +struct vfio_platform_reset_node { + struct list_head link; + char *compat; + struct module *owner; + vfio_platform_reset_fn_t reset; +}; + extern int vfio_platform_probe_common(struct vfio_platform_device *vdev, struct device *dev); extern struct vfio_platform_device *vfio_platform_remove_common @@ -89,4 +98,9 @@ extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, unsigned start, unsigned count, void *data); +extern int vfio_platform_register_reset(struct module *owner, + char *compat, + vfio_platform_reset_fn_t reset); +extern int vfio_platform_unregister_reset(char *compat); + #endif /* VFIO_PLATFORM_PRIVATE_H */