From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guenter Roeck Subject: Re: [RFC PATCH] gpiolib: Provide and export gpiod_export_name Date: Fri, 25 Jul 2014 07:09:59 -0700 Message-ID: <53D26537.9000203@roeck-us.net> References: <1406139132-5404-1-git-send-email-linux@roeck-us.net> <53D0A7E4.1040707@aksignal.cz> <53D0A983.9000900@roeck-us.net> <53D20B6E.9010808@aksignal.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mail.active-venture.com ([67.228.131.205]:59144 "EHLO mail.active-venture.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752279AbaGYOKA (ORCPT ); Fri, 25 Jul 2014 10:10:00 -0400 In-Reply-To: <53D20B6E.9010808@aksignal.cz> Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: jiri.prchal@aksignal.cz, Alexandre Courbot Cc: "linux-gpio@vger.kernel.org" , Linux Kernel Mailing List , "linux-doc@vger.kernel.org" , Linus Walleij , Randy Dunlap On 07/25/2014 12:46 AM, Ji=C5=99=C3=AD Prchal wrote: > What about this modification? If is defined label, use it prioritlly,= at second use name in chip description. > > @@ -842,7 +842,9 @@ int gpiod_export(struct gpio_desc *desc, bool dir= ection_may_change) > spin_unlock_irqrestore(&gpio_lock, flags); > > offset =3D gpio_chip_hwgpio(desc); > - if (desc->chip->names && desc->chip->names[offset]) > + if (desc->label) > + ioname =3D desc->label; > + else if (desc->chip->names && desc->chip->names[offset]) > ioname =3D desc->chip->names[offset]; > Label is not unique. It is, for example, used by the sysfs export funct= ion, and all pins exported from user space have the same label. The first pin exported through sysfs would be named "sysfs", the second export would fail. Guenter -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760493AbaGYOKD (ORCPT ); Fri, 25 Jul 2014 10:10:03 -0400 Received: from mail.active-venture.com ([67.228.131.205]:56153 "EHLO mail.active-venture.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759874AbaGYOKA (ORCPT ); Fri, 25 Jul 2014 10:10:00 -0400 X-Originating-IP: 108.223.40.66 Message-ID: <53D26537.9000203@roeck-us.net> Date: Fri, 25 Jul 2014 07:09:59 -0700 From: Guenter Roeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: jiri.prchal@aksignal.cz, Alexandre Courbot CC: "linux-gpio@vger.kernel.org" , Linux Kernel Mailing List , "linux-doc@vger.kernel.org" , Linus Walleij , Randy Dunlap Subject: Re: [RFC PATCH] gpiolib: Provide and export gpiod_export_name References: <1406139132-5404-1-git-send-email-linux@roeck-us.net> <53D0A7E4.1040707@aksignal.cz> <53D0A983.9000900@roeck-us.net> <53D20B6E.9010808@aksignal.cz> In-Reply-To: <53D20B6E.9010808@aksignal.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/25/2014 12:46 AM, Jiří Prchal wrote: > What about this modification? If is defined label, use it prioritlly, at second use name in chip description. > > @@ -842,7 +842,9 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) > spin_unlock_irqrestore(&gpio_lock, flags); > > offset = gpio_chip_hwgpio(desc); > - if (desc->chip->names && desc->chip->names[offset]) > + if (desc->label) > + ioname = desc->label; > + else if (desc->chip->names && desc->chip->names[offset]) > ioname = desc->chip->names[offset]; > Label is not unique. It is, for example, used by the sysfs export function, and all pins exported from user space have the same label. The first pin exported through sysfs would be named "sysfs", the second export would fail. Guenter