From patchwork Wed Jan 8 03:13:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11322567 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C272C138C for ; Wed, 8 Jan 2020 03:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0EBB2077B for ; Wed, 8 Jan 2020 03:14:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rXGSfnOd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbgAHDOY (ORCPT ); Tue, 7 Jan 2020 22:14:24 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:40466 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgAHDOY (ORCPT ); Tue, 7 Jan 2020 22:14:24 -0500 Received: by mail-pj1-f66.google.com with SMTP id bg7so440540pjb.5; Tue, 07 Jan 2020 19:14:23 -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=UDt70vT9CBypJ9FiN1tWwjjJ5WMMLvj4KFgZR5+sM14=; b=rXGSfnOdNFjAAO8OGOpbD7qmBASFq4LJQGLaWaS6oDyNgpPZektf8QFw5nUfWNXK9z IsiA0zcaGmF71e9p/bksTn4kT5jzNeTyesIDMmg9VJmZtfPdL9KJs9PInIo7x6g0/Ry/ qNSFJ3lagn9DTA3edjXoN4yyOoTJiYT78p1YTQoaXnNBRQdGH1jB3n/J8IzEspM1mhXQ TtGh9cmEsLRsBot+6A7C7XwKd8Ij0DqyBbEt94F33Oc7kwtG9LhWzkHi7jloeuLhmB7o Ic6ml9RcgWbPqGepl7cdNvpZqgTyW5aAPuvfBeLcdcZ4fA3KlAXigjkMeJraJ5MqB47k 8AAQ== 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=UDt70vT9CBypJ9FiN1tWwjjJ5WMMLvj4KFgZR5+sM14=; b=d9V9Zgnjr0fdpEeMI1C+0D7GRxoNH18WpGd5efbAyuKp46YB85bFG1BxT9uj2iKQT4 zuTxVrHDCr6jb403rfRWMX/8UVBO3VvbwbzKN7j2vSbjqVdf5jbZsJYOAqSXJPqrReqj A1MwmZ01QQt9gny74mld1PCZ9T37dgu6An3buD+SNVHgXrON7Y+Lh1cRqmMo2hj+BLfY Nb2ZZ5Ls/7q1XZXDBpNi2fOoFWv9p0Biyc/Fhtxb5cn/EUBa/nrpgCgn5BheRG32bo31 p+b6JBTsJkvDjV83Zda5PEp2iMfZSJajdUzOSTqrtr7iJNv8AkeWiQ9M8iiF6NRSHxcp S9fA== X-Gm-Message-State: APjAAAXpFzSzy9xdYaCbpcZfWd6klXMMeGouVOR0MiueCD/5uKoYFyxN gJtqgH14PYaWc8Gy8CmdS+w= X-Google-Smtp-Source: APXvYqyz7eGu7Qm8kFTYBlWn4ZJtcTU7XVR3gWZJTxrkiHPhAWl/LG7yjJ6m58wfXDjIDS6QE9+9Kw== X-Received: by 2002:a17:902:5a85:: with SMTP id r5mr3188552pli.222.1578453263274; Tue, 07 Jan 2020 19:14:23 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id z4sm1016811pfn.42.2020.01.07.19.14.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jan 2020 19:14:22 -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 RESEND 1/3] hwspinlock: omap: Change to use devm_platform_ioremap_resource() Date: Wed, 8 Jan 2020 11:13:59 +0800 Message-Id: <6c09c5034a7e68fdfc22d2cb5daa375bccb33a66.1578453062.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Use the new helper that wraps the calls to platform_get_resource() and devm_ioremap_resource() together, which can simpify the code. Meanwhile renaming the error label to make more sense after removing iounmap(). Signed-off-by: Baolin Wang --- drivers/hwspinlock/omap_hwspinlock.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index 14e1a53..dbb1a4c 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -76,7 +76,6 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) struct device_node *node = pdev->dev.of_node; struct hwspinlock_device *bank; struct hwspinlock *hwlock; - struct resource *res; void __iomem *io_base; int num_locks, i, ret; /* Only a single hwspinlock block device is supported */ @@ -85,13 +84,9 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) if (!node) return -ENODEV; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; - - io_base = ioremap(res->start, resource_size(res)); - if (!io_base) - return -ENOMEM; + io_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(io_base)) + return PTR_ERR(io_base); /* * make sure the module is enabled and clocked before reading @@ -101,7 +96,7 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) { pm_runtime_put_noidle(&pdev->dev); - goto iounmap_base; + goto runtime_err; } /* Determine number of locks */ @@ -114,12 +109,12 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) */ ret = pm_runtime_put(&pdev->dev); if (ret < 0) - goto iounmap_base; + goto runtime_err; /* one of the four lsb's must be set, and nothing else */ if (hweight_long(i & 0xf) != 1 || i > 8) { ret = -EINVAL; - goto iounmap_base; + goto runtime_err; } num_locks = i * 32; /* actual number of locks in this device */ @@ -127,7 +122,7 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL); if (!bank) { ret = -ENOMEM; - goto iounmap_base; + goto runtime_err; } platform_set_drvdata(pdev, bank); @@ -147,16 +142,14 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) reg_fail: kfree(bank); -iounmap_base: +runtime_err: pm_runtime_disable(&pdev->dev); - iounmap(io_base); return ret; } static int omap_hwspinlock_remove(struct platform_device *pdev) { struct hwspinlock_device *bank = platform_get_drvdata(pdev); - void __iomem *io_base = bank->lock[0].priv - LOCK_BASE_OFFSET; int ret; ret = hwspin_lock_unregister(bank); @@ -166,7 +159,6 @@ static int omap_hwspinlock_remove(struct platform_device *pdev) } pm_runtime_disable(&pdev->dev); - iounmap(io_base); kfree(bank); return 0; From patchwork Wed Jan 8 03:14:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11322577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC8D18B8 for ; Wed, 8 Jan 2020 03:14:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE4562080A for ; Wed, 8 Jan 2020 03:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vNrxg+7R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgAHDO3 (ORCPT ); Tue, 7 Jan 2020 22:14:29 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42200 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgAHDO0 (ORCPT ); Tue, 7 Jan 2020 22:14:26 -0500 Received: by mail-pg1-f194.google.com with SMTP id s64so829975pgb.9; Tue, 07 Jan 2020 19:14:26 -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=vNrxg+7Rf+tWo8jf9OHR26y1P20aJIfEscmVIi7vtGVBT3WB2C/ycErDqFMLvyVOAP wfzM3rmjiGzHQX/1wQ8LMjTV5XFQd4xZsrYcEWjZxu1lbp1CS+oE1yLefmUMQ0wE4T8j qw1mta5QY83FBnVqw5gwCUJZmP1/qdWWUe7ehlJf/esyT7wjMDE9e2rnMPops2bgPIKK 0uSK4qNcLuBj8GluGMylkbTT3GpxmIijYwisMOucPYA76C3GQDf3ixhXUN/z4cZfuJ1m OT10JeLEP0dMWMFrQ15kJrysxzFY8np6FvY77KIU1qb6DObjcfICpQnZoH1YMM1Z3Xxa nZVA== 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=EA6pi4WlupWqxQmjaxsrJ/gmDbH72w5EKZ7ZF30evnH/yAdOYUnntBLbbG1XxBiNCT Uc8JF4vrssrypes/xz4Gmq8gz+w3xlh+VUecga2K9hOnUayBbSvg6+K6qspt3CozJSQi VpAf9F3NdTjGU+VOOltoyGYbUIxLYvXz8dX4qthp3F+Z6QGtK5e+q/d/GugVdpdABwWX RGuwEubpuNt8peN2oSXvpsKR45m9bU586lMgytWxB8NXziw2y0p8a+dfVLUoPrwPPKlN FB9ONMU4dwboNQ9XCON3A8xH9R0Bj5+k4Q+LLhkE5iBJfZ39jZrAtSjJsBiGEW3W5Tjh raRA== X-Gm-Message-State: APjAAAX2HbIXF6pSVcBpiyC8b5E6SloqDxnggg/c2QoPNtXhrq0PPD0h PudXiVpV4lGpeCI7t3zRCGo= X-Google-Smtp-Source: APXvYqwvuv5efVJHnAEOZ2h9lY7js3XK6QbUOxhKwdrqRGRP51XOqjXb9zJqeSfDHtYEQLbsZoUYDg== X-Received: by 2002:aa7:8687:: with SMTP id d7mr2786761pfo.164.1578453265726; Tue, 07 Jan 2020 19:14:25 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id z4sm1016811pfn.42.2020.01.07.19.14.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jan 2020 19:14:25 -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 RESEND 2/3] hwspinlock: omap: Use devm_kzalloc() to allocate memory Date: Wed, 8 Jan 2020 11:14:00 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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; } From patchwork Wed Jan 8 03:14:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11322573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA0D114B4 for ; Wed, 8 Jan 2020 03:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 885C92087F for ; Wed, 8 Jan 2020 03:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cjA+8s6B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgAHDOa (ORCPT ); Tue, 7 Jan 2020 22:14:30 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38261 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbgAHDO2 (ORCPT ); Tue, 7 Jan 2020 22:14:28 -0500 Received: by mail-pl1-f196.google.com with SMTP id f20so517917plj.5; Tue, 07 Jan 2020 19:14:28 -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=MEMVCvrI0WADDr1Rd4hdPFBKPBKqjIAdQ9vka/nhGK8=; b=cjA+8s6BieRSdKkZZL6r9MDFx2P3Rkf0tVFLPBVtAuVqIuiznU66SXDNOEYoLYV2GV PavIpJ9NZm5cubQ08N4vO7fJ4qmEVVX/hVlcWWpyp2sfnDABnAZvaehqEQf6GIYbacVT dkWxwGLTQMF7mWKRk26Oc6YWr42K0ajSp9fdCIobtPRmoUIk8EUuDygVgPEI6isxLY3+ gWhy8Bbd8uLAvGPNAh+bKsNZ+Tc2FZLpeTYPVxqD4MeueP5SmgZ84c6HUGZOCoPJxlTv 3KNUCCsXFlOrNMY91CnEev9qTghLF5v75bLrVUJsTQeGJqOVAvoC9G9+C9SvH/h6PBKP yWtw== 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=MEMVCvrI0WADDr1Rd4hdPFBKPBKqjIAdQ9vka/nhGK8=; b=CDxTkOUouFGvoB+3sf8bKbpmJ/xhqe9YuxkrIrvHhML+71FuWStkfFFNejj4R3yLKW j0AOfoOFGPyZx/susWS8e5Cm7OcXtmCDPcnzaQ39d/xwKu/exuKBEcSmrYvPR0WEVEE0 M+FQsP9saNoOCe/RMTcdPABzAQvmbexzmwfsHt1aKn+QGBdcsNfgZW+3lePMq3C3XSPe Zo3YPCwb8k33N4BGQZ0S1MXiw89A7PFGDse3O387mt4yUL2sv6LhXkEVhJsb31unxk6H Zq/XrzlBbhYMLVC7zBzfzMQtXHqi36u5SM1iDDLM0YHrE6HDppsTmIJqhq5hqyBh5X26 PaaQ== X-Gm-Message-State: APjAAAW62jBW6vGcYsdhwXCrft01HXily2ebFGMAoxZ0gm46NKHmZfn8 oWwy5S9l25P8adX4gri/ICQ= X-Google-Smtp-Source: APXvYqyLt8wcr8zHu/gJz+x9jIYAWiQGf4diuYdoxJFt5UvVAKXJNb077Nb+ebThPHThkllp1h9Emg== X-Received: by 2002:a17:90b:145:: with SMTP id em5mr1990768pjb.20.1578453268158; Tue, 07 Jan 2020 19:14:28 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id z4sm1016811pfn.42.2020.01.07.19.14.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jan 2020 19:14:27 -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 RESEND 3/3] hwspinlock: omap: Use devm_hwspin_lock_register() to register hwlock controller Date: Wed, 8 Jan 2020 11:14:01 +0800 Message-Id: <315adcc5dfc6aa5c001448401dda4065e33deef2.1578453062.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Use devm_hwspin_lock_register() to register the hwlock controller instead of unregistering the hwlock controller explicitly when removing the device. Signed-off-by: Baolin Wang --- drivers/hwspinlock/omap_hwspinlock.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index 3b05560..9e8a8c2 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -131,8 +131,8 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) for (i = 0, hwlock = &bank->lock[0]; i < num_locks; i++, hwlock++) hwlock->priv = io_base + LOCK_BASE_OFFSET + sizeof(u32) * i; - ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops, - base_id, num_locks); + ret = devm_hwspin_lock_register(&pdev->dev, bank, &omap_hwspinlock_ops, + base_id, num_locks); if (ret) goto runtime_err; @@ -148,15 +148,6 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) static int omap_hwspinlock_remove(struct platform_device *pdev) { - struct hwspinlock_device *bank = platform_get_drvdata(pdev); - int ret; - - ret = hwspin_lock_unregister(bank); - if (ret) { - dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret); - return ret; - } - pm_runtime_disable(&pdev->dev); return 0;