From patchwork Fri Jul 14 09:17:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 703139 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 C99A0EB64DA for ; Fri, 14 Jul 2023 09:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234972AbjGNJST (ORCPT ); Fri, 14 Jul 2023 05:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231415AbjGNJSS (ORCPT ); Fri, 14 Jul 2023 05:18:18 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC6682D77; Fri, 14 Jul 2023 02:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689326289; x=1720862289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H0rPHJ2jq2GzhHsonePV+vqX4ZEBf1cEpTQE3p6vSwE=; b=L8LfPZ4wD2c2davDQGqrFRU8kVeBWQtGLMOkPb0XmugTaWUT3QaWfrMk bDG5B2IiXDf8pHuL2TV1UAEvdOymhfvvtMwvCdV3w1IDMsPnogqcgrt2s MuYKaHZxSiGFMiXTn95WrgVSSr+x5IdIAVDwPjFygguDno8arnqS/46Gu GjtAfAXhZh4EUWWjG6J+OzHnGQzJmgidsTXPKxYxoKa2v53AM3a6LPY3/ Dw4vmBPExw5trK5mo3fvPTo1BemrN8VGbgF0Ki4k1bMETXZ6pJaRJnFoR JckdNAJzrdoB6HzrNSWScmMjQsIya2x5t/vtKckBGIgO/BS/DlYNA3Flo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="365469003" X-IronPort-AV: E=Sophos;i="6.01,204,1684825200"; d="scan'208";a="365469003" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2023 02:17:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="716281744" X-IronPort-AV: E=Sophos;i="6.01,204,1684825200"; d="scan'208";a="716281744" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 14 Jul 2023 02:17:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A652C4BD; Fri, 14 Jul 2023 12:17:50 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sebastian Reichel Subject: [PATCH v4 3/4] spi: Use BITS_TO_BYTES() Date: Fri, 14 Jul 2023 12:17:47 +0300 Message-Id: <20230714091748.89681-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230714091748.89681-1-andriy.shevchenko@linux.intel.com> References: <20230714091748.89681-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org BITS_TO_BYTES() is the existing macro which takes care about full bytes that may fully hold the given amount of bits. Use it. Signed-off-by: Andy Shevchenko --- drivers/spi/spi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 05f702339182..8d6304cb061e 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3877,11 +3877,9 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) || spi_get_csgpiod(spi, 0))) { - size_t maxsize; + size_t maxsize = BITS_TO_BYTES(spi->bits_per_word); int ret; - maxsize = (spi->bits_per_word + 7) / 8; - /* spi_split_transfers_maxsize() requires message->spi */ message->spi = spi;