Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753994AbbEKOlA (ORCPT ); Mon, 11 May 2015 10:41:00 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33221 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbbEKOk6 (ORCPT ); Mon, 11 May 2015 10:40:58 -0400 MIME-Version: 1.0 In-Reply-To: <1430323164-26945-1-git-send-email-lee.jones@linaro.org> References: <1430323164-26945-1-git-send-email-lee.jones@linaro.org> Date: Mon, 11 May 2015 20:10:58 +0530 Message-ID: Subject: Re: [PATCH 1/1] mailbox: Add ability for clients to request channels by name From: Jassi Brar To: Lee Jones Cc: "linux-arm-kernel@lists.infradead.org" , lkml , Jassi Brar , kernel@stlinux.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2253 Lines: 58 On 29 April 2015 at 21:29, Lee Jones wrote: > This patch supplies a new framework API; mbox_request_channel_byname(). > > It works by supplying the usual client pointer as the first argument and > a string as the second. The API will search the client's node for a > 'mbox-names' property then request a channel in the normal way using the > requested string's index as the expected second 'index' argument. > The api seems prudent. Thanks. > Signed-off-by: Lee Jones > --- > drivers/mailbox/mailbox.c | 23 +++++++++++++++++++++++ > include/linux/mailbox_client.h | 2 ++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c > index 19b491d..981a76cb 100644 > --- a/drivers/mailbox/mailbox.c > +++ b/drivers/mailbox/mailbox.c > @@ -357,6 +357,29 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) > } > EXPORT_SYMBOL_GPL(mbox_request_channel); > > +struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, > + const char *name) > +{ > + struct device_node *np = cl->dev->of_node; > + struct property *prop; > + const char *mbox_name; > + int index = 0; > + > + if (!np) { > + dev_err(cl->dev, "%s() only supports DT\n", __func__); > + return ERR_PTR(-ENOSYS); > + } > + > + of_property_for_each_string(np, "mbox-names", prop, mbox_name) { > + if (!strncmp(name, mbox_name, strlen(name))) > + break; > + index++; > + } > + > + return mbox_request_channel(cl, index); > 'mbox-names' property is specified as optional in Mailbox bindings. We don't want to return chan@0 if the property isn't populated. Also please remove the line "The use of this property is discouraged ..." from Documentation/devicetree/bindings/mailbox/mailbox.txt now that we add an api for just that. Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/