From patchwork Sun Mar 26 14:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96012 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp853445qgd; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) X-Received: by 10.84.213.16 with SMTP id f16mr23749281pli.156.1490539392307; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a74si6836527pfj.78.2017.03.26.07.43.12; Sun, 26 Mar 2017 07:43:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 S1751317AbdCZOmk (ORCPT + 1 other); Sun, 26 Mar 2017 10:42:40 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:36648 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbdCZOmi (ORCPT ); Sun, 26 Mar 2017 10:42:38 -0400 Received: by mail-wr0-f179.google.com with SMTP id w11so10702639wrc.3 for ; Sun, 26 Mar 2017 07:42:37 -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; bh=k7wbhBR1FgkhlaT+yf8h6b4Tthbkw9zuvc04Wju8OuI=; b=DB56WgbA5UdRlXs/ToCLLPTL5S0WJDB9WR8R9V5DMy90SsARAy03z/FgJ92IXtATZu NZfvIEgEy5aZN2JZFpUXh9H+w5/hK+j68ws/RWhWsDKLn2Tlwf44JffTfvWAXHcSsHE2 jrQ8B1q7Pix9D2EDHlc9g9TexOiQhJHbBGCsE= 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; bh=k7wbhBR1FgkhlaT+yf8h6b4Tthbkw9zuvc04Wju8OuI=; b=IlFECk0Jc7Cltz2/zq69VV/jwSNqFq9BKPpc8WF+BV+qKA4YJY1pNMTp+hHBvLeIbQ MBdkaHEpx6rxTYvFGbz5D/6kVncdeMY94O0R4nF1XP9IMw5uUm345Hfaramyn14yLJbg 8Irnvrx2bUklvEyEStg4WaWnMaAs3iA2CfLzrMISm0Ym8EGViOoJ1eQ8e6g5eQalShwF p6UtesvMe7PXZPLk+GMpNg92cYb/5FBSaiQqhelXl+tz859NKg7P0pm0pQAyzNScGYnW G4XEQ15fb7emrVJ76mGcy6k3MbN1qYbTREW5wqJcFOMkKlw0SZ3VAflnUWljhLU3v/EF H5ug== X-Gm-Message-State: AFeK/H1IQ7PSzZK1K9ksslKNNnPVDW+ESyywpB23AawBlvOOAaqbOHKfqrHAeY+bMJ++EgHP X-Received: by 10.223.170.210 with SMTP id i18mr17604570wrc.114.1490539356132; Sun, 26 Mar 2017 07:42:36 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id l90sm10619516wmi.25.2017.03.26.07.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 07:42:35 -0700 (PDT) From: Leo Yan To: Russell King , Dmitry Torokhov , Alessandro Zummo , Alexandre Belloni , Linus Walleij , Baptiste Reynal , Alex Williamson , Jaroslav Kysela , Takashi Iwai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Leo Yan Subject: [PATCH 2/5] drivers/rtc/rtc-pl030.c: Convert to use devm_*() Date: Sun, 26 Mar 2017 22:41:51 +0800 Message-Id: <1490539314-9681-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> References: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Convert driver to use devm_*() APIs so rely on driver model core layer to manage resources. This eliminates error path boilerplate and makes code neat. Signed-off-by: Leo Yan --- drivers/rtc/rtc-pl030.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Linus Walleij diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index f85a1a9..372b1fd 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -102,49 +102,30 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) struct pl030_rtc *rtc; int ret; - ret = amba_request_regions(dev, NULL); - if (ret) - goto err_req; - rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL); - if (!rtc) { - ret = -ENOMEM; - goto err_rtc; - } + if (!rtc) + return -ENOMEM; - rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); - if (!rtc->base) { - ret = -ENOMEM; - goto err_rtc; - } + rtc->base = devm_ioremap_resource(&dev->dev, &dev->res); + if (IS_ERR(rtc->base)) + return PTR_ERR(rtc->base); __raw_writel(0, rtc->base + RTC_CR); __raw_writel(0, rtc->base + RTC_EOI); amba_set_drvdata(dev, rtc); - ret = request_irq(dev->irq[0], pl030_interrupt, 0, - "rtc-pl030", rtc); + ret = devm_request_irq(&dev->dev, dev->irq[0], pl030_interrupt, 0, + "rtc-pl030", rtc); if (ret) - goto err_irq; + return ret; - rtc->rtc = rtc_device_register("pl030", &dev->dev, &pl030_ops, - THIS_MODULE); - if (IS_ERR(rtc->rtc)) { - ret = PTR_ERR(rtc->rtc); - goto err_reg; - } + rtc->rtc = devm_rtc_device_register(&dev->dev, "pl030", &pl030_ops, + THIS_MODULE); + if (IS_ERR(rtc->rtc)) + return PTR_ERR(rtc->rtc); return 0; - - err_reg: - free_irq(dev->irq[0], rtc); - err_irq: - iounmap(rtc->base); - err_rtc: - amba_release_regions(dev); - err_req: - return ret; } static int pl030_remove(struct amba_device *dev) @@ -152,12 +133,6 @@ static int pl030_remove(struct amba_device *dev) struct pl030_rtc *rtc = amba_get_drvdata(dev); writel(0, rtc->base + RTC_CR); - - free_irq(dev->irq[0], rtc); - rtc_device_unregister(rtc->rtc); - iounmap(rtc->base); - amba_release_regions(dev); - return 0; } From patchwork Sun Mar 26 14:41:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96014 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp853458qgd; Sun, 26 Mar 2017 07:43:14 -0700 (PDT) X-Received: by 10.84.217.2 with SMTP id o2mr23492426pli.51.1490539394286; Sun, 26 Mar 2017 07:43:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a74si6836527pfj.78.2017.03.26.07.43.14; Sun, 26 Mar 2017 07:43:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 S1751518AbdCZOmz (ORCPT + 1 other); Sun, 26 Mar 2017 10:42:55 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:35360 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751513AbdCZOmy (ORCPT ); Sun, 26 Mar 2017 10:42:54 -0400 Received: by mail-wr0-f172.google.com with SMTP id u1so22389700wra.2 for ; Sun, 26 Mar 2017 07:42:52 -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; bh=Kg1tHTicO5RHrZ7CvtEBKgDIkiFAiw69YL/8YdjT9o0=; b=Rq8wVndWfxR+yx0k0AWVKAqtXzpRmDLyOePbw52PecCruYmqvF/z66b3mHGBfCkpYT GeqYlsi2O2J7Fg84GJfVuhF/9ifeRDxsTT2uEZG4obkU2vNNfP+SW9tJveVhpsviXvvE ALgnI95lt1X8Tnapf5hDufVhlQTCqcofmZjD8= 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; bh=Kg1tHTicO5RHrZ7CvtEBKgDIkiFAiw69YL/8YdjT9o0=; b=B2APEXNh0GGS417fQo6LAzlEhTn/HVG1u7VpKBq6OjNyUP7VAE8t/Ba6ildAym/aIv S+aPpKGKt3qV4VY1R+rVzeRty1CtwETXyXdL852ej3ldFHLLAbOXF9zKyOAMmZ5kn9NF agNP2AEw70kY9Kt8QnIZX09F6TUsUf3PTgKHdT12kHnrCd2TO3RT2I92z0cedmh2CjZG +b32C6v7jj4i4ukfX+nHt0YCJwmLXl6cm0kzG8hvkvseqNYIiHHYFDw8tYZcEaHd7nGv zgTwebliC1TUyEFw3OkjxbZg6jkZuLYVhK1YZFxqabl4K5Y3hnIRbao9DQ3IN8Njdexs qfUA== X-Gm-Message-State: AFeK/H2QLoCcvwmyCqUTlZrugOuTbqkbGMQexWQBhpu2tahWU3anaFRZA06ao8LjKAu6HRAg X-Received: by 10.223.166.162 with SMTP id t31mr2208119wrc.15.1490539366996; Sun, 26 Mar 2017 07:42:46 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id l90sm10619516wmi.25.2017.03.26.07.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 07:42:46 -0700 (PDT) From: Leo Yan To: Russell King , Dmitry Torokhov , Alessandro Zummo , Alexandre Belloni , Linus Walleij , Baptiste Reynal , Alex Williamson , Jaroslav Kysela , Takashi Iwai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Leo Yan Subject: [PATCH 4/5] vfio: platform: Convert to use devm_*() Date: Sun, 26 Mar 2017 22:41:53 +0800 Message-Id: <1490539314-9681-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> References: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Convert driver to use devm_*() APIs so rely on driver model core layer to manage resources. This eliminates error path boilerplate and makes code neat. This patch also renames amba_id structure, the old code used some code which directly copied from other driver. Signed-off-by: Leo Yan --- drivers/vfio/platform/vfio_amba.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Eric Auger diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c index 31372fb..433db1f 100644 --- a/drivers/vfio/platform/vfio_amba.c +++ b/drivers/vfio/platform/vfio_amba.c @@ -53,15 +53,14 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) struct vfio_platform_device *vdev; int ret; - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); + vdev = devm_kzalloc(&adev->dev, sizeof(*vdev), GFP_KERNEL); if (!vdev) return -ENOMEM; - vdev->name = kasprintf(GFP_KERNEL, "vfio-amba-%08x", adev->periphid); - if (!vdev->name) { - kfree(vdev); + vdev->name = devm_kasprintf(&adev->dev, GFP_KERNEL, + "vfio-amba-%08x", adev->periphid); + if (!vdev->name) return -ENOMEM; - } vdev->opaque = (void *) adev; vdev->flags = VFIO_DEVICE_FLAGS_AMBA; @@ -71,11 +70,6 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) vdev->reset_required = false; ret = vfio_platform_probe_common(vdev, &adev->dev); - if (ret) { - kfree(vdev->name); - kfree(vdev); - } - return ret; } @@ -84,25 +78,22 @@ static int vfio_amba_remove(struct amba_device *adev) struct vfio_platform_device *vdev; vdev = vfio_platform_remove_common(&adev->dev); - if (vdev) { - kfree(vdev->name); - kfree(vdev); + if (vdev) return 0; - } return -EINVAL; } -static struct amba_id pl330_ids[] = { +static struct amba_id vfio_ids[] = { { 0, 0 }, }; -MODULE_DEVICE_TABLE(amba, pl330_ids); +MODULE_DEVICE_TABLE(amba, vfio_ids); static struct amba_driver vfio_amba_driver = { .probe = vfio_amba_probe, .remove = vfio_amba_remove, - .id_table = pl330_ids, + .id_table = vfio_ids, .drv = { .name = "vfio-amba", .owner = THIS_MODULE, From patchwork Sun Mar 26 14:41:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96015 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp853471qgd; Sun, 26 Mar 2017 07:43:15 -0700 (PDT) X-Received: by 10.99.163.91 with SMTP id v27mr19354281pgn.171.1490539395776; Sun, 26 Mar 2017 07:43:15 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a74si6836527pfj.78.2017.03.26.07.43.15; Sun, 26 Mar 2017 07:43:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-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 S1751584AbdCZOnL (ORCPT + 1 other); Sun, 26 Mar 2017 10:43:11 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:36738 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbdCZOnJ (ORCPT ); Sun, 26 Mar 2017 10:43:09 -0400 Received: by mail-wr0-f181.google.com with SMTP id w11so10707280wrc.3 for ; Sun, 26 Mar 2017 07:43:08 -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; bh=nWkUeaxeGMxaj0cB7gWYS2wiwG302GpGU8GcxUamdic=; b=F/SzTh8i30EYcU4GUEKYOK7BgymlXRVkd4Mo3wHVMYlAoNI4Y1E/iYzPaRVnBnVFQE 169FPF5SBMfgDP42pYDTbybKbqCfxX4NTGXa00JoliVM0xGauip8vByqYcfOFSQeiN6/ nX6Shr9V+xeoaKl/rT5GacfcMPkG8RB39A8GQ= 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; bh=nWkUeaxeGMxaj0cB7gWYS2wiwG302GpGU8GcxUamdic=; b=Dcjp/wQIbOn0ZiTsRZsgE8zCTwZ529qm/FoQHjYHXjf3EFtwRMCX8nq0HN+EsrLFsE zGk6fMfdhgZqo/rZhqoiiJo74holS/Gzijceec+9qx2CnVSPaMoGYtkmOPdvxJPNNZIM 38ckSjlCEhNgGlu+sfIdHXXIaG3lzB+a7VM9bizYBcpRtrzRHNC5BGFU8IG534Fs1ZDT VX5zbDtwecmNiO4sVLk/BdF3SpLHtXBqjICoXsxDC/wmCy6AaZxKgBukpMcvkI5p2uRs qthSXuSBf1oIDP5OA8yh1jBwiizW+jRKYh6fbW8MgQz2MqLviYCrCnKrdotYjHUy8cIO ODaQ== X-Gm-Message-State: AFeK/H0KqLokFbZtyMUFBzTC5Eb/MW82kX+xi/TdWzHLAbxIj3l4cqB4t65hymfJ80nsbFWL X-Received: by 10.28.182.7 with SMTP id g7mr6068632wmf.108.1490539372311; Sun, 26 Mar 2017 07:42:52 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id l90sm10619516wmi.25.2017.03.26.07.42.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 07:42:51 -0700 (PDT) From: Leo Yan To: Russell King , Dmitry Torokhov , Alessandro Zummo , Alexandre Belloni , Linus Walleij , Baptiste Reynal , Alex Williamson , Jaroslav Kysela , Takashi Iwai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, alsa-devel@alsa-project.org Cc: Leo Yan Subject: [PATCH 5/5] ALSA: AACI: Convert to use devm_ioremap_resource() Date: Sun, 26 Mar 2017 22:41:54 +0800 Message-Id: <1490539314-9681-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> References: <1490539314-9681-1-git-send-email-leo.yan@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Convert to use devm_ioremap_resource() in probe function, otherwise it's missed to unremap this region if probe failed or rmmod module. Signed-off-by: Leo Yan --- sound/arm/aaci.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" 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/sound/arm/aaci.c b/sound/arm/aaci.c index 4140b1b..2078568 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -990,19 +990,13 @@ static int aaci_probe(struct amba_device *dev, struct aaci *aaci; int ret, i; - ret = amba_request_regions(dev, NULL); - if (ret) - return ret; - aaci = aaci_init_card(dev); - if (!aaci) { - ret = -ENOMEM; - goto out; - } + if (!aaci) + return -ENOMEM; - aaci->base = ioremap(dev->res.start, resource_size(&dev->res)); - if (!aaci->base) { - ret = -ENOMEM; + aaci->base = devm_ioremap_resource(&dev->dev, &dev->res); + if (IS_ERR(aaci->base)) { + ret = PTR_ERR(aaci->base); goto out; } @@ -1064,9 +1058,7 @@ static int aaci_probe(struct amba_device *dev, } out: - if (aaci) - snd_card_free(aaci->card); - amba_release_regions(dev); + snd_card_free(aaci->card); return ret; } @@ -1079,7 +1071,6 @@ static int aaci_remove(struct amba_device *dev) writel(0, aaci->base + AACI_MAINCR); snd_card_free(card); - amba_release_regions(dev); } return 0;