Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp826230rda; Sun, 22 Oct 2023 11:28:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQjiy4aBk0oA9odGudB+ztBrVZaULGtQzalJu2mqTsGlFWpvam48mEfSMDygmU0/X0svTo X-Received: by 2002:a05:6a20:841e:b0:17a:e981:7fe4 with SMTP id c30-20020a056a20841e00b0017ae9817fe4mr15057629pzd.16.1697999324856; Sun, 22 Oct 2023 11:28:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697999324; cv=pass; d=google.com; s=arc-20160816; b=krbxbvZs1q+nay88JeLs+ed6ijW5Czf/rqk5gio3OWqHQMSptkNn4u91ZMdSWj3mXP dh3nFADG3wfKRRM0zQafB0+1NjhSox6goLX6SbqdpB9PZbfXy0hcYKp8kUx0d6RoTS2k D3Uwe7uNpXPwvSINjVosHi7ObH6tcGf/I8UahubwN6JrLljHoXLQ6XBzTulxlZ4t0N1S y4IU+q8pdXXOD+NDuMU8MZi34HMPLTvYcbdafDAqzQh1HTNqxI+S/SWSi4TQyLip3NoQ Ig+e0gMRtU5fUwfPCdL43AwKKolrkwmTJ3uR4Azfdvff3EFCh7cjfADrEJ9yrZp6PKRz KL+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bguMoSyeuFLmZ7hAyCAVY0JsaNTASlkxnBZas76M24o=; fh=ktRUHjJMJZ90fjET5xHgCneFu4+Zz/5kumO4coXP8IY=; b=UG1J0oGupIfs+G6VFt2BwEhpDK7BsjtjGWgRIv4k6QTTUY/tLCo7UwD43ePcb3c0xr l9Fudw/UUIHyAjCvJxeA+N/tfpXqctGXgPcoK1QQPQbV2MNX7FntifT2wLvL4YftkZa/ CzXYu714eyzZcAYD/VntCtkoPpzBvvrjJFkLPDdsrXQxvJ1c5OYNW+Y0wzVRXZg1Eone 0iXeYojEhihschGvCSuHk7b0LhYg+C52XkqhsOJ9n/c152vtJOoyRAkSTGpMUymHFzxe 71fuKrEh1qAOAHSAMRRYag63PZyJNIkP0XRde9mRwt8t7wGl1x1yKbCVGeCA8EcdGWXS yU7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NETORG5796793.onmicrosoft.com header.s=selector1-NETORG5796793-onmicrosoft-com header.b=GnZ4U9Tg; arc=pass (i=1 spf=pass spfdomain=labundy.com dkim=pass dkdomain=labundy.com dmarc=pass fromdomain=labundy.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ca28-20020a056a02069c00b00553800fe4dcsi5748834pgb.583.2023.10.22.11.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 11:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@NETORG5796793.onmicrosoft.com header.s=selector1-NETORG5796793-onmicrosoft-com header.b=GnZ4U9Tg; arc=pass (i=1 spf=pass spfdomain=labundy.com dkim=pass dkdomain=labundy.com dmarc=pass fromdomain=labundy.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6B596809B72A; Sun, 22 Oct 2023 11:28:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbjJVS2Z (ORCPT + 99 others); Sun, 22 Oct 2023 14:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjJVS2Y (ORCPT ); Sun, 22 Oct 2023 14:28:24 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49F2E0; Sun, 22 Oct 2023 11:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JRus//SPzae2jdyzzf0rmwB1CNu7We8cfCd8XSo5bxnz2inewqxs9Rroh8OlQ5ThmFVmhuGi+Y33jNOJu03cFtfTOnFyx11yeDLE6SkLRtqXVU02wzJjWB6sZKLVuAPcVjfpLvIcr9C/4SjI/xDZEPwX0dn0DIOxKB60v4xnm5bAYinXZQqfJRKEuksR19UeKlJfkrooozFmUGgKoiZsYqTLp6CnsrXnPK6Xub6ae7bXAej5SaOcYrtn9u5V0V4wbHnB2qjuGUle1KG1lDc7IULEEegRaL1rydfIHvN4YJmqrBFEEspvfPzPaTywSJDQ3su4apzUuFRIaI/OtuftdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bguMoSyeuFLmZ7hAyCAVY0JsaNTASlkxnBZas76M24o=; b=h9zJBMpTJbppwuOohZw2ibQNP4LKZEDIV3G1ueLmtg30YlM4XMr40a7O4/4qi+WrAon3j21sjmaQE12oW0v0fZS1cATPdqgYUT6bZTwNYN5SgpEPqvN5Vb4EDJXVQDzP3wjYrFI650beebeyXwjeBAF03KmTaofuRCYOVQD9lNSKfgeB/5ygcBEXi/mRdAdh0GmFIPSwSg+Dr3MwHFzzoKZhSjlaZlUk7s+Mcg11oqkaLUZp/5CoAbVuDvLUt4sK7y4piYzu6Zp7eUDLvB4tPBRkujWXWOQ7namhcfepDXispba6iVz4aM7zjFtT9qNfRQSK29ecKgJRDH9tob8z1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bguMoSyeuFLmZ7hAyCAVY0JsaNTASlkxnBZas76M24o=; b=GnZ4U9Tg+2lD0k/rFtCF2QJkzvs8wm++OPCqbciUap0lmtssGrUr0KFgj9wrfsSLp9qxJTaqLMyhbQlEhLaTJcgOTAwjB2AMQcflXO5j8qockNmh9gMdj29iU6MKeELrUOkG9EX/5zt1CtQJHamJkvuD5TCsfmJeCV3m9EVsptY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from DM5PR0801MB3767.namprd08.prod.outlook.com (2603:10b6:4:7c::37) by SJ0PR08MB7831.namprd08.prod.outlook.com (2603:10b6:a03:3d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.31; Sun, 22 Oct 2023 18:28:16 +0000 Received: from DM5PR0801MB3767.namprd08.prod.outlook.com ([fe80::7eda:274f:8165:2155]) by DM5PR0801MB3767.namprd08.prod.outlook.com ([fe80::7eda:274f:8165:2155%4]) with mapi id 15.20.6907.032; Sun, 22 Oct 2023 18:28:16 +0000 Date: Sun, 22 Oct 2023 13:28:14 -0500 From: Jeff LaBundy To: Stephan Gerhold Cc: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Albrieux Subject: Re: [PATCH 2/2] Input: add Himax HX852x(ES) touchscreen driver Message-ID: References: <20230913-hx852x-v1-0-9c1ebff536eb@gerhold.net> <20230913-hx852x-v1-2-9c1ebff536eb@gerhold.net> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: DM6PR02CA0038.namprd02.prod.outlook.com (2603:10b6:5:177::15) To DM5PR0801MB3767.namprd08.prod.outlook.com (2603:10b6:4:7c::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0801MB3767:EE_|SJ0PR08MB7831:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ad96ee7-ebef-49d4-6eb3-08dbd32ca8c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HRdZIJLKQJ6eUXAbfvuMl4qkx/Nnj9/MOKM54SZmWkJ/UXpiUtIVlgy9i6k+N5VU1ajl5AstIMV+v03gjp6OzhsKq8c+HfALa4vZOojsq/Z9dBKrkiB1ItW4/ZEF71hvGcco+rIELgyQr3Q6tDYK+8nhjAZ7J/CTWVzkilnYzmvOXmKcrW5fFVJd6xnJFt/iUCs9IzFqIH8Bxa/zHInmxiH5Dxbnqz1PUsd3k5P+n8SuOWZNnCAULYjT6D/yZhTtG76WLofOJ7e1jQNLPGvOw7+Xz2gRDy7L5x9Urivr+ZNrnTTmgs9xDk/EFp11GNwpV85hRs9kf2nBUBKhTHBxovjP4evDNHBQu7xC7kdO8X337HO1c+HVNTN4Xia3wiMcGY/tyMiiiVKZS//0BELjbTBFOUzOeJ4BTLBt5KwXbmGdN9YlSVrst57stweOMPY3cJVb+1Q2+aCBAiKUz1IqJAoViMOWPfJwNT3z0nsCYWJUPspKkunMfOyVUDaq14kcMNN/N8ubA+5DB4MfIrfbum/M48gKUa7s65L6lY07FjrsbSPnxymqpLV67W3iuAke X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0801MB3767.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(136003)(376002)(396003)(39830400003)(346002)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(26005)(33716001)(38100700002)(2906002)(41300700001)(86362001)(7416002)(5660300002)(8676002)(8936002)(4326008)(478600001)(6506007)(66476007)(54906003)(316002)(66556008)(66946007)(6916009)(83380400001)(6486002)(6512007)(9686003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gRee0F/tdLeF68xU0B6B5vcQEr40jTr9vhu+wdPmBntVPKHDQaITWpMK2rm7?= =?us-ascii?Q?N+PdUILWk17/ETjcjYoDtnTOWKNlzt/6E/8hkAn4bQgfE5c1p+AIWSliD+6Z?= =?us-ascii?Q?nARQY8Suy7tdKO2NtnkltpKltfKqCJSIkOJNfKeWjpSYxxQ4PPEdLuLTVE5G?= =?us-ascii?Q?4BqSMWLDfVwn/eRbFVfWAflFXrY8gNXe3YfN6XkjIaOLW4kWJTnhs9+juhtf?= =?us-ascii?Q?EEsuEZfuwucAHXuSbNcHN0Hyebr9VqCR+jL56XDRx5l9EVVwrMu8LGT1z5Ne?= =?us-ascii?Q?kVTiBjiqvzcC1M5H31FhZn1GETJt+t2mlC/Nx6T7qF2gLR7i9SLK6GVD33VE?= =?us-ascii?Q?pnHWEOunCfJJkbbWLmak+EcrUfS9kOp1E7SGrpGGv9b1mHw30iy/b6NYBxSA?= =?us-ascii?Q?ijXXY0lt3pFVNe6QblfqHX3jrVkXZAofH4tTKfl3dqbf9iy9cPJM05hSrWhz?= =?us-ascii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LcS/XLZU5RABIQ?= =?us-ascii?Q?DxdUx0NRy9i0EFewsq1eWDUhy5jydMBW0KINa2Ul5yWe6xbRby46CEbMX5Jz?= =?us-ascii?Q?U3nfSXOJXrxWnrqaai+q3cpTHU1GASOBPi/fu3woBGbTYarlhy2lQI9fX9Fp?= =?us-ascii?Q?g2K4swDeRx9fXrG1oylK58L524bzxI8G6zXTzUEUiJpAQhUrjLVBXfhbi2pS?= =?us-ascii?Q?XijyVODJ8DJuBuO9heGvb8m9YnEObU3ijIAq8tBv?= X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ad96ee7-ebef-49d4-6eb3-08dbd32ca8c4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0801MB3767.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2023 18:28:16.7659 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uULBDG4KONP44Lza3E23F1TCurD24iUUCmuI/6NFXukgKY1OeUiIGlmPwVb6Xu+faFnDrPAeS7qhwhT/b5mNMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR08MB7831 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 22 Oct 2023 11:28:42 -0700 (PDT) Hi Stephan, On Sat, Sep 30, 2023 at 05:28:57PM +0200, Stephan Gerhold wrote: [...] > In v2 I have added linux/of.h and linux/mod_devicetable.h, since I'm > actually using definitions from these two only. Seems like including > of_device.h is discouraged nowadays, see commit dbce1a7d5dce ("Input: > Explicitly include correct DT includes"). Apologies for the delayed response and some confusion from my side. What you have added in v2 is correct, and what I should have suggested in the first place. [...] > > Nit: it would still be nice to preserve as many return values as possible, perhaps > > as follows: > > > > +exit_test_mode: > > error = i2c_smbus_write_byte_data(...) ? : error; > > > > > +power_off: > > > + hx852x_power_off(hx); > > > + return error; > > > > Similarly, with hx852x_power_off() being promoted to int as suggested above, > > this could be: > > > > return hx852x_power_off(...) ? : error; > > > > There are other idiomatic ways to do the same thing based on your preference. > > Another (perhaps more clear) option would be to move some of these test mode > > functions into a helper, which would also avoid some goto statements. > > > > I played with this for a bit. A problem of the "? : error" approach is > that it hides the original error in case the new calls error again. That's correct; good catch. > > Let's assume > > error = hx852x_start(hx); > if (error) > goto power_off; > > fails with error = -ENXIO. We jump to power_off: > > power_off: > return hx852x_power_off(hx) ? : error; > > Let's say for whatever reason hx852x_power_off() fails too but returns > -EINVAL. Then the final return value will be -EINVAL, while with the > current approach in this patch it would return the original cause > (-ENXIO). I think that's more clear. > > I also played with moving code to a separate function to avoid the > gotos, but I feel like that makes the fairly focused logic of this > function (reading the configuration by temporarily entering the test > mode) just more confusing. > > To still fix the error handling I ended up with duplicating the > "success" code path and the "error" code path (it's just two function > calls), i.e.: > > error = i2c_smbus_write_byte_data(hx->client, HX852X_REG_SRAM_SWITCH, 0); > if (error) > goto err_power_off; > > return hx852x_power_off(hx); > > err_test_mode: > i2c_smbus_write_byte_data(hx->client, HX852X_REG_SRAM_SWITCH, 0); > err_power_off: > hx852x_power_off(hx); > return error; > > I hope that's fine too. A bit ugly maybe but in this case I would prefer > having the main code path (reading the configuration) clearly readable. > > Let me know if you have a better suggestion for these (I'll send v2 in a > bit so that you can see the full diff there). Maybe we can massage this just a bit more; I have followed up with another suggestion in v2. > > Thanks! > Stephan Kind regards, Jeff LaBundy