From patchwork Fri Dec 2 22:03:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 86374 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp464301qgi; Fri, 2 Dec 2016 14:04:31 -0800 (PST) X-Received: by 10.84.174.129 with SMTP id r1mr100317046plb.19.1480716271201; Fri, 02 Dec 2016 14:04:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si6606015pli.124.2016.12.02.14.04.30; Fri, 02 Dec 2016 14:04:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754292AbcLBWE3 (ORCPT + 9 others); Fri, 2 Dec 2016 17:04:29 -0500 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34623 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbcLBWE0 (ORCPT ); Fri, 2 Dec 2016 17:04:26 -0500 Received: by mail-pg0-f44.google.com with SMTP id x23so111744659pgx.1 for ; Fri, 02 Dec 2016 14:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=H+58XYDoIgZl4+65fdza3wtVT2GTZVghrP8Kdb7/8CU=; b=OAfp2tvqRhvDB84Mw4LF7pqJ7w2cm+0kCW7hf3VtgPijw1FOeEHUL4cX39RCu1VFCz fu/NUaIZEvQg4Ot+/VtAJNpowPcgD02PsLoz+mY3vOtXg1VQbfpq84UthyiB0bGFgy8k tAGyrPIivmTsgkugPCdaVN+6WEiqrjXtLR7i0= 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; bh=H+58XYDoIgZl4+65fdza3wtVT2GTZVghrP8Kdb7/8CU=; b=fzpfO12xuejY72TXb1vvdIgMivR0Te74v5pqzwWUm627jW2wkxD+n0ehUcvn7nOwsJ rJk/8EHQVbRkbO7hVnFc+g/COAk9jpMJDrOcuc6LQL5k1vs1e5itLh5UWm2mSC0wYC9i buy9vOpdE/sXWzpovaSUT9xcV0dW6mK1so3LkYYSwkv4HgbE5qKJWhWbxWA4bcFueAWB J4Ozx2XilKtTXMzLjJTOYYMtZe2FZE6WF9hQ9i2g+6Ij99xELs7GlMT7Xj9PVgniiRE3 fJCyWrxLYSg3wPnVOFed8hsILot6EJ8LjjzxSI8e5KU67TkheWvuE8aKNt651tb7d1c8 8/WQ== X-Gm-Message-State: AKaTC02igKRWsRXaT1TL6D95w/GpH0z1oWzlQpdmzhvKUEJA11UQQwxCucHGQYDjtvqa5+o4 X-Received: by 10.99.4.213 with SMTP id 204mr82953248pge.77.1480716220935; Fri, 02 Dec 2016 14:03:40 -0800 (PST) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id q20sm9908719pgn.39.2016.12.02.14.03.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Dec 2016 14:03:39 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 1/4] rpmsg: Introduce "poll" to endpoint ops Date: Fri, 2 Dec 2016 14:03:34 -0800 Message-Id: <1480716217-23303-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This allows rpmsg backends to implement polling of the outgoing buffer, which provides poll support to user space when using the rpmsg character device. Signed-off-by: Bjorn Andersson --- Changes since v1: - New patch drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 3 +++ include/linux/rpmsg.h | 13 +++++++++++++ 3 files changed, 36 insertions(+) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index a79cb5a9e5f2..5ec8a06c24fa 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -240,6 +240,26 @@ int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) EXPORT_SYMBOL(rpmsg_trysendto); /** + * rpmsg_poll() - poll the endpoint's send buffers + * @ept: the rpmsg endpoint + * @filp: file for poll_wait() + * @wait: poll_table for poll_wait() + * + * Returns mask representing the current state of the endpoint's send buffers + */ +unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait) +{ + if (WARN_ON(!ept)) + return 0; + if (!ept->ops->poll) + return 0; + + return ept->ops->poll(ept, filp, wait); +} +EXPORT_SYMBOL(rpmsg_poll); + +/** * rpmsg_send_offchannel() - send a message using explicit src/dst addresses * @ept: the rpmsg endpoint * @src: source address diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 8075a20f919b..6176f2457b6b 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -21,6 +21,7 @@ #define __RPMSG_INTERNAL_H__ #include +#include #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) @@ -70,6 +71,8 @@ struct rpmsg_endpoint_ops { int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); int (*trysend_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); + unsigned int (*poll)(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait); }; int rpmsg_register_device(struct rpmsg_device *rpdev); diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 18f9e1ae4b7e..10d6ae8bbb7d 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -41,6 +41,7 @@ #include #include #include +#include #define RPMSG_ADDR_ANY 0xFFFFFFFF @@ -156,6 +157,9 @@ int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); +unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait); + #else static inline int register_rpmsg_device(struct rpmsg_device *dev) @@ -254,6 +258,15 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, return -ENXIO; } +static inline unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, + struct file *filp, poll_table *wait) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + #endif /* IS_ENABLED(CONFIG_RPMSG) */ /* use a macro to avoid include chaining to get THIS_MODULE */