Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2638134ybl; Sun, 11 Aug 2019 05:53:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsebP34MkDgE9WFWK/TRCckbO0JT/i/1dmUzt89esxh+tDcVQm7pp92oUz7i36WLRnCszl X-Received: by 2002:a17:90a:ab01:: with SMTP id m1mr18057963pjq.69.1565527992655; Sun, 11 Aug 2019 05:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565527992; cv=none; d=google.com; s=arc-20160816; b=kICHDXtl7cyIiNqNy+5tMFPm4aZSmV12LiGzJ9N6tF0jONPV7lc2LItr4Xwx4gjP24 orox8clJqY5BnJJJ7RrcfPpiljb1PL9JIksLZ4nIcisyqgHnxpaBkp4YJMTU0h1H3mY1 iQxpV/wrThulQr5RNX1zvxiaJ16DL81RGxO3+zMA55oPt4OA+DX/i1AnL55aMLC37Py6 vNTDZAosMwKooSdHq0mYBaHWf4aSHHIjIWCqZPh5X0EdhvDZdg9qA3IGYQyAkwgbnTMU CE/qN1J8/lWvj0l0A7LgA+3SLiPPM6g5VebWlSMkWjuVSMeG1DdMDWLlq/YZv6nLnXu8 4T+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=9vaOsX6xjsXhfgGchvNQGFFfuLtXqJtssGmMQXkZBaE=; b=eCBeXEk54PoWAP9lDkPv/otq7HhW5TrpIZeACHVW63huIHZrl8/cwpUJ5Y7tHYcyOA 2RnsDtwz2kA4lA9rApHoggC9SJWRyJj4SSHT8ycn1FCp1UjtnhzIiALyrodBLbB7+iKo V6CpFijPpFJnOdN9yQmjNruFJcg8poi9a1DMvDHtMic+AEfTW8WUXjHZoV1snfY8qZWv /DcM+R3dKtHcYwXtfbTiGlAtq4d9rv8J7VVClACJerHJbcpfh3LSE/aWsPOd8bRJEQKO is8sf6mN4LTAhRwwNtWxXDlDqScd+V1HwOetrlM9yS16+wbWe92HI/6x6ABNhfsz6Dmf Dftw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aJ4ML8UB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 143si61000857pgc.479.2019.08.11.05.52.46; Sun, 11 Aug 2019 05:53:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aJ4ML8UB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbfHKMvy (ORCPT + 99 others); Sun, 11 Aug 2019 08:51:54 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46707 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbfHKMvy (ORCPT ); Sun, 11 Aug 2019 08:51:54 -0400 Received: by mail-pf1-f193.google.com with SMTP id q139so120133pfc.13; Sun, 11 Aug 2019 05:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9vaOsX6xjsXhfgGchvNQGFFfuLtXqJtssGmMQXkZBaE=; b=aJ4ML8UBq0EMN3lbtl5fIskSyMSoFQd1sjRYEGSfzg3X4NSo/Zvzb6qCEeUFMoLCpZ 8T7uUMYctR/eq+VswZWaYd3XJkm7rvk+c5l+9sRUl3eNwJcQZbiMJ6COfiaX+909QP8z v+O8U7Of7JHA3XWOvaA9deqxaBsrfGcODARASOuN5ZvySO7JYwMfuS+nJyn89WJCOOmh rkr622UtmNtn4hgX2r9BlT1RX1utpEbn6A22HRjMrmcu2OEyS38eHkPcmJqs7v1Pv7CB m3tGed8JRAZ4ePcI7DkXbtSmDen6Lm1KYeN6z+wGWlJpGxkWNFQuA7qcoVU5GYx6vHrJ VCWA== 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:mime-version :content-transfer-encoding; bh=9vaOsX6xjsXhfgGchvNQGFFfuLtXqJtssGmMQXkZBaE=; b=geF9i8u6edY5hzsxwQ4PZmLmD7n7A2vdbNwDAAEFLITW0UZjrDede15mwvw/j/tzy7 xbISaxYXYTltJ6p3KRUU/Wt0MeEhBK9u6qZfTuz4YXm3HdVZZUV26wPEBIFuzhvSyqVp uLDnznX/TfW6Uma9Z+3ax09HYFNg45BhKv6AOffjhaSV5Yt+dmP3dAAmHFxAR7BqcMEP cnt3w26Isr3UrHmpZRFzQ2tHac6yFc3/FNdnxHpECZ7GKrwDXln6URVLxrPzPcQH2Cff RD2H7mF9o4Bom2ICE/VZIUam1l9qH1kh/W7Wxnc5dv2vmB3UvQaDQBPqkSiHyz7p19me mVpQ== X-Gm-Message-State: APjAAAVVPpGUtGODFPwOQHd/OVeIQPvQLAB4kg96jcASgEJznfVtCUZv mc2nceSrKoRqPUEyjh3vG9o= X-Received: by 2002:a62:1a45:: with SMTP id a66mr5354560pfa.142.1565527913856; Sun, 11 Aug 2019 05:51:53 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id p13sm12664500pjb.30.2019.08.11.05.51.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 05:51:52 -0700 (PDT) From: Chuhong Yuan Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v2] iio: adc: max1027: Use device-managed APIs Date: Sun, 11 Aug 2019 20:51:46 +0800 Message-Id: <20190811125146.21355-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use device-managed APIs to simplify the code. Signed-off-by: Chuhong Yuan --- Changes in v2: - Delete the debug print and _remove. drivers/iio/adc/max1027.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index da84adfdb819..214883458582 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -427,8 +427,9 @@ static int max1027_probe(struct spi_device *spi) return -ENOMEM; } - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, - &max1027_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, + &iio_pollfunc_store_time, + &max1027_trigger_handler, NULL); if (ret < 0) { dev_err(&indio_dev->dev, "Failed to setup buffer\n"); return ret; @@ -439,7 +440,7 @@ static int max1027_probe(struct spi_device *spi) if (st->trig == NULL) { ret = -ENOMEM; dev_err(&indio_dev->dev, "Failed to allocate iio trigger\n"); - goto fail_trigger_alloc; + return ret; } st->trig->ops = &max1027_trigger_ops; @@ -454,7 +455,7 @@ static int max1027_probe(struct spi_device *spi) spi->dev.driver->name, st->trig); if (ret < 0) { dev_err(&indio_dev->dev, "Failed to allocate IRQ.\n"); - goto fail_dev_register; + return ret; } /* Disable averaging */ @@ -462,34 +463,10 @@ static int max1027_probe(struct spi_device *spi) ret = spi_write(st->spi, &st->reg, 1); if (ret < 0) { dev_err(&indio_dev->dev, "Failed to configure averaging register\n"); - goto fail_dev_register; - } - - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&indio_dev->dev, "Failed to register iio device\n"); - goto fail_dev_register; + return ret; } - return 0; - -fail_dev_register: -fail_trigger_alloc: - iio_triggered_buffer_cleanup(indio_dev); - - return ret; -} - -static int max1027_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - pr_debug("%s: remove(spi = 0x%p)\n", __func__, spi); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static struct spi_driver max1027_driver = { @@ -498,7 +475,6 @@ static struct spi_driver max1027_driver = { .of_match_table = of_match_ptr(max1027_adc_dt_ids), }, .probe = max1027_probe, - .remove = max1027_remove, .id_table = max1027_id, }; module_spi_driver(max1027_driver); -- 2.20.1