Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp486033rdb; Fri, 26 Jan 2024 01:25:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdpB/olLcHCgot7o8z6qrxHig4sFVi7TTytFm/sxBPb2/m4EdqfUOF+CMKtkwKbQHAomg4 X-Received: by 2002:a05:6358:8814:b0:176:bf5c:b578 with SMTP id hv20-20020a056358881400b00176bf5cb578mr948285rwb.42.1706261144220; Fri, 26 Jan 2024 01:25:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706261144; cv=pass; d=google.com; s=arc-20160816; b=H/qRz+XEx/eyFMYmzScCHUZcd7wLKAWEWFShAqVnXf4JqtI8rvgSKRk0RQb8w6wPXd coZLKwN87Y6mwneoj8rKTfapYfVL9JagDXuc4BKwGXwithqyvp0XuIp8Gc9ajSVuWH4O p6ZgfzuRtQn/BfiviuzOX9JbjTrCCVHlylPbuwfarJaoTKnpgHn/3hJ7YcZ5RRXjgFqx c3kJT9oYfrNBax8+Ig6/mxcBGdhRvwVvet71wTnCyb9Ybn8IrWGmrj/fwqYQHAReCCrr nVjnEA3T6cULhqmtYVqK4Tf0HXdH6Zvxrn/WjfLD97dxjfMMiG/hI8Fpk1sFRKxWq/SR 5SpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=SxXvp45WIZMJk6naBF28BXtWC3N8nQIyBhkXmU92Lmo=; fh=STcorcAUr2S3K5qTja0306c8mgUIN/x+9Hnkm3IilH0=; b=qpJmMYklY3p7nOLBVPOi+ESrjMGHUivP0FJZia/aH0Qi5bKUeNsTCbY/0zqSnSdWC1 n+QRySCNSBwLySKLmRr5vTz44B0I1ZrRjABV1+WJDHSKkNCoQWw7VY9+zWqEW5+3ax1v LGgJ+ab4O9iTVcFZhon4H6MfBIN61M2gpu2NUKPLamb03AanFKoAyUzbU6F1fcM/F6EJ xA59UwhBY/attx2icSmbt0uxh+Oj108YCff+Fnmhzu4rgooZA+meth95SJsguyzko7Z1 fytsRamZ5s5bGizRYT2cjQwyLvOoVoV6Ln1+LtycsGKzFblCSppzImJj5XqVEUAJGTni fGxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjOvfehB; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-39790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b1-20020a6567c1000000b005bddb7249e0si842157pgs.313.2024.01.26.01.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 01:25:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjOvfehB; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-39790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3F68D2899D2 for ; Fri, 26 Jan 2024 09:24:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F0E51D69E; Fri, 26 Jan 2024 08:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QjOvfehB" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 9503A12CDBA for ; Fri, 26 Jan 2024 08:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706258968; cv=none; b=hGRUgnHEawok15I9Tu8FzDbklv0a4K/mLfUVlcJcfkrKj25YaBPcJsubHSX/71g31HCsoGEnOPOMpzbXh6ENeMSNKAQnKc/yJ5GZF3CLGZehtkYT0UzJZsl4B4b6+/vTaWjktpcRJUQjerbh6pDpIv08wpivGC1gaqVU0dVVTRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706258968; c=relaxed/simple; bh=t/ysEWbT7DsgI1OKWJZlsnVlTSlU/XcsSNTRoDVp2uI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZepTHATWQ6unJelJNFNW+uIRRFLUUAdDxGbabtxl6zefQBtcEYuH4io2yqvcahUHTtjTjgKbR8HzCNqgDbTbhYqUwV51nof7vmIKhjiMOh/zISb2c9Hl8rT8xYqxqDKUnxVkTufggPKJ7n7KnKcxLknwAzm1sm73mak2Pnmx8T8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QjOvfehB; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-339289fead2so135212f8f.3 for ; Fri, 26 Jan 2024 00:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706258965; x=1706863765; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SxXvp45WIZMJk6naBF28BXtWC3N8nQIyBhkXmU92Lmo=; b=QjOvfehBwf3WuBI044r7UjrgnPxxU39vStixilzothah09+vwDEy9YXFQ6+edgLDiG ZOv2bsgCReYBPgbk/DHLkAGUZuTuOOvTofof8IiVAMd3etlGcY2twJzUv26qONkUp6C0 AhzhyygS5v/2LCdC7mqhry3z4rmHopRr8NzPxx5DgPxpiML2uu6ASugxyU9aEm6U5DzY jtbzmEt791PMCbWPEvsS3lovtIejCjNjtiV0Y87F37jul6VkAW+/+9Qw8c3wJIxIAwhh kySUgW40NjmUsEiUvw/wyzUVOqpBuf+5krxiL9du/KcZ6mcvS43YXWzRcvPs0FWK03EN 7hyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706258965; x=1706863765; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SxXvp45WIZMJk6naBF28BXtWC3N8nQIyBhkXmU92Lmo=; b=gfvK7TtxGpdUXmp0e35PdV17qpbR/RhXyFziXdiL8RA39tc4LC6hlhmI63gNdy90F3 hdD/ocUIGsg+uyGYLxnDZHeZeGgNbD9Ma8//zU113yEzQI+i8WvvhLl7tT0Ko9nIQ48d tixFbTJYz6uYBbYmBN0F6HCuUNVZh2UErzirM6KY5nJgyQhys9zDIne4/d7kSmEPRQAD 4xWdEOfUr5Z+ddev5MG5BiJmezzZa6RpGGBNDgMFi/qReFk8tM0U9xex07GhTe9ggkYR 5RQEKbSGCeXVOYgcL/EHDnLqyN8GNAl7NnTfnenVaOrl6rpHFb9PkWahJInX6F9zgw3x 7Nfw== X-Gm-Message-State: AOJu0YzTlguFoc5ZGRbulIr7di4u0uJXFoPQ3VZjexsk0tVI9vu/ElsM X3xgCr5v3sLL82kw/vc74O1I/GmPwReUBCXKglS7DiJibIiETbKNQA4Xmjme77g= X-Received: by 2002:a05:600c:19c8:b0:40e:b95b:e482 with SMTP id u8-20020a05600c19c800b0040eb95be482mr598802wmq.115.1706258964791; Fri, 26 Jan 2024 00:49:24 -0800 (PST) Received: from [192.168.2.107] ([79.115.63.202]) by smtp.gmail.com with ESMTPSA id r12-20020a05600c35cc00b0040ecd258f29sm5158250wmq.0.2024.01.26.00.49.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jan 2024 00:49:24 -0800 (PST) Message-ID: Date: Fri, 26 Jan 2024 08:49:22 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 09/28] spi: s3c64xx: use bitfield access macros Content-Language: en-US To: Sam Protsenko , Mark Brown Cc: broonie@kernel.org, andi.shyti@kernel.org, arnd@arndb.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, alim.akhtar@samsung.com, linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com References: <20240125145007.748295-1-tudor.ambarus@linaro.org> <20240125145007.748295-10-tudor.ambarus@linaro.org> From: Tudor Ambarus In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 1/25/24 19:50, Sam Protsenko wrote: > On Thu, Jan 25, 2024 at 8:50 AM Tudor Ambarus wrote: >> >> Use the bitfield access macros in order to clean and to make the driver >> easier to read. >> >> Signed-off-by: Tudor Ambarus >> --- >> drivers/spi/spi-s3c64xx.c | 196 +++++++++++++++++++------------------- >> 1 file changed, 99 insertions(+), 97 deletions(-) >> >> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c >> index 1e44b24f6401..d046810da51f 100644 >> --- a/drivers/spi/spi-s3c64xx.c >> +++ b/drivers/spi/spi-s3c64xx.c >> @@ -4,6 +4,7 @@ cut >> +#define S3C64XX_SPI_PSR_MASK GENMASK(15, 0) > > But it was 0xff (7:0) originally, and here you extend it up to 15:0. this is a bug from my side, I'll fix it, thanks! cut >> default: >> - val |= S3C64XX_SPI_MODE_BUS_TSZ_BYTE; >> - val |= S3C64XX_SPI_MODE_CH_TSZ_BYTE; >> + val |= FIELD_PREP(S3C64XX_SPI_MODE_BUS_TSZ_MASK, >> + S3C64XX_SPI_MODE_BUS_TSZ_BYTE) | >> + FIELD_PREP(S3C64XX_SPI_MODE_CH_TSZ_MASK, >> + S3C64XX_SPI_MODE_CH_TSZ_BYTE); > > I don't know. Maybe it's me, but using this FIELD_PREP() macro seems > to only making the code harder to read. At least in cases like this. I > would vote against its usage, to keep the code compact and easy to > read. I saw Andi complained about this too, maybe Mark can chime in. To me this is not a matter of taste, it's how it should be done. In this particular case you have more lines when using FIELD_PREP because the mask starts from bit 0. If the mask ever changes for new IPs then you'd have to hack the code, whereas if using FIELD_PREP you just have to update the mask field, something like: FIELD_PREP(drv_prv_data->whatever_reg.field_mask, S3C64XX_SPI_MODE_CH_TSZ_BYTE); Thus it makes the code generic and more friendly for new IP additions. And I have to admit I like it better too. I know from the start that we're dealing with register fields and not some internal driver mask.