From patchwork Mon May 11 16:08:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 48304 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D2AF21550 for ; Mon, 11 May 2015 16:09:24 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf40018687lbb.3 for ; Mon, 11 May 2015 09:09:22 -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=VKwrlNTQZAgc3UGLItVRRbwpqcwQ6b2osoIrUePOJoM=; b=IUSAK5r8KvHRcXuCq+rPwVs0Fxko0Ilhuz3jHGdSrHYTxcUDvMKr2NLL0Vb5P9Fqgx mQyMpGym9W8sKWQkJOAWzGeJkH+t4H4JEVvij8iJYyC14MnYiljS8VaN9cN86HCVT0+z ksAxyGK65Xw6D87S6J0JyZgsFvcCopVcSfHCzS2kze+EL2/spkMwJ+VfF3YXygujKa9d h28i6jQIEUEcwUf8xRBWgyee3Dm9c6EFqgj6jvJwyivzOa4haZIclYWjKge2r5KFOyqS hHUfb8oy8e0I3/lYz6ehfDzJ5bvoVALyKh/95zjMXmLTkFZp578o5hxZrGTnHAKfo/6d 8BDA== X-Gm-Message-State: ALoCoQlx2A16zbuYXEu4czuQR8iyvnThD5iagZMCKobdgjco0jog+Q09Q9bXWSUJVlc8uaEi6xMj X-Received: by 10.180.10.136 with SMTP id i8mr7956386wib.7.1431360562922; Mon, 11 May 2015 09:09:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.196 with SMTP id u4ls669636lau.6.gmail; Mon, 11 May 2015 09:09:22 -0700 (PDT) X-Received: by 10.112.137.164 with SMTP id qj4mr8532989lbb.105.1431360562696; Mon, 11 May 2015 09:09:22 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id v13si8590054lal.98.2015.05.11.09.09.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 09:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laat2 with SMTP id t2so96770791laa.1 for ; Mon, 11 May 2015 09:09:22 -0700 (PDT) X-Received: by 10.152.29.161 with SMTP id l1mr8383670lah.76.1431360562570; Mon, 11 May 2015 09:09:22 -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.108.230 with SMTP id hn6csp1591152lbb; Mon, 11 May 2015 09:09:21 -0700 (PDT) X-Received: by 10.68.167.131 with SMTP id zo3mr20046764pbb.123.1431360560631; Mon, 11 May 2015 09:09:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si18528838pas.13.2015.05.11.09.09.19; Mon, 11 May 2015 09:09:20 -0700 (PDT) Received-SPF: none (google.com: devicetree-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 S1752295AbbEKQJS (ORCPT + 6 others); Mon, 11 May 2015 12:09:18 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:38068 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbbEKQJR (ORCPT ); Mon, 11 May 2015 12:09:17 -0400 Received: by wiun10 with SMTP id n10so102337492wiu.1 for ; Mon, 11 May 2015 09:09:16 -0700 (PDT) X-Received: by 10.194.47.165 with SMTP id e5mr21300333wjn.128.1431360555330; Mon, 11 May 2015 09:09:15 -0700 (PDT) Received: from localhost.localdomain (host81-129-169-99.range81-129.btcentralplus.com. [81.129.169.99]) by mx.google.com with ESMTPSA id ju2sm452335wid.12.2015.05.11.09.09.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 09:09:14 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, jassisinghbrar@gmail.com, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH 1/2] mailbox: Add ability for clients to request channels by name Date: Mon, 11 May 2015 17:08:50 +0100 Message-Id: <1431360531-31337-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.42 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 | 29 +++++++++++++++++++++++++++++ include/linux/mailbox_client.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 19b491d..c533826 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -357,6 +357,35 @@ 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() currently only supports DT\n", __func__); + return ERR_PTR(-ENOSYS); + } + + if (!of_get_property(np, "mbox-names", NULL)) { + dev_err(cl->dev, + "%s() requires an \"mbox-names\" property\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 */