Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp378601pxx; Mon, 26 Oct 2020 10:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTkX/bLJWeQCkYi7IBOEWT3YF+R80pPGWdsRGdhlHsGSKJM2GdruNt/GyqTtS9lifFJxF9 X-Received: by 2002:a17:906:824b:: with SMTP id f11mr16269285ejx.16.1603733558683; Mon, 26 Oct 2020 10:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603733558; cv=none; d=google.com; s=arc-20160816; b=avLb+HxfAlpsnCKrjzAxqW3c4ND9wARR28vEkVv9jSbaX8y6pb86SnlWRZTbwUVBw2 8wb/UiGFFcU0AC8g/D074l/dnE8vmIDDs2Zz4AOH3TdC9TIHABPWLDtPYWVzl+9MPVH2 +HHvHIlgmnyC14J/HSU3bCFwFh+JwtBto8WuIZbGFAqGNrD+NDEPu88NMpZIllcSabRV neeOx5oss6Jl4DyzWB6IoHc8Ve1o+wND0jt46BU30+8s/ppkVlTB6iB6aej7pwrkrKWJ /idj2Bj+6EaCnzvLedP0c3Cwj1/uWKaXOHyQGkV8jOUyJTu38NcxV7uQ3DRwGLrUgKlJ KLKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2ELZQG2NaQttMYr9kJgm589fBatjQILmOfzJPCuqc5Y=; b=i/dOB9dAB9V1OjL9Ms2gfYFyp8AQmC/i9heAuWMkCf2b0gcbJrKMwahxIOUmbnB+1A 0ttp9CNNJTpJbH3UcUxgnXx2PuFxHKuy/2NYrUA2FSAAuA8ybc+Rz9UHE1H9P74ykMUq Norta8f6rUamdMwWDkrCDj3I1QDy2fhfpNXLvAaGV+jx/CB1JPyJgDqicsXESsWeg3Iq n0BSVGw8DKhevqB2i5WeGXwzv0PWLgyd5Mt3OqmTVt7qwYxfWVkv6egYfdyM9P8gpCFf nJaKMpEJfFafaojB71kRw6H6Zwl6jIAgWZqH/kxg+p5xrDW6/qC+6LmyjZl4vDJQXyB2 F2tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=UnKuxJDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i25si7557782ejd.567.2020.10.26.10.32.16; Mon, 26 Oct 2020 10:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=UnKuxJDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1780269AbgJZNgf (ORCPT + 99 others); Mon, 26 Oct 2020 09:36:35 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33393 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1780180AbgJZNg3 (ORCPT ); Mon, 26 Oct 2020 09:36:29 -0400 Received: by mail-wr1-f67.google.com with SMTP id b8so12619777wrn.0 for ; Mon, 26 Oct 2020 06:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2ELZQG2NaQttMYr9kJgm589fBatjQILmOfzJPCuqc5Y=; b=UnKuxJDLDxWVkgZLJZaKbCEGY8XmPdeCTb13G4N7oB+0BCGxI2N1raabhO7DLxB9gt baq0L2TyGPLzvLPriFZb6iprKVze14yzvC2oi0IHGX0VQ7eIziDOOfHhkHGhjZ+/pG+J DRrMOkin1ClHgXmGdfzMQkZOEhyDXcwGJn1RODHk8RkTyLURuFYcdBZcIoVFMOUXQ6sW mqF8fDmb/NRHoxLyR/+p572ecPm48+Vr+2Wp7uqv6GIKKdaQHv3CoJXZADWcgXwgplrm rrowddeaQhtAnDT9f4njAIUti8jdp9hszOl0iCQEXAqh0vqql92EqKpeugFKcb07SoOa 8Lkw== 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:mime-version:content-transfer-encoding; bh=2ELZQG2NaQttMYr9kJgm589fBatjQILmOfzJPCuqc5Y=; b=k9cfAKQpOKL1cu1ahK2bNbotwp2kSS1vGtP1+pwi1FK6tDl5squxB0SunQE3SrE3fF UdPfYKheMHk30WUoxbZq/VEg/YpWGqvPB/SvAHfiYS6J+P2t2+mOQ4+vsAVYNdW2VB7u EICEYITgcFb7z/OKS6KF6BFWkwZuqQSjcLqgDSW5MFMMm/bRUkYfJoScpW+UbQX405ZA 60LQg7aSNDeaD/u5fCv++3IW6OZNtmEU/RRQGGg6+Ze2El5NWbu5LnfX1J/8sL8s31qe SxaWwIbALay6VRTkHz6wsJGHESZuyZJbOOkj8zquGThphvYl7Aeu2vWI3WFhAifEg20x Lh9g== X-Gm-Message-State: AOAM533bKmLrQg3FdI2vay7Aa9it+mvNoYbAlJuHGCiHf+RDa/2q4Zoe ysRB6GqvkTWehTkm+naF/31whg== X-Received: by 2002:a5d:554b:: with SMTP id g11mr18112929wrw.370.1603719386608; Mon, 26 Oct 2020 06:36:26 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-190-206.w2-15.abo.wanadoo.fr. [2.15.39.206]) by smtp.gmail.com with ESMTPSA id f7sm23688991wrx.64.2020.10.26.06.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 06:36:25 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 4/5] iio: adc: xilinx: use devres for irq handling Date: Mon, 26 Oct 2020 14:36:08 +0100 Message-Id: <20201026133609.24262-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201026133609.24262-1-brgl@bgdev.pl> References: <20201026133609.24262-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Further simplify the remove() callback and error paths in probe() by using the managed variant of request_irq() as well as using a devm action for cancelling the delayed work at driver detach. Signed-off-by: Bartosz Golaszewski --- drivers/iio/adc/xilinx-xadc-core.c | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index e0da6258092c..4440b7a9bd36 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1192,6 +1192,13 @@ static void xadc_clk_disable_unprepare(void *data) clk_disable_unprepare(clk); } +static void xadc_cancel_delayed_work(void *data) +{ + struct delayed_work *work = data; + + cancel_delayed_work_sync(work); +} + static int xadc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1289,14 +1296,19 @@ static int xadc_probe(struct platform_device *pdev) } } - ret = request_irq(xadc->irq, xadc->ops->interrupt_handler, 0, - dev_name(dev), indio_dev); + ret = devm_request_irq(dev, xadc->irq, xadc->ops->interrupt_handler, 0, + dev_name(dev), indio_dev); + if (ret) + goto err_free_samplerate_trigger; + + ret = devm_add_action_or_reset(dev, xadc_cancel_delayed_work, + &xadc->zynq_unmask_work); if (ret) goto err_free_samplerate_trigger; ret = xadc->ops->setup(pdev, indio_dev, xadc->irq); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; for (i = 0; i < 16; i++) xadc_read_adc_reg(xadc, XADC_REG_THRESHOLD(i), @@ -1304,7 +1316,7 @@ static int xadc_probe(struct platform_device *pdev) ret = xadc_write_adc_reg(xadc, XADC_REG_CONF0, conf0); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; bipolar_mask = 0; for (i = 0; i < indio_dev->num_channels; i++) { @@ -1314,17 +1326,17 @@ static int xadc_probe(struct platform_device *pdev) ret = xadc_write_adc_reg(xadc, XADC_REG_INPUT_MODE(0), bipolar_mask); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; ret = xadc_write_adc_reg(xadc, XADC_REG_INPUT_MODE(1), bipolar_mask >> 16); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; /* Disable all alarms */ ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK, XADC_CONF1_ALARM_MASK); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; /* Set thresholds to min/max */ for (i = 0; i < 16; i++) { @@ -1339,7 +1351,7 @@ static int xadc_probe(struct platform_device *pdev) ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i), xadc->threshold[i]); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; } /* Go to non-buffered mode */ @@ -1347,15 +1359,12 @@ static int xadc_probe(struct platform_device *pdev) ret = iio_device_register(indio_dev); if (ret) - goto err_free_irq; + goto err_free_samplerate_trigger; platform_set_drvdata(pdev, indio_dev); return 0; -err_free_irq: - free_irq(xadc->irq, indio_dev); - cancel_delayed_work_sync(&xadc->zynq_unmask_work); err_free_samplerate_trigger: if (xadc->ops->flags & XADC_FLAGS_BUFFERED) iio_trigger_free(xadc->samplerate_trigger); @@ -1380,8 +1389,6 @@ static int xadc_remove(struct platform_device *pdev) iio_trigger_free(xadc->convst_trigger); iio_triggered_buffer_cleanup(indio_dev); } - free_irq(xadc->irq, indio_dev); - cancel_delayed_work_sync(&xadc->zynq_unmask_work); return 0; } -- 2.29.1