Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1670144

[PATCH v2 3/5] i2c: pca-platform: use gpio_is_valid

From Chris Packham <chris.packham@alliedtelesis.co.nz>
Newsgroups linux.kernel
Subject [PATCH v2 3/5] i2c: pca-platform: use gpio_is_valid
Date 2017-06-20 03:20 +0200
Message-ID <tUfZM-1SN-13@gated-at.bofh.it> (permalink)
References <tUfZL-1SN-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Use gpio_is_valid() instead of gpio > -1.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 drivers/i2c/busses/i2c-pca-platform.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 87ca2f02f607..3a9845bae9a4 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -197,7 +197,7 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
 	} else {
 		i2c->adap.timeout = HZ;
 		i2c->algo_data.i2c_clock = 59000;
-		i2c->gpio = -1;
+		i2c->gpio = -ENODEV;
 	}
 
 	i2c->algo_data.data = i2c;
@@ -220,8 +220,7 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
 		break;
 	}
 
-	/* Use gpio_is_valid() when in mainline */
-	if (i2c->gpio > -1) {
+	if (gpio_is_valid(i2c->gpio)) {
 		ret = gpio_request(i2c->gpio, i2c->adap.name);
 		if (ret == 0) {
 			gpio_direction_output(i2c->gpio, 1);
@@ -255,7 +254,7 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
 	if (irq)
 		free_irq(irq, i2c);
 e_reqirq:
-	if (i2c->gpio > -1)
+	if (gpio_is_valid(i2c->gpio))
 		gpio_free(i2c->gpio);
 
 	iounmap(i2c->reg_base);
@@ -277,7 +276,7 @@ static int i2c_pca_pf_remove(struct platform_device *pdev)
 	if (i2c->irq)
 		free_irq(i2c->irq, i2c);
 
-	if (i2c->gpio > -1)
+	if (gpio_is_valid(i2c->gpio))
 		gpio_free(i2c->gpio);
 
 	iounmap(i2c->reg_base);
-- 
2.13.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/5] i2c: pca-platform: updates Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-20 03:20 +0200
  [PATCH v2 1/5] dt-bindings: add bindings for i2c-pca-platform Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-20 03:20 +0200
    Re: [PATCH v2 1/5] dt-bindings: add bindings for i2c-pca-platform Wolfram Sang <wsa@the-dreams.de> - 2017-06-22 10:30 +0200
      Re: [PATCH v2 1/5] dt-bindings: add bindings for i2c-pca-platform Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-06-22 23:30 +0200
        Re: [PATCH v2 1/5] dt-bindings: add bindings for i2c-pca-platform Wolfram Sang <wsa@the-dreams.de> - 2017-06-23 10:20 +0200
        Re: [PATCH v2 1/5] dt-bindings: add bindings for i2c-pca-platform Rob Herring <robh@kernel.org> - 2017-06-23 23:50 +0200
  [PATCH v2 4/5] i2c: pca-platform: use device managed allocations Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-20 03:20 +0200
  [PATCH v2 3/5] i2c: pca-platform: use gpio_is_valid Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-20 03:20 +0200
  [PATCH v2 5/5] i2c: pca-platform: use dev_warn/dev_info instead of printk Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-20 03:30 +0200
  [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
    Re: [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness Wolfram Sang <wsa@the-dreams.de> - 2017-06-27 22:00 +0200
    Re: [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 11:30 +0200
      Re: [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness Wolfram Sang <wsa@the-dreams.de> - 2017-06-28 11:50 +0200
      Re: [PATCH v3 3/5] i2c: pca-platform: add devicetree awareness Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-06-28 23:20 +0200
  [PATCH v3 1/5] dt-bindings: add bindings for i2c-pca-platform Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
    Re: [PATCH v3 1/5] dt-bindings: add bindings for i2c-pca-platform Rob Herring <robh+dt@kernel.org> - 2017-06-26 16:10 +0200
    Re: [PATCH v3 1/5] dt-bindings: add bindings for i2c-pca-platform Wolfram Sang <wsa@the-dreams.de> - 2017-06-27 22:00 +0200
  [PATCH v3 2/5] i2c: pca-platform: switch to struct gpio_desc Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
    Re: [PATCH v3 2/5] i2c: pca-platform: switch to struct gpio_desc Wolfram Sang <wsa@the-dreams.de> - 2017-06-27 22:00 +0200
    Re: [PATCH v3 2/5] i2c: pca-platform: switch to struct gpio_desc Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 11:30 +0200
      Re: [PATCH v3 2/5] i2c: pca-platform: switch to struct gpio_desc Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-06-28 23:30 +0200
        Re: [PATCH v3 2/5] i2c: pca-platform: switch to struct gpio_desc Wolfram Sang <wsa@the-dreams.de> - 2017-06-29 00:20 +0200
  [PATCH v3 0/5] i2c: pca-platform: updates Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
    [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
      Re: [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Wolfram Sang <wsa@the-dreams.de> - 2017-06-27 22:00 +0200
      Re: [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 11:30 +0200
        Re: [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Wolfram Sang <wsa@the-dreams.de> - 2017-06-28 11:40 +0200
          Re: [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 13:00 +0200
            Re: [PATCH v3 4/5] i2c: pca-platform: use device managed allocations Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-06-28 23:10 +0200
    [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead of printk Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-26 02:50 +0200
      Re: [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead  of printk Wolfram Sang <wsa@the-dreams.de> - 2017-06-27 22:00 +0200
      Re: [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead  of printk Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 11:30 +0200
        Re: [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead  of printk Wolfram Sang <wsa@the-dreams.de> - 2017-06-28 11:40 +0200
          Re: [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead  of printk Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-28 13:00 +0200
            Re: [PATCH v3 5/5] i2c: pca-platform: use dev_warn/dev_info instead  of printk Wolfram Sang <wsa@the-dreams.de> - 2017-06-28 14:10 +0200

csiph-web