From patchwork Thu Feb 15 18:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 201679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp19590dyb; Thu, 15 Feb 2024 10:02:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5urRpkukJBdQfghRoM3h+hF+dbl7lnUk1QXEXQDlite+PC+WwxHebyQnpQjw1DTlZ9cJ7br4PPantssHfAcPIYArLLg== X-Google-Smtp-Source: AGHT+IGk7h8z/eTxzSZFEF7tAwdklEsa2SZoP0WWYAJmoibDDC9Oo9NNsZY/7hpmm3kQEXaKbLsN X-Received: by 2002:a1f:4c46:0:b0:4c0:266b:8818 with SMTP id z67-20020a1f4c46000000b004c0266b8818mr2117481vka.8.1708020144413; Thu, 15 Feb 2024 10:02:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708020144; cv=pass; d=google.com; s=arc-20160816; b=GzGQSNMysxlqMJFsebDz8IcXROxB2Fhu0KKovEHky113S9d/BMdCfIa3EEDTj9oaHz KVerIGXZG1e1o93GOX0IepGUTNlDHVPjLaodCFb48/t1jDsTm8wkwm+uRyBJd6ubSqqQ 8RyGY2AANtnlpEz2hGGLOnDAH2LoMLDF7z2lPHA6K88Vgk1k+07l39iBFEV+7WRTdHPb 0HnSVDRAn8OQdg6eMSgM/VzxT6dz5wnr26h/6nqtXY83S+Ui5h4WXLLgeGROxUCrhwni fuU2Bc2o4Q6oEsSPtIaJboqXKrjzFAdssKUBAKbvxriU3KB5HJhbw/Z7LUqs+B8WwhKu +I0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KLCazRBvduZGAf5Ar9NFgHrrEMFYuzekFNqGJYTp0sg=; fh=n84SbGPX+lMqR1931kk+sc/vwSgttIsM0Tj3SqtTzAQ=; b=NzNVDflQsW0Xa3srE3B/kOA51Wo2/CGtRswboNHiQRO4IparvO1byP9lCtwzoBK9/h VsNNGr/shP7fign5gD1UDMAjHtiOCkJOSnjtILqnXihTzIwe8c3MoT9y3RTxl4rwkVdo /WXKhTQBOLXuL+jqkEp9K+y77/N16K3pLGRFvXSmS6dNCvtdQHKBMTFmgLyjs2mcoHMU OM7M9Qr0hw28ivkiZshKaaKRPKxD5vypl2Ranp6UqZzCSM8ycIA4PrAXBkb9G7vlJlHR gaR0QVCFKAqBSaADGARdFE/HmmuLXZLLkTTVi8yt9G5xHjJAyOgpjBu7NmHVrKFwLF8v uHpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XGpGn8ec; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i30-20020a056122209e00b004c01a90d64bsi449933vkd.136.2024.02.15.10.02.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:02:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XGpGn8ec; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EA2251C24481 for ; Thu, 15 Feb 2024 18:01:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 034B3139566; Thu, 15 Feb 2024 18:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XGpGn8ec" Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9F981369A5; Thu, 15 Feb 2024 18:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020087; cv=none; b=BFKx2XMKgysfCgvQdWGAn2shmcdhEtK3i/hkn4uYEqU4QNZ0raQymnf874YF2mKXlXG8JTVEUoIRDAhBvcvdmUZ2JkeAldQfN32+OqZbKBX/hlWuEhalwPZnKj7BF6UTFRGl1c+onk15XsPf82BUIL/cSlvgaeIAsHAq3wbXjD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020087; c=relaxed/simple; bh=xxvmjWW84hnS6jVrUMwkpVn2pbnGr3EfgjkVUWZRK3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YRVz2tE8mf6yZKuHK9YRmVBg7J+qZlytw6wBgdfCs9ccRtDhO3i8K7euwi7zCQX9XGpIz4h3dHl+q1V+QQXIrpYsYBvXMkdH+msH8FkqPCqZW3G1kMisrXsd1GLHPa14Q362eDBHzMgCmgnyL5MOmOZKR+JhRq0FtnvXZwB2YuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XGpGn8ec; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-511acd26c2bso1698106e87.2; Thu, 15 Feb 2024 10:01:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708020084; x=1708624884; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KLCazRBvduZGAf5Ar9NFgHrrEMFYuzekFNqGJYTp0sg=; b=XGpGn8ecojc5NSHb/eGqZTCSEiARH5KDKwNWdtBasRFO+Xa0ui2jXS7cni8cuDYYL2 di0W9DF1rpKmnLuaT9HbJhj8YGm3soFcKny85iLsfTHYduHJXOTi89AaLfWbzffGxKkx W+HFdCwyCsX/DNZbiR0kzOVPb5JF7F/LXFPhPZP0L+8NNlAOuZ2FEECz6Ti+9IWwGT3r QkhvAJBduHbGTSkCZgG+Ee6Ter77+9mgxy/0XAvrzgUbdnr4y+laPP7wpy0PqIM6e36b lQarqlc7wIZObe9mcRa3tLXPPD9UAf9fhKd42ak8Lh2dBMtnRIJkOWLRc2zR8D/NQowv +OrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708020084; x=1708624884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KLCazRBvduZGAf5Ar9NFgHrrEMFYuzekFNqGJYTp0sg=; b=l7ZGsZNQ/Q/2YSLS+3g8ElGA/2jQv0aTpSIM2YHC4ECTNJpwVlWwpnhyO+RkkiN3ff WxZZuy7w5N56qnYp/Hi7P9vHlqbWFy6da3Ef3dzJkqJZZp13ZroOldiXaB8/aoSO85Y8 BLBQnpcBpQsGc85QCCR/on6HEhdthRxF+FeACUfMl92U9IuuxMyHzrL+NOmeEOPZleEh jcS9b8isI7yIaBosdpmbRsjkNsjvnZozXI1KHLpXt9GQMdkWvhvSLNVfmmmutfblkmYO s1QDPXxE0JsulamlQpq+SxlmoJqgKNkFtKovx5x6hByMaY9FEVcR/g0AmhnC7/oeb1LD rMug== X-Forwarded-Encrypted: i=1; AJvYcCWGGi3HNaAJD6HCnkaakNe/QpuLICMX6nB30drCYPENdT6nAO0PvZXXCBlpklxmfUis1ds2CB2OU/RxiJCaI87k7UDDxm2zAQQ24CW2kOkCFpnBlf+ju9dzcWlyMRq+HmXC5BIw2RIJ X-Gm-Message-State: AOJu0YykjXo4ZUKRHaxU/9Kf+K82SOlwvCI7w8W7HvLhFixgzSm4jGLk inlnXinm1HKf8eA1K2dT0+iFc93Ha0kYtezG+ATxP+DJFzkutsAB X-Received: by 2002:a05:6512:3e16:b0:511:79ac:2d78 with SMTP id i22-20020a0565123e1600b0051179ac2d78mr2399451lfv.39.1708020083333; Thu, 15 Feb 2024 10:01:23 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id v22-20020a197416000000b0051181cbea91sm321468lfe.228.2024.02.15.10.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:01:23 -0800 (PST) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Alexey Malahov , Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] spi: dw: Convert to using BITS_TO_BYTES() macro Date: Thu, 15 Feb 2024 21:00:46 +0300 Message-ID: <20240215180102.13887-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215180102.13887-1-fancer.lancer@gmail.com> References: <20240215180102.13887-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790988930869276241 X-GMAIL-MSGID: 1790988930869276241 Since commit dd3e7cba1627 ("ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use") there is a generic helper available to calculate a number of bytes needed to accommodate the specified number of bits. Let's use it instead of the hard-coded DIV_ROUND_UP() macro function. Signed-off-by: Serge Semin --- drivers/spi/spi-dw-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 0274c9295514..722b5eb1f709 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -421,10 +422,7 @@ static int dw_spi_transfer_one(struct spi_controller *host, int ret; dws->dma_mapped = 0; - dws->n_bytes = - roundup_pow_of_two(DIV_ROUND_UP(transfer->bits_per_word, - BITS_PER_BYTE)); - + dws->n_bytes = roundup_pow_of_two(BITS_TO_BYTES(transfer->bits_per_word)); dws->tx = (void *)transfer->tx_buf; dws->tx_len = transfer->len / dws->n_bytes; dws->rx = transfer->rx_buf; From patchwork Thu Feb 15 18:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 201680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp19768dyb; Thu, 15 Feb 2024 10:02:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXE1yZTVikKM8uyKHv9nTm+w8zuY+zGzBwwXp8s6pRYw3LLHgA4PHs9/SKDouAO6qzJ41ycaTkY8FRupY8j0jNfFg5wtw== X-Google-Smtp-Source: AGHT+IH96QUpg80BB4NSbVKQWMNZdeOUBFZVdW+OIdoxS8ns4x475UuyyYiHFR9ZCMNVHjnlxoRn X-Received: by 2002:a17:907:3592:b0:a3d:57a6:8c50 with SMTP id ao18-20020a170907359200b00a3d57a68c50mr1868791ejc.26.1708020157013; Thu, 15 Feb 2024 10:02:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708020157; cv=pass; d=google.com; s=arc-20160816; b=gL4czj9kV8uJshocqNgqR0NOuxMJSE1XXE9lcWeF3c9pYXXO4xjt2eDzjhNYvgdw3D cGW1wBFXmtwu5Fj2bJhKSjQaITt0z/9lV0houltgs8pkDOfbvFI1LEGEn0GADKiPp6V+ d7Jj5ZRLOusPY4QP3x2whY12RMfi5PLlZuu7TMG1Aj6AhoMu3G9/YfWqvV+x7G8KhIt+ /+sdVzI642TCLlA21DqoVqqPj+i6TWCOz+aPaDWVAfCwmgETYIjjTomHo/XBmYltfH1j kLT3dglyQMAKiqWP2OP5fIwVyF5UCSLim6HMCJjzR49JfrM0Zj4FoZ8qjuREmVwuvEQi JfiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ef0c0lkPbUi43MY5AODLBrbnTIwKOtyjY4A1tP/i59I=; fh=8QR3YP2+G9bDWSYPIN6zlh0fuiauNXNLi06nWPfg0dQ=; b=pUQuKekrzmRPC4k7v1JBZjMVGblfikDs2VIznyFjhLuFguoeBYLuu6vMu/cNk0ym0P MkrnGbK6+bqg/D3iFWoAm8SAaJMK7iw4HjlgtymA6uhdf4kwMENj1htgJx//++Xrj7mk y+RGdt5Y1vQ9nRbwtVcd3wDwJz2NN6JD7FujxjzWszvsKEVofCLVKXhwAsyRPb4EZLXK lW1DyuHp3/p4CWmWnOrtRo7wenVxY/xB9dOr2fAmmxitu0pcsnNm5hxxy43ghu1yspzm PjyehVqKsQtQhIETtAwR1Hdj9kwrdJK6qaMUCKkL9ozCZxYJGTTbDxB1+L/gBnDuRAT8 SMKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hLijPB+4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67462-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67462-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q7-20020a17090622c700b00a3d77fbe7fdsi829832eja.399.2024.02.15.10.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:02:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67462-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hLijPB+4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67462-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67462-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 38ADE1F24215 for ; Thu, 15 Feb 2024 18:02:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2368E13959A; Thu, 15 Feb 2024 18:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hLijPB+4" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDAA91386C1; Thu, 15 Feb 2024 18:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; cv=none; b=sYL1TVLGfbLL03+R0js7H5Iz1AYe912QW0e1nNz68rErs75rNabX0rpbe7oJZatMGB/cHsT3p27SNyQfbLTRLRhv1rA7d+g8NmIs3eWP1C+xxzcN4Ydeuu5qT6I9UGbWd+MH3F/TuD9XdGv4atVk0DFhyTUytFhA0NEArK/Dl4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; c=relaxed/simple; bh=KBAkQBgpYdLDaJ5qYLlC9p8SlXhmDfw3UvehvJhSkG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I5TFkfZCITTvjpoNLnXNAQTIqFSW7fJn06K4pdB7c4Dmws0mM2caOj4+3Q5OxNUWyWg+41cKKaMVg0U4LaHPxwpYOHP2Bsk4T4ehLHjeqCrPiRyN2VjPVtecG8oPuLgfZOEEQDTF9iUDQ68yzbL8F8ZECEa7ZqlKNm5e31Pyyok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hLijPB+4; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-511831801f3so1203100e87.2; Thu, 15 Feb 2024 10:01:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708020086; x=1708624886; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ef0c0lkPbUi43MY5AODLBrbnTIwKOtyjY4A1tP/i59I=; b=hLijPB+4/4rFFtoTdtnw2fOkvvknMJy5zQa2JWAzVoaUruqBbQDdRrNQQyQ/qsbguP CxKzJj3BQrDN3ChRd0ODgflCTHamKWQDoHweML6EO4t2m6Ft/5/zumNljIG03DRxHN7c 5zDvvKSLPueDayZwEcj5VAE97HSfkwtKdMiffOTIHGhPK7pGcx+7LnB+8Vse32QBVV5u ilGqQZGzrK0ljTSV61NzYUCa5jnV7nyBGzDTlFFTEkkzz6SIEqjcPBgIfGuUbst2NFQD AZshjoOZhoJcB+YzN5hjOdXymhjyE0pucaW4TcA5CDR6EVmp9qe6hel6T4CxgTu5iVB7 9/iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708020086; x=1708624886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ef0c0lkPbUi43MY5AODLBrbnTIwKOtyjY4A1tP/i59I=; b=opVCDZ2Hkw3u/o/0JvvQQKJd+5F/baiH9hjDQGrDfULCsi6UCh6GEz9ee4/BoTaVG6 mLBtkQq9kN3iY5H+OsN4H3h439szjIiN2urwtrhWyPphiftKSqIJ1c0BiO9jXLBouX5b hsax+BH5Ero33snd7Zo/PoJJB/lDzNXi4pKozGaoldYjD7YMJOcC3CfsCo7U6qWP2N7M pijjrK59ase9JWW0h173o+SNW9dPHX2rXWrsQhBU+UyUz9tF/n6SxIu3fOK0NHJIDgv1 fa9BLsxyGn+RptiU7OWxHRbkp+00IVQjMoPUcc8cDWoffE4htjqRcuZhb8rdo5kqRw94 ShyQ== X-Forwarded-Encrypted: i=1; AJvYcCX8OPJvcE8sGa7r8bIoraQPiEGcpFflrNixHbqMP1S08yyzbxAWRL2vToGuSQl2sHffWdKR1QjS+wkDrwTZtiwNFCvpEosz18IeCZPWASE/6tLBIguE7MWNPu+egyXiCXQLDKut+DyV X-Gm-Message-State: AOJu0YwC5PoqamiZ1qb8lrS5EsH292TFz3pRg//e5wiRF2BjMXoN4GBG cCAbD0KX9oCoFn/7ybGBpzLgJ6MQPtVdn0OLuAiOWEemuFWfDtcs X-Received: by 2002:ac2:59d0:0:b0:512:851d:41c5 with SMTP id x16-20020ac259d0000000b00512851d41c5mr1898427lfn.20.1708020084995; Thu, 15 Feb 2024 10:01:24 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id k11-20020ac2456b000000b00511ae3225d1sm321197lfm.226.2024.02.15.10.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:01:24 -0800 (PST) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Alexey Malahov , Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] spi: dw: Add a number of native CS auto-detection Date: Thu, 15 Feb 2024 21:00:47 +0300 Message-ID: <20240215180102.13887-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215180102.13887-1-fancer.lancer@gmail.com> References: <20240215180102.13887-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790988944157179274 X-GMAIL-MSGID: 1790988944157179274 Aside with the FIFO depth and DFS field size it's possible to auto-detect a number of native chip-select synthesized in the DW APB/AHB SSI IP-core. It can be done just by writing ones to the SER register. The number of writable flags in the register is limited by the SSI_NUM_SLAVES IP-core synthesize parameter. All the upper flags are read-only and wired to zero. Based on that let's add the number of native CS auto-detection procedure so the low-level platform drivers wouldn't need to manually set it up unless it's required to set a constraint due to platform-specific reasons (for instance, due to a hardware bug). Signed-off-by: Serge Semin --- drivers/spi/spi-dw-core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 722b5eb1f709..ddfdb903047a 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -834,6 +834,20 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws) DW_SPI_GET_BYTE(dws->ver, 1)); } + /* + * Try to detect the number of native chip-selects if the platform + * driver didn't set it up. There can be up to 16 lines configured. + */ + if (!dws->num_cs) { + u32 ser; + + dw_writel(dws, DW_SPI_SER, 0xffff); + ser = dw_readl(dws, DW_SPI_SER); + dw_writel(dws, DW_SPI_SER, 0); + + dws->num_cs = hweight16(ser); + } + /* * Try to detect the FIFO depth if not set by interface driver, * the depth could be from 2 to 256 from HW spec From patchwork Thu Feb 15 18:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 201681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp19775dyb; Thu, 15 Feb 2024 10:02:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOGaNLzKA5h8xSzAY3/z6M8IAkKvF52GtUFcEcnyaw3iBrAEsOQSN6/LdLyVLpD1r//pzMqRERzX9OsJ5rLcjb0AC+cQ== X-Google-Smtp-Source: AGHT+IFos+gsdYzQQnzATeysIjhDb63Uh5GWB9soapiALuBsW0uX44OC5KtW693Az1/i6lZzp6Nq X-Received: by 2002:a17:906:360a:b0:a3d:b150:2144 with SMTP id q10-20020a170906360a00b00a3db1502144mr966015ejb.34.1708020157508; Thu, 15 Feb 2024 10:02:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708020157; cv=pass; d=google.com; s=arc-20160816; b=WUXFE9Usmo6znJcuubr8dezhkzGKONBuHPfYfUM70uMVb6meWbRSsVxEs9TQkD1vCi UqtuMuXY4lSvmosf+Th/ES75hbo2zCSr6neDP0ocROBmv7z03vmXMFJpO7b5QpLRaI1i Zg7IpGi+IBbC0OHhjxVhobd7qFWW+bfL7rk0r/2iKMjdGCi3ar/jjXvEKmqJmnHlXLgf ISmid4ONjmgo+cN1tABziHQR8Fgs71cqFe67PSuEAnbGtNgIqKYrZ5OGHDOizKsTW61q cD4Q7FrpclvE+yQ5BoOQyfYY35nmSJBncc9OvYRfGzvVNvzY+EUZcihqXv3uIkaCoqRv f7VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; fh=OC9+bkJQZ7EAZTN/NfNfaqlrEuuc0dEUeVaHir05ixI=; b=ROvC/X10GBEwDRAcy64WQ2AU2V+9oO7W803wsXzd04+MG7QrD+/DvVIIHvX5ZafGYP 8Ao1GgqbMeaw44rPj6kwhSp/D1FAlgkO06lP/lJbwCs+CDeE80vIAVkuZ1/O3oxqxQ5o jIVdzkaqE/TrByn8He2NNAGbNb9pD97l+hBMrOuybzPUQs0QoBkLUd5MmApAG5m5i/Ur bgfJj26h6XL3JazLz2PoPECgWc0UUqZdLzweI0s9nx1vwRhNZjEUNk8ggz7y+e6l050b fDqBGY7kL0qH44h2ZU3x+KGhW649SyOSpAXnvo06rfEKg9gg+dz0jV/Y4y1bXJGjKjmR dfRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AUwvJFXh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kk27-20020a170907767b00b00a3d41bd0afasi845251ejc.907.2024.02.15.10.02.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:02:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AUwvJFXh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0D7B11F23387 for ; Thu, 15 Feb 2024 18:02:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F2F413959C; Thu, 15 Feb 2024 18:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AUwvJFXh" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 036B11386DE; Thu, 15 Feb 2024 18:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; cv=none; b=MmUrODagNJzzu9b2WY2whIkx5TleJX/CyPKlQBkqgPMiBmnE5gdBmRH8QBBS9X5DLRC3sW9nxG1D+FaHBecAPb1I/YIdw7Z7ZjukPKcud9OS2MldTZb90LpsLRNquAG7rzxrBijS3emqj+glII0oVQqU1K2TWpxola7GZqKqGes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; c=relaxed/simple; bh=F8Y/aairEGyfuvo2EhCMfvxfxlwtJhutuIxOg1R0p08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VqM56v4FXlQmCjZI/pT2dAkLkiFJ/6xyhTbBX5wjVjCI0/NCFPO39oE8A5yLOmxR4VJEZzZo4aET9t/kPKzmsDNupRDU+I4XDMF/uzstRIteNAXiSoeNF+251BIoIT2t5jwKwQOmKZXh7P2CZRZfJRZigo8/p5aGsYBFtQA/IVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AUwvJFXh; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-511acd26befso1438303e87.1; Thu, 15 Feb 2024 10:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708020087; x=1708624887; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; b=AUwvJFXhXiFYN22auaZiEEPHGvIGgZgOazZDxq8BQ25rVG+RHCd/VB9Xtvpsipao/l TdZfuGnhtrtSw7jqIbgS3vN4vvbUe1XXsGhptJTZ+L6wmqgphXi55UCraT7dO92vfz0o jA9sTRn/aH3DCHF0dyhXxwR9XjhYnsKuOXQ8U4hPp7h40JnRAJGk3tZ9G/BTo2/Dy4lY daU15JkDb0VpmVFSWK876Vkm9hDY+JxfjAlwu9knJwycwgWehZ5stUuOg5nBUKVlmEwD UhHrbAVQYh/kbakAtktNO1tToQ4T7aOE0eIjX58UyAJ6wiDe/aI9FkR9NYCkGFyKc7A1 KjUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708020087; x=1708624887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; b=F521ACCwCW0xuVlQxgnEfnndqEiPvGG2QY6FgS3Ti2nDqaenj8euv93qAnjPpZhJkG f/GtY0H0y26n0411497vzX2SIsQS781xRuIsPTBW5SnNNmtVX7b0i/rW8FMFlrt0AsBz JjPFPuYn4/xLBHMoNNwBd204QwXzVSqt70pEP66eTAwlP82VcRw4lw1TSkzM55/us52N PNfYqUCazGYn757sSHb76oVjjpnpPBsgbAzH9Z9JOIK8IeKZ7EbQs97B+vulE4FWjujg 66fIrUGm8oTgUy4bUHawF7UAV2Mx4TTmwl8fzcDXbpMHJou3hirhBUQZYt5ls7c/Zh3a zdYw== X-Forwarded-Encrypted: i=1; AJvYcCUHaDDN5bV2cq8JIEtuxCQ08INklpsyREOO0+EyTm1O+7CYUbceIQRs362ZdRW/cO6QdjW3DN6go480KKfaUNxiMifXunElc+b8ExLE0DX+B9tpiTje9gKr7Hp45g3OAG8ZXglE+O9j X-Gm-Message-State: AOJu0YxVZKH7rE6sT5M0CGvbwHM4Or5S2r1tYkpGjCN0QUTZIFG6jQwV q6B2QmcjqB1DZbd9edfcXHND7+vDyoU2kqHO4tVtMUN6+SFHYTcw X-Received: by 2002:a19:9152:0:b0:511:4824:6718 with SMTP id y18-20020a199152000000b0051148246718mr1991126lfj.56.1708020086584; Thu, 15 Feb 2024 10:01:26 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x7-20020a19f607000000b005118c6d6a2fsm322769lfe.305.2024.02.15.10.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:01:26 -0800 (PST) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Alexey Malahov , Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] spi: dw: Drop default number of CS setting Date: Thu, 15 Feb 2024 21:00:48 +0300 Message-ID: <20240215180102.13887-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215180102.13887-1-fancer.lancer@gmail.com> References: <20240215180102.13887-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790988944917435150 X-GMAIL-MSGID: 1790988944917435150 DW APB/AHB SSI core now supports the procedure which automatically determines the number of native CS. Thus there is no longer point in defaulting to four CS if platform doesn't specify the real number. Signed-off-by: Serge Semin --- drivers/spi/spi-dw-mmio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index cc74cbe03431..eb335fcc8720 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -364,11 +364,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) &dws->reg_io_width)) dws->reg_io_width = 4; - num_cs = 4; - - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); - - dws->num_cs = num_cs; + if (!device_property_read_u32(&pdev->dev, "num-cs", &num_cs)) + dws->num_cs = num_cs; init_func = device_get_match_data(&pdev->dev); if (init_func) {