From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbdHANLt (ORCPT ); Tue, 1 Aug 2017 09:11:49 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:36257 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750AbdHANLp (ORCPT ); Tue, 1 Aug 2017 09:11:45 -0400 MIME-Version: 1.0 In-Reply-To: <20170801142936.5df48702@bbrezillon> References: <1501518290-5723-1-git-send-email-boris.brezillon@free-electrons.com> <1501518290-5723-3-git-send-email-boris.brezillon@free-electrons.com> <20170731231509.77d1fba4@bbrezillon> <20170801142936.5df48702@bbrezillon> From: Arnd Bergmann Date: Tue, 1 Aug 2017 15:11:44 +0200 X-Google-Sender-Auth: u7ZiAcVQv1ZL2Atrf2ag5zZ9iHc Message-ID: Subject: Re: [RFC 2/5] i3c: Add core I3C infrastructure To: Boris Brezillon Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Greg Kroah-Hartman , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Jan Kotas , Cyprian Wronka , Alexandre Belloni , Thomas Petazzoni , Nishanth Menon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 1, 2017 at 2:29 PM, Boris Brezillon wrote: > On Tue, 1 Aug 2017 14:00:05 +0200 > Arnd Bergmann wrote: >> Another argument for a combined bus would be devices that >> can be attached to either i2c and i3c, depending on the host >> capabilities. > > Hm, that's already the case, isn't it? And you'll anyway need to > develop specific code for both cases in the I2C/I3C device driver > because I2C and I3C transfers are different. So I don't see how it > would help to have a single bus here. > >> We have discussed whether i2c and spi should be >> merged into a single bus_type in the past, as a lot of devices >> can be attached to either of them. > > Oh, really? What's the rational behind that? I mean, I2C and SPI are > quite different, and even if some devices provide both interfaces, I > don't see why we should merge them. But you probably had good reasons > to do so. Well, we never changed it, so at least the work required to merge the two was considered too much to justify any advantages. The main problem with having one driver that can operate on different bus types (i2c plus either spi or i3c) is the handling for the various combinations in configurations (e.g. I2C=m, SPI=y). The easy case is having a module_init function that registers two device drivers, but that requires having a Kconfig dependency on both subsystems, and you can't use the module_i2c_driver() helper. The second way is to have a number of #ifdef and complex Kconfig dependencies for the driver to only register the device_driver objects for the buses that are enabled. This is also doable, but everyone gets the logic wrong the first time. What we end up doing to work around this for other drivers is to have the base driver in one library module, and separate modules for the bus-specific portions, which can then use module_i2c_driver again. There are many instances for combined i2c/spi drivers in the kernel, and it works fine, but it adds a fair bit of overhead compared to having one driver that would e.g. use regmap to abstract the differences in the probe() function and otherwise keeps everything in one place. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [RFC 2/5] i3c: Add core I3C infrastructure Date: Tue, 1 Aug 2017 15:11:44 +0200 Message-ID: References: <1501518290-5723-1-git-send-email-boris.brezillon@free-electrons.com> <1501518290-5723-3-git-send-email-boris.brezillon@free-electrons.com> <20170731231509.77d1fba4@bbrezillon> <20170801142936.5df48702@bbrezillon> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20170801142936.5df48702@bbrezillon> Sender: linux-doc-owner@vger.kernel.org To: Boris Brezillon Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Greg Kroah-Hartman , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Jan Kotas , Cyprian Wronka , Alexandre Belloni , Thomas Petazzoni , Nishanth Menon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Ku List-Id: devicetree@vger.kernel.org On Tue, Aug 1, 2017 at 2:29 PM, Boris Brezillon wrote: > On Tue, 1 Aug 2017 14:00:05 +0200 > Arnd Bergmann wrote: >> Another argument for a combined bus would be devices that >> can be attached to either i2c and i3c, depending on the host >> capabilities. > > Hm, that's already the case, isn't it? And you'll anyway need to > develop specific code for both cases in the I2C/I3C device driver > because I2C and I3C transfers are different. So I don't see how it > would help to have a single bus here. > >> We have discussed whether i2c and spi should be >> merged into a single bus_type in the past, as a lot of devices >> can be attached to either of them. > > Oh, really? What's the rational behind that? I mean, I2C and SPI are > quite different, and even if some devices provide both interfaces, I > don't see why we should merge them. But you probably had good reasons > to do so. Well, we never changed it, so at least the work required to merge the two was considered too much to justify any advantages. The main problem with having one driver that can operate on different bus types (i2c plus either spi or i3c) is the handling for the various combinations in configurations (e.g. I2C=m, SPI=y). The easy case is having a module_init function that registers two device drivers, but that requires having a Kconfig dependency on both subsystems, and you can't use the module_i2c_driver() helper. The second way is to have a number of #ifdef and complex Kconfig dependencies for the driver to only register the device_driver objects for the buses that are enabled. This is also doable, but everyone gets the logic wrong the first time. What we end up doing to work around this for other drivers is to have the base driver in one library module, and separate modules for the bus-specific portions, which can then use module_i2c_driver again. There are many instances for combined i2c/spi drivers in the kernel, and it works fine, but it adds a fair bit of overhead compared to having one driver that would e.g. use regmap to abstract the differences in the probe() function and otherwise keeps everything in one place. Arnd