[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120114175447.GF29012@ericsson.com>
Date: Sat, 14 Jan 2012 09:54:47 -0800
From: Guenter Roeck <guenter.roeck@...csson.com>
To: Alex Rio <scasbyte@...il.com>
CC: "khali@...ux-fr.org" <khali@...ux-fr.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC][PATCH 2/2] hwmon: (w83627ehf) Add GPIO port 3 functionality
Alex,
On Fri, Jan 13, 2012 at 08:39:56PM -0500, Alex Rio wrote:
> The w83627ehf chip has 5 GPIO ports, currently none of them is supported.
> This patch adds the GPIO port 3 driver with the following functions:
> set/get pin values, direction_in/out, set_debounce.
> The values are also available to the userspace (if requiered)
> in the path /sys/class/gpio by using the export/unexport functions.
> Please look at the REVISIT comment, this is the main reason of the RFC,
> suggestions will be highly appreciated.
>
> Signed-off-by: Alex Rio <scasbyte@...il.com>
> ---
[ ... ]
> +/* REVISIT!: This is a global variable for sioreg.
> + * How could a function like gpio_get be able to access
> + * sioreg from w83627ehf_sio_data?
> + * Maybe we can make the sioreg global?
> + */
> +int global_sioaddr;
> +
This is a complete no-go, even more so since the variable name is very generic
and visible in the entire kernel. Define the variables you need as part of
a structure for which you get a pointer to, then use container_of()
to get the pointer to the outer data structure. Other gpio drivers
do this already; just look there for examples.
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists