Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp775738pxp; Fri, 11 Mar 2022 14:50:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqCnovRVzCuoWG8KMZPfjLitP4A5B44CI86H18SVsMmhZV9xaEI6HobJMdUanIj22qFEID X-Received: by 2002:a17:902:e890:b0:151:e9c1:6386 with SMTP id w16-20020a170902e89000b00151e9c16386mr12492937plg.40.1647039016366; Fri, 11 Mar 2022 14:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647039016; cv=none; d=google.com; s=arc-20160816; b=koAA0CIA1nuKVI/wy1YLuz8HiiyxTci2TxJm23VavFdN9dLbKog6jkc1fjIiiEaEh/ hdAIPoBwi11QurAY+9HL2snoPMzJIOkMr4bxXF2GqJk+MOKd9dnzzKtp7nn9WVWJ3L7+ Abi+dvVUdMj8wdIp1I3F0FztHP0wmg6UDVQYdkPn22CwdJWQNPJ+no1ExCzCMcuguAa2 LwVSP69fyYYLUwkLIirZYYQaEM1lLlVe5hgOZxHqI3K03PPFCGpKCEyz7hI7CH+OdCoy XjOzJJL4KIjLjDAqh9OQ+PY7LVAJxpGpyLF4ogN4uzViamMS1v78f2xq2HUneAfdPw5H OskQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CXOd8MAvaJE8qndqkxaaHcRzMbRi8Q5CNbT1YDUQPIU=; b=oCKHWR9MAwDxFXcoQC/3DWgEbZyOPW6gLpr9b2oPcQSux0GZGWA1zhwmnOM2EEsHh3 ljPbHnidTWUWXQWdHxhFu94WaaqZDTIHZhY3R3H2AynmYA9jhauND/PQAtpo+CLFyIDF TRJA6/PWHe72dg6tiL1mhOJjH5jC69QxWESmrGaPfHz8eJFXJI8OHlZj1o9M93SVf/C7 I1DFmGZ2g6i9673rvQqjqsf7LHnlIH+W2pj7H9raAVnMTcJfsYzczesf4UFy2eTq7vVE IJuZENzLp5WUwfjLdxGxQzkPutrOm4Ko52IbEI4jRzG0yYmI3nao13SF0Nj0afCHdVRJ NO5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="E/bpg2Jz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u32-20020a056a0009a000b004f71c652b6csi9365041pfg.20.2022.03.11.14.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:50:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="E/bpg2Jz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 127AC24A12C; Fri, 11 Mar 2022 13:47:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346399AbiCKRDJ (ORCPT + 99 others); Fri, 11 Mar 2022 12:03:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350596AbiCKRDB (ORCPT ); Fri, 11 Mar 2022 12:03:01 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8421D5296; Fri, 11 Mar 2022 09:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647018117; x=1678554117; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=xAtkn+6Yrm4CPGtSJwRMIk0Yc8i3ptN3pVxxjuuFOVQ=; b=E/bpg2Jz5xLr7XEAFjHFdea/hFYc4uBpzocYfowGotyxjMLNLdiBqADR hz1BWSlmD9fQAlGcOlO8VKJZCZDKxPJcrgKjA/FiNH18GPZ+IRlCIvKh1 QHuD15u5QrqQAPsGVScI/jUxNm5LEu8wNY0+x/8aVEpvvJ1EaSJ05Gp3D s667t8TF8a0eNbArf/n5cXydVLKAuleuM7+L6ZAXo8+Jmcl/D28c9s3vF JxnQfVonDzeffnkisW2fYQBwdLjxDF9hepTeVyRE/5GoBNYzrv6KhmXm8 mq80LAiMXFCkretuo6LQrmNKeV35FMEGqjXA04T8JhdpaCayshpgoxjyY g==; X-IronPort-AV: E=McAfee;i="6200,9189,10283"; a="237782111" X-IronPort-AV: E=Sophos;i="5.90,174,1643702400"; d="scan'208";a="237782111" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 09:01:56 -0800 X-IronPort-AV: E=Sophos;i="5.90,174,1643702400"; d="scan'208";a="633469267" Received: from smile.fi.intel.com ([10.237.72.59]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 09:01:55 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nSidc-00FTUT-Sz; Fri, 11 Mar 2022 19:01:12 +0200 Date: Fri, 11 Mar 2022 19:01:12 +0200 From: Andy Shevchenko To: Jan Dabros Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, jarkko.nikula@linux.intel.com, wsa@kernel.org, upstream@semihalf.com Subject: Re: [PATCH v2 -next] i2c: designware: Remove code duplication Message-ID: References: <20220310220932.140973-1-jsd@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220310220932.140973-1-jsd@semihalf.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 10, 2022 at 11:09:32PM +0100, Jan Dabros wrote: > Simplify code by moving common part to one function. LGTM Reviewed-by: Andy Shevchenko > Signed-off-by: Jan Dabros > Suggested-by: Andy Shevchenko > --- > v1->v2: > * Add kudos for Andy who suggested this change > * Get rid of extra function and move common code to psp_send_i2c_req > * Update commit message and commit title > (was "i2c:designware: Add helper to remove redundancy") > drivers/i2c/busses/i2c-designware-amdpsp.c | 35 ++++++++++------------ > 1 file changed, 15 insertions(+), 20 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c > index c64e459afb5c..5c32255c3239 100644 > --- a/drivers/i2c/busses/i2c-designware-amdpsp.c > +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c > @@ -214,17 +214,28 @@ static int psp_send_i2c_req(enum psp_i2c_req_type i2c_req_type) > PSP_I2C_REQ_RETRY_DELAY_US, > PSP_I2C_REQ_RETRY_CNT * PSP_I2C_REQ_RETRY_DELAY_US, > 0, req); > - if (ret) > + if (ret) { > + dev_err(psp_i2c_dev, "Timed out waiting for PSP to %s I2C bus\n", > + (i2c_req_type == PSP_I2C_REQ_ACQUIRE) ? > + "release" : "acquire"); > goto cleanup; > + } > > ret = status; > - if (ret) > + if (ret) { > + dev_err(psp_i2c_dev, "PSP communication error\n"); > goto cleanup; > + } > > dev_dbg(psp_i2c_dev, "Request accepted by PSP after %ums\n", > jiffies_to_msecs(jiffies - start)); > > cleanup: > + if (ret) { > + dev_err(psp_i2c_dev, "Assume i2c bus is for exclusive host usage\n"); > + psp_i2c_mbox_fail = true; > + } > + > kfree(req); > return ret; > } > @@ -249,16 +260,8 @@ static int psp_acquire_i2c_bus(void) > }; > > status = psp_send_i2c_req(PSP_I2C_REQ_ACQUIRE); > - if (status) { > - if (status == -ETIMEDOUT) > - dev_err(psp_i2c_dev, "Timed out waiting for PSP to release I2C bus\n"); > - else > - dev_err(psp_i2c_dev, "PSP communication error\n"); > - > - dev_err(psp_i2c_dev, "Assume i2c bus is for exclusive host usage\n"); > - psp_i2c_mbox_fail = true; > + if (status) > goto cleanup; > - } > > psp_i2c_sem_acquired = jiffies; > psp_i2c_access_count++; > @@ -294,16 +297,8 @@ static void psp_release_i2c_bus(void) > > /* Send a release command to PSP */ > status = psp_send_i2c_req(PSP_I2C_REQ_RELEASE); > - if (status) { > - if (status == -ETIMEDOUT) > - dev_err(psp_i2c_dev, "Timed out waiting for PSP to acquire I2C bus\n"); > - else > - dev_err(psp_i2c_dev, "PSP communication error\n"); > - > - dev_err(psp_i2c_dev, "Assume i2c bus is for exclusive host usage\n"); > - psp_i2c_mbox_fail = true; > + if (status) > goto cleanup; > - } > > dev_dbg(psp_i2c_dev, "PSP semaphore held for %ums\n", > jiffies_to_msecs(jiffies - psp_i2c_sem_acquired)); > -- > 2.31.0 > -- With Best Regards, Andy Shevchenko