From patchwork Fri Jun 22 08:08:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 139580 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp580429lji; Fri, 22 Jun 2018 01:09:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSaesSECQ+J8aeZ2fDNfcuh1GIjCsrNxkurhPP1UyMZizpNMKPwx75E/QwJL/6ksISikAZ X-Received: by 2002:a63:704a:: with SMTP id a10-v6mr470749pgn.443.1529654998422; Fri, 22 Jun 2018 01:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529654998; cv=none; d=google.com; s=arc-20160816; b=cRkjLuRIhGonvCgxMWMo050YmegBiscTsPfN7gIPPCcPIpM7+EJRsKwnOOJ50TyB7l MuD58zUQ2gdhvspTF5qoh7watIRG7nTTfvt+LMgrGbJBUyHJTWoB3oboTas1U4dFa0zH fZZQItTL5jGnKriZrHK3x/VfaSEn1WWMj4+chG6TUJlOz3bAPqvZYxnHWHTaKN/p7qYw KnpF5GWSRC5WoOYNMFNVM6OxULNl4cYsKN9zLAKKckWorJMqXAvXVHSsars9xBI/pY5+ aC+rtb4s6wtXEJ2wHS+KOvDJWBPK6sjo6Ohe+HtjerjQlmlrg/wNo45B06VMUNCLqakT rLHg== 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=kKP0zyVYQGtqg6IlZtf4wtOK53Zr8POTLojLEZmt+lY=; b=l31CbDdckfyToExunciXkVq/Z6tuQfY7SuQCrWr5KYdpVvssAMblZZsJo05sbW4QPy fEySgeKcIjZxbK/2IhoC15as7Xq+hTWjzE87W8yrmZW7WpUQkz1fMXdo5rNGAxrLem5G MtxdMr8qVmlmuC47YIAEndWqCPl0k1eC+iMao54kvY5QN/o+9HQHi3wVPbt+pnTcr2qc u5i5v8wTaEqpftde3mCZcEjWza7XgY/uAfXnjcI3Bketzv+aW+M/SNtPQG2EG7jjaaIt TJI/RG/wV5bb+oD5tj/SrR3NQXZeuRypOBlKfJnkuMRWml37YLpJ2JydLe05ck6DkTm/ yidg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="j/2RjIxS"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=fail (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 r1-v6si6851794plb.172.2018.06.22.01.09.58; Fri, 22 Jun 2018 01:09:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="j/2RjIxS"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbeFVIJ5 (ORCPT + 1 other); Fri, 22 Jun 2018 04:09:57 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:37632 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbeFVIJy (ORCPT ); Fri, 22 Jun 2018 04:09:54 -0400 Received: by mail-pg0-f68.google.com with SMTP id r21-v6so2632949pgv.4 for ; Fri, 22 Jun 2018 01:09:54 -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=iTLLhdNlaIGY0bI+lB6w+m6AewzVL5yDimWaS8xtwqU=; b=j/2RjIxS3v5mOm83rmN7PDBXzKjbQEmp7vzJq4UD2LP6z6VUwRSys/YWlsskSjS6iE 6czE75yFjifAtG9wUd7R6YIz+Mt2Y+zTNS2NECk7sOl4UfPdw6KFr6HYV8HfXH8VUUqq BVh64Ns9hPu9CwPRAcCTtVwZOYF/i/jepT+4A= 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=iTLLhdNlaIGY0bI+lB6w+m6AewzVL5yDimWaS8xtwqU=; b=uUfG6STF2ymIA+LxGW5MIJLuQyZ6IdoXG4MPvODtiJBEy9Ctocx/RSVihgRW2vnASs wrH7V/LMct0nfZAk+rxcs3beVfAQ83podyPQRFkH/tV6BslffXf7HrhwcUiLgS2279gc DdVzdUpM/IAsNcWxb0O7auvWNyMc1nq1BoDS3OkIR31lg0KWz355gxb242DIdTzDhTXY a7Tqe7JjNhFQmphV5stFSq7Rc4XczGLm0Vplat6QQi9TTgtk9cQiXAaUZXYBmoU2ZvkE YSQvz9+KuWc9Nsnxnk5IHIh6rrycmSk5rXiiV+DGs22cBFeYLcj/NjpCNzcDkW/yxCet Ougg== X-Gm-Message-State: APt69E2PpFB+WJt4GYX6FJJHxAVzN6PBTYrlpagrnJGBJuFtbYdmCe0E KFKxfSnAclGTRZg0dyeWkYiRYw== X-Received: by 2002:a62:ca99:: with SMTP id y25-v6mr623976pfk.187.1529654993821; Fri, 22 Jun 2018 01:09:53 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id i65-v6sm22656131pfd.17.2018.06.22.01.09.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jun 2018 01:09:53 -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/8] hwspinlock: Add one new API to support getting a specific hwlock by the name Date: Fri, 22 Jun 2018 16:08:58 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@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(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index d16e6a3..bea3586 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -367,6 +367,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 57537e6..2b6f389 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -66,6 +66,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 */ @@ -125,6 +126,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 */ /**