From patchwork Wed Apr 29 15:59:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 47733 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F94B20553 for ; Wed, 29 Apr 2015 15:59:47 +0000 (UTC) Received: by laat2 with SMTP id t2sf7923481laa.2 for ; Wed, 29 Apr 2015 08:59:46 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=PEjs50q+cYm0o46TwgTcSwC6nLfaAiCKWHIk5dihovA=; b=aX8ezu3CsJMTlr/rKOEoTINMRH3f4vyHPSwVYTifFLAJzjnimw77E9nPu+/wb6jHW1 QZNoUof7MvVVjXe+/C649LGnVWL65mq3P0XDCwk9eUT97qp7MzztzP/bZGcmtf2fx8iI IMIlrelI+vf23byqRPZR1XN+VS02lNxHMARXliNhwSeRx+qNp7UcRDm6fYi8llHWWGds 4liEgS8lufHw7t4z4XyTKsdHaUbDHFcFKxUXV5awiQ0tHRObqMcK0AU4UqrhW5VraIIb 13iCDyIHZDlRsbz8FTfO7C7jVgD3/BwN6mCxwA2I9mNWa/XiHhe4YGdyaQS9rp5Afm8B x4oA== X-Gm-Message-State: ALoCoQkmOtv5G9beekGpBjT76Hnm7/02aJHIkuFbEp9Tn5qHSk82Kq/pUhNZVJG/vlDUOQcwzZ5b X-Received: by 10.152.87.140 with SMTP id ay12mr13627523lab.8.1430323186012; Wed, 29 Apr 2015 08:59:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls257900lag.7.gmail; Wed, 29 Apr 2015 08:59:45 -0700 (PDT) X-Received: by 10.112.199.1 with SMTP id jg1mr19898466lbc.59.1430323185765; Wed, 29 Apr 2015 08:59:45 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id pk3si19662800lbb.75.2015.04.29.08.59.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 08:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labbd9 with SMTP id bd9so23666184lab.2 for ; Wed, 29 Apr 2015 08:59:45 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr20166171lbc.32.1430323185639; Wed, 29 Apr 2015 08:59:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp2593188lbt; Wed, 29 Apr 2015 08:59:44 -0700 (PDT) X-Received: by 10.70.42.139 with SMTP id o11mr43673141pdl.66.1430323183756; Wed, 29 Apr 2015 08:59:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd8si40107124pdb.6.2015.04.29.08.59.42; Wed, 29 Apr 2015 08:59:43 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753874AbbD2P7h (ORCPT + 27 others); Wed, 29 Apr 2015 11:59:37 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:35177 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604AbbD2P7e (ORCPT ); Wed, 29 Apr 2015 11:59:34 -0400 Received: by wgyo15 with SMTP id o15so33432118wgy.2 for ; Wed, 29 Apr 2015 08:59:33 -0700 (PDT) X-Received: by 10.180.88.72 with SMTP id be8mr7215800wib.42.1430323173035; Wed, 29 Apr 2015 08:59:33 -0700 (PDT) Received: from localhost.localdomain (host81-129-168-240.range81-129.btcentralplus.com. [81.129.168.240]) by mx.google.com with ESMTPSA id go4sm21801714wib.1.2015.04.29.08.59.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Apr 2015 08:59:32 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, jassisinghbrar@gmail.com, Lee Jones Subject: [PATCH 1/1] mailbox: Add ability for clients to request channels by name Date: Wed, 29 Apr 2015 16:59:24 +0100 Message-Id: <1430323164-26945-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@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.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. 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); +} +EXPORT_SYMBOL_GPL(mbox_request_channel_byname); + /** * mbox_free_channel - The client relinquishes control of a mailbox * channel by this call. diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index 1726ccb..4434871 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -40,6 +40,8 @@ struct mbox_client { void (*tx_done)(struct mbox_client *cl, void *mssg, int r); }; +struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, + const char *name); struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index); int mbox_send_message(struct mbox_chan *chan, void *mssg); void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */