From: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
To: eric miao <eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jack Ren <jack.ren-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-arm-kernel
<linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
Subject: Re: [PATCH] gpio: max732x: add support for MAX7319, MAX7320-7327 I2C Port Expanders
Date: Sun, 13 Jul 2008 12:18:29 -0700 [thread overview]
Message-ID: <200807131218.29575.david-b@pacbell.net> (raw)
In-Reply-To: <f17812d70807130645i755c1c62la30d5c515c2d2080-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Sunday 13 July 2008, eric miao wrote:
> And David, apart from my misunderstanding of the I2C address, which
> I don't think have impact to the patch itself, can I have you Acked-by so
> I'll mail Andrew Morton to see his willingness to include this into -mm
> tree?
I'll forward it with my signed-off-by, if the appended updates are OK.
Notice the memory leak fix, removing the pr_warning(), and other minor
tweaks. The Kconfig text now matches other similar drivers; and also
doesn't explain twice about some ports being single-direction.
This doesn't apply quite as-is to with the current pending GPIO patches
(found in the MM tree) FWIW; the Makefile conflict doesn't show up in
the diffs below.
- Dave
--- g26.orig/drivers/gpio/max732x.c 2008-07-13 11:56:29.000000000 -0700
+++ g26/drivers/gpio/max732x.c 2008-07-13 11:56:22.000000000 -0700
@@ -21,7 +21,9 @@
#include <linux/i2c.h>
#include <linux/i2c/max732x.h>
-/* Each port of MAX732x (including MAX7319) falls into one of the
+
+/*
+ * Each port of MAX732x (including MAX7319) falls into one of the
* following three types:
*
* - Push Pull Output
@@ -37,7 +39,8 @@
* - Group A : by I2C address 0b'110xxxx
* - Group B : by I2C address 0b'101xxxx
*
- * where 'xxxx' is decided by the connections of pin AD2/AD0.
+ * where 'xxxx' is decided by the connections of pin AD2/AD0. The
+ * address used also affects the initial state of output signals.
*
* Within each group of ports, there are five known combinations of
* I/O ports: 4I4O, 4P4O, 8I, 8P, 8O, see the definitions below for
@@ -47,7 +50,7 @@
* and GPIOs from GROUP_A are numbered before those from GROUP_B
* (if there are two groups).
*
- * NOTE: MAX7328/MAX7329, however, resembles much closer to PCF8574,
+ * NOTE: MAX7328/MAX7329 are drop-in replacements for PCF8574/a, so
* they are not supported by this driver.
*/
@@ -82,6 +85,7 @@ MODULE_DEVICE_TABLE(i2c, max732x_id);
struct max732x_chip {
struct gpio_chip gpio_chip;
+ struct i2c_client *client; /* "main" client */
struct i2c_client *client_dummy;
struct i2c_client *client_group_a;
struct i2c_client *client_group_b;
@@ -185,7 +189,8 @@ static int max732x_gpio_direction_input(
chip = container_of(gc, struct max732x_chip, gpio_chip);
if ((mask & chip->dir_input) == 0) {
- pr_warning("%s: port %d is output only\n", __func__, off);
+ dev_dbg(&chip->client->dev, "%s port %d is output only\n",
+ chip->client->name, off);
return -EACCES;
}
@@ -201,7 +206,8 @@ static int max732x_gpio_direction_output
chip = container_of(gc, struct max732x_chip, gpio_chip);
if ((mask & chip->dir_output) == 0) {
- pr_warning("%s: port %d is input only\n", __func__, off);
+ dev_dbg(&chip->client->dev, "%s port %d is input only\n",
+ chip->client->name, off);
return -EACCES;
}
@@ -240,15 +246,18 @@ static int __devinit max732x_setup_gpio(
port++;
}
- gc->direction_input = max732x_gpio_direction_input;
- gc->direction_output = max732x_gpio_direction_output;
+ if (chip->dir_input)
+ gc->direction_input = max732x_gpio_direction_input;
+ if (chip->dir_output) {
+ gc->direction_output = max732x_gpio_direction_output;
+ gc->set = max732x_gpio_set_value;
+ }
gc->get = max732x_gpio_get_value;
- gc->set = max732x_gpio_set_value;
gc->can_sleep = 1;
gc->base = gpio_start;
gc->ngpio = port;
- gc->label = "max732x";
+ gc->label = chip->client->name;
gc->owner = THIS_MODULE;
return port;
@@ -270,6 +279,7 @@ static int __devinit max732x_probe(struc
chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
+ chip->client = client;
nr_port = max732x_setup_gpio(chip, id, pdata->gpio_base);
@@ -294,7 +304,8 @@ static int __devinit max732x_probe(struc
default:
dev_err(&client->dev, "invalid I2C address specified %02x\n",
client->addr);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out_failed;
}
mutex_init(&chip->lock);
@@ -345,7 +356,7 @@ static int __devexit max732x_remove(stru
return ret;
}
- /* unregister the dummy i2c_client */
+ /* unregister any dummy i2c_client */
if (chip->client_dummy)
i2c_unregister_device(chip->client_dummy);
--- g26.orig/drivers/gpio/Kconfig 2008-07-13 11:56:29.000000000 -0700
+++ g26/drivers/gpio/Kconfig 2008-07-13 10:10:35.000000000 -0700
@@ -43,7 +43,7 @@ config GPIO_SYSFS
comment "I2C GPIO expanders:"
config GPIO_MAX732X
- tristate "MAX7319, MAX7320-7327 8/16-bit I2C Port Expanders"
+ tristate "MAX7319, MAX7320-7327 I2C Port Expanders"
depends on I2C
help
Say yes here to support the MAX7319, MAX7320-7327 series of I2C
@@ -52,17 +52,14 @@ config GPIO_MAX732X
Input and Output (designed by 'P'). The combinations are listed
below:
- MAX7319 (8I), MAX7320 (8O), MAX7321 (8P), MAX7322 (4I4O),
- MAX7323 (4P4O), MAX7324 (8I8O), MAX7325 (8P8O)
- MAX7326 (4I12O), MAX7327 (4P12O)
+ 8 bits: MAX7319 (8I), MAX7320 (8O), MAX7321 (8P),
+ MAX7322 (4I4O), MAX7323 (4P4O)
- The board code has to specify the model to use, and the start
- number for these GPIOs. Model specific information is calculated
- automatically. Due to the fixed role of each port, configuration
- of the port direction will be ignored and a warning be issued if
- the corresponding port isn't applicable. And gpio_get_value() to
- those output only ports will return the configured output status
- instead of a real input.
+ 16 bits: MAX7324 (8I8O), MAX7325 (8P8O),
+ MAX7326 (4I12O), MAX7327 (4P12O)
+
+ Board setup code must specify the model to use, and the start
+ number for these GPIOs.
config GPIO_PCA953X
tristate "PCA953x, PCA955x, and MAX7310 I/O ports"
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
next prev parent reply other threads:[~2008-07-13 19:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 6:13 [PATCH] gpio: max732x: add support for MAX7319, MAX7320-7327 I2C Port Expanders Eric Miao
[not found] ` <4875A893.3090402-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-07-11 8:29 ` Jean Delvare
[not found] ` <20080711102952.31d2d943-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11 8:57 ` eric miao
[not found] ` <f17812d70807110157p5e421222sc9ef420ceb80970c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11 9:31 ` Jean Delvare
[not found] ` <20080711113114.79d80212-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11 9:39 ` eric miao
[not found] ` <f17812d70807110239q6c175f5cn70db966681ae387d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11 9:48 ` eric miao
[not found] ` <f17812d70807110248y7fab3328q59ea41084c491df-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11 11:15 ` Jean Delvare
2008-07-11 21:25 ` David Brownell
[not found] ` <200807111425.00961.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-12 7:16 ` Jean Delvare
[not found] ` <20080712091610.4ec242c3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-12 7:46 ` David Brownell
[not found] ` <200807120046.29389.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-12 7:53 ` Jean Delvare
[not found] ` <20080712095300.1ba4b3a7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-12 21:42 ` David Brownell
2008-07-13 6:55 ` Jean Delvare
2008-07-13 6:04 ` eric miao
[not found] ` <f17812d70807122304o533d8af9k1384db653b264912-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13 7:20 ` Jean Delvare
[not found] ` <20080713092050.6dffd8d3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-13 8:53 ` eric miao
[not found] ` <f17812d70807130153g290e17ecq10ab12529effc8d4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13 9:13 ` Jean Delvare
[not found] ` <20080713111306.791bbc41-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-13 13:45 ` eric miao
[not found] ` <f17812d70807130645i755c1c62la30d5c515c2d2080-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13 19:18 ` David Brownell [this message]
[not found] ` <200807131218.29575.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-14 1:35 ` Eric Miao
2008-07-13 9:12 ` David Brownell
[not found] ` <20080713091236.015E920ABDD-ZcXrCSuhvln6VZ3dlLfH/g4gEjPzgfUyLrfjE7I9kuVHxeISYlDBzl6hYfS7NtTn@public.gmane.org>
2008-07-13 9:18 ` Jean Delvare
2008-07-13 14:37 ` Jean Delvare
2008-07-11 9:54 ` Jean Delvare
[not found] ` <20080711115436.22134ce7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11 10:04 ` eric miao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200807131218.29575.david-b@pacbell.net \
--to=david-b-ybekhbn/0ldr7s880joybq@public.gmane.org \
--cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
--cc=jack.ren-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.