Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1866547ybl; Sun, 18 Aug 2019 12:19:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGfHEO123A1Rvbb907pD4shmwUmN5IaPucM1EfNPz6KRrUM+llo4tz2OdDthxGjoBZZzI0 X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr18055859pji.142.1566155972249; Sun, 18 Aug 2019 12:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566155972; cv=none; d=google.com; s=arc-20160816; b=fVx6T45Sw6hkk9D8K7v1C/6M7zVf5uwhRC5T341smBiyQLbQVISS7IOK8KoaRCBKOA txnfu2zilleEq+7Xa51gWu4WRMK8xSB0KpXcauAxLfMYm7wmmSfLBj0KPnNQWgclbOcH l3eS5gSKVqOP+5DfG2ORjpstA5pvvVBi6/W6Hu+3AqKI6y7BB4k8tOkLZCCC88LCEwn3 O5xuF4Yfy00Opsj6ixD+1TzIh8N0K5woTzHSCQFtxRyNCCH+raFWnMn/SEDceLiF1bRc tLnSstveYcOSS1IDqrn5cupL/KSfeURYr3Q4gWx9XzIDShFWLHkkSEzHtFky2mT1Vcg4 oc5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9mnW7z/bzoZ/YaRuReoLM/OflUAERuzY927CvaBVSxE=; b=Ik+n8V8tDzWECGKaz2Mju4hF8kmTX71VkXh9uGvl+sQ4sRBx9LGKCEJUxXlFx9CvZR lIUfhWbDb961VElwOwr8l0SEg6DTAypFsMiC3ILGpps/bBqhbe7QnjkpXqE6vVU3vQY7 2E3OP75hghNRUg6Bl+F7ezWC34fPbR2aZ94tFRxwtQAjoprlKE0knQhfQZ2Dbk+Cwkf+ MNznGZqnVkKVxmpLaAUR/H0HhXYEycEpdzNnxZFcAxiNyiTQWL/C6hZCcRhvoiZ+7Rpw 1fZsRjIgvLRqdpCUwN0gIAdPbechiiE2EB6Q3dFHvcwLScS23O/hJjdXLAyqWY3qCLep XsKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1TZ6N2et; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v201si8285015pgb.394.2019.08.18.12.19.17; Sun, 18 Aug 2019 12:19:32 -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=pass header.i=@kernel.org header.s=default header.b=1TZ6N2et; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbfHRTSa (ORCPT + 99 others); Sun, 18 Aug 2019 15:18:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfHRTSa (ORCPT ); Sun, 18 Aug 2019 15:18:30 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 92FD121855; Sun, 18 Aug 2019 19:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566155908; bh=0hKqAm8WRdNsfrQ67ZkPbGirgEewejdFpbrPcSivozo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1TZ6N2etplwW6WNpkTlJG1OuqrzdKNQdGVhqU2Abx3cyjcwNNQRpvYyuYcruK4hD2 BgOGFulslbxuFsiz/bi/q2rCxdX2khA7TDxvQR/j7b3Y0GSzZBnTA76LMMJ/776Scy KZ7FLTXP4218Jy9R8ONLiPo+6SKuy4Ut4+8Sp2IU= Date: Sun, 18 Aug 2019 20:18:24 +0100 From: Jonathan Cameron To: Chuhong Yuan Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: adc: max1027: Use device-managed APIs Message-ID: <20190818201824.49af545e@archlinux> In-Reply-To: <20190811125146.21355-1-hslester96@gmail.com> References: <20190811125146.21355-1-hslester96@gmail.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 11 Aug 2019 20:51:46 +0800 Chuhong Yuan wrote: > Use device-managed APIs to simplify the code. > > Signed-off-by: Chuhong Yuan Great thanks, Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > 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);