Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp227746ybl; Wed, 4 Dec 2019 01:33:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxj9H+uXTSuNjqJZ6q+PX5MRB8F0K0yYvfgg70ZYxOwoTiwobOTVF241rc5R4sjigUZuKkL X-Received: by 2002:a9d:6496:: with SMTP id g22mr1812316otl.340.1575452034356; Wed, 04 Dec 2019 01:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575452034; cv=none; d=google.com; s=arc-20160816; b=dBTvxu8yDPPegKe/L7mi/MeTFt+Au2Q/1qru64sxmzxYGdgl8AeC+bgQKPXQRtKS4G T2K0EFnGfZdLwTfspAyv+joXnDlCoBgqScST5C8n2f/5u9kTjussOXz3a2R6z7gebhgC XLOGG47wITlPdScocf11U4gzMpkdJ0LgmKkO7KOtTL8OgWQXFCKPmUNXBMGe3orrUXRF sfVooIFc5yL4abbTMjZ7NgFRTb2u7FS5g8NpmUGBNV23KeMOK7ZS+GJFqGDyFdkFGjXo VH0mbgDTOZOzEZ08MhM/VuoW5xPzBtkP/a71O6gBeJykiunGvifH7k/ApmLYmdAMcXr8 PrFg== 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; bh=4bkpUfs7eIWG8ngSeP18jBoFZdQNW5P5Kn+adde7u5o=; b=g1WNReb4hYNWmNUjAYkKZrpFaXHgWqrDoo5HbdV8QLnRZKJnWfj2190JHYXBuvGrd1 /32jQ6cP6ueflz39PPy+TK1VkRIIU9iiOjx0LfvvsgJcjIbHsDGk4la/6wkE9H6yoeUb FdLZgSEVn9En6wluOyg2eT+oLg4ic1za4TCa9Vll03v3qwkakY0wfaMzM+11bjPGUwaz 6WAKaB/vSn6zwTa2n/PoENaLnTdn0+zDiyPNzN+xKlxnCfuFhFA8htLwPynciuQHiUOj 1Fw8yvlLkwnECd5rF0VXioE5269hW/FL1rjHfGUhyyZoFR8KeaTcl9af4LVx/JXEIzBL hbxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aYYWZsJi; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si3059034oic.119.2019.12.04.01.33.41; Wed, 04 Dec 2019 01:33:54 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=aYYWZsJi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727447AbfLDJcR (ORCPT + 99 others); Wed, 4 Dec 2019 04:32:17 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:44425 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725922AbfLDJcP (ORCPT ); Wed, 4 Dec 2019 04:32:15 -0500 Received: by mail-pj1-f67.google.com with SMTP id w5so2746321pjh.11; Wed, 04 Dec 2019 01:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=4bkpUfs7eIWG8ngSeP18jBoFZdQNW5P5Kn+adde7u5o=; b=aYYWZsJigk7358H8li+5bb4cvWZCvwhyy4sUdYUnIAHpojjw3tNOQ9f5pypQx0brQ4 rpMwoGcO/53e6RSpPMK1en7HhLg0/tAwYf2MW5zdDfEJbbBrfwrORJmCUWOrwShXNTAG cpcQDN4fzFvlRsC67VO1wchoC214EttAXitoEIifRJUAIazP/Ua8EQKy4QaDDfWcdgwC QZzrk4RXjMoVXicnO3VqVnjUINB8HTQW8rbTK8kNDOWOfNFb++aBEF63ZmvY8tD82jkt CJ2ssKj31iDhPNkSaidt9KIz3UGO/RIhEAmONSo45G2ZPWUUGIiLOXXUHySSi4b/bwYR cLBQ== 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=4bkpUfs7eIWG8ngSeP18jBoFZdQNW5P5Kn+adde7u5o=; b=NKhZiPiCeABReBQREIDLsa+iNoQG8XTH/t6yj4gTmnV2a7CSft/LEqry8LM2QSlzrq zssQ/3jO55e2SJlatFCHISCCZtF9cyDdnFl8ycaYYmKfY+dH8+xKlvJkIMlqwd3mPTua Rnpal77JuOwGtHnXCpOou1DEWhpXDdzGctLbQJJraGs4wRiH8Fu2el1e6L45wtFvhnwQ bmRkeuYdA4y6qRJws0Jq/bS8oHhd0QaZc4k1IwSv85ee+nfpBroWhxHmT8+c8vXoq2DX a/y6yuC8f8B5mKab4t4k6aGgw4YjjSRjkwijaQjYFBJB5RGvwB4FgLw95V8qQBfIqz5P PaJg== X-Gm-Message-State: APjAAAUgCLDQl+hU9MN3lYBq7w0J5P1hS+/OwFuyah3HjjHCvn5sn+B2 22aXulkHJQew1W8uf+R/1FA= X-Received: by 2002:a17:90a:77c8:: with SMTP id e8mr2186745pjs.83.1575451934861; Wed, 04 Dec 2019 01:32:14 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 91sm2380086pjq.18.2019.12.04.01.32.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Dec 2019 01:32:14 -0800 (PST) From: Baolin Wang To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: baolin.wang7@gmail.com, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwspinlock: omap: Use devm_kzalloc() to allocate memory Date: Wed, 4 Dec 2019 17:31:30 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_kzalloc() to allocate memory, which can simplify the error handling. Signed-off-by: Baolin Wang --- drivers/hwspinlock/omap_hwspinlock.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index dbb1a4c..3b05560 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -119,7 +119,8 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) num_locks = i * 32; /* actual number of locks in this device */ - bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL); + bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks), + GFP_KERNEL); if (!bank) { ret = -ENOMEM; goto runtime_err; @@ -133,15 +134,13 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops, base_id, num_locks); if (ret) - goto reg_fail; + goto runtime_err; dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n", num_locks); return 0; -reg_fail: - kfree(bank); runtime_err: pm_runtime_disable(&pdev->dev); return ret; @@ -159,7 +158,6 @@ static int omap_hwspinlock_remove(struct platform_device *pdev) } pm_runtime_disable(&pdev->dev); - kfree(bank); return 0; } -- 1.7.9.5