Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2528300rdg; Mon, 14 Aug 2023 05:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFx4Mssq7rF7EN9qbKpvGUHRo42lbCD3xOPfQFENudPARU4b6nwn+gROIzegcC+ZAgFHWi X-Received: by 2002:a05:6a00:178b:b0:666:e621:d83e with SMTP id s11-20020a056a00178b00b00666e621d83emr14652709pfg.13.1692016757459; Mon, 14 Aug 2023 05:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692016757; cv=none; d=google.com; s=arc-20160816; b=pDs1fEWKgmScVXHsQHxCQ92iGaXUyHbcoFlou+iY6hzzG4oT2M0GnPt/k0caLElM5X WsgBLcefqQIGHbhQwgTMBmtAqGyp12by3VgbzD4qTXr16NTUSy9ZHVH3Ugzmm2ZOc4Vf izTEGXZW/myJyCTRorfUEIi6YnnOkLCjn1U3FFUHvcRO8PtVx7EpPnC8630w0VdYiHcF JrvVV6ppQlsVOveAUYkgOOMEYRovv7LjrNlIO/PUPCVHMz9eLsbHr9smXFLNoIkE4csm YZMU59LURNaRc0BCMWPU18sPVjsQoKl/r0hvxLqB1D4P+znchHHGigAfvbwBrXkXIpf4 XFzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=jfwP6oZUs8EGVLwkqju+PtJRX1CinD3ct3lzUDwZEgk=; fh=DP61/jJCya+1W1X7P2vK6pKSD4lkczCotBkmA6jh/us=; b=advS/UB8Vn2p/RtDrrPkfH/V7gmbo9ZJK6ocOUr5vVZVcYeHzUmPC1T1obcYp2CDvh 7G6Jbxctqf+vNxcqNsJxo8Xq+PA0ZV4TBSNXIRtO1hT3HB7gGOamOGyDVt+AV8reLvGy gkjHdjnQ7qXr0AyIPZW6fqRp2Z+jmG0wgxEz/Y8JhH+s+g5EwBNqXimkisnnIlh7FKxy tq5M9jrGHWWs97/UN/UYMMl21OOp9o9c9RPOyL8c9MIC7pnvedrlGMQYtEn6xtpfoudl tBAUzt1voQo7YRXGRHrch+o7iz4HJFnE9pZhQ1lRj6UA5djhhG0Q2TFK9M6CBqHPtOOd OpIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=SZSjrG9v; dkim=neutral (no key) header.i=@suse.de header.b=SxbC5mE+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw19-20020a056a00409300b006872e4035b1si7752183pfb.37.2023.08.14.05.39.04; Mon, 14 Aug 2023 05:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=SZSjrG9v; dkim=neutral (no key) header.i=@suse.de header.b=SxbC5mE+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233020AbjHNL5E (ORCPT + 99 others); Mon, 14 Aug 2023 07:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232418AbjHNL4a (ORCPT ); Mon, 14 Aug 2023 07:56:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50B610FB for ; Mon, 14 Aug 2023 04:56:12 -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-out1.suse.de (Postfix) with ESMTPS id 415F22199B; Mon, 14 Aug 2023 11:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692014146; 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=jfwP6oZUs8EGVLwkqju+PtJRX1CinD3ct3lzUDwZEgk=; b=SZSjrG9vuq9kIRCPQTxzwMV05MGcjPpYLVa9Ky4I69ukqgy3eFqGVFAlWGll/hBJQTIJQ+ cl75/uIZxsaizW7PUa6livgluXpeiTzGp3aSkd9+XwAEHCT9hAyNQ+sUTGX0i8qO4jBlq4 8JlJjUfT5xa8gRLpitKNThGBaYnoIoQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692014146; 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=jfwP6oZUs8EGVLwkqju+PtJRX1CinD3ct3lzUDwZEgk=; b=SxbC5mE+qcKRiJ2tf77kKljLrAyXh+pXGWxIuBs/iHZedKMt0JIsfkeGToRyka5tDib1m0 cJaFJFWmkfrKCiAA== 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 1BE9F138EE; Mon, 14 Aug 2023 11:55:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OODDBUIW2mRnMAAAMHmgww (envelope-from ); Mon, 14 Aug 2023 11:55:46 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Takashi Iwai Subject: [PATCH 05/25] ALSA: gus: Convert to generic PCM copy ops Date: Mon, 14 Aug 2023 13:55:03 +0200 Message-Id: <20230814115523.15279-6-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230814115523.15279-1-tiwai@suse.de> References: <20230814115523.15279-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch converts the GUS driver code to use the new unified PCM copy callback. It's a straightforward conversion from *_user() to *_iter() variants. Note that copy_from/to_iter() returns the copied bytes, hence the error condition is inverted from copy_from/to_user(). Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_pcm.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 388db5fb65bd..f67b53612d5f 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -369,7 +369,7 @@ static int playback_copy_ack(struct snd_pcm_substream *substream, static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, int voice, unsigned long pos, - void __user *src, unsigned long count) + struct iov_iter *src, unsigned long count) { struct snd_pcm_runtime *runtime = substream->runtime; struct gus_pcm_private *pcmp = runtime->private_data; @@ -379,27 +379,11 @@ static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, bpos = get_bpos(pcmp, voice, pos, len); if (bpos < 0) return pos; - if (copy_from_user(runtime->dma_area + bpos, src, len)) + if (!copy_from_iter(runtime->dma_area + bpos, len, src)) return -EFAULT; return playback_copy_ack(substream, bpos, len); } -static int snd_gf1_pcm_playback_copy_kernel(struct snd_pcm_substream *substream, - int voice, unsigned long pos, - void *src, unsigned long count) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct gus_pcm_private *pcmp = runtime->private_data; - unsigned int len = count; - int bpos; - - bpos = get_bpos(pcmp, voice, pos, len); - if (bpos < 0) - return pos; - memcpy(runtime->dma_area + bpos, src, len); - return playback_copy_ack(substream, bpos, len); -} - static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream, int voice, unsigned long pos, unsigned long count) @@ -830,8 +814,7 @@ static const struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .prepare = snd_gf1_pcm_playback_prepare, .trigger = snd_gf1_pcm_playback_trigger, .pointer = snd_gf1_pcm_playback_pointer, - .copy_user = snd_gf1_pcm_playback_copy, - .copy_kernel = snd_gf1_pcm_playback_copy_kernel, + .copy = snd_gf1_pcm_playback_copy, .fill_silence = snd_gf1_pcm_playback_silence, }; -- 2.35.3