Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp437273imu; Thu, 8 Nov 2018 23:36:15 -0800 (PST) X-Google-Smtp-Source: AJdET5ea0KBPLVkLNAikcRqdQHJClEG8KfTpa20SgkmqvpDRpkVVGjE48is7sAowGS3irIDTmdNX X-Received: by 2002:a63:f141:: with SMTP id o1mr6609210pgk.134.1541748974990; Thu, 08 Nov 2018 23:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541748974; cv=none; d=google.com; s=arc-20160816; b=qNiACLMdcbl8vtZyhX85lo++K3Ksqye+gWp/+YELSeHezU6Gvi3mLRMyIKvFczjKwD X3uWilTQbh8w/0ZsGD30OLrZjKdwks+O0EMnrZ3YtATpTmLb6BsUzPAazD7JVRd8eRdT cW4xnhYihYkK2yL9njpaaEh3aDTGqHyfe+jxhCbr0MN8P8fRQHzc81S8p6GE3gf6zvXc QFvjkY5E0T8oX7jFbVQ8jfLItAKWAVUwy/7TCYQn0ET1hR83VmEhT9Frcu6brDK2KZt7 V5WT/BpMLagzgpFdUhI4GEko/rkOCvV0UiNruaIjNl2k5PnNPOz/sv/D1B2hVoDOpx5K 7Vnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kf7F8wtFsGvrz6CVwT+ZgV4e1Du8AsiVGW49VRpy7h0=; b=0cJloLTlqdH1aNyQvSwFX8dOGVMgVnw+qzVBOTUW93n0VTvzz58SJ4S5hZ8/uy5/c9 mEbnKFxr7ZN6ZU+0nj1UYU/KknbP6IDQSQ/d1tZu9bMdgsqweVuYbE5MUQP+xxvjOoEl qrCflqHVnXgV4IQLLaKM4aofkAMFIOQlnvzg7iir3/aeabCvYDcXX41fd6gwAFn2ireh 6ayudz5EF8VceBZ98D9XlDL9LEo62nRwkyTtTIWDKwjCsWHi+uB42bSaz8rp6jhVft4T 18ooC438r4KwWdPqb6QjuLjRtZnWqH8pu16mO7ZP9nhmMMunz/FxmumS6ZwcP5Y9lj/C cB8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ng1Im+w+; 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=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 gn20si2469869plb.273.2018.11.08.23.35.59; Thu, 08 Nov 2018 23:36:14 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=ng1Im+w+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728195AbeKIROq (ORCPT + 99 others); Fri, 9 Nov 2018 12:14:46 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44279 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727845AbeKIROq (ORCPT ); Fri, 9 Nov 2018 12:14:46 -0500 Received: by mail-pg1-f193.google.com with SMTP id w3-v6so489347pgs.11; Thu, 08 Nov 2018 23:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kf7F8wtFsGvrz6CVwT+ZgV4e1Du8AsiVGW49VRpy7h0=; b=ng1Im+w+bGHfLgjj0UMCVN2NXy44vnynJkgqjF1GXMVXJJBnJpImxBPr30dyi6mQsr SKkQVDWI1GlvWZLctk+SUxpWFAz1gwtY94ZchQeoZOO8FVtEPGhq6WNrKSYBI77oWZc+ TWd0sBO95xBLMF1hwGxqDz1IW6cTb29upWXVvoR+zklD0vmjoAuTTAS4fkpzoePnqLLG JHgFWkwr3eNcXUdD6cWkVKgcQHTfT3snzCleovH4+0FscSvwwIbztwI607ILVhWugG1C BBV401cYNFd38USHx9hrVYBlqVOOoU+blngK9aiHfYfUu5MgtvtifoOT2HAH/XgVWeJo Sw4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kf7F8wtFsGvrz6CVwT+ZgV4e1Du8AsiVGW49VRpy7h0=; b=pbV32JgYftg5eM5xMh8xRG/3bIn4U/Yyc/fScOunWPrn7bNHKhLzo0T78e0z71/JXy 3pORA9jfFvPcn/MG7Wml7ktDl74yqGiYWItAW+Am3JTLreIORzGJOrPBFZm2kkrrEOM5 836b5cwdVevXGSfAnuHe7Jl+UmC4/8UIrkjH76wbO645Grbv4cXjq2gSuEeh42awxHoO 5MeeliGkutdu6XO6XesCe4RUWmJ1sAdOdRc1nMKpJVe+q1c760SYP7cXdsyE+onMVdcD o7VLZtXfuFeV4FZ2FtPJkehVgD9q/8662NKySEXVZr6HzeqPKwVriBKkl07YCAtSg9oY GrjA== X-Gm-Message-State: AGRZ1gJnLf3Z2r2ru5Zx0niqOWNG/vntpJGk32gHy9UW5gt1NIj3Lwqg f5kV7CYoxvJef84D+Vxc6CA= X-Received: by 2002:a63:6a42:: with SMTP id f63-v6mr6737388pgc.48.1541748926698; Thu, 08 Nov 2018 23:35:26 -0800 (PST) Received: from nishad ([106.210.186.71]) by smtp.gmail.com with ESMTPSA id m3sm1787836pgl.69.2018.11.08.23.35.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 23:35:26 -0800 (PST) Date: Fri, 9 Nov 2018 13:05:17 +0530 From: Nishad Kamdar To: Lars-Peter Clausen Cc: Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] staging: iio: ad7816: Switch to the gpio descriptor interface Message-ID: <3f9ea18864230b2758f86899b9bd1acb020dd176.1541733949.git.nishadkamdar@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod interface for rdwr_pin, convert_pin and busy_pin instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/adc/ad7816.c | 80 ++++++++++++++------------------ 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index bf76a8620bdb..12c4e0ab4713 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include @@ -44,9 +44,9 @@ struct ad7816_chip_info { struct spi_device *spi_dev; - u16 rdwr_pin; - u16 convert_pin; - u16 busy_pin; + struct gpio_desc *rdwr_pin; + struct gpio_desc *convert_pin; + struct gpio_desc *busy_pin; u8 oti_data[AD7816_CS_MAX + 1]; u8 channel_id; /* 0 always be temperature */ u8 mode; @@ -61,28 +61,28 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) int ret = 0; __be16 buf; - gpio_set_value(chip->rdwr_pin, 1); - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); ret = spi_write(spi_dev, &chip->channel_id, sizeof(chip->channel_id)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI channel setting error\n"); return ret; } - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 1); if (chip->mode == AD7816_PD) { /* operating mode 2 */ - gpio_set_value(chip->convert_pin, 1); - gpio_set_value(chip->convert_pin, 0); + gpiod_set_value(chip->convert_pin, 1); + gpiod_set_value(chip->convert_pin, 0); } else { /* operating mode 1 */ - gpio_set_value(chip->convert_pin, 0); - gpio_set_value(chip->convert_pin, 1); + gpiod_set_value(chip->convert_pin, 0); + gpiod_set_value(chip->convert_pin, 1); } - while (gpio_get_value(chip->busy_pin)) + while (gpiod_get_value(chip->busy_pin)) cpu_relax(); - gpio_set_value(chip->rdwr_pin, 0); - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); ret = spi_read(spi_dev, &buf, sizeof(*data)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI data read error\n"); @@ -99,8 +99,8 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data) struct spi_device *spi_dev = chip->spi_dev; int ret = 0; - gpio_set_value(chip->rdwr_pin, 1); - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); ret = spi_write(spi_dev, &data, sizeof(data)); if (ret < 0) dev_err(&spi_dev->dev, "SPI oti data write error\n"); @@ -129,10 +129,10 @@ static ssize_t ad7816_store_mode(struct device *dev, struct ad7816_chip_info *chip = iio_priv(indio_dev); if (strcmp(buf, "full")) { - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 1); chip->mode = AD7816_FULL; } else { - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 0); chip->mode = AD7816_PD; } @@ -345,15 +345,9 @@ static int ad7816_probe(struct spi_device *spi_dev) { struct ad7816_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *pins = dev_get_platdata(&spi_dev->dev); int ret = 0; int i; - if (!pins) { - dev_err(&spi_dev->dev, "No necessary GPIO platform data.\n"); - return -EINVAL; - } - indio_dev = devm_iio_device_alloc(&spi_dev->dev, sizeof(*chip)); if (!indio_dev) return -ENOMEM; @@ -364,34 +358,28 @@ static int ad7816_probe(struct spi_device *spi_dev) chip->spi_dev = spi_dev; for (i = 0; i <= AD7816_CS_MAX; i++) chip->oti_data[i] = 203; - chip->rdwr_pin = pins[0]; - chip->convert_pin = pins[1]; - chip->busy_pin = pins[2]; - - ret = devm_gpio_request(&spi_dev->dev, chip->rdwr_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n", - chip->rdwr_pin); + + chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN); + if (IS_ERR(chip->rdwr_pin)) { + ret = PTR_ERR(chip->rdwr_pin); + dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->rdwr_pin); - ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n", - chip->convert_pin); + chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", GPIOD_IN); + if (IS_ERR(chip->convert_pin)) { + ret = PTR_ERR(chip->convert_pin); + dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->convert_pin); - ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n", - chip->busy_pin); + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN); + if (IS_ERR(chip->busy_pin)) { + ret = PTR_ERR(chip->busy_pin); + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->busy_pin); indio_dev->name = spi_get_device_id(spi_dev)->name; indio_dev->dev.parent = &spi_dev->dev; -- 2.17.1