Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 7930D2F56 for ; Wed, 24 Sep 2025 02:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758681664; cv=none; b=WPuIPtjOoQFY+ErMzrgwk1xA85SePKYuL2OYFENYoS3BvYdVYgE2IyW+pjpzmh7y9OdVecHyT05TyZklCJMXFowoAtYoBveTxmaqaJXKEPmKXJtZFKDqjFxGpL7xxM4uRCl1TJQenJqTa1UqloCeOyKPSPJKT7PkkXknAk8IqNQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758681664; c=relaxed/simple; bh=Uha/InzQTMU2XSWRXEyQ5VSO3HoUfrMeKudmNEUQGUc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IE6T6O+7FTkd+NjA4C2wOexlP3V8wPxOYYXmaXqJcEwKQGjAVzMi/HPGPVp6E8hYw0UCD/3RalYT6FMLccLj/Qai5Ux2szi4q79rruNdrYEqIrACZ1o9zebDm+c181d5oKmeA0kiAYdoKZ4pcwZT+DTqH1sT15GJ39fAvEFiQXo= 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=C979Wyey; arc=none smtp.client-ip=209.85.210.170 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C979Wyey" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-77f605f22easo962735b3a.2 for ; Tue, 23 Sep 2025 19:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758681663; x=1759286463; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uoZZYfcg1eDQ+SJZ5L9LQV2KxrPo1OhoDjYQOppmFGk=; b=C979WyeyIk49+gDTxmmpWDTS2Chki33BatjBnjIRgwsng9LbXjDe4jBnTn1mKj1nLE V8VL+smAD1U05tEQWzWwKruf9nzRjjvcqMYxbtm7z+rTaosd8oYuergBsMN7jVe8c8vT fl1lbbCGYvlPFG4a/ifqIZp65tz5c14AKEHIGR7Z3jryi1jYqIH+FWYbUAw+MH/ZTjxt nc6VNHIg0gi20VYPmVubyq5Ei2QamOt5gM9ptR0x65Akfnl1pyeO/4sj2+qVNABo0ru8 PzWaPTPp1YxI7lrFfFSH0KVxoGYN+HBqpT+JF3lXrXCOmmsHmDhjB/nsQYRIYqcp7jF8 P3QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758681663; x=1759286463; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uoZZYfcg1eDQ+SJZ5L9LQV2KxrPo1OhoDjYQOppmFGk=; b=SSeyNAYYzVlpVFAHVyNWCSbwTimb4ILITA4So79vv7uxbgMU+brLQeuYZpPNCsnLBF BJ0UyxCeLnE0JAXXAF6DpiBS5MxtsmCfKIk8irr7V6PHpAm1a2FusOQGMuxJtfS9jY3V 0Re7ENChqL11YeL1OaEMjoqxUYna3yjJUtN/+hD5NPyE+5Fe5kh/La5lR0pctKKuQiT/ 8JrndSbzzkKYaC7dQLFNAwiFMMjqZDqeYVPGu1DZECAkrYrIMZ9OGxdQydbbcwPBZhsB 7CDmEnlct1H8S84oQTT6UGrDpwUf5zLGoAtF85wjqInrsfYC3GPJTVkkyKzXx7hRZtbW MWOQ== X-Forwarded-Encrypted: i=1; AJvYcCWM/elkOLLYaqmcqleneqkgH2Qslw/WG/x5yPR7DlHE1y//4Of9XgptJJ1IDQh0/phg6kyzxwwaoZs1@vger.kernel.org X-Gm-Message-State: AOJu0YwE3q6K6LRW+qsC58XqdwwbJ+EvNW7Cc3ydOBUDCN2lCMluw9hi jEsEry02cSjDEcG37u7Ei0PjG5mz5YcLGrjTqQQEpF4U6rMd6uIg7wWx X-Gm-Gg: ASbGncsTi2Eo42bzg+GP2pUCIEOXVmrc5+iAwS2FlvyQZ72RYxK30y5lqCLH5CmKi7n dPcVDlw/WjEy20hBLm33MdONKFbAmON0MXQXaZqw2nJAbnU86skCUYMGNJ0A1/HrixjVtjtdLpU d0NggThUxVAVhaUADfX9IE3yrYPvNaSSYnBL/qWu1nvmogp6f/3MZwjUuV2ACUnyG/2B1v4JuTa k1FV62lUE7895PCsnllii37J0iTr7tP7/JtfjaajseHfbLgXk/86K8keiUoLN31m5B4OCtMdb8q 7zsDWefaKhzUlOr+8b6Ze+wMawiL5zgl4Zcs06LYRdQzMZSnY+6oeZ+v9nB/4Y/O9gaWfU3OWRi oC7T9/Y7Va3/8m2+g4+3MYi9kpdOrNj+FjswAH75/3iU2F5T5neAYLb2AwR3y2AnWeUnmVoS/CO 8aLg9Gq+xdquL8 X-Google-Smtp-Source: AGHT+IGQhBGrCzcmK6hv9moOx8ggT0aDNbcu/Pe0LQUZCBDVl4Fibpr1kyaVHD04dtyoEjoOsTg6CA== X-Received: by 2002:a05:6a20:b90f:b0:2dc:40f5:3c6c with SMTP id adf61e73a8af0-2dc40f57e34mr1601675637.54.1758681662762; Tue, 23 Sep 2025 19:41:02 -0700 (PDT) Received: from ?IPV6:2804:7f5:b08b:e4a8:158e:d41f:a482:c1c9? ([2804:7f5:b08b:e4a8:158e:d41f:a482:c1c9]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b55199e08f1sm12736678a12.24.2025.09.23.19.40.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Sep 2025 19:41:01 -0700 (PDT) Message-ID: <1b269e4f-5a2d-4de9-8757-cd4218d36bac@gmail.com> Date: Tue, 23 Sep 2025 23:40:55 -0300 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 2/3] iio: adc: max14001: New driver To: David Lechner , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Kim Seer Paller , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marcelo Schmitt , Marcelo Schmitt , Ceclan Dumitru , Jonathan Santos , Dragos Bogdan References: <2d5ef36b-ae37-453d-a19b-76fc97b7f14f@baylibre.com> <83018b80-b939-4e2f-a9ee-7fbf07648181@gmail.com> Content-Language: en-US From: Marilene Andrade Garcia In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 23/09/2025 11:27, David Lechner wrote: > On 9/22/25 7:56 PM, Marilene Andrade Garcia wrote: >> On 16/09/2025 15:04, David Lechner wrote: >>> On 9/15/25 5:16 PM, Marilene Andrade Garcia wrote: > > ... > > > In general, please trim out extra stuff like I've done here when you > reply. It makes it easier to find the important parts. I hope I didn't > miss any of your questions. > >>>> +    /* >>>> +     * The following buffers will be bit-reversed during device >>>> +     * communication, because the device transmits and receives data >>>> +     * LSB-first. >>>> +     * DMA (thus cache coherency maintenance) requires the transfer >>>> +     * buffers to live in their own cache lines. >>>> +     */ >>>> +    __be16 spi_tx_buffer __aligned(IIO_DMA_MINALIGN); >>>> +    __be16 spi_rx_buffer; >>> >>> These would no longer be strictly big-endian, so we could >>> just make them u16 with a note in the comments. >> >> Hello David, I have some doubts that I would like to clarify before sending v12. Since I am not able to test the case using SPI_LSB_FIRST, I noticed that you suggest saving the data as __le in this case. Just out of curiosity, if I use SPI_LSB_FIRST, would saving the data as __be lead to errors? > > My thinking is that since we are sending things out 1 byte at a time, in order > for the least significant bit of 16 bits to be sent first, the least significant > byte has to be sent first. So will little-endian, the byte containing the least > significant bit of the 16 bits will be first in memory. > > __be is just a naming convention and doesn't actually cause any bytes to > be swapped in memory. It just lets readers of the code know that the > value stored there has to be handled carefully because it may not be > cpu-endian. It would be confusing to readers to store a little-endian > value in a __be16 variable, but technically, no, it would not cause any > errors. > > This is why I suggested to make it u16. It is still wrong but it is > equally wrong in both cases. If you still want to use __be16 though, > you could make a union instead. > > union { > __be16 be; > __le16 le; > } spi_tx_buffer; > union { > __be16 be; > __le16 le; > } spi_rx_buffer; > >>> >>> The scoped_guard() looks a bit odd with the extra indent. I would write >>> it like this instead: >>> >>> >>> >>>     case IIO_CHAN_INFO_RAW: { >>>         guard(mutex)(&st->lock); >>> >>>         ret = regmap_read(st->regmap, MAX14001_REG_ADC, val); >>>         if (ret) >>>             return ret; >>> >>>         return IIO_VAL_INT; >>>     } >>> >> >> Ok, thank you. But since I removed the mutex, as it was mentioned in the first comments, I should not use the guard, right? At least not for now. >> > > Correct. The regmap_read() has something similar internally already. > Ok, Thank you for the answers. Best Regards, Marilene