lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4D6B7FE6.8090802@metafoo.de>
Date:	Mon, 28 Feb 2011 11:58:46 +0100
From:	Lars-Peter Clausen <lars@...afoo.de>
To:	Kukjin Kim <kgene.kim@...sung.com>
CC:	'Ben Dooks' <ben-linux@...ff.org>,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 08/09] ARM: s3c2440: gta02: Request usb pullup pin before
 using it

On 02/28/2011 11:44 AM, Kukjin Kim wrote:
> Lars-Peter Clausen wrote:
>>
>> On 02/28/2011 07:16 AM, Kukjin Kim wrote:
>>> Lars-Peter Clausen wrote:
>>>>
>>>> Request the gpio pin used to control the usb pullup before using it to
>>> avoid
>>>> a
>>>> runtime warning about an auto-requested gpio.
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
>>>> ---
>>>>  arch/arm/mach-s3c2440/mach-gta02.c |   17 +++++++++++++++--
>>>>  1 files changed, 15 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/arm/mach-s3c2440/mach-gta02.c
>>> b/arch/arm/mach-s3c2440/mach-
>>>> gta02.c
>>>> index 1396639..94456fa 100644
>>>> --- a/arch/arm/mach-s3c2440/mach-gta02.c
>>>> +++ b/arch/arm/mach-s3c2440/mach-gta02.c
>>>> @@ -451,11 +451,11 @@ static void gta02_udc_command(enum
> s3c2410_udc_cmd_e
>>>> cmd)
>>>>  	switch (cmd) {
>>>>  	case S3C2410_UDC_P_ENABLE:
>>>>  		pr_debug("%s S3C2410_UDC_P_ENABLE\n", __func__);
>>>> -		gpio_direction_output(GTA02_GPIO_USB_PULLUP, 1);
>>>> +		gpio_set_value(GTA02_GPIO_USB_PULLUP, 1);
>>>
>>> How about following instead?
>>> 	gpio_request(GTA02_GPIO_USB_PULLUP, "USB_PULLUP");
>>> 	gpio_direction_output(GTA02_GPIO_USB_PULLUP, 1);
>>> 	gpio_free(GTA02_GPIO_USB_PULLUP);
>>>
>>
>> I don't think that is a good idea. This gpio should really be reserved for
>> the
>> udc driver. If it is freed again, it could be requested from someone else
>> which
>> could lead to undefined behaviour.
>>
> Yes right, but I mean the board designer already knows the usage of
> regarding GPIOs on his board.
> So why do we really need gpio_request for it?...

Well, for one because it's part of the gpio-api. You should not call any other
gpio functions on a pin unless you've successfully requested that pin.
On the other hand this helps debugging and ensures that the same gpio is not
used by two drivers accident. For example it is also possible to request gpios
from userspace using the gpio sysfs. So by keeping the gpio requested it wont
be possible to request it from userspace by accident. And the gpio will also be
listed in the gpio debugfs file, which can be helpful for debugging as well.

- Lars
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ