From patchwork Thu Sep 1 22:27:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 75256 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp537617qga; Thu, 1 Sep 2016 15:32:16 -0700 (PDT) X-Received: by 10.98.56.207 with SMTP id f198mr30944816pfa.83.1472769129663; Thu, 01 Sep 2016 15:32:09 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id x2si7661247pav.91.2016.09.01.15.32.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 15:32:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaVb-0005Nm-SI; Thu, 01 Sep 2016 22:30:55 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaTP-0002Dj-Rm for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 22:28:46 +0000 Received: by mail-pa0-x229.google.com with SMTP id hb8so33832549pac.2 for ; Thu, 01 Sep 2016 15:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h3ww3esiwtUzZxXSxSBdPF3p+2+Rm4FK3jwXd1Bji2k=; b=hx8B/qZr6V7NQ5ZFT6RUvu8y8Jy1dhsXh5D0gucszv0iOD9DT3p1mkCewpXkfIGJzC RtJRzbfa+45Ewe1Z7XlYWbp2THFKrwK6QPIaAQ/7WaHw8ejvnmw4eNOHGiDfbxzbOFQl QzPOtsQANPsboqA5/3NtW7ZPyM+bAxb44p5pg= 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=h3ww3esiwtUzZxXSxSBdPF3p+2+Rm4FK3jwXd1Bji2k=; b=dvqgkew4D64duokhTQ0fKoDjaqJeCpLmT13TcdwjBtQ7eB2SlNCskzirKRDKmfUf2I QLeD7yoC8Eo9tYZvJQmBHIAl+A4txOyzamsfTiYpRlP2DvfAf6zIvI92//Am5aQiEU1d xkWopTpSTse/62TF9AdBmq6T4VodQOUBkG5lSOnZbWXkoHE0uybMCrxJslyJPEDPfBjM fHCaBp2/QUPdEOEQjRd+qAW0CDoGUWkOA/83jCaYwbBPK8O6j8c2KNHm5ROPnCQI97Eg HAED3MBDDTGsOjt78keaXT48IavFaT1PMVnONH6dnoyQ/S8IRlUk53nHvJSoywNoEs1L p4qA== X-Gm-Message-State: AE9vXwNhrmE4dyrZxGCkoFlfteynfy7bDYgW+PpYmK/Pm9W7z52OMBo/tCWmhIbKdQXdSzsq X-Received: by 10.66.139.227 with SMTP id rb3mr30532993pab.26.1472768898340; Thu, 01 Sep 2016 15:28:18 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id iw10sm8887131pac.14.2016.09.01.15.28.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Sep 2016 15:28:17 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH v2 05/17] rpmsg: Clean up rpmsg device vs channel naming Date: Thu, 1 Sep 2016 15:27:57 -0700 Message-Id: <1472768889-3906-6-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> References: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160901_152840_170794_033D183E X-CRM114-Status: GOOD ( 21.59 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The rpmsg device representing struct is called rpmsg_channel and the variable name used throughout is rpdev, with the communication happening on endpoints it's clearer to just call this a "device" in a public API. Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/rpmsg/virtio_rpmsg_bus.c | 42 ++++++++++++++++++------------------- include/linux/rpmsg.h | 32 +++++++++++++++------------- samples/rpmsg/rpmsg_client_sample.c | 6 +++--- 3 files changed, 41 insertions(+), 39 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 7c7c6a8b21d9..1ac9fd871760 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -73,7 +73,7 @@ struct virtproc_info { struct rpmsg_endpoint *ns_ept; }; -#define to_rpmsg_channel(d) container_of(d, struct rpmsg_channel, dev) +#define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) /* @@ -113,7 +113,7 @@ static ssize_t \ field##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); \ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ \ return sprintf(buf, format_string, rpdev->path); \ } @@ -127,7 +127,7 @@ rpmsg_show_attr(announce, announce ? "true" : "false", "%s\n"); static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name); } @@ -142,7 +142,7 @@ static struct device_attribute rpmsg_dev_attrs[] = { }; /* rpmsg devices and drivers are matched using the service name */ -static inline int rpmsg_id_match(const struct rpmsg_channel *rpdev, +static inline int rpmsg_id_match(const struct rpmsg_device *rpdev, const struct rpmsg_device_id *id) { return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0; @@ -151,7 +151,7 @@ static inline int rpmsg_id_match(const struct rpmsg_channel *rpdev, /* match rpmsg channel and rpmsg driver */ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv); const struct rpmsg_device_id *ids = rpdrv->id_table; unsigned int i; @@ -166,7 +166,7 @@ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv) static int rpmsg_uevent(struct device *dev, struct kobj_uevent_env *env) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); return add_uevent_var(env, "MODALIAS=" RPMSG_DEVICE_MODALIAS_FMT, rpdev->id.name); @@ -194,7 +194,7 @@ static void __ept_release(struct kref *kref) /* for more info, see below documentation of rpmsg_create_ept() */ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp, - struct rpmsg_channel *rpdev, + struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, u32 addr) { @@ -282,7 +282,7 @@ free_ept: * * Returns a pointer to the endpoint on success, or NULL on error. */ -struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rpdev, +struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, struct rpmsg_channel_info chinfo) { @@ -339,7 +339,7 @@ EXPORT_SYMBOL(rpmsg_destroy_ept); */ static int rpmsg_dev_probe(struct device *dev) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); struct virtproc_info *vrp = rpdev->vrp; struct rpmsg_channel_info chinfo = {}; @@ -387,7 +387,7 @@ out: static int rpmsg_dev_remove(struct device *dev) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); struct virtproc_info *vrp = rpdev->vrp; int err = 0; @@ -451,7 +451,7 @@ EXPORT_SYMBOL(unregister_rpmsg_driver); static void rpmsg_release_device(struct device *dev) { - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); kfree(rpdev); } @@ -461,10 +461,10 @@ static void rpmsg_release_device(struct device *dev) * this is used to make sure we're not creating rpmsg devices for channels * that already exist. */ -static int rpmsg_channel_match(struct device *dev, void *data) +static int rpmsg_device_match(struct device *dev, void *data) { struct rpmsg_channel_info *chinfo = data; - struct rpmsg_channel *rpdev = to_rpmsg_channel(dev); + struct rpmsg_device *rpdev = to_rpmsg_device(dev); if (chinfo->src != RPMSG_ADDR_ANY && chinfo->src != rpdev->src) return 0; @@ -484,15 +484,15 @@ static int rpmsg_channel_match(struct device *dev, void *data) * this function will be used to create both static and dynamic * channels. */ -static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp, - struct rpmsg_channel_info *chinfo) +static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, + struct rpmsg_channel_info *chinfo) { - struct rpmsg_channel *rpdev; + struct rpmsg_device *rpdev; struct device *tmp, *dev = &vrp->vdev->dev; int ret; /* make sure a similar channel doesn't already exist */ - tmp = device_find_child(dev, chinfo, rpmsg_channel_match); + tmp = device_find_child(dev, chinfo, rpmsg_device_match); if (tmp) { /* decrement the matched device's refcount back */ put_device(tmp); @@ -544,7 +544,7 @@ static int rpmsg_destroy_channel(struct virtproc_info *vrp, struct virtio_device *vdev = vrp->vdev; struct device *dev; - dev = device_find_child(&vdev->dev, chinfo, rpmsg_channel_match); + dev = device_find_child(&vdev->dev, chinfo, rpmsg_device_match); if (!dev) return -EINVAL; @@ -669,7 +669,7 @@ static void rpmsg_downref_sleepers(struct virtproc_info *vrp) * * Returns 0 on success and an appropriate error value on failure. */ -int rpmsg_send_offchannel_raw(struct rpmsg_channel *rpdev, u32 src, u32 dst, +int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, u32 src, u32 dst, void *data, int len, bool wait) { struct virtproc_info *vrp = rpdev->vrp; @@ -879,11 +879,11 @@ static void rpmsg_xmit_done(struct virtqueue *svq) } /* invoked when a name service announcement arrives */ -static void rpmsg_ns_cb(struct rpmsg_channel *rpdev, void *data, int len, +static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src) { struct rpmsg_ns_msg *msg = data; - struct rpmsg_channel *newch; + struct rpmsg_device *newch; struct rpmsg_channel_info chinfo; struct virtproc_info *vrp = priv; struct device *dev = &vrp->vdev->dev; diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index f278407fcf48..35a0f39fd09b 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -110,7 +110,7 @@ struct rpmsg_channel_info { }; /** - * rpmsg_channel - devices that belong to the rpmsg bus are called channels + * rpmsg_device - device that belong to the rpmsg bus * @vrp: the remote processor this channel belongs to * @dev: the device struct * @id: device id (used to match between rpmsg drivers and devices) @@ -119,7 +119,7 @@ struct rpmsg_channel_info { * @ept: the rpmsg endpoint of this channel * @announce: if set, rpmsg will announce the creation/removal of this channel */ -struct rpmsg_channel { +struct rpmsg_device { struct virtproc_info *vrp; struct device dev; struct rpmsg_device_id id; @@ -129,7 +129,7 @@ struct rpmsg_channel { bool announce; }; -typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32); +typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); /** * struct rpmsg_endpoint - binds a local rpmsg address to its user @@ -155,7 +155,7 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32); * create additional endpoints by themselves (see rpmsg_create_ept()). */ struct rpmsg_endpoint { - struct rpmsg_channel *rpdev; + struct rpmsg_device *rpdev; struct kref refcount; rpmsg_rx_cb_t cb; struct mutex cb_lock; @@ -174,19 +174,21 @@ struct rpmsg_endpoint { struct rpmsg_driver { struct device_driver drv; const struct rpmsg_device_id *id_table; - int (*probe)(struct rpmsg_channel *dev); - void (*remove)(struct rpmsg_channel *dev); - void (*callback)(struct rpmsg_channel *, void *, int, void *, u32); + int (*probe)(struct rpmsg_device *dev); + void (*remove)(struct rpmsg_device *dev); + void (*callback)(struct rpmsg_device *, void *, int, void *, u32); }; +int register_rpmsg_device(struct rpmsg_device *dev); +void unregister_rpmsg_device(struct rpmsg_device *dev); int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); void unregister_rpmsg_driver(struct rpmsg_driver *drv); void rpmsg_destroy_ept(struct rpmsg_endpoint *); -struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *, +struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, rpmsg_rx_cb_t cb, void *priv, struct rpmsg_channel_info chinfo); int -rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); +rpmsg_send_offchannel_raw(struct rpmsg_device *, u32, u32, void *, int, bool); /* use a macro to avoid include chaining to get THIS_MODULE */ #define register_rpmsg_driver(drv) \ @@ -224,7 +226,7 @@ rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); */ static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; u32 src = ept->addr, dst = rpdev->dst; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); @@ -251,7 +253,7 @@ static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; u32 src = ept->addr; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); @@ -281,7 +283,7 @@ static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); } @@ -306,7 +308,7 @@ int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; u32 src = ept->addr, dst = rpdev->dst; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); @@ -332,7 +334,7 @@ int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; u32 src = ept->addr; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); @@ -361,7 +363,7 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len) { - struct rpmsg_channel *rpdev = ept->rpdev; + struct rpmsg_device *rpdev = ept->rpdev; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); } diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index 37975eddd64e..4fcd7ee13fb9 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -28,7 +28,7 @@ struct instance_data { int rx_count; }; -static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, +static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src) { int ret; @@ -52,7 +52,7 @@ static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); } -static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) +static int rpmsg_sample_probe(struct rpmsg_device *rpdev) { int ret; struct instance_data *idata; @@ -76,7 +76,7 @@ static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) return 0; } -static void rpmsg_sample_remove(struct rpmsg_channel *rpdev) +static void rpmsg_sample_remove(struct rpmsg_device *rpdev) { dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); }