Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1453204lqh; Mon, 6 May 2024 08:09:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXM+YioL0q3X2SaRvmVTjrUnGCpwAEDcBk689hEHc5zlNkdIJ52wlt+sTLHFIZtbSKHn9Uld755R+GFgqmXN6bVWZYkdG4f83+dWuHauA== X-Google-Smtp-Source: AGHT+IGhjUnSBUVOxBCgn0AWmo2leF6+neKvXTxU2TH3PwdqBQhfis7lGUSJ3Co/n7ykNMgKZa75 X-Received: by 2002:a05:6808:c3:b0:3c9:6ef1:f0d7 with SMTP id t3-20020a05680800c300b003c96ef1f0d7mr2864029oic.20.1715008173675; Mon, 06 May 2024 08:09:33 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o125-20020a1f7383000000b004c8cb1f79eesi1639947vkc.316.2024.05.06.08.09.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=D7cr83Ck; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-170043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170043-linux.lists.archive=gmail.com@vger.kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 118F91C229F9 for ; Mon, 6 May 2024 15:09:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A2E5154C18; Mon, 6 May 2024 15:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="D7cr83Ck" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 A089815359F for ; Mon, 6 May 2024 15:09:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008166; cv=none; b=eM0IbLt9zm8MhGBrV9e0rj8w2eUpXhqn8HvQnJflVK3GCe7mTxQeZsz1IH15i5rq6185D5NmaeGiZyUbmtFsg0hmvCFeq71+LQUvj4MKISufJ+YwHZ1phadt+UDy/ZxUg8T6UjtAbpJB8awJmssfxf3LkGw8sVCQ5+Hw9Q/sczI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008166; c=relaxed/simple; bh=ChkvKKXLsQfoTAngZYFoQe3YF0MVY7h2bQeifwJOfXk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FluCF4zjl2O6rl3jvhuuwuTqsOPPdTw0OoCUEjypx604IEXS81SuzeCjSafAIbdMCXTM7qo/FA5HwEY7M8BF5uFCQRt3Ob5CB9G/80kNfGIMCTFXdQ6l2A3N9kgvymgpM5ZH8Fv2PHc4N8w4ICYcQw4WI9G9xsTdV3UXvY8tXQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=D7cr83Ck; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1ec92e355bfso19677165ad.3 for ; Mon, 06 May 2024 08:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715008164; x=1715612964; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eqhhV/e5mzK+6hrJY0o8mJ/dhifJ48pvMgC6Mb03m1s=; b=D7cr83CkvLjIWUYEJCkNYrBeNWOSZbxfu1cTC6X0JdHucDTa2sQbimKLYKe6WyEr+w RCWIaJB8/7yifgTAPioVa1+hZn5zdAwHARBTBP6S+3Ok5CZ9WH18RzUU7QNQR8a3iu0l hb0XJGSdyFGR3Q80JmQWX680NnG4iiZqA3T8ptOjaeFtDIq8WIJ424+rakNmWEZe4mpS t7w/ANcwVyxNEVEDxJP5W2Hu7dm8knNvVdchTC6ikP9vCPDDAblddaXLLFMmbjq4gsZd vGdzGvVHHr26EeUA8YVNZYTE+cTHTD2BXAVH+W6nu44cuyOoN43BOfCalXGb0jSA9Ixx g2CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715008164; x=1715612964; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eqhhV/e5mzK+6hrJY0o8mJ/dhifJ48pvMgC6Mb03m1s=; b=Js3YArz3PuqYiBeRhEK3TxOLa+FdoCnoED4ZhDlIhJXzJ390lFB5ZGpadwEhxFht8R Py2CkXfdRjc8qId7DQcL8BSLBKLqby926OsKTW0Bot8cOdxDtyPmB7B0GvXJStMCHq/C XCt0cR5lw6MziZP6XigA6OgMqq/Xw/6qDSKIeiGAqOYS0EKoIH6C6v7ABcSecgZDnywH ljijAPDjC/lEFizd9XRODUPhV87IQIycze2yy1I8tUdZrVsvDOLRuR8s34SCVzyInVgv QOSCCT0KQWTbzqGvfWlbuRo1rKAj/tvlew0LLx16bGZdMAFkiPp3VlFu4TDKibVfjVoo XQVQ== X-Forwarded-Encrypted: i=1; AJvYcCU0cO7Knb5ZOqjHWaCSRWFOtDkJ/sM7mAlnGzU79eIcChQ1ne7U2eGGo0KLjxKHk9dji1tRChVD6gkrLVEocdhRlX/b99KvkVfh3LiR X-Gm-Message-State: AOJu0YzFMUU8XHQtEOKCFo4C0/7IMoN+9lQE/2Ko4ZpensK/Qduuy74a yoCVZgBIb3Axt8tEts1ISDRgBdswNniqud3QtJ+ssMJ2Are+oJ04/Kabqroqs2P/nWkYQLFYhc4 kjOx7w+bKzPFD5ORuBAz7gt3ShxkoF0Ss8/YSHA== X-Received: by 2002:a17:902:6847:b0:1eb:51fb:de09 with SMTP id f7-20020a170902684700b001eb51fbde09mr9967887pln.14.1715008163823; Mon, 06 May 2024 08:09:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240501-adding-new-ad738x-driver-v6-0-3c0741154728@baylibre.com> <20240501-adding-new-ad738x-driver-v6-10-3c0741154728@baylibre.com> In-Reply-To: From: David Lechner Date: Mon, 6 May 2024 10:09:11 -0500 Message-ID: Subject: Re: [PATCH RFC v6 10/10] iio: adc: ad7380: add support for resolution boost To: =?UTF-8?B?TnVubyBTw6E=?= Cc: Julien Stephan , Lars-Peter Clausen , Michael Hennerich , =?UTF-8?B?TnVubyBTw6E=?= , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , kernel test robot , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 3:55=E2=80=AFAM Nuno S=C3=A1 = wrote: > > On Wed, 2024-05-01 at 16:55 +0200, Julien Stephan wrote: .. > > + /* > > + * If bits_per_word =3D=3D realbits (resolution boost enabled), w= e don't > > + * need to manipulate the raw data, otherwise we may need to fix = things > > + * up a bit to fit the scan_type specs > > + */ > > + if (bits_per_word < realbits) { > > + if (realbits > 16 && bits_per_word <=3D 16) { > > + /* > > + * Here realbits > 16 so storagebits is 32 and > > bits_per_word is <=3D 16 > > + * so we need to sign extend u16 to u32 using rev= erse > > order to > > + * avoid writing over union data > > + */ > > + for (i =3D st->chip_info->num_channels - 2; i >= =3D 0; i--) > > + st->scan_data.raw.u32[i] =3D sign_extend3= 2(st- > > >scan_data.raw.u16[i], > > + > > bits_per_word - 1); > > + } else if (bits_per_word < 16) { > > Can't we have bits_per_word =3D 16 in case realbits <=3D 16? > This case is handled by the outermost if, so can't have that here. (In that case, no manipulation is required so the whole big if statement is skipped). realbits will never be < bits_per_word.