From patchwork Thu May 7 14:27:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 48127 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 031EF2121F for ; Thu, 7 May 2015 14:30:21 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf12912015lbb.0 for ; Thu, 07 May 2015 07:30:19 -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=3Gq/jVuR0EcSDVqAeOjjewDC96u66pgUdVJAGxkPzVk=; b=SvqsPcVnnYUMUMCZYZu4Kz7+9ASYDyIHNJXs1DMyOuMXbsfyq6kvsQg9xU2eL8DicG OcyFQFW1nZyz/zc5HGg8YMhBD4A5i5Axs0ojmYa1J3yJ1IRoqdNMs9/lljTT0VtrPWlq IySxEKevQ+VitySzMhlcyWMLIOkzkZgJxN2EuWpVtZDqYLC01wSlYODZxo3yGlKYQEl1 gBYd5I9/WDIRuejbnCgN3X/UEuMfR2QG9uhMKGkXLBLk0LFKIJWqSb1DDwgBcgRw05Ja 4qh8jKzh/oGatfCIZE1OdCbQZ0pNqDQbldI7XmaUH9PmxyVmABc6DCFiRsTzCOEHdGWi KGtw== X-Gm-Message-State: ALoCoQmYUQ1GghmpZ5BNLKajU8S43L6GPXpR0gtk2BPhkQ6Xw3+BicADjZVr4vhMrLT+LcNW/VFl X-Received: by 10.194.121.67 with SMTP id li3mr2358289wjb.3.1431009019506; Thu, 07 May 2015 07:30:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.229 with SMTP id w5ls200833lag.44.gmail; Thu, 07 May 2015 07:30:19 -0700 (PDT) X-Received: by 10.152.21.170 with SMTP id w10mr3233544lae.27.1431009019350; Thu, 07 May 2015 07:30:19 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ug3si1390881lbb.130.2015.05.07.07.30.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 07:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbuc2 with SMTP id uc2so32333983lbb.2 for ; Thu, 07 May 2015 07:30:19 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr3350386lab.35.1431009019219; Thu, 07 May 2015 07:30:19 -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.67.65 with SMTP id l1csp3476055lbt; Thu, 7 May 2015 07:30:18 -0700 (PDT) X-Received: by 10.194.173.40 with SMTP id bh8mr7000532wjc.99.1431009018540; Thu, 07 May 2015 07:30:18 -0700 (PDT) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com. [74.125.82.48]) by mx.google.com with ESMTPS id dn3si4166560wid.77.2015.05.07.07.30.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 07:30:18 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.48 as permitted sender) client-ip=74.125.82.48; Received: by wgiu9 with SMTP id u9so45444222wgi.3 for ; Thu, 07 May 2015 07:30:18 -0700 (PDT) X-Received: by 10.194.61.82 with SMTP id n18mr7705964wjr.35.1431009018243; Thu, 07 May 2015 07:30:18 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id z12sm3704874wjw.39.2015.05.07.07.30.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 May 2015 07:30:17 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, agraf@suse.de, Bharat.Bhushan@freescale.com Subject: [PATCH 2/5] VFIO: platform: add get_device callback Date: Thu, 7 May 2015 16:27:20 +0200 Message-Id: <1431008843-28411-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431008843-28411-1-git-send-email-eric.auger@linaro.org> References: <1431008843-28411-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.175 as permitted sender) smtp.mail=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: , It is needed to introduce a new callback enabling to retrieve the struct device* from the vfio_platform_device. Implementation depends on the underlying device, platform or amba. This will be used to retrieve the compatibility string of the device. Signed-off-by: Eric Auger --- drivers/vfio/platform/vfio_amba.c | 9 +++++++++ drivers/vfio/platform/vfio_platform.c | 10 ++++++++++ drivers/vfio/platform/vfio_platform_private.h | 1 + 3 files changed, 20 insertions(+) diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c index ff0331f..fd68115 100644 --- a/drivers/vfio/platform/vfio_amba.c +++ b/drivers/vfio/platform/vfio_amba.c @@ -48,6 +48,14 @@ static int get_amba_irq(struct vfio_platform_device *vdev, int i) return ret ? ret : -ENXIO; } +static struct device *vfio_amba_get_device(struct vfio_platform_device *vdev) +{ + struct amba_device *pdev = (struct amba_device *) vdev->opaque; + struct device *dev = &pdev->dev; + + return dev; +} + static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) { struct vfio_platform_device *vdev; @@ -67,6 +75,7 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) vdev->flags = VFIO_DEVICE_FLAGS_AMBA; vdev->get_resource = get_amba_resource; vdev->get_irq = get_amba_irq; + vdev->get_device = vfio_amba_get_device; ret = vfio_platform_probe_common(vdev, &adev->dev); if (ret) { diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c index cef645c..c025d76 100644 --- a/drivers/vfio/platform/vfio_platform.c +++ b/drivers/vfio/platform/vfio_platform.c @@ -51,6 +51,15 @@ static int get_platform_irq(struct vfio_platform_device *vdev, int i) return platform_get_irq(pdev, i); } +static struct device *vfio_platform_get_device( + struct vfio_platform_device *vdev) +{ + struct platform_device *pdev = (struct platform_device *) vdev->opaque; + struct device *dev = &pdev->dev; + + return dev; +} + static int vfio_platform_probe(struct platform_device *pdev) { struct vfio_platform_device *vdev; @@ -65,6 +74,7 @@ static int vfio_platform_probe(struct platform_device *pdev) vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM; vdev->get_resource = get_platform_resource; vdev->get_irq = get_platform_irq; + vdev->get_device = vfio_platform_get_device; ret = vfio_platform_probe_common(vdev, &pdev->dev); if (ret) diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index da2d60b..68909a4 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -67,6 +67,7 @@ struct vfio_platform_device { struct resource* (*get_resource)(struct vfio_platform_device *vdev, int i); int (*get_irq)(struct vfio_platform_device *vdev, int i); + struct device *(*get_device)(struct vfio_platform_device *vdev); }; typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev);