Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965360AbbHKQLB (ORCPT ); Tue, 11 Aug 2015 12:11:01 -0400 Received: from mail-bn1bon0133.outbound.protection.outlook.com ([157.56.111.133]:11973 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752728AbbHKQK6 (ORCPT ); Tue, 11 Aug 2015 12:10:58 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yorksun@freescale.com; Message-ID: <55CA1ADF.200@freescale.com> Date: Tue, 11 Aug 2015 08:55:11 -0700 From: York Sun User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Wolfram Sang CC: , , Paul Bolle , Peter Korsgaard , Alexander Sverdlin Subject: Re: [Patch v3] driver/i2c/mux: Add register-based mux i2c-mux-reg References: <1434657458-16553-1-git-send-email-yorksun@freescale.com> <20150811153916.GD1525@katana> In-Reply-To: <20150811153916.GD1525@katana> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BY2PR05CA050.namprd05.prod.outlook.com (10.141.250.40) To BL2PR03MB148.namprd03.prod.outlook.com (10.255.230.27) X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB148;2:gXRtTQHAr+B38PB9qfN9BdCK3AwV2DZ7DB01/I5otwndXBMynbJshlpmaNQw76KiZnmDx5qZtluZp1tpvU1OuM+PiXfgPGRmy4bk2HsF62OMWM/5JTU23r55V/OG6J1vk6vfMPfpJ1INvXQ9p3dYsY3aU23U9CQVgfzlf7Zy6K0=;3:PKK6QvD+VSc3ArF/jpBwxEIgHHf0bkurWS5k2dZV9TzKciNk4rrO5zkLWY5R87JvxiaUuEEa8f0Lz6WTpTfzv8xIqoN74yM+vuVhQ6D7ulz0Y0Zt720a07ZKT0X4GEiPRKB6LSu/HjY3LvL9U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1/M4HGxajFUKKmatWx0dJ3h152ydC6UEnZIl3kN6nbfaetB/6GPsE6Bv/CTwrD5VWfFFgAJYF/nBFbx1iyGo/ooaVh4j2G/SYxghsSAaUENYbViM6Ypb9q4TrYCpKxiY266UfYaQV9r2mk6a1mdI6/5X86fk9qJwlT/mhK6SKM9HOKepuPV+ecLIh14U5fZjaDvWZX8qjbaQDpMMuALAUIV1ft4xwxI6Y= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BL2PR03MB148;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB148; X-Forefront-PRVS: 066517B35B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6049001)(24454002)(52604005)(479174004)(189002)(377454003)(199003)(77096005)(50986999)(5001960100002)(122386002)(62966003)(2950100001)(40100003)(23746002)(5001830100001)(110136002)(4001540100001)(101416001)(65816999)(97736004)(47776003)(36756003)(77156002)(105586002)(76176999)(68736005)(42186005)(81156007)(106356001)(4001350100001)(54356999)(19580405001)(189998001)(64126003)(64706001)(50466002)(83506001)(92566002)(5001860100001)(46102003)(19580395003)(33656002)(87976001)(86362001)(66066001)(230783001)(65956001)(65806001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB148;H:[10.214.82.34];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BL2PR03MB148;23:Zx+zyIh0//6dRYzyYiqf8LYPaY4X50lvwljOZK?= =?Windows-1252?Q?shNT9B/9IK6PzspBnxJfurCH4JGcauzwkYQ+zYVYq8dU4105xB/FAtEd?= =?Windows-1252?Q?70tUPz8aPbHzJ9uWIwxd5O7KG2pVh7G4GlfABxRCRE7AiZBWarztffyK?= =?Windows-1252?Q?UNcZCqzH5l1L6pO5URNriqTqPl+Y9qy5tUVWd1zZsfZ/qsTH6MQshfVp?= =?Windows-1252?Q?NJ3Tz7q6PY+Tq+PWd9hhaIf7c9JfhWA5rP6M/uV+4yDW3z7f0aIcz3sG?= =?Windows-1252?Q?pJVYs83MZTZHVmPztj0n6D3bIFN9Uvo6lgbQwlUhWjVN+8VHX2WZBev1?= =?Windows-1252?Q?2lJsn2cEcIkGjiDxhxrek3APomWuXQhPLI3Fp3j254154cwrvlth45F/?= =?Windows-1252?Q?ScCU2NggKPciOtH+IqVHXEN4D9sZyBij1oex6Ufy6l4zrks5jOth5JaP?= =?Windows-1252?Q?a0Q2pTJFQ+7/HmVl4+fEq+pTCNI5lob2e9OLESZSuDz+F3/jAWy/IfBl?= =?Windows-1252?Q?MBVR4v7yL4ie98nrbJsOmajKgGAKrmfR2ckDkBGUIngHSgMSv8Cb1bEW?= =?Windows-1252?Q?Aklsv1T0IFOg5bvmOLrnlFjHsBLmNkQHDLIBn0dWgt3NBw+0+QwyT52R?= =?Windows-1252?Q?MOTzyrUXcDqb001YRTv5yUx9VbKCRWxbzYo4e8SaaXJppbgUqpj+jQxq?= =?Windows-1252?Q?7sE9TC2xd3zHHcb63MVafJZotBUyHesIxm/Oe89S55D4VP52Lzr6ucnK?= =?Windows-1252?Q?uhjaPSlORLE0ektg1+TnDcstCxbyZ6mtA+5hV1UN2KmZ8uPGYR5OWi7A?= =?Windows-1252?Q?md/5AV0DXP2BaaqPuznaRn4zNCxhfXCMR0nSESsPSorobm2dXTPuUa6x?= =?Windows-1252?Q?z/74TDAZTevM3f+WwDx/HtrjY0yCvJQ5mMwywx86stEOXGnRnXdtTljj?= =?Windows-1252?Q?Ii72ozYTip1ivQWZDURU7HYPKZLJ2ezlFNa9d8oWxeNUazWmeoLKPG3K?= =?Windows-1252?Q?g7BQBjrjJH+ArUPWsZ23v6mDF0MaPb3lFRBIi+T6UmuRyI69cqQg/cUE?= =?Windows-1252?Q?7kneg+CR57wbaBxFmSjfqiUL1iQWukEt8DaQTEcT2xaFdyjoCZSoEZ5M?= =?Windows-1252?Q?j43CGX+qG0X9KmUP8kLeLnz0CQCB1QAS5EjaCYrNGoX34MmlSbmnTVp0?= =?Windows-1252?Q?T8R4tqRzvAEx5JDwsMLuaH40otDLd73iycfcOsX3o2c/T27zL4nY/Jdt?= =?Windows-1252?Q?MlTms8AhED0XLgjw2D5L5zjPTebp15kfgB04cymm4XX8H/6ktnsTLO51?= =?Windows-1252?Q?Wcip3pT3lMea/cnpm/EGfwWuNmKTtIBgoU4ae1JJjumfm4Ja+qKbv85c?= =?Windows-1252?Q?Qr+zKhp4DYNo88bmEsDBvpEociTTdtzQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB148;5:RagUzydoRyp/EV00MdbQS7iJOLi7gZU1gpg+6JBfoGRYAjxCvAhi+eEDrrVMHcX0+BYcovSkUasuNhNGed972aSPt5FYls7MOCyGm2l2uW+3PEaBEYkHSblUp+nkHZkonIWkbu8QShXMXXdrIugCPQ==;24:zP4vHr+r6X55Wb2+mGOUIr/Nt96mBN2KiyVvNzMgenUiEMMyEI8O9xegzo2+qtpkZD5IAIeFeOxohzRESdMC3ZGi8yt3a7DFdem05KoZsRI=;20:pqKpdOwAIJjh16fGhcB2iAKQQdf2w4vK9nmNmUvJwDzDEpqQDpEm19y6/u0WqIwE1L1I1c9uAnfuHwADTSqxUg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2015 15:55:20.3084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB148 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3720 Lines: 124 On 08/11/2015 08:39 AM, Wolfram Sang wrote: > On Thu, Jun 18, 2015 at 12:57:38PM -0700, York Sun wrote: >> Based on i2c-mux-gpio driver, similarly the register-based mux >> switch from one bus to another by setting a single register. >> The register can be on PCIe bus, local bus, or any memory-mapped >> address. The endianness of such register can be specified in device >> tree if used, or in platform data. >> >> Signed-off-by: York Sun > > Thanks for this driver! > > ... > >> +- no-read: The existence indicates reading the register is not allowed. > > Given that we have "read-only" properties already, I'd prefer this one > to be "write-only". Sure. That's easy to fix. > >> +For each i2c child node, an I2C child bus will be created. They will >> +be numbered based on their order in the device tree. > > This is a Linux specific detail (which can be overridden by aliases), so > it should not be in this document, I'd say. OK. I can remove it. > >> diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig >> index f6d313e..77c1257 100644 >> --- a/drivers/i2c/muxes/Kconfig >> +++ b/drivers/i2c/muxes/Kconfig >> @@ -29,6 +29,17 @@ config I2C_MUX_GPIO >> This driver can also be built as a module. If so, the module >> will be called i2c-mux-gpio. >> >> +config I2C_MUX_REG >> + tristate "Register-based I2C multiplexer" >> + help >> + If you say yes to this option, support will be included for a >> + register based I2C multiplexer. This driver provides access to >> + I2C busses connected through a MUX, which is controlled >> + by a sinple register. > > Typo here. And keep the sorting, please. Will fix. > >> obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o >> +obj-$(CONFIG_I2C_MUX_REG) += i2c-mux-reg.o > > Keep the sorting, please. > >> obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o >> obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o >> obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o > >> + adapter = of_find_i2c_adapter_by_node(adapter_np); >> + if (!adapter) { >> + dev_err(&pdev->dev, "Cannot find parent bus\n"); > > I don't think we should print something when deferring. OK. > >> + return -EPROBE_DEFER; >> + } >> + mux->parent = adapter; >> + mux->data.parent = i2c_adapter_id(adapter); >> + put_device(&adapter->dev); >> + >> + mux->data.n_values = of_get_child_count(np); >> + if (of_find_property(np, "little-endian", NULL)) { > > You should check for a "big-endian" property as well, no? I use the little-endian as an option to indicate the nature of litten-endian register. It is default to big-endian if this property doesn't exist. I prefer this way unless you strongly suggest to add both and throw out an error if neither exists. > >> + parent = i2c_get_adapter(mux->data.parent); >> + if (!parent) { >> + dev_err(&pdev->dev, "Parent adapter (%d) not found\n", >> + mux->data.parent); >> + return -EPROBE_DEFER; > > Ditto about printing when deferred probing. OK. > >> +static int i2c_mux_reg_remove(struct platform_device *pdev) >> +{ >> + struct regmux *mux = platform_get_drvdata(pdev); >> + int i; >> + >> + for (i = 0; i < mux->data.n_values; i++) >> + i2c_del_mux_adapter(mux->adap[i]); >> + >> + i2c_put_adapter(mux->parent); >> + >> + dev_dbg(&pdev->dev, "Removed\n"); > > No need for that debug. The driver core has debug output for that. Will remove. Thanks for reviewing. I will send a new version after testing. York -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/