Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp361313imm; Fri, 1 Jun 2018 02:07:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL6WzYGEmhtgbBagc1FGr95iqZ/RuYLKHHcEBoQOMuSdmN9/nkeOMJW+Yew6SGqAfxYcLEW X-Received: by 2002:a17:902:b409:: with SMTP id x9-v6mr10514555plr.180.1527844066275; Fri, 01 Jun 2018 02:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527844066; cv=none; d=google.com; s=arc-20160816; b=SofHrfFbGN4r3dpiIC0vahiDlaiu8dfMztx5Uw/DasCWFasO3ruTeQwfrm8yTtkBAC 1xvzyvTZrvndDklfnUwFL+35iCQMPwUOiDhMAZuBt2j6435Hou22/+21TP6uy3GO3/Xk LZ/Dwb+En1EVq3uLLsRCZ7eG49amY0lHzGP0JqrakJ8VbhnmvRjPG8AlsmNgkrDWzHA7 bGPOu6LOzdrATWEkIrCP3wv4AbTq43c7vttW7XuqI57RN9Eh1KmP0CcEJ3pqlz7nfhKe t3DXu0MqVmhJe6LdR9gry13OGDzaygVYHAIZi8B5lsnZYELV1N5+r4sALvRDXXy4DWYy M1yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1lXVCiBKqpsJgxB7Vp47gLA9OXi6CS54txe0RIlLh9k=; b=azzRw3a2ahlD5f1s60Q/Ta6mSNe52q0Rk49YyFdMvCJRUtusJQVgKJmJwcrLefd96C q7M2fpvh/KK+zzIZe6GvAmR7iJMQLHo511ZoE01yDe/8q5BgAcSckzT6LqmHbwOHRkou jSADFYYmpck3diNDQtPkXokVULbHbs/nPavJgUoHLug3IvIpZQtrImIfkGGB8WQJUvD7 MjmqzZAQSm7BuCnvEygtI8UyD4kz0XfhY+CAihs/rPHyYVYjM/Gq8UVH4R5/nwi7+xyg 0vg/uZVhfaojgg8Qkjz2MRC42gUtCGR/+G6QpHDD+Shv1Ep5qDSBARlD2C0MQNjtHoeu UH2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Es2/RhTT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12-v6si20331004plq.595.2018.06.01.02.07.31; Fri, 01 Jun 2018 02:07:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Es2/RhTT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbeFAJF6 (ORCPT + 99 others); Fri, 1 Jun 2018 05:05:58 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38462 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750831AbeFAJFt (ORCPT ); Fri, 1 Jun 2018 05:05:49 -0400 Received: by mail-pg0-f66.google.com with SMTP id c9-v6so8165515pgf.5 for ; Fri, 01 Jun 2018 02:05:49 -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; bh=1lXVCiBKqpsJgxB7Vp47gLA9OXi6CS54txe0RIlLh9k=; b=Es2/RhTTKB5hzppdA83ceOLQJV7b+QLgU/5L7TaLRTPh41lYXVcB/NU00kwOHb0hiX f1s17liOKIWMe9kpV9MsLP/MKCh5AQsMLJZROtdL9ERm7MPZaxHZgwXoOoU0oqVbyqNA qA7b5lEKOGVMfTWKJXGwVSjc4eCZcgd78skks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1lXVCiBKqpsJgxB7Vp47gLA9OXi6CS54txe0RIlLh9k=; b=PsbNayGzGnbbzRUgYbml/6+Zj3lSqSCtKR7m1scsYMdAIP2iKoyN6NPALCrAjQwZJa hCSyzUOUYHpB5/ka8nLJlEkWkw2wBJCjIxYWiawRAUnPAYJIpqVxJnzMt59Akca83luq lmIEE6roYoQ/ll2fz04X5lkAU9TTnjWvcH+NEmp1+IZmvVeqv55XwSJPkrEe43twc+pf DxkMq+5w/MtNGSRRHDH55w1WMXsyu9Dl+kiiW+ER9h1hoUw7MmzZTNHT7owEipYZafaV kEyd6n7diznp4xLpen4wx4FK/V6/kFdVV5IbsiCnMPowCXJSlEl5g8ZgOTLnPkSOnQQM vFDQ== X-Gm-Message-State: ALKqPweSK+qLNkah+UU5A3M7Tbs1InjcmQM7dgKomGbVmDdyp9RLY52N 9/YsmrMO7qh4Okt2II35QFPRPhO6Xj0= X-Received: by 2002:a65:4bcd:: with SMTP id p13-v6mr8251015pgr.114.1527843948833; Fri, 01 Jun 2018 02:05:48 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id a4-v6sm89505351pfj.19.2018.06.01.02.05.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Jun 2018 02:05:48 -0700 (PDT) From: Baolin Wang To: ohad@wizery.com, bjorn.andersson@linaro.org, broonie@kernel.org Cc: baolin.wang@linaro.org, linux-spi@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] hwspinlock: Add one new API to support getting a specific hwlock by the name Date: Fri, 1 Jun 2018 17:04:52 +0800 Message-Id: <1be6adeb558fada77de79a40cd5ef7dc2719c945.1527843425.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hardware spinlock binding already supplied the 'hwlock-names' property to match and get a specific hwlock, but did not supply one API for users to get a specific hwlock by the hwlock name. So this patch introduces one API to support this requirement. Signed-off-by: Baolin Wang --- drivers/hwspinlock/hwspinlock_core.c | 29 +++++++++++++++++++++++++++++ include/linux/hwspinlock.h | 7 +++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index 5278d05..00bde06 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -375,6 +375,35 @@ int of_hwspin_lock_get_id(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id); +/** + * of_hwspin_lock_get_id_byname() - get lock id for an specified hwlock name + * @np: device node from which to request the specific hwlock + * @name: hwlock name + * + * This function provides a means for DT users of the hwspinlock module to + * get the global lock id of a specific hwspinlock using the specified name of + * the hwspinlock device, so that it can be requested using the normal + * hwspin_lock_request_specific() API. + * + * Returns the global lock id number on success, -EPROBE_DEFER if the hwspinlock + * device is not yet registered, -EINVAL on invalid args specifier value or an + * appropriate error as returned from the OF parsing of the DT client node. + */ +int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) +{ + int index; + + if (!name) + return -EINVAL; + + index = of_property_match_string(np, "hwlock-names", name); + if (index < 0) + return index; + + return of_hwspin_lock_get_id(np, index); +} +EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id_byname); + static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) { struct hwspinlock *tmp; diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index fe450ee..f165cc8 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -74,6 +74,7 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, unsigned long *); int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); void __hwspin_unlock(struct hwspinlock *, int, unsigned long *); +int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name); #else /* !CONFIG_HWSPINLOCK */ @@ -133,6 +134,12 @@ static inline int hwspin_lock_get_id(struct hwspinlock *hwlock) return 0; } +static inline +int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) +{ + return 0; +} + #endif /* !CONFIG_HWSPINLOCK */ /** -- 1.7.9.5