Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp496884rdb; Tue, 23 Jan 2024 06:11:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFa2UcA34SaM2VxEOg0idS2rGI+zLwyKwGkBjVEcRbVDV7IYaNkh6hZsy/9aJLZrK7Rs6+d X-Received: by 2002:a05:620a:1a23:b0:783:a21d:649e with SMTP id bk35-20020a05620a1a2300b00783a21d649emr2704251qkb.13.1706019083789; Tue, 23 Jan 2024 06:11:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706019083; cv=pass; d=google.com; s=arc-20160816; b=WzSyxKa4rriZKGP5NRXRAxCN6tbDZg7UZsoOhqCLipaD5+q3fK0SoCjS0b3/66S1xX WR6J3WpAcCwd54ZwID5xRICEzHnjF32B5DoZ9KTa8XLO2kRyH6eZdNPOrEXKfO3kS7jR zJLu1EWXBHONvLDryenWnTodDcA49QdBJh/mYiR8zz6Dk/Xnr1QmjN9HKxrRGMV3comB tIwJthjQK1p93aAHWgxTu8wuhP5Ayyuyc7yfmheP5yQ6y4zNqHczR8SRGHgO+BgxBgNC iYrkZqD/NW1y/48CpkWqPFBh0S/DqtwrPTPhzY8WVNZXcy8E7gVLb/krp8CreTSi8QMD tXTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IIMacfmmzZD5CEfpZoAVBQCrv9WjJ7QV14EBtyNiVMc=; fh=9aCTWzhdHmTATz92ptPknh05eXqxgTaEVA9XqyMfwgc=; b=U80VqR5HR8O0BG5uFS5QDasZjmV5A+dYvRSOJGZtM+Bu6IBC7LK7nrGRKVIB/2GNLK m5nDOhcQQ0eUPexvUMwm/1xxxhuyJeCaypcgwQg7vtyindlqtQK2cfVB9BwAGCX25pep cmLn0SFe0eW+DdvK6fDNkL5uNf9qFvtJELV61IkUOUTC3XDYP4pWhN50bObFbL2mXVtd nBAqIVeKNJhKeqiD7tdjvxZRQwfdPNqddetm+hjTR2tpIlHl+CAFOjuuPVhg2HpYHIXR KQMfmv1fCJr8hTp47CW26ZIorS4cluCS/9+f66382iV6fUQS2VrNsQn6G7MLjuLnMHpN GN9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZaWtHge3; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l11-20020a05620a210b00b007837f6ef00asi7793718qkl.377.2024.01.23.06.11.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 06:11:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZaWtHge3; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D048E1C2780C for ; Tue, 23 Jan 2024 14:10:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7BE75FDDD; Tue, 23 Jan 2024 14:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZaWtHge3" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 604F55FDC8; Tue, 23 Jan 2024 14:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706018987; cv=none; b=IGZQ1IV3ihIyC6m+wHFkyAvw4imSv/c8TBAtPgbzhNRG30EIJzc96lMCPQG0W/BsNHLVPZLRJm4eLFluZcIfSZ4HQqk81BPQTfgb7Fm7vhLPA/6pHNaqvK6b0tv9jI4gCuaY9etaMQc/nEHetcU0IfiomruMv0q5o8joEdQoZ38= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706018987; c=relaxed/simple; bh=ZVwSX8hBbcyG6jlkyackNQ9w5I8lTGDkQfMizsNkTEE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=deNv51MQKFuKL1eWzZZkmc9cyGDnREmPRLlrLsopvMtEc0bTv6seujG/xUr98NW69j/oqHOBUwIm+61GBtXI35r6mBt6trn2/gCMlcZHvF8kq6jjgZemmwFzjHZ+LMldTVNc93+quR8IZeeMlwOmr8eIVK3IJleaw3rrKOvstvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ZaWtHge3; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NE9KtK031523; Tue, 23 Jan 2024 08:09:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706018960; bh=IIMacfmmzZD5CEfpZoAVBQCrv9WjJ7QV14EBtyNiVMc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZaWtHge3VEVMACQrPxv4lbwYQ7DsTsfFV+CQBzp9B/qIrWVpkYA/n2yKu88VXjAX2 AWAx6uvwV05DcwAOl9KGWL+UqJhiRJ4w8kckDAMtH2ULR4CltalIdp/EeYMheMtYRL a3Abage53/6CS8ZqPtoEDtENw16bl4dh7/1LqRqo= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NE9KV7113055 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 08:09:20 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 23 Jan 2024 08:09:20 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 23 Jan 2024 08:09:20 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40NE9Iuu034990; Tue, 23 Jan 2024 08:09:19 -0600 From: Andrew Davis To: Jonathan Cameron , Lars-Peter Clausen , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= CC: , , Andrew Davis Subject: [PATCH 4/4] iio: health: afe4404: Use devm IIO helpers Date: Tue, 23 Jan 2024 08:09:18 -0600 Message-ID: <20240123140918.215818-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123140918.215818-1-afd@ti.com> References: <20240123140918.215818-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use a device lifecycle managed IIO helper functions. This helps prevent mistakes like unregistering and freeing out of order in cleanup functions and forgetting to unregister and free on error paths. Signed-off-by: Andrew Davis --- drivers/iio/health/afe4404.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 75a513a92242c..7768b07ef7a6f 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -547,7 +547,7 @@ static int afe4404_probe(struct i2c_client *client) iio_trigger_set_drvdata(afe->trig, indio_dev); - ret = iio_trigger_register(afe->trig); + ret = devm_iio_trigger_register(afe->dev, afe->trig); if (ret) { dev_err(afe->dev, "Unable to register IIO trigger\n"); return ret; @@ -564,42 +564,21 @@ static int afe4404_probe(struct i2c_client *client) } } - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, - afe4404_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(afe->dev, indio_dev, + &iio_pollfunc_store_time, + afe4404_trigger_handler, NULL); if (ret) { dev_err(afe->dev, "Unable to setup buffer\n"); - goto unregister_trigger; + return ret; } - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(afe->dev, indio_dev); if (ret) { dev_err(afe->dev, "Unable to register IIO device\n"); - goto unregister_triggered_buffer; + return ret; } return 0; - -unregister_triggered_buffer: - iio_triggered_buffer_cleanup(indio_dev); -unregister_trigger: - if (afe->irq > 0) - iio_trigger_unregister(afe->trig); - - return ret; -} - -static void afe4404_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct afe4404_data *afe = iio_priv(indio_dev); - int ret; - - iio_device_unregister(indio_dev); - - iio_triggered_buffer_cleanup(indio_dev); - - if (afe->irq > 0) - iio_trigger_unregister(afe->trig); } static const struct i2c_device_id afe4404_ids[] = { @@ -615,7 +594,6 @@ static struct i2c_driver afe4404_i2c_driver = { .pm = pm_sleep_ptr(&afe4404_pm_ops), }, .probe = afe4404_probe, - .remove = afe4404_remove, .id_table = afe4404_ids, }; module_i2c_driver(afe4404_i2c_driver); -- 2.39.2