From patchwork Tue Jun 12 18:26:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9239 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F129B23E56 for ; Tue, 12 Jun 2012 18:27:13 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id A8C3CA182E4 for ; Tue, 12 Jun 2012 18:27:13 +0000 (UTC) Received: by yenq6 with SMTP id q6so4052493yen.11 for ; Tue, 12 Jun 2012 11:27:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=nJjMGTN9LXnYB3AkbnCoN5mYioNQ0MMap5WgVLx78i8=; b=PPG6ZpNGzELs0VEW/yS+vHhx1QdNCTCvQ+CzmEV/XSDkN4KVCwVDxhRKa4MMdkH4Jx cXZ5IEqdk+ZVfQM1G6kIV4BJiV94ss7V7Za84niPQXfgZ1JhS9djeBHGJrXNzqjG3Cg0 otjMGcgk5E/FHUTeLkVkgjeU2n0j0lMgFu1lfx0jiEFJseQ9SMdFDzCyimU2J8u3jQLj +UjBR/vZoxMv0m2UiGR4IRqbC/5RRarmLHwNKMfRd9QP7Z7ZeNv4kqLKZvuE630VZxIN 90SIcdDVVbF89A6MJLzDdPGU1sibpk45JHLn7rqnmcSXbAU879jMtuUrHMco0T2UmiiH kEnA== Received: by 10.50.160.198 with SMTP id xm6mr9257077igb.0.1339525632839; Tue, 12 Jun 2012 11:27:12 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp182118ibb; Tue, 12 Jun 2012 11:27:12 -0700 (PDT) Received: by 10.14.47.3 with SMTP id s3mr7379250eeb.127.1339525631529; Tue, 12 Jun 2012 11:27:11 -0700 (PDT) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com. [207.126.144.139]) by mx.google.com with SMTP id p41si9629739eef.15.2012.06.12.11.27.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 11:27:11 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKT9eJ+/ugXiDmIJ6LYy1UV4NiExwyTkdu@postini.com; Tue, 12 Jun 2012 18:27:11 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 3C7AB58; Tue, 12 Jun 2012 18:26:44 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 262C84A; Tue, 12 Jun 2012 15:38:42 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 29DD924C07C; Tue, 12 Jun 2012 20:26:55 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 12 Jun 2012 20:27:04 +0200 From: Linus Walleij To: Samuel Ortiz , Cc: Linus Walleij Subject: [PATCH] mfd: ab3100-core: use devm allocation Date: Tue, 12 Jun 2012 20:26:58 +0200 Message-ID: <1339525618-8318-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmqcmTuaOMFgS3uDHCcDeIal83suQp6KQ6Zg3KXShvJW+1OV6ai0Ca0/4NjtDzcWORnTSJ/ From: Linus Walleij Allocate memory and irq for device state using devm_* helpers to simplify memory accounting. Signed-off-by: Linus Walleij --- drivers/mfd/ab3100-core.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c index 1efad20..4276aab 100644 --- a/drivers/mfd/ab3100-core.c +++ b/drivers/mfd/ab3100-core.c @@ -867,7 +867,7 @@ static int __devinit ab3100_probe(struct i2c_client *client, int err; int i; - ab3100 = kzalloc(sizeof(struct ab3100), GFP_KERNEL); + ab3100 = devm_kzalloc(&client->dev, sizeof(struct ab3100), GFP_KERNEL); if (!ab3100) { dev_err(&client->dev, "could not allocate AB3100 device\n"); return -ENOMEM; @@ -921,7 +921,7 @@ static int __devinit ab3100_probe(struct i2c_client *client, /* Attach a second dummy i2c_client to the test register address */ ab3100->testreg_client = i2c_new_dummy(client->adapter, - client->addr + 1); + client->addr + 1); if (!ab3100->testreg_client) { err = -ENOMEM; goto exit_no_testreg_client; @@ -931,13 +931,13 @@ static int __devinit ab3100_probe(struct i2c_client *client, if (err) goto exit_no_setup; - err = request_threaded_irq(client->irq, NULL, ab3100_irq_handler, - IRQF_ONESHOT, "ab3100-core", ab3100); - /* This real unpredictable IRQ is of course sampled for entropy */ - rand_initialize_irq(client->irq); - + err = devm_request_threaded_irq(&client->dev, + client->irq, NULL, ab3100_irq_handler, + IRQF_ONESHOT, "ab3100-core", ab3100); if (err) goto exit_no_irq; + /* This real unpredictable IRQ is of course sampled for entropy */ + rand_initialize_irq(client->irq); err = abx500_register_ops(&client->dev, &ab3100_ops); if (err) @@ -962,7 +962,6 @@ static int __devinit ab3100_probe(struct i2c_client *client, i2c_unregister_device(ab3100->testreg_client); exit_no_testreg_client: exit_no_detect: - kfree(ab3100); return err; } @@ -972,16 +971,8 @@ static int __devexit ab3100_remove(struct i2c_client *client) /* Unregister subdevices */ mfd_remove_devices(&client->dev); - ab3100_remove_debugfs(); i2c_unregister_device(ab3100->testreg_client); - - /* - * At this point, all subscribers should have unregistered - * their notifiers so deactivate IRQ - */ - free_irq(client->irq, ab3100); - kfree(ab3100); return 0; }