Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754163AbdDKIoy (ORCPT ); Tue, 11 Apr 2017 04:44:54 -0400 Received: from mail-by2nam01on0064.outbound.protection.outlook.com ([104.47.34.64]:8667 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751350AbdDKIoq (ORCPT ); Tue, 11 Apr 2017 04:44:46 -0400 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; axentia.se; dkim=none (message not signed) header.d=none;axentia.se; dmarc=bestguesspass action=none header.from=analog.com; Reply-To: Subject: Re: [PATCH v4 2/2] i2c: mux: ltc4306: LTC4306 and LTC4305 I2C multiplexer/switch References: <1491397671-14675-1-git-send-email-michael.hennerich@analog.com> <1491397671-14675-2-git-send-email-michael.hennerich@analog.com> To: Linus Walleij CC: Wolfram Sang , Peter Rosin , "Rob Herring" , Mark Rutland , "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Michael Hennerich Organization: Analog Devices Inc. Message-ID: <75c28713-0139-7b6e-f554-fcc4f9e1e040@analog.com> Date: Tue, 11 Apr 2017 10:46:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39400400002)(39850400002)(39410400002)(39840400002)(2980300002)(438002)(189002)(377454003)(199003)(24454002)(50986999)(54356999)(23676002)(76176999)(4001350100001)(6246003)(2906002)(7636002)(305945005)(77096006)(33646002)(54906002)(65956001)(4326008)(31686004)(106466001)(53546009)(43066003)(110136004)(5660300001)(38730400002)(47776003)(8676002)(8936002)(36756003)(83506001)(356003)(50466002)(31696002)(86362001)(2870700001)(229853002)(3450700001)(2950100002)(6916009)(6666003)(189998001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2286;H:nwd2mta2.analog.com;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD044;1:jR0pqJ13t3SGdDFylj6fxh9eHYkwuJEQ3MV+OIeOciA7JfH+87TINakDDy2n2I3iOL/xkWm14dPvx/5quCEgqLFW+0J3xbTKwTiB/PwhtSOj69IcYttJhkdALXAwdp2Vzi6lny2cGg355jSvPJgH6fw4JLAgAa6WuP5tkYkwr6tiXMqs4BrSj726sJLToop7E0lyuaVMRbCQBpUe90wNwCldWVrA60ySqVIfNvzyDFUPzMWZoy/6snLbsUCWhdR+/CuDLY/iUwB6khZt2tsrrXLR1bO2Ua9U2hsNISLDVj0fWX+aivaSBY5UAsWRZxIhgeUG3s3O+NKTvGjMgM+e1+HoyUGgo/hIoi+q2n5BebkRtKOw2a6ot9PIDusm0X1DGyHrZ7/Zgy6/gb1b/clzIkIFbWKGtoX3Zj3hkJs+daGWsEIiqGuobdpDYCN2Ty43jHOD3mLvDiFkXJ3HO2sKC29vh7+FhcCUPIYZsWTowm9xqq8Zry/5epBXDjvwojA22j7EgR+IEr1fC3onuhX5Wx6RsYdEaMHMRY38sBSQTBvmbznfX5EGIklinMmnS5Of9W5Mm8FeqsHNcHXTxwvXOqhDsyY73t3a4VW75mB2SAycQR2ZY+SZnYFG2b2WzQVW X-MS-Office365-Filtering-Correlation-Id: fe9aa177-7ebd-468e-70ff-08d480b70023 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081);SRVR:SN2PR03MB2286; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2286;3:zZ9hrOI1t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SlVXBVgQbAypbI3rvZbsX7KZSfO4oUsLm2wbxXzS15MbOJ6FW1l81bljW5dQW85ZpmG+ZEyDru4+Ozy/J7iqKxaFdiR84mM1VjeTwYMbzBmqzIk+QprZ+VGq8rYqaSrGXrKToyV10yqNMHiCqiNPswYl44X1wAcUzv77HqkuI0l//BovuKVhDYx0wQjpeFxjSs38Pc+Z8EU3aFJnDu8DhKy3sasnk= X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2286;20:ngHe5xM6K9eIwdIeRT/GhdH+uyDAhMc9Zv8VVTyA0lgHi58Q/oEMK8Z6bahlf97lSiDLmlUWWZNNpuiYxjJEzIoY7OPX/iDQf/6wvstqp8ZnvMh0dlJaxWGTpybQN8n3w43HqY42Bvq/r1ZJfIrZXTxYvC865OkLyiLTCu32pdxgrmNazY5rCVlOS57wczeSAUIgVewxI7SXsokJLLWtC2FbK3rjEtm/Qu3AKJve1CVobFQO3s6Fye8EDkK0r1IqCx0efMZ71sVUuEalH9W7v0yFl8RMcpH89iavLub4B1J2GZ1bfUYAcC365/NjfA9AzQ+WL+NKBVzTKuc8at7QuOBZDUE/ssU1uERg0Wh8IzBGsSmzxkzAAiYbs7UwuTuxP/cW7IJyxOl2NWzXPil5KVdPow8ErwmYqPnIeYgON0NC6P1nMuIvfGi97rr6HEiWnDZVSXlbU1V4GLNpKChjTMLPet9dAONjwXSBO/SIRvSe8Y+YoGNBLcH7urTUXr2k X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(13015025)(13023025)(13024025)(13018025)(8121501046)(13017025)(5005006)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(6072148);SRVR:SN2PR03MB2286;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB2286; X-Microsoft-Exchange-Di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WNPLHpLo0CLZVweSlwh8Oe0ns3N52T3gN6C5nEYH/Z2+t/HYhXuw/1JaBW1ODPBN/tQsKLa1GDFPj8AeF9Oocia8zKLZ8c9NOwxjwQRiDH3VbFjLL5b4/9mzi0aRCysmJv4sagUYPxtnyAKTtQVzmYqpjESc8ceOzxc66XiZMabp3RF8idGZ253tJ8TX4XF14o5UXMvTHSrPezBxYgHRlgkyMQpgA3RW5qhoxPq9M=;5:wDKe6C0kNinRFcJyFiKoEZM9LBw87+714PhdHOAyLHfB6SG9Bml2TE2VPpdFj8vUpPCCjjZUwV2Q5s3OsGSxHXGOnl1J9u/dknFugN3BbWNJhlZOvUACPsllmsqfmPvaz5QYq/F/Ty/uScO5YJz6yQ==;24:caO4/XtIXt0xoHrq7PmlgGFwDmHFnCGW3UisTNAK4hXymUtUaEP8wosJG4bmhmL/lYD5oLRTu8AWpd0/NABg61iPoFYUj225BSOaX3QLBDc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2286;7:xtFraA1gLAJAvlLFPKl+LeXnUco2H5tPC2+KWl7aI+lRikumx7Rm9Q4LsDByopQnNcKd+qpEAIBwiRSDHMXjiZoZfQQbI7LobEaA5/OdSg9ozm/QZvk1qfrOQdS/cn+c0JxWDeZ11wOgMcTCvGWZYa3IFcFE8IkpntZgG/Yfbh57Y0kSAognHy4EiWXUq+fT6giJKQV3TnG1U9xSXFgto4ORfyRJf4JmOLA+zWzXbSQXXwgirO0wQfPws6R2kifu5jfGX/wuYDG9CL+OZ9vo8NpREIno1e8rQWEel74yeZuCveYLFkvs5i5zoEfvqrzCQgrSB3hP8d0AZnFd+2JmxA== X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2017 08:44:43.4371 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2286 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3574 Lines: 120 On 10.04.2017 22:04, Linus Walleij wrote: > On Wed, Apr 5, 2017 at 3:07 PM, wrote: > >> From: Michael Hennerich >> >> This patch adds support for the Analog Devices / Linear Technology >> LTC4306 and LTC4305 4/2 Channel I2C Bus Multiplexer/Switches. >> The LTC4306 optionally provides two general purpose input/output pins >> (GPIOs) that can be configured as logic inputs, opendrain outputs or >> push-pull outputs via the generic GPIOLIB framework. >> >> Signed-off-by: Michael Hennerich > > Okay! Hi Linus, Thanks for your review. Comments below. > >> +#include >> +#include >> +#include >> +#include > > Why are you including all these? > Normally a GPIO driver should just include > Well - this driver is also a gpio consumer. But right I can drop gpio.h, and while gpio/driver.h also includes device.h - we don't need it here as well. > >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include > >> +static int ltc4306_gpio_get(struct gpio_chip *chip, unsigned int offset) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + unsigned int val; >> + int ret; >> + >> + ret = regmap_read(data->regmap, LTC_REG_CONFIG, &val); >> + if (ret < 0) >> + return ret; >> + >> + return (val & BIT(1 - offset)); > > Do this: > > return !!(val & BIT(1 - offset)); > > So you clamp the return value to [0,1] That's what I had in a previous version of the patch. Then I noticed gpiolib is also doing this. Anyways I'll add it back. > >> +static int ltc4306_gpio_set_config(struct gpio_chip *chip, >> + unsigned int offset, unsigned long config) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + unsigned int val; >> + >> + switch (pinconf_to_config_param(config)) { >> + case PIN_CONFIG_DRIVE_OPEN_DRAIN: >> + val = 0; >> + break; >> + case PIN_CONFIG_DRIVE_PUSH_PULL: >> + val = BIT(4 - offset); >> + break; >> + default: >> + return -ENOTSUPP; >> + } >> + >> + return regmap_update_bits(data->regmap, LTC_REG_MODE, >> + BIT(4 - offset), val); >> +} > > Nice! > >> + data->gpiochip.label = dev_name(dev); >> + data->gpiochip.base = -1; >> + data->gpiochip.ngpio = data->chip->num_gpios; >> + data->gpiochip.parent = dev; >> + data->gpiochip.can_sleep = true; >> + data->gpiochip.direction_input = ltc4306_gpio_direction_input; >> + data->gpiochip.direction_output = ltc4306_gpio_direction_output; >> + data->gpiochip.get = ltc4306_gpio_get; >> + data->gpiochip.set = ltc4306_gpio_set; >> + data->gpiochip.set_config = ltc4306_gpio_set_config; >> + data->gpiochip.owner = THIS_MODULE; > > Please implement .get_direction(). > This is very helpful to userspace, have you tested to use tools/gpio/* > from the kernel? Like lsgpio? Ok - convinced me. > > Yours, > Linus Walleij > -- Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne