From patchwork Fri Nov 17 14:40:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 13459009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CBBDC072A2 for ; Fri, 17 Nov 2023 14:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbjKQOlL (ORCPT ); Fri, 17 Nov 2023 09:41:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231145AbjKQOlL (ORCPT ); Fri, 17 Nov 2023 09:41:11 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32E8C5; Fri, 17 Nov 2023 06:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700232064; x=1731768064; h=from:to:cc:subject:date:message-id; bh=oJMlxIX+xGl6Bb9PQ7qfp+lKIWOfx1gEg/uC2QjrdSE=; b=arKd14o0v7nbIweOaAPYgdzMIc7MsXFDT2kiUlM3rGXEc/zk3uoNPZeb sizsEy9P9/1Ke5KgyyhPUSx8XR+yo4h7/bSJQzzvR/yIUYr12Z8i0LRTD y8N82ISCYdU3dmmeybiDPpODiPgcOgtSnsPLJWoLPhtMXxGCVaqY8mtMl CVgWoCmOzD8yzzBWPSP0WqOht06xwbwnRr8W+YidkQyqFTxhp/OKZWTVo yHRin+4EYFAO8Z2y4FHjQQe8OPPTSg21/ruh3lu3i4okuLnJfPqhxe49A W+sI6qUkyge6LXqgoL1F/ZPpFeSeGt+bRXGRi06l2K3FcS1YD6dALIyPK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="370661074" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="370661074" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 06:41:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="742092615" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="742092615" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by orsmga006.jf.intel.com with ESMTP; 17 Nov 2023 06:41:01 -0800 From: Raag Jadav To: broonie@kernel.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1] spi: intel: make mem_ops comparison unique to opcode match Date: Fri, 17 Nov 2023 20:10:53 +0530 Message-Id: <20231117144053.24005-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Instead of comparing parameters for every supported mem_ops, only compare on opcode match, which is relatively more efficient. Signed-off-by: Raag Jadav Reviewed-by: Mika Westerberg --- drivers/spi/spi-intel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-intel.c b/drivers/spi/spi-intel.c index 98ec4dc22b81..3654ae35d2db 100644 --- a/drivers/spi/spi-intel.c +++ b/drivers/spi/spi-intel.c @@ -711,8 +711,7 @@ static bool intel_spi_cmp_mem_op(const struct intel_spi_mem_op *iop, { if (iop->mem_op.cmd.nbytes != op->cmd.nbytes || iop->mem_op.cmd.buswidth != op->cmd.buswidth || - iop->mem_op.cmd.dtr != op->cmd.dtr || - iop->mem_op.cmd.opcode != op->cmd.opcode) + iop->mem_op.cmd.dtr != op->cmd.dtr) return false; if (iop->mem_op.addr.nbytes != op->addr.nbytes || @@ -737,11 +736,12 @@ intel_spi_match_mem_op(struct intel_spi *ispi, const struct spi_mem_op *op) const struct intel_spi_mem_op *iop; for (iop = ispi->mem_ops; iop->mem_op.cmd.opcode; iop++) { - if (intel_spi_cmp_mem_op(iop, op)) - break; + if (iop->mem_op.cmd.opcode == op->cmd.opcode && + intel_spi_cmp_mem_op(iop, op)) + return iop; } - return iop->mem_op.cmd.opcode ? iop : NULL; + return NULL; } static bool intel_spi_supports_mem_op(struct spi_mem *mem,