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 */ /** From patchwork Fri Jun 22 08:08:59 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: 139587 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp584013lji; Fri, 22 Jun 2018 01:14:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKi+op6Nrv73IBbTOs48hOqAq6IxyGb4EBWXAg73hzJRzP+nJ8c3M6v/bZYh3V6H5bpH7Pb X-Received: by 2002:a63:a602:: with SMTP id t2-v6mr523430pge.146.1529655246483; Fri, 22 Jun 2018 01:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529655246; cv=none; d=google.com; s=arc-20160816; b=FUXPOFK5ClIwyZ7pnaVvbj1n9iOakYws3PUPLbSc/5P75BlEHlw+2mVuwbGs8xWxEQ h6YyWvyzORbrVo/xnkDzTyN/Y+Rra7qJEWcL14OQLwbVAmLbQHWMiGnmABxQRPS/EAZU kLf9mnM53TQ3P2Rt4+Ckql8BS9O78dwOQRrL9LuWNw4EEDscff/7gCcvXSF50FJAO0IX pr8+hqlASX+g3/JEdNe6ji4JncZJxND/HgoIy8vSFoMWqefK0A9gncUZ3vnqeAPvkOPo oTIUw4PcmJlpC1vzlOmghcqidtviFVzM6PgzqzYe9yLQJZg2N1E/UadEy5yKuPY35UZQ GwVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=qHO66S8erMfUKMpnxi2Vyge81gSdYv/ngERgyfjv/w0=; b=tJPCSBRujBog8TxFc4EQ6kSjROjkpE6Qb5zaZhvecrj/eE430bSdOH4yW76ZEwnwQ1 hg5C/9Giq9ZHZWSijwSidPcRdfuZZyvps4WC9SpVZTBnIZOcGh/jAA4Tl6fHlGsRLG9M nlFncVwhL0Acaz18eod99KpWREJe6oeco/VREm0GSv7JoDIS0PEl0BZdwixJGyJ/+TTc YXute3+uSTL4kOVj3cNNrU94Vppp+BVJMkMXGEGTz6Mvfp8o19TNM9f9G4c0YaZ+3HHu D/xNhvT/uzVkNEbJhLwAOaTqyAJQG2T7whMSdZyS1FbTrSsb+N97xNZMS/RHk5pXzyPe V2tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QGn5hNib; 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 k1-v6si5974206pgr.13.2018.06.22.01.14.06; Fri, 22 Jun 2018 01:14:06 -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=QGn5hNib; 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 S1753219AbeFVIOF (ORCPT + 1 other); Fri, 22 Jun 2018 04:14:05 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39469 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbeFVIJ4 (ORCPT ); Fri, 22 Jun 2018 04:09:56 -0400 Received: by mail-pl0-f66.google.com with SMTP id s24-v6so3109194plq.6 for ; Fri, 22 Jun 2018 01:09:56 -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:in-reply-to:references :in-reply-to:references; bh=EvEb9AghybtdnkxHfKvMzouMMdmNPOMDUDXqyHf1hyQ=; b=QGn5hNibPxZvcY+B8cCrU5jZegOWBsI956F5lIQd0q/RYra2/LPc3P3vKd0X+NluHy KZTAe8xCyRJ2WMB1dhZRc9RbFoVXeOcqJLyuEctmn8SZWc3HzEahke5m+2vuneWhUvsx md4VioeOYEhWs6eyTgyvTih1QRbzRA2P2mVdY= 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:in-reply-to :references:in-reply-to:references; bh=EvEb9AghybtdnkxHfKvMzouMMdmNPOMDUDXqyHf1hyQ=; b=Lv55ydGMb2QVb52Ed/OxRXkY4+RQaP3pcupV9IkMYwgAwMKpb/uTF/D/gFi5ZVrySg lLrK7VRkab9sZ8ywnDK0T23r+LEkidVPhfur5lb7/NmdxsGXdTW9UTMs0UI4xrFCjFoC FKkmkgMZPgh3VdNDGRtCx9Pw7KFOfClrj0U9jnxng5V3V2N10YDqDA5IFCW7SsOP8ZtY XkhuE3Fhhx5C6uNNEqdVOQAFp+vUrQ/w5LF+Dtqq8XozY2SgMQOJFGCIBTmGxmmNsm4G loAUNBjimJETPoCcgVpiv7Vf0Q92cYn94SoGzJ+eZRcReCaB8AQ8WL1RQNcru/I39FUy FSDw== X-Gm-Message-State: APt69E16QZdtrY1BkWZHGMbYaBzlxjowrNvxM2ENvAw8W5PXFX+zLHm7 tAJrC813R7H/l6U/HMnxOvgDYBP+h0U= X-Received: by 2002:a17:902:6bc7:: with SMTP id m7-v6mr633780plt.162.1529654996417; Fri, 22 Jun 2018 01:09:56 -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.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jun 2018 01:09:55 -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 2/8] hwspinlock: Add devm_xxx() APIs to request/free hwlock Date: Fri, 22 Jun 2018 16:08:59 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This patch introduces some devm_xxx() APIs to help to request or free the hwlocks, which will help to simplify the cleanup code for drivers requesting one hwlock, ensuring that the hwlock is automatically freed whenever the device is unbound. Signed-off-by: Baolin Wang --- drivers/hwspinlock/hwspinlock_core.c | 110 ++++++++++++++++++++++++++++++++++ include/linux/hwspinlock.h | 22 +++++++ 2 files changed, 132 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 bea3586..d542b6f 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -735,6 +735,116 @@ int hwspin_lock_free(struct hwspinlock *hwlock) } EXPORT_SYMBOL_GPL(hwspin_lock_free); +static int devm_hwspin_lock_match(struct device *dev, void *res, void *data) +{ + struct hwspinlock **hwlock = res; + + if (WARN_ON(!hwlock || !*hwlock)) + return 0; + + return *hwlock == data; +} + +static void devm_hwspin_lock_release(struct device *dev, void *res) +{ + hwspin_lock_free(*(struct hwspinlock **)res); +} + +/** + * devm_hwspin_lock_free() - free a specific hwspinlock for a managed device + * @dev: the device to free the specific hwspinlock + * @hwlock: the specific hwspinlock to free + * + * This function mark @hwlock as free again. + * Should only be called with an @hwlock that was retrieved from + * an earlier call to hwspin_lock_request{_specific}. + * + * Should be called from a process context (might sleep) + * + * Returns 0 on success, or an appropriate error code on failure + */ +int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) +{ + int ret; + + ret = devres_release(dev, devm_hwspin_lock_release, + devm_hwspin_lock_match, hwlock); + WARN_ON(ret); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_hwspin_lock_free); + +/** + * devm_hwspin_lock_request() - request an hwspinlock for a managed device + * @dev: the device to request an hwspinlock + * + * This function should be called by users of the hwspinlock device, + * in order to dynamically assign them an unused hwspinlock. + * Usually the user of this lock will then have to communicate the lock's id + * to the remote core before it can be used for synchronization (to get the + * id of a given hwlock, use hwspin_lock_get_id()). + * + * Should be called from a process context (might sleep) + * + * Returns the address of the assigned hwspinlock, or NULL on error + */ +struct hwspinlock *devm_hwspin_lock_request(struct device *dev) +{ + struct hwspinlock **ptr, *hwlock; + + ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + hwlock = hwspin_lock_request(); + if (!IS_ERR(hwlock)) { + *ptr = hwlock; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return hwlock; +} +EXPORT_SYMBOL_GPL(devm_hwspin_lock_request); + +/** + * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for + * a managed device + * @dev: the device to request the specific hwspinlock + * @id: index of the specific hwspinlock that is requested + * + * This function should be called by users of the hwspinlock module, + * in order to assign them a specific hwspinlock. + * Usually early board code will be calling this function in order to + * reserve specific hwspinlock ids for predefined purposes. + * + * Should be called from a process context (might sleep) + * + * Returns the address of the assigned hwspinlock, or NULL on error + */ +struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, + unsigned int id) +{ + struct hwspinlock **ptr, *hwlock; + + ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + hwlock = hwspin_lock_request_specific(id); + if (!IS_ERR(hwlock)) { + *ptr = hwlock; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return hwlock; +} +EXPORT_SYMBOL_GPL(devm_hwspin_lock_request_specific); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Hardware spinlock interface"); MODULE_AUTHOR("Ohad Ben-Cohen "); diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 2b6f389..dfd0593 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -67,6 +67,10 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, 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); +int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); +struct hwspinlock *devm_hwspin_lock_request(struct device *dev); +struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, + unsigned int id); #else /* !CONFIG_HWSPINLOCK */ @@ -132,6 +136,24 @@ int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) return 0; } +static inline +int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) +{ + return 0; +} + +static inline struct hwspinlock *devm_hwspin_lock_request(struct device *dev) +{ + return ERR_PTR(-ENODEV); +} + +static inline +struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, + unsigned int id) +{ + return ERR_PTR(-ENODEV); +} + #endif /* !CONFIG_HWSPINLOCK */ /** From patchwork Fri Jun 22 08:09:05 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: 139583 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp580750lji; Fri, 22 Jun 2018 01:10:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3jaJ3fpRb+jASBZWpy8tyDSeCV/Vio32GJQ+bLD22ciCtLGf9uVHj3uAKF28IBmPAFm1Z X-Received: by 2002:a62:808f:: with SMTP id j137-v6mr640784pfd.91.1529655020371; Fri, 22 Jun 2018 01:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529655020; cv=none; d=google.com; s=arc-20160816; b=dZDu30+dlxeZhiYbdbC1Yk2k0VqL0RQogOLpNAzE3SUhHDjE+IZ8g7U5SmQwp684tV 0ATvDQwVuOpIKL3EyB847o/k5EXo/MvdHYVZsuGBcfNOSAbqZJ1VW4Y3wVF/8lMxqgcg +d/BHv6dGJ58lNV+6NoYIeF/W888pLceMHpOYad2aWj9oFUL6+wn5cPDTJ10Udu8CjFW OH1LAUDrIQds9ZzzyDtynrvaxT15Dn5wUwidaVYyAHJT4jp6cApR6QgS60JwCY4cXS1t Roiwvy8bDeMx7X4jaP1ELwDL1hNLKAORkjtpMRN6H7oHosiU9OK9JsWn8TDznojnD333 8JFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=OtaJ4V/8jDqUsSCCtDtLkrWulFPxrnjYWzsXpS/O6sc=; b=bD9/fys6EKyKo0kU7/pttvbMsOkOdc74EVZzyaAkpY66eEN10346C2TUWWjA7Lwfwn QbX9fTaar44RennLXV35/e1MvUiU3w3mwxkMKIIml6IvcqI3Q/yMNBxGENCVQ/sOsWFy ZOa1A2gCNmsdd5V/jcvZXd3eZnfWD/zCH2k6zz04NLqNRkf+7Zsg8A1YU/nslaz/BPbZ 95OrdvhcU12iLgwgVhCIgjNYCvAOyklaYCOB2h1UtS1/34u5VYyfgclWL6R8ZZRo6+QG RupL5bBmPQQtlFfJru0p3xk7eD7QYRmxYb72D9UzCXXfI2dWPi+lnCUBGBv/+HXApUIC Y8yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kqLbuKHW; 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 r8-v6si8100476plj.40.2018.06.22.01.10.20; Fri, 22 Jun 2018 01:10:20 -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=kqLbuKHW; 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 S1754345AbeFVIKR (ORCPT + 1 other); Fri, 22 Jun 2018 04:10:17 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37325 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754339AbeFVIKO (ORCPT ); Fri, 22 Jun 2018 04:10:14 -0400 Received: by mail-pf0-f195.google.com with SMTP id y5-v6so2845087pfn.4 for ; Fri, 22 Jun 2018 01:10:14 -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:in-reply-to:references :in-reply-to:references; bh=y6rwY3jFptgeXlF1nA+iIjbA4Z16sjg0bDMz2V84xl4=; b=kqLbuKHW/+VNUrQYSiHOPno0CbY7pYXtYPCLda0MHAVsKgMwbbqOzL8820VxtCZPQT NURCutWbp1fdESZz1H1QyYckGS2Yaqil24aAhMzAban4tAuH3A/ZYAFloAMg1mw6kMg+ skmpvY6VCP/bR6rfDvlPz7iPfdpnSTJ0SCRbE= 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:in-reply-to :references:in-reply-to:references; bh=y6rwY3jFptgeXlF1nA+iIjbA4Z16sjg0bDMz2V84xl4=; b=p9P7bmam6dPlpDmdT8furC4UCKEHda/fZ+KHEyj3ExxhSRMF5643J6vGoSI6Rf1PUb PSlJyWxw3UkIETV83fhKI4Sdp6w+ltIr1LHfy3nGNI46rLQgWooKhzDlDa2yjKa1iUKW rlIbKFceCMhOMNCJoA6VudopGQ/8GttL97vuKDRRmjhuj0vje2f/DE+sMS240R9hwU21 sXuQmfAN+rveXKREZIzlCO7UI/3oE3/vBvr5fTNiYe2rqxtcLRAjqCAdMzlqZiA2JxW8 ud/5or6LGZTffo606dnoy61s4yxFJdBiZ27sspiaXs2LYZSmLacH7IpIWUUpmAQiO3X8 2j+A== X-Gm-Message-State: APt69E1ajJL8RY2bFI9EKFxpORB6IX3gpcQxqsMI6BJG0zS6d5WTBOsU acwjaUY27348e7Ht5cf+qUhtwg== X-Received: by 2002:a65:62cd:: with SMTP id m13-v6mr501456pgv.207.1529655014243; Fri, 22 Jun 2018 01:10:14 -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.10.11 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jun 2018 01:10:13 -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 8/8] spi: sprd: Change to use devm_hwspin_lock_request_specific() Date: Fri, 22 Jun 2018 16:09:05 +0800 Message-Id: <1662400fb204bbbe9a36edf580ea267079a2a02e.1529654288.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Change to use devm_hwspin_lock_request_specific() instead of freeing the hwlock explicitly when unbound the device. Signed-off-by: Baolin Wang --- drivers/spi/spi-sprd-adi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 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/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index d8d5e2f..6fb5c0c 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -465,7 +465,7 @@ static int sprd_adi_probe(struct platform_device *pdev) goto put_ctlr; } - sadi->hwlock = hwspin_lock_request_specific(ret); + sadi->hwlock = devm_hwspin_lock_request_specific(&pdev->dev, ret); if (!sadi->hwlock) { ret = -ENXIO; goto put_ctlr; @@ -483,7 +483,7 @@ static int sprd_adi_probe(struct platform_device *pdev) ret = devm_spi_register_controller(&pdev->dev, ctlr); if (ret) { dev_err(&pdev->dev, "failed to register SPI controller\n"); - goto free_hwlock; + goto put_ctlr; } sadi->restart_handler.notifier_call = sprd_adi_restart_handler; @@ -491,13 +491,11 @@ static int sprd_adi_probe(struct platform_device *pdev) ret = register_restart_handler(&sadi->restart_handler); if (ret) { dev_err(&pdev->dev, "can not register restart handler\n"); - goto free_hwlock; + goto put_ctlr; } return 0; -free_hwlock: - hwspin_lock_free(sadi->hwlock); put_ctlr: spi_controller_put(ctlr); return ret; @@ -509,7 +507,6 @@ static int sprd_adi_remove(struct platform_device *pdev) struct sprd_adi *sadi = spi_controller_get_devdata(ctlr); unregister_restart_handler(&sadi->restart_handler); - hwspin_lock_free(sadi->hwlock); return 0; }