From patchwork Wed Feb 20 14:00:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 10822173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B87F717FB for ; Wed, 20 Feb 2019 14:07:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A087C2E095 for ; Wed, 20 Feb 2019 14:07:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 947B32E365; Wed, 20 Feb 2019 14:07:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 567FA2E367 for ; Wed, 20 Feb 2019 14:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbfBTOHD (ORCPT ); Wed, 20 Feb 2019 09:07:03 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([85.215.255.103]:21387 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfBTOHC (ORCPT ); Wed, 20 Feb 2019 09:07:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550671620; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=XsPC/aju7F7ifIrh5ctlr6x24fEHYPUbd63O6lin5RY=; b=CdrY3jLvSXGtny0ImCQKnw6TOAKvxvDeJm/oeRonIMWrPGlUYQ3hhp3v3qGcepydmI UWE3tMR32g8+sciGM/XcpQk5+hF6BGHd+XsRlVNzx2kLDD4Bh6L38W7MzyPhBI83lQpJ scTjv6Unm+l6HsgZuulviJac/KXWMvv8bdgph9MG/x48X7PEIBeSYr2r0ukjumqgkKQS HI7jMSBTPLmBl4F/8YtGNN9ICOGyWhoFmQ2PXB7OAeW62FmmhoNss09wrpnUsSwmT9SB AxO1uwxR3VqLRlxNB3tWFgpnHCFOtNgbKLkEhGgJq8XiHuDU39hYhiZAqJ6NZ9ZrvTVW A+ug== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1OAA2UNf2M0OzzrKQ==" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id 608499v1KE10EqX (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 20 Feb 2019 15:01:00 +0100 (CET) From: "H. Nikolaus Schaller" To: Linus Walleij , Jonathan Cameron , Rob Herring , Mark Rutland , "H. Nikolaus Schaller" , Andy Shevchenko , Charles Keepax , Song Qiang Cc: letux-kernel@openphoenux.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] iio: accel: bma180: convert to devm Date: Wed, 20 Feb 2019 15:00:52 +0100 Message-Id: <900f59b94ef2e1b5559b363c0d1af4fefccd0366.1550671256.git.hns@goldelico.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This simplifies the code a little. Signed-off-by: H. Nikolaus Schaller --- drivers/iio/accel/bma180.c | 56 ++++++++++++++------------------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 248be67e4f41..3f5ee2d495d3 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -738,7 +738,7 @@ static int bma180_probe(struct i2c_client *client, ret = data->part_info->chip_config(data); if (ret < 0) - goto err_chip_disable; + goto err; mutex_init(&data->mutex); indio_dev->dev.parent = &client->dev; @@ -748,12 +748,25 @@ static int bma180_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bma180_info; + ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, NULL, + bma180_trigger_handler, NULL); + if (ret < 0) { + dev_err(&client->dev, "unable to setup iio triggered buffer\n"); + goto err; + } + + ret = devm_iio_device_register(&client->dev, indio_dev); + if (ret < 0) { + dev_err(&client->dev, "unable to register iio device\n"); + goto err; + } + if (client->irq > 0) { - data->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, - indio_dev->id); + data->trig = devm_iio_trigger_alloc(&client->dev, "%s-dev%d", + indio_dev->name, indio_dev->id); if (!data->trig) { ret = -ENOMEM; - goto err_chip_disable; + goto err; } ret = devm_request_irq(&client->dev, client->irq, @@ -761,7 +774,7 @@ static int bma180_probe(struct i2c_client *client, "bma180_event", data->trig); if (ret) { dev_err(&client->dev, "unable to request IRQ\n"); - goto err_trigger_free; + goto err; } data->trig->dev.parent = &client->dev; @@ -769,34 +782,14 @@ static int bma180_probe(struct i2c_client *client, iio_trigger_set_drvdata(data->trig, indio_dev); indio_dev->trig = iio_trigger_get(data->trig); - ret = iio_trigger_register(data->trig); + ret = devm_iio_trigger_register(&client->dev, data->trig); if (ret) - goto err_trigger_free; - } - - ret = iio_triggered_buffer_setup(indio_dev, NULL, - bma180_trigger_handler, NULL); - if (ret < 0) { - dev_err(&client->dev, "unable to setup iio triggered buffer\n"); - goto err_trigger_unregister; - } - - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&client->dev, "unable to register iio device\n"); - goto err_buffer_cleanup; + goto err; } return 0; -err_buffer_cleanup: - iio_triggered_buffer_cleanup(indio_dev); -err_trigger_unregister: - if (data->trig) - iio_trigger_unregister(data->trig); -err_trigger_free: - iio_trigger_free(data->trig); -err_chip_disable: +err: data->part_info->chip_disable(data); return ret; @@ -807,13 +800,6 @@ static int bma180_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct bma180_data *data = iio_priv(indio_dev); - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - if (data->trig) { - iio_trigger_unregister(data->trig); - iio_trigger_free(data->trig); - } - mutex_lock(&data->mutex); data->part_info->chip_disable(data); mutex_unlock(&data->mutex);