From patchwork Sun Aug 23 08:52:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 509875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8AA45140518 for ; Mon, 24 Aug 2015 06:22:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753443AbbHWUWR (ORCPT ); Sun, 23 Aug 2015 16:22:17 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36825 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752839AbbHWUWQ (ORCPT ); Sun, 23 Aug 2015 16:22:16 -0400 Received: by wicja10 with SMTP id ja10so55043245wic.1 for ; Sun, 23 Aug 2015 13:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:subject:to:in-reply-to:references :date:message-id; bh=L/Lrn5cZJ0QqTYIaEuVWlYHxIfa+ufJeMF+sGtyK7Ys=; b=eQ0qgmcoh3IbVHt0FpVfyJ6zV7NfX29NeY5i3DMOEGSYynKglhrr1IxAsTEXYytxH9 twVhuWkG3fP7Ll4b4y4XCNlmPeZkyEJZld1J659A46mwzHckBciYflCCYtFLN0bKLIL6 AbCsOxnGjbmc91hrFByMiPU6sgRlTbtrSrzjTRk4ZLCSPCsu6UjYSU0KhS0ixsmuVNF8 aoYvstvv6WhbGRb89qHb2u+bbK26q8P0AqB+HJyWloEmhWVRKLOuj9R9YLv/uQ9DzQBF xLTkmuRyS9pOfMowNXudKvbtxr8THDT8rnyEEGnj2gZUS2bFYMgkF1oojQE5lv9YNWAs KoWA== X-Gm-Message-State: ALoCoQkk9vKCSmbDRGP+gumUPYVlTtHBF5QXVp59f0hjmovUmfgKY0/Z9Zbv0VIBB0DtIt9nMFzB X-Received: by 10.180.107.70 with SMTP id ha6mr22824237wib.20.1440361334644; Sun, 23 Aug 2015 13:22:14 -0700 (PDT) Received: from trevor.secretlab.ca (host109-155-121-92.range109-155.btcentralplus.com. [109.155.121.92]) by smtp.gmail.com with ESMTPSA id i6sm19970640wje.33.2015.08.23.13.22.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Aug 2015 13:22:12 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id D9178C40941; Sun, 23 Aug 2015 01:52:53 -0700 (PDT) From: Grant Likely Subject: Re: [PATCH 0/2] FTDI CBUS GPIO support To: Stefan Agner , Stefan Agner , johan@kernel.org, linus.walleij@linaro.org, gnurou@gmail.com, gregkh@linuxfoundation.org, x-linux@infra-silbe.de, hachti@hachti.de, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: <1434838377-8042-1-git-send-email-stefan@agner.ch> <20150620234957.25729.qmail@stuge.se> Date: Sun, 23 Aug 2015 01:52:53 -0700 Message-Id: <20150823085253.D9178C40941@trevor.secretlab.ca> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Sun, 21 Jun 2015 21:44:30 +0200 , Stefan Agner wrote: > On 2015-06-21 01:49, Peter Stuge wrote: > > Stefan Agner wrote: > >> libftdi requires to detach the kernel driver to get access to the device > > > > Control transfers ought to be possible without a detach. > > Good to know, thanks for this input. The detach is probably a default > behavior of libftdi... Will have a look at that. libftdi is built on libusb. libusb detaches the device from ftdi_sio and binds it to a special driver for userspace access. There may indeed be another way to do it, but libusb doesn't know how to do it AFAIKS. We can't avoid the detach on current libftdi, but I do have a patch to libftdi that will at least reconnect the ftdi_sio driver after userspace has finished. I'll be posting it to the libftdi list in the next week, but I've attached it below for anyone who wants to play. > Having kernel level gpiolib would still have advantages: It would make > the matching of the GPIO's and tty device easier, since with this patch > the gpiolib device is a sub-node of the usb-serial device in sysfs and > the user would have to use kernel interfaces only (no libftdi)... NAK on the sysfs interface. Don't add a new ABI. gpiolib is the right way to expose these pins. g. --- Subject: [PATCH] Automatically reattach kernel driver on close The built-in libusb auto detach feature supports automatically reattaching the kernel driver when the device is closed. Switch libftdi to use the libusb auto-detach code so that we can get the Linux ftdi_sio driver reattached automatically when finished with the device. --- src/ftdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ftdi.c b/src/ftdi.c index 68489ea096be..0d043690aeca 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -548,7 +548,7 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, libusb_device *dev) // Likely scenario is a static ftdi_sio kernel module. if (ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE) { - if (libusb_detach_kernel_driver(ftdi->usb_dev, ftdi->interface) !=0) + if (libusb_set_auto_detach_kernel_driver(ftdi->usb_dev, 1)) detach_errno = errno; }