Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1566376yba; Thu, 25 Apr 2019 01:51:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzp+gKeLp4RznQChfs3OVuVmOgpkdts81Z/ysDBQLhraLuns+I5udCaWsXu1AKcZQBl+wTY X-Received: by 2002:a17:902:e70c:: with SMTP id co12mr38019291plb.339.1556182288729; Thu, 25 Apr 2019 01:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556182288; cv=none; d=google.com; s=arc-20160816; b=zafMgeeIrsdooR/fOtp1DBgHYJB3TlVjXvz6AIlyzKuQLL2AvQZ5ZrvIEtuJ9mi6BJ VNN+W7sm2721FPsFafohHLxYTFDKyabegJaAhURkSpohw1JHTW/cFX8AaUdvAe0cAcRF ayNVEKFl6ZyPOYPw2xLK8NrGJN18U6KWQHxr2fLBlB/GQdLU95nfEc8nRvmXcZ+3Ix6a 5hyHBqelV4GSSSR4j4hC5MsZAOskSNaxi3HMG3AWXaZDORTzcIyb9X+ftPnKMfZq3tpt irSymBwMx98ZatDsRQV5f0FyX+/5CIubW4H3ppm4zq/FdoB7baRjdzE/6NbTd2/pnRbA Zokw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:dkim-filter :date; bh=lq7lOg21NMstBfMPwJyCfee3PVxHETx90IAqg2pLV/Q=; b=sLce8LLxI3/EUwHpbghGkRJA4wToVPsuRn8B0T0/hInfNBNQcFgH9QQl7+hIqtM/pT 6voE7zJQzmlSrM4otF7YAnr6A/63tbEeXivJyDLFKzMBRtPTJt/94ddFiF52BJTGIs2z XJZYqZOz//sjXQKzfE15+xNzIqctAe9nVKUY3UmZueLmynP/nLKapYaUo9t6sl7S/7aw vYCMTr/3VLtLNgsKPCUnqDq6e7kCc55nixY6QYy+71LttMoBGTd+F31xAlCBkCGz7sob Zlv1R35fTfMbIcH81N+EPwnTywS9eof7vzs6Hz98ey+pQbEklyWGTtJuLwMnIUThV2tJ e6QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@innovation.ch header.s=default header.b=fDsOtqUo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=innovation.ch Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u17si2803069pgj.218.2019.04.25.01.51.13; Thu, 25 Apr 2019 01:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@innovation.ch header.s=default header.b=fDsOtqUo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=innovation.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbfDYITt (ORCPT + 99 others); Thu, 25 Apr 2019 04:19:49 -0400 Received: from chill.innovation.ch ([216.218.245.220]:54636 "EHLO chill.innovation.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725951AbfDYITt (ORCPT ); Thu, 25 Apr 2019 04:19:49 -0400 Date: Thu, 25 Apr 2019 01:19:48 -0700 DKIM-Filter: OpenDKIM Filter v2.10.3 chill.innovation.ch 70EAE640126 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=innovation.ch; s=default; t=1556180388; bh=lq7lOg21NMstBfMPwJyCfee3PVxHETx90IAqg2pLV/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fDsOtqUoEikGbmuFIYqWmGCpvMKLlfEf9KtcgXjjvcw1lGml9RNlR2RjRtsFoz0PE bD9Ts5ozS6gVgu6IO4rM1hBZwhcfsIy3oXKa9BuDZwHTnzVH/UUnteqJVF8dOW4WvS LGfChyKsBb/6wcw5MqS7EmfhQkk3PzRxInRqwn09yHmJZymVjAAqEwSDRtUzFVVPpL WUBBHCG5wehfZkHXbRLbx5gVAvJ7lsW+llQq65q+mpoTDo+Gc2EzDUKcMIznZEReOU t//e+61vP27+LYNbG4N2jNAzgQI1OuJK1iRkQvyj9U8ZjFpczFboBHGJo/Jz/VCdHx pZ7+2tBXYJJ7w== From: "Life is hard, and then you die" To: Benjamin Tissoires Cc: Jiri Kosina , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lee Jones , "open list:HID CORE LAYER" , linux-iio@vger.kernel.org, lkml Subject: Re: [PATCH 1/3] mfd: apple-ibridge: Add Apple iBridge MFD driver. Message-ID: <20190425081948.GB31301@innovation.ch> References: <20190422031251.11968-1-ronald@innovation.ch> <20190422031251.11968-2-ronald@innovation.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Benjamin, Thank you for looking at this. On Wed, Apr 24, 2019 at 04:18:23PM +0200, Benjamin Tissoires wrote: > On Mon, Apr 22, 2019 at 5:13 AM Ronald Tschal?r wrote: > > > > The iBridge device provides access to several devices, including: > > - the Touch Bar > > - the iSight webcam > > - the light sensor > > - the fingerprint sensor > > > > This driver provides the core support for managing the iBridge device > > and the access to the underlying devices. In particular, since the > > functionality for the touch bar and light sensor is exposed via USB HID > > interfaces, and the same HID device is used for multiple functions, this > > driver provides a multiplexing layer that allows multiple HID drivers to > > be registered for a given HID device. This allows the touch bar and ALS > > driver to be separated out into their own modules. > > Sorry for coming late to the party, but IMO this series is far too > complex for what you need. > > As I read this and the first comment of drivers/mfd/apple-ibridge.c, > you need to have a HID driver that multiplex 2 other sub drivers > through one USB communication. > For that, you are using MFD, platform driver and you own sauce instead > of creating a bus. Basically correct. To be a bit more precise, there are currently two hid-devices and two drivers (touchbar and als) involved, with connections as follows (pardon the ugly ascii art): hdev1 --- tb-drv / / / hdev2 --- als-drv i.e. the touchbar driver talks to both hdev's, and hdev2's events (reports) are processed by both drivers (though each handles different reports). > So, how about we reuse entirely the HID subsystem which already > provides the capability you need (assuming I am correct above). > hid-logitech-dj already does the same kind of stuff and you could: > - create drivers/hid/hid-ibridge.c that handles USB_ID_PRODUCT_IBRIDGE > - hid-ibridge will then register itself to the hid subsystem with a > call to hid_hw_start(hdev, HID_CONNECT_HIDRAW) and > hid_device_io_start(hdev) to enable the events (so you don't create > useless input nodes for it) > - then you add your 2 new devices by calling hid_allocate_device() and > then hid_add_device(). You can even create a new HID group > APPLE_IBRIDGE and allocate 2 new PIDs for them to distinguish them > from the actual USB device. > - then you have 2 brand new HID devices you can create their driver as > a regular ones. > > hid-ibridge.c would just need to behave like any other hid transport > driver (see logi_dj_ll_driver in drivers/hid/hid-logitech-dj.c) and > you can get rid of at least the MFD and the platform part of your > drivers. > > Does it makes sense or am I missing something obvious in the middle? Yes, I think I understand, and I think this can work. Basically, instead of demux'ing at the hid-driver level as I am doing now (i.e. the iBridge hid-driver forwarding calls to the sub-hid-drivers), we demux at the hid-device level (events forwarded from iBridge hdev to all "virtual" sub-hdev's, and requests from sub-hdev's forwarded to the original hdev via an iBridge ll_driver attached to the sub-hdev's). So I would need to create 3 new "virtual" hid-devices (instances) as follows: hdev1 --- vhdev1 --- tb-drv / -- vhdev2 -- / hdev2 --- vhdev3 --- als-drv (vhdev1 is probably not strictly necessary, but makes things more consistent). > I have one other comment below. > > Note that I haven't read the whole series as I'd like to first get > your feedback with my comment above. Agreed: let's first get the overall strategy stabilized (also so I can avoid having to rewrite the code too many more times ;-) ). [snip] > > +static __u8 *appleib_report_fixup(struct hid_device *hdev, __u8 *rdesc, > > + unsigned int *rsize) > > +{ > > + /* Some fields have a size of 64 bits, which according to HID 1.11 > > + * Section 8.4 is not valid ("An item field cannot span more than 4 > > + * bytes in a report"). Furthermore, hid_field_extract() complains > > this must have been fixed in 94a9992f7dbdfb28976b565af220e0c4a117144a > which is part of v5.1, so not sure you actually need the report > descriptor fixup at all. Wasn't aware of this change - thanks. Yes, with that the warning message should be gone and this fixup can be avoided. One thing I find strange, though, is that while 94a9992f7dbd changes the condition at which the warning is emitted, it still truncates the value to 32 bits, albeit completely silently now for lengths between 32 and 256 bits. I.e. I'm somewhat surprised that hid_field_extract() (and __extract() ) weren't updated to actually return the full values for longer fields. Either that, or the callers of hid_field_extract() changed to read longer fields in 32 bit chunks. Cheers, Ronald