Received: by 10.192.165.148 with SMTP id m20csp1539118imm; Thu, 10 May 2018 12:18:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrGlXYxlIT2TPDH956jJ8OM8GjbK5IjQ+/UqsgKzN+2+Q+eplEIIFzMd7H6ad7c4Fmf0/Vs X-Received: by 2002:a65:6449:: with SMTP id s9-v6mr2137105pgv.236.1525979916562; Thu, 10 May 2018 12:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525979916; cv=none; d=google.com; s=arc-20160816; b=H4851OQu34cpf139Xvu2BXAU2jrRvFUAv7O0B7d6XIINT/QbLg8o356KliAifeSshr BmX3K1xZBAWF53jMPGgw1km+QMiRekits5iiJVygsT6/6nEzALiDxPdkQ2Ok/kHfKGmm 1srasdByT/HBq2amqD9EEyEhomJkgJzF1tdz084d8BFodTVJQpItlPelOJQ684o17BOA Nor9TqqXIIRT3+h7v98elmInQIww7xAB39AMl3K/IasX7qLl0YKYyDerYsT8eAOd31n+ YR8bc+8ME40PJAQed6Dr9nurICkzaFqoo7fckQmFJUYQeXE8atA1QbpALkVOOy79HbiY /cxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=yxHxOiqYA/Gz1BLPmJrEvuUy3iGpWrh5ECELOfnWILE=; b=VGipAeFhq9PwdlA26hipK3er/eD6GrMOeY6ivQcPAmr46vVfXTDx9Yjgx6KsoS22Er Z0IYM9PusI2Qk9gpG1Y20166+aVEzmvAN4acofylpRAG9ToF4MDdiQLh/GqARK5sXTpa t3R1LlSySRgl8KNZgz4kI9bCDIHVhywCe+bDDFmyQLh71gsI74Psmk/6OOP1oR6LDiNH 8zqY/vZfYOoOpEKD2RlbpvBx4J/HgSgpF93iw1HnXO7enIDv4dhxq2o0ScfhirqtL74q eO6mJRZdHlVdLyQwYD05biY4bpl315gS8vy8t76S7vhTBvueiS78n12ov1GJI9SyHLRZ FsIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axentia.se header.s=selector1 header.b=o7CxOcH8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si1448286pln.72.2018.05.10.12.18.21; Thu, 10 May 2018 12:18:36 -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=@axentia.se header.s=selector1 header.b=o7CxOcH8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbeEJTQq (ORCPT + 99 others); Thu, 10 May 2018 15:16:46 -0400 Received: from mail-he1eur01on0137.outbound.protection.outlook.com ([104.47.0.137]:61264 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751948AbeEJTQj (ORCPT ); Thu, 10 May 2018 15:16:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yxHxOiqYA/Gz1BLPmJrEvuUy3iGpWrh5ECELOfnWILE=; b=o7CxOcH8tk8A+4mkNSwhnhJaWVjSiRY+Y/1oeTxP6wYgaxQNEeeh7USJ/jEkSaeDuCJbnVMZF1Uk6AUExX3NvYFqKb2qwmyXzG1bOwNcdqp//nQAFw3t8J3v6IYfISiAJrwDumnVSfVSmk6TZjBMMryazavH2aWRyy69muW5I2g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from [192.168.13.3] (85.226.244.23) by DB6PR0202MB2775.eurprd02.prod.outlook.com (2603:10a6:4:a8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Thu, 10 May 2018 19:16:32 +0000 Subject: Re: [PATCH 1/2] i2c: exynos5: remove some dead code To: Andrzej Hajda , linux-kernel@vger.kernel.org Cc: Kukjin Kim , Krzysztof Kozlowski , Wolfram Sang , Masahiro Yamada , Andy Shevchenko , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org References: <20180509194532.28929-1-peda@axentia.se> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: Date: Thu, 10 May 2018 21:16:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1P190CA0002.EURP190.PROD.OUTLOOK.COM (2603:10a6:3:bc::12) To DB6PR0202MB2775.eurprd02.prod.outlook.com (2603:10a6:4:a8::21) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(7021125)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(5600026)(2017052603328)(7153060)(7193020);SRVR:DB6PR0202MB2775; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;3:bBuWjs3xaP2mFcplNvB9StXCPK45mjJy5G7cmlntpaagispZcwcuzAQJyoMeNBlhxu6DSuVBFlaplX5Efsych35VwHOWA64kudz2MKAJb8J9qenPfYRfWKbnswGNSNbiMmqoc41jPqZL8AqfyNpB9Zy3YWPklDRc+edmygNGZb6OOLZ+g78qq5n9iN6MIMR3CM83qJmDlX7mPnzihEmRQFkgO5MSw+UOEnuZ/Y8e2K69VdFhrWQq+ZTHjYQizAoP;25:p843vVS6HJ/s5AbWN/yCViQM32e9ljjIiag4z8zv9tSKHNgxiPG2JXlrVDHVp8kMA3TY5xxVso+JKJagKUvpDP7OftkYmeTAk33NzMgV/41MONQUaQo//DFc63JYqLACw5gbUkbQ59R754tQ5w3JhJT0SMp20n9XYavtesLY3xuhaI5C6TOHC3d6V3mDzDNIVT/7fMps+s0qnSOJkFKNO12g16nnXumNCIM0bNqq/iVP3gPU24dSi3JmX3EMQILPkWnAjkoRdKR/TL3O5N7BHO0p7je+W97IDo+z2X46Mmr1sqfj1QUwZLQ4UlG9Zaz5bLAgGb05Cew33/kLUFfCXg==;31:IzopVl3E2OpzmU0SCgx3kn9D5GzQIyxWTR8Sxh8QQqgy2+HUKJGRvGku+Zfl25FSb/+ozCn6NejkEKKw7NCvJpJQ0Y+yYoZJ/pKX8gimcD5OYCsCK3daB6HU6eAS8di3iFqNB6e5aClAbPpOxREYnILTfKBb3QzA5euPegjErgu7CN3xOrq9nAoNsLmgnngAULxZCUlxv2iHpSVoz9JzEbxHLEt3sc9PXzuVKFhr5AA= X-MS-TrafficTypeDiagnostic: DB6PR0202MB2775: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(7411616537696); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(2016111802025)(20161123564045)(20161123562045)(20161123560045)(6072148)(6043046)(201708071742011);SRVR:DB6PR0202MB2775;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0202MB2775; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;4:VUkArMfXGk0l1VxpvIzebReyT/7XsaoqEdWcS95apE6IWMs46KfyCgc6eAE3dpxJE6yMnAj20qve4jkkkzINMmoIQlBH5g0srLyyvOM/H4Sx6fHvXbhM9lv5EDVv00aiJKZKCtbZQD94wVTSFRJjZusK43OP4OJVGOwN+7tsZQ16GdgjNhgavkVQnYieKwW9oRBJoQPGcuAW8mDEuEBvmRpJpFMH8v0/I2FAuZU83cDzl7mzEDZty9KNjVorf50qEWvoJEu3NQB/RZIQvs8ndX88k4BDZnB+0sxwjTUrByS/SuRdgd7VQlFHx9yGWUc3 X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(39830400003)(396003)(366004)(39380400002)(376002)(346002)(377424004)(199004)(189003)(51444003)(58126008)(25786009)(36756003)(16576012)(117156002)(3260700006)(54906003)(76176011)(305945005)(7736002)(5660300001)(23676004)(2486003)(36916002)(31686004)(52116002)(316002)(64126003)(65826007)(52146003)(26005)(65806001)(50466002)(7416002)(77096007)(229853002)(105586002)(16526019)(59450400001)(47776003)(65956001)(53546011)(2906002)(386003)(66066001)(186003)(68736007)(106356001)(31696002)(86362001)(81156014)(81166006)(478600001)(4326008)(2616005)(11346002)(446003)(476003)(956004)(8676002)(6116002)(3846002)(97736004)(6246003)(6486002)(74482002)(230700001)(8936002)(6666003)(53936002)(486006)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0202MB2775;H:[192.168.13.3];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjAyMDJNQjI3NzU7MjM6WG5WRTM1c1ZxbDNMSERXWUxRcy8rYTI2?= =?utf-8?B?WXJxdStBVkhaZG55WTk3ZjN6aTJReGE5L1JKRTI0RGFWemFLSC9RbjVZYWx3?= =?utf-8?B?K3JvcEhIKy8yb0lITWRqRHVEMmk3QjBkY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iedzt4Tffk6ormx9mXcA3Hz54ZHAMkiUib7YeRISLwfkhuXHfIecSAt6K4qdN1nB1Xr7T7vp9kteJ1f+ioGsR/n7YFmwV4p8nO7R4uPEhEsbw92DQIvYpr8cp92dpHhLxN0gDkNZGtQyLLwgw=;24:hZ9X3RCEShZVpcT8K0W1bSLQpyA3Owyvcrx0jlVlLJ43+thTGPDTpBfsV+xpHkHjmwJSo0LDU67EtugOvRbewdIaoud8QHCX6HTgPEB9c9s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;7:NedEsZp178pSSWk5lQhBYggzvXI3+CZNTDOrOFuRbHxQ0aD6iZn7Bhj57bQMSAXQCnxNM1JmAKQCl6FO28a+Lz/H3ApIWwCz4L9cueeWRfiiS9PUlLWN78M4zZ5TONLskE9QY+zV3AO5JKt3EZm2AbcT162Jt6k8OV212HBOkMp6p3f0p24Rc7MqIHlcAfgs9xHlmR/j2GEAFJrkYjc23KrTE+eQaabA6WpuLEHQtZw1ME8Gzat7i3bdjx1SLrBp X-MS-Office365-Filtering-Correlation-Id: ec961203-8cbd-4c3c-7e8d-08d5b6aa8b07 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 19:16:32.7106 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec961203-8cbd-4c3c-7e8d-08d5b6aa8b07 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0202MB2775 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-10 10:36, Andrzej Hajda wrote: > On 09.05.2018 21:45, Peter Rosin wrote: >> The else branch cannot be taken as i will always equal num. >> Get rid of the whole construct. >> >> Signed-off-by: Peter Rosin >> --- >> drivers/i2c/busses/i2c-exynos5.c | 12 +----------- >> 1 file changed, 1 insertion(+), 11 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c >> index 12ec8484e653..a2cbc779c33a 100644 >> --- a/drivers/i2c/busses/i2c-exynos5.c >> +++ b/drivers/i2c/busses/i2c-exynos5.c >> @@ -727,17 +727,7 @@ static int exynos5_i2c_xfer(struct i2c_adapter *adap, >> goto out; >> } >> >> - if (i == num) { >> - ret = num; >> - } else { >> - /* Only one message, cannot access the device */ >> - if (i == 1) >> - ret = -EREMOTEIO; >> - else >> - ret = i; >> - >> - dev_warn(i2c->dev, "xfer message failed\n"); >> - } >> + ret = num; >> >> out: >> clk_disable(i2c->clk); > > You can go further and remove "out:" label, use break instead, and at > the end use "return (i == num) ? num : ret;" or sth similar. > > With this change you can add: > > Reviewed-by: Andrzej Hajda But then the patch wouldn't be so obviously safe. If I would write a function equivalent to the original function, I think I'd write something like: static int exynos5_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { struct exynos5_i2c *i2c = adap->algo_data; int i, ret; if (i2c->suspended) { dev_err(i2c->dev, "HS-I2C is not initialized.\n"); return -EIO; } ret = clk_enable(i2c->clk); if (ret) return ret; for (i = 0; !ret && i < num; i++) ret = exynos5_i2c_xfer_msg(i2c, msgs + i, i == num - 1); clk_disable(i2c->clk); return ret ?: num; } And I think that is safe because I don't see any possibility for exynos_i2c_xfer_msg to return anything but zero success or negative errors. Since I can only compile-test, so I do not feel all that good about going further than I did. But if you or anyone can test the above function, feel free to make a patch out of it. I don't care enough to make a bunch of iterations on these trivialities. I just spotted dead code and dumb initializers while looking for other things. So, take it or leave it. I.e. it was just a couple of drive-by patches. Cheers, Peter