From nobody Thu Dec 18 07:52:37 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80E6CC04FE2 for ; Tue, 15 Aug 2023 19:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239772AbjHOTDD (ORCPT ); Tue, 15 Aug 2023 15:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239788AbjHOTCk (ORCPT ); Tue, 15 Aug 2023 15:02:40 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AEB4269E for ; Tue, 15 Aug 2023 12:02:21 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3F76D1FD64; Tue, 15 Aug 2023 19:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692126108; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lu8lb3bHhmPhKXNMb+mmGurfLxLx/VLPR5QQUqntmKQ=; b=MlqT5XvafyDPjf1x2nD3fgibQP/p2/djqKkJU1L6NB1q2/io1nno0OGqoincwBfT2i4cc4 GwyeKBMNyqHIvYYToEBRnZrllPJQSB9NqM22lXpmAN9sADy5BEMUmDMY6tcTxXKiR9o11p V8tuRQZoHc/ibBSmph6KQY/YBmR/f+Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692126108; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lu8lb3bHhmPhKXNMb+mmGurfLxLx/VLPR5QQUqntmKQ=; b=E2Sv8+yqGwRUW6uVvh0pDjuyLR5O+AA39/DW8PFzxdWEhD2xCq2hbgQiB72hEMLQR/i4sF gcZ+bUJFwB1kTsDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 212E81390C; Tue, 15 Aug 2023 19:01:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2H44B5zL22QTVAAAMHmgww (envelope-from ); Tue, 15 Aug 2023 19:01:48 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Takashi Iwai Subject: [PATCH v2 07/25] ALSA: es1938: Convert to generic PCM copy ops Date: Tue, 15 Aug 2023 21:01:18 +0200 Message-Id: <20230815190136.8987-8-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230815190136.8987-1-tiwai@suse.de> References: <20230815190136.8987-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch converts the es1938 driver code to use the new unified PCM copy callback. It's a straightforward conversion from *_user() to *_iter() variants in most parts. Note that copy_from/to_iter() returns the copied bytes, hence the error condition is adjusted accordingly. Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index e34ec6f89e7e..ec598ba1a883 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -824,7 +824,7 @@ static snd_pcm_uframes_t snd_es1938_playback_pointer(st= ruct snd_pcm_substream *s =20 static int snd_es1938_capture_copy(struct snd_pcm_substream *substream, int channel, unsigned long pos, - void __user *dst, unsigned long count) + struct iov_iter *dst, unsigned long count) { struct snd_pcm_runtime *runtime =3D substream->runtime; struct es1938 *chip =3D snd_pcm_substream_chip(substream); @@ -832,36 +832,17 @@ static int snd_es1938_capture_copy(struct snd_pcm_sub= stream *substream, if (snd_BUG_ON(pos + count > chip->dma1_size)) return -EINVAL; if (pos + count < chip->dma1_size) { - if (copy_to_user(dst, runtime->dma_area + pos + 1, count)) + if (copy_to_iter(runtime->dma_area + pos + 1, count, dst) !=3D count) return -EFAULT; } else { - if (copy_to_user(dst, runtime->dma_area + pos + 1, count - 1)) + if (copy_to_iter(runtime->dma_area + pos + 1, count - 1, dst) !=3D count= - 1) return -EFAULT; - if (put_user(runtime->dma_area[0], - ((unsigned char __user *)dst) + count - 1)) + if (copy_to_iter(runtime->dma_area, 1, dst) !=3D 1) return -EFAULT; } return 0; } =20 -static int snd_es1938_capture_copy_kernel(struct snd_pcm_substream *substr= eam, - int channel, unsigned long pos, - void *dst, unsigned long count) -{ - struct snd_pcm_runtime *runtime =3D substream->runtime; - struct es1938 *chip =3D snd_pcm_substream_chip(substream); - - if (snd_BUG_ON(pos + count > chip->dma1_size)) - return -EINVAL; - if (pos + count < chip->dma1_size) { - memcpy(dst, runtime->dma_area + pos + 1, count); - } else { - memcpy(dst, runtime->dma_area + pos + 1, count - 1); - runtime->dma_area[0] =3D *((unsigned char *)dst + count - 1); - } - return 0; -} - /* ---------------------------------------------------------------------- * Audio1 Capture (ADC) * ----------------------------------------------------------------------*/ @@ -987,8 +968,7 @@ static const struct snd_pcm_ops snd_es1938_capture_ops = =3D { .prepare =3D snd_es1938_capture_prepare, .trigger =3D snd_es1938_capture_trigger, .pointer =3D snd_es1938_capture_pointer, - .copy_user =3D snd_es1938_capture_copy, - .copy_kernel =3D snd_es1938_capture_copy_kernel, + .copy =3D snd_es1938_capture_copy, }; =20 static int snd_es1938_new_pcm(struct es1938 *chip, int device) --=20 2.35.3