From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 83BB741C31C for ; Mon, 2 Mar 2026 16:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772469077; cv=none; b=iwqjdnIGFy80HJKEN9HoaQPNVePVlqSCEPp4OBE8hdKXjOmLwYdVymYog7vHZnb2TUNPWwIjN6MkXUgUS8b72N4e6XHz2ESRQd2oni+eYNYKp/oYWWzrADgoTV92JHY0DrMyCN1Rqu4nrK0IJdN1tTie1A7GSeK4wzNza661Wkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772469077; c=relaxed/simple; bh=qLsyFY2PisIQLMl+fOtmh+GE8NpLwMnRWMFJshDHLT8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PKTu2se/lDGFt4syWZMNgjopfe4gFuPUHQbZ4LqNyXjNP9LzMcIpmLfzDC6RYcrTXIfUPTMq8yBKdXKNjwVb8xrEl0O1MBU9GSKrTDBNiQZ2XQ+c5hP/cqUKPtrLDIoDMbZQz77TH8v06iMqr7cVgdC8z13K4u6Ke5PgSdkaCaw= 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=g80OEKGw; arc=none smtp.client-ip=209.85.161.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="g80OEKGw" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-676815e147dso2462555eaf.3 for ; Mon, 02 Mar 2026 08:31:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772469073; x=1773073873; 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=G0JygeW3HP09zEKnP/VD/fOu2e7U19JBgO1ed/d8lMc=; b=g80OEKGw7xlCSqpskdiHQHtCWfyRBVXY6qcBEgo6HI4gEe5nXhPiQM6TiZQR3Oh+AB l/Grdbx+hwEVu7HfO73Dk51X80w8oO/1opXocxI7gA/gyzeW918J65p+A1N2MC5eRheN et/hLl8LFrrhOGsT3tAHJnzvUo3nQU81OEin2NA/i5DfCml4qEaata4Ww6oGRpzNf+LM UGVAzPXv8z6dvMTiu6u+Jz1UoLC+/IWAZGOlFTBD5eATXp4uNJy+0t12YX/d+562FMAX V02QjWDZei+RkqeIGutb8pB1terUD7INJzCn0M9tc3AdStJmw4tex+2v7+/lb9GEB/UD JzfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772469073; x=1773073873; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G0JygeW3HP09zEKnP/VD/fOu2e7U19JBgO1ed/d8lMc=; b=SKwBeUbFdKzp+VJ/KlG2R1mGvkHUZTxeV3I7crvaj6tfV0KDtQWOGq60+zXNpgR9kl r6J00mVJYONQmSipaQyBJhlmIlBBVommeNLjoxUSAKS8+/n+y8lVQ2+mWl5iCSK5a1u/ /VBL5SYyTSMU2m1oYljF04fGL4zZk34o7wkrUpOmCwiLw25sHDUSwU+qmfj/kmUWJeTi tZWiDHfKeR/xHTi5D8NibtERxhl/gna7oLcVxjDeLvH1C4Py/KVdfIKbRNVpGO1Annbl QQUugk2PmHiagDyQRhjV/pCP6gOoI9Zaq1sGoQ4MqzkL/y5wHbqgOyYmooVL7NgLu8gf Vn/w== X-Forwarded-Encrypted: i=1; AJvYcCW2gZlKL+c2kAxlmoLQPQVwj/mZS0FzZuNWKx9k0Rs4gGAN1naokhZ1XEJLOBOn+wy13dpsW0HLXXc/OSk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9A3MAWZc8vULggWZi8FW8k+izV2XjAAk61JaGHmoIqM35ywWb eowrsUWaD/zfruyFlpXt1bMj16nfdRgAuGUosKQlOrX6+kIdrd5UoxftPUMvIvA0OWw= X-Gm-Gg: ATEYQzzWiHw9yDPRzzdQ3ajej8BAE6xy/z6umJpDLcxahWdrywT9PU7rGx/Eq/gmgRP KNBiA1C019P/xARtFa+Y8+XI/06AosfvGJqRC7EweIx6JjpkHefe0ELGW0rx1umcnx0D1S8UOqu VFjdhCwmKmuIKr5Ha1uIaYiXlVwwKjOb+t/Xpnr4gv/gygkpdjtAQHhghW34L2hg8XGTrQP+wnZ wU954Sct5iwB4LDJ9AwfhnvR8ARf1NKSjuVh6eXO+nJq7DvAxF0+G2a4QUCZQ5OzAyBuXFAYUTV vYdxqvz77I1dgebxOTr2LKEixVaDjGeajpROBPZB/+aUqev9hxJfH+yxb4f/PyJLaz447gUwozJ MUsKGHEkmx7H++0exvejk+xy3HRhoQA7YdtFl2cTlTnPF75T87Na9kv7SBCuNn2WlnOh+hAVlee uOgioXaHf+ZsEM7fUfYRGulbGxXbe6biFK73+JbVC/8odw25k0ThtYzuk729i7tEVnfm0eBIAsr QsmQYH7ws6S X-Received: by 2002:a05:6820:620:b0:679:efb4:a396 with SMTP id 006d021491bc7-679faef89eemr7688750eaf.35.1772469073280; Mon, 02 Mar 2026 08:31:13 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:4c09:7c6b:bc48:f2f7? ([2600:8803:e7e4:500:4c09:7c6b:bc48:f2f7]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-679f2da4390sm9443084eaf.14.2026.03.02.08.31.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Mar 2026 08:31:12 -0800 (PST) Message-ID: Date: Mon, 2 Mar 2026 10:31:12 -0600 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 v3 1/4] iio: adc: ad799x: make rx_buf static and DMA-safe To: Archit Anant , jic23@kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com Cc: nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260302130632.29144-1-architanant5@gmail.com> <20260302130632.29144-2-architanant5@gmail.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260302130632.29144-2-architanant5@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/2/26 7:06 AM, Archit Anant wrote: > Currently, rx_buf is dynamically allocated using kmalloc() every time > ad799x_update_scan_mode() is called. This can lead to memory leaks if > the scan mask is updated multiple times. > > Drop the dynamic allocation and replace it with a static, buffer at the > end of the state structure using IIO_DECLARE_DMA_BUFFER_WITH_TS(). > This eliminates the allocation overhead, prevents leaks, and removes > the need for manual kfree() on driver removal. > > Suggested-by: David Lechner > Signed-off-by: Archit Anant > --- ... > @@ -217,11 +218,11 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) > } > > b_sent = i2c_smbus_read_i2c_block_data(st->client, > - cmd, st->transfer_size, st->rx_buf); > + cmd, st->transfer_size, (u8 *)st->rx_buf); > if (b_sent < 0) > goto out; > > - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, > + iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf, Don't need & here since rx_buf is still an array. > iio_get_time_ns(indio_dev)); > out: > iio_trigger_notify_done(indio_dev->trig);