Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3230138pxb; Sun, 26 Sep 2021 08:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3ii/sezk0mq3Vm/MJ/C7n4958Chro0BIhDA8UsmjG54OQvknGnz3lXADoMwh0s3kBKetl X-Received: by 2002:a17:906:308d:: with SMTP id 13mr22344599ejv.570.1632671590562; Sun, 26 Sep 2021 08:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632671590; cv=none; d=google.com; s=arc-20160816; b=nXCEJDtL3pdyTVycTsQQwfAYqRPeY4Z+lB5qGP0BEYy6rHVnYPPbvRmgjoawTO1sQG h/6S1TuwjvxKZEkA6gCeFI1jCZUWak7juyktUbafZT1+BYzZLNh5KeCly73evMZ4dnt1 AZni+dTK4IzjOSg+7Z2QUEDjLtIwHIIBUhejp/NFfW7ZOlDQ+SLAI6/OnL0jwA+uk8Vg wZc3X62eA6gSQia8pjSp1HOLTWllXMdW0el0qzwQFFtzp7rlD7MuczuanLdzYai3QWul PmqjerbgYFBEZMBQ9jQkYV3PtSsSm1rYD+x1/OcTi4KmcBhqZ1zLsXNKw8xG54BZmj4c I8pQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=G7Hf5GrZ92QHrs2oP0z+Ce2L1Cm+CIcH6pC/yH99vLU=; b=VbSnaiuvwTzF52sKib+i75XYoautAAzdtIZEamT3tiNdztnHmCIK5DCZSzNFgEx6KS LB8VHPzm8dfF8kBTj21RoQ1Jx1ILnT9baTnYaqTLLYDfm4FDWUqG+X6pIXlfDlb6Kg00 tRlfdSV9uiLYgWtRogdWcJ4xtmuuytSnaRnUi+q9tvS9RLjldxnlBL66zQkQnRoq+5FH DT5yGsE3Gt0QQ5UdAZ1Ks/syKmI6bJPdKE/J0emtlC3n63pD+mDSuyvBwaMzpmsztV6K jseG66v7ekSTvWmeWGwTEoD+WjYqkqSaAG0BzJLuBJIVfjJsRPcJ/rTUUX+9sILKFvgI HB1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=FWXoCoOh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si13851626edi.151.2021.09.26.08.52.30; Sun, 26 Sep 2021 08:53:10 -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=@deviqon.com header.s=google header.b=FWXoCoOh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbhIZPvS (ORCPT + 99 others); Sun, 26 Sep 2021 11:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232060AbhIZPvR (ORCPT ); Sun, 26 Sep 2021 11:51:17 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4F80C061575 for ; Sun, 26 Sep 2021 08:49:40 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id dm26so24050389edb.12 for ; Sun, 26 Sep 2021 08:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G7Hf5GrZ92QHrs2oP0z+Ce2L1Cm+CIcH6pC/yH99vLU=; b=FWXoCoOhp/3CuRldq4F414is8Y2msOk2LuLifdsXvalRtmaQCh8bPPw337IJQSMagc I3qtDs5DkKbZZH1ZL1I1GcydZF/k9ZTYQ3rkKuEsujze+bTCdH2ZPMVf/jM+sMauMtwo zHJ3XW7Y+YjnIKnRb4djMPdvsKe0TqR83PB+wkcerjqkYY4GtakYcWbxlsFhuQw3sp8R avcGBdl16HQj2LC4qCo7ZLOXeHFJsk+UhJ1QNYbqSctUg4A65hCMRXt4Qy3drW1pEQS6 NoYA5XA5lSFxcoTuBbpmrxFX7K6EmtJLP2HuhxffuPQZx21uEpm6mFiW+KAMX//M8H1I QsPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G7Hf5GrZ92QHrs2oP0z+Ce2L1Cm+CIcH6pC/yH99vLU=; b=fESQeY0WcMjYwUwpgArxw37UtlH59ij2Dn5AWZKijcohMA/I0HUBMQa34ps+fu+L5Z w2jDQ8+0EpLgG8aQiBHl464QBeUXgAIq5437VG+P/hfXdExX0f4lgmcUHzqn6Scj/IiP c2f+o9x9V+GrB+pPnosJdGsDOIaY7vNm3o3ZPA+X+FWeMJOWGZcGrJHN5YCaxhcZCs8S x3elb90MnM1gpyja+Ptb/Qhmf1tnDbHQyDDRFZ38nccYZYXR5vbWSBMFiAfPo7CjRQCp 7xBpvP2HI4FnVn2w6d6cnhLYAvNdwVH7CVMyM6sYkaiYlV3VuG+E+Kmog9G8FlKyMOA4 6dwQ== X-Gm-Message-State: AOAM531VE92YoGCrWAxO4D2g/k96Ya1H63frZdx53qjY+s9e+aYJ9RTG Yjqe+WyT72jjWMFyCe/9+y61s1iHIUid+A== X-Received: by 2002:a17:906:2314:: with SMTP id l20mr4823102eja.334.1632671379046; Sun, 26 Sep 2021 08:49:39 -0700 (PDT) Received: from neptune.. ([188.27.128.17]) by smtp.gmail.com with ESMTPSA id l8sm7395782ejn.103.2021.09.26.08.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 08:49:38 -0700 (PDT) From: Alexandru Ardelean To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: jic23@kernel.org, Alexandru Ardelean Subject: [PATCH] iio: adc: nau7802: convert probe to full device-managed Date: Sun, 26 Sep 2021 18:49:32 +0300 Message-Id: <20210926154932.3287590-1-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a trivial conversion to device-managed functions. The mutex_destroy() calls are redundant, as the data will be free'd anyway. And the IRQ and IIO register functions both have device-managed equivalents. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/nau7802.c | 50 +++++++-------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index bb70b51d25b1..976c235f3079 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -428,8 +428,6 @@ static int nau7802_probe(struct i2c_client *client, st = iio_priv(indio_dev); - i2c_set_clientdata(client, indio_dev); - indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &nau7802_info; @@ -495,13 +493,13 @@ static int nau7802_probe(struct i2c_client *client, * will enable them back when we will need them.. */ if (client->irq) { - ret = request_threaded_irq(client->irq, - NULL, - nau7802_eoc_trigger, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT | - IRQF_NO_AUTOEN, - client->dev.driver->name, - indio_dev); + ret = devm_request_threaded_irq(&client->dev, client->irq, + NULL, + nau7802_eoc_trigger, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT | + IRQF_NO_AUTOEN, + client->dev.driver->name, + indio_dev); if (ret) { /* * What may happen here is that our IRQ controller is @@ -526,7 +524,7 @@ static int nau7802_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL2, NAU7802_CTRL2_CRS(st->sample_rate)); if (ret) - goto error_free_irq; + return ret; } /* Setup the ADC channels available on the board */ @@ -536,36 +534,7 @@ static int nau7802_probe(struct i2c_client *client, mutex_init(&st->lock); mutex_init(&st->data_lock); - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&client->dev, "Couldn't register the device.\n"); - goto error_device_register; - } - - return 0; - -error_device_register: - mutex_destroy(&st->lock); - mutex_destroy(&st->data_lock); -error_free_irq: - if (client->irq) - free_irq(client->irq, indio_dev); - - return ret; -} - -static int nau7802_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct nau7802_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - mutex_destroy(&st->lock); - mutex_destroy(&st->data_lock); - if (client->irq) - free_irq(client->irq, indio_dev); - - return 0; + return devm_iio_device_register(&client->dev, indio_dev); } static const struct i2c_device_id nau7802_i2c_id[] = { @@ -582,7 +551,6 @@ MODULE_DEVICE_TABLE(of, nau7802_dt_ids); static struct i2c_driver nau7802_driver = { .probe = nau7802_probe, - .remove = nau7802_remove, .id_table = nau7802_i2c_id, .driver = { .name = "nau7802", -- 2.31.1