From patchwork Mon Aug 14 11:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 135388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2715491vqi; Mon, 14 Aug 2023 05:37:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWRCIFDo5gvqN1BuTceYXMdxXW7Ysz3Uu/ck7TN1q3UFshQLqSZNJLUE0YFHeVPsUxXjcP X-Received: by 2002:a05:6a20:9146:b0:134:37bb:89be with SMTP id x6-20020a056a20914600b0013437bb89bemr8857447pzc.57.1692016665056; Mon, 14 Aug 2023 05:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692016665; cv=none; d=google.com; s=arc-20160816; b=NW2O92gAf18AwU6sx90SSjlImAj7mIRfct3Os7f43MmqPw2YaOrpb0qTtoKK+tK1xE ZS3HUh8IGE88fTu6dHHWn4/PVw1FMbP7rc5MArqAZ0VQff44FYJiO+j/gaHF295Eoczg 8YAg+iupwh5jSnKR9VgdWQCtZAxg7JZ2WCmAMyyIGNt0FHU0YHQLVIyIHwz7O3w21kHr Ji63L67ouseFWRiCxyRqCJfNZaa4StxY1ZL0irOJsdw9iWO6E9gqjdabyyCcqxlL2MVn NQtIqhIPY/BAYlTohxE2xjSvZMkK6zQqiHLdvqX9jo2/1yzYnlXMwF0pxyCe5gHkMeEC mtmg== 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=eEyKWEV49JtEdl1DYURZo9RW0RDOuBmS/jGSdWXcXwE=; fh=DP61/jJCya+1W1X7P2vK6pKSD4lkczCotBkmA6jh/us=; b=JXYLvp1gFLj+1tH+TAiHzdJaxTqgEbMoeq9oDkjKAzygblv3/A83BbfDuQljkRWlcD YZ03478e4kcxkCDxZFZMSrSspF3rLWitetol6sv4IVu9Zyxe/jSOzacfO+Hu92IbmX6d wrxJdv6ujlv9b5rjIZ5kiqip26jUHOryBMbNJXmLElrTT0+7XRprXwY5hwXz9xtXt7u0 rw1zlNbciJCv6KquA+0tp8S6z1/m4Xc2zJ8VA/SxbtaSTFNTp/fcvifgcBWdmUPMpcQt I3DZYgyzHDmycPCfsOHzL9jxyuDFv9VrreCFOBsiRKwOtRLMUkBn/uoySW5iP2QvWIUb /csA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EnsRFA1q; dkim=neutral (no key) header.i=@suse.de; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a63f116000000b00564a32a6a8esi8141894pgi.790.2023.08.14.05.37.30; Mon, 14 Aug 2023 05:37:45 -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=EnsRFA1q; dkim=neutral (no key) header.i=@suse.de; 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 S233375AbjHNL5I (ORCPT + 99 others); Mon, 14 Aug 2023 07:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbjHNL4e (ORCPT ); Mon, 14 Aug 2023 07:56:34 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E67171A for ; Mon, 14 Aug 2023 04:56:16 -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 24F731FD66; Mon, 14 Aug 2023 11:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692014150; 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=eEyKWEV49JtEdl1DYURZo9RW0RDOuBmS/jGSdWXcXwE=; b=EnsRFA1qKgyhKt0gFJjMzw6as2fKYaaHSZYZvJc/825TQ2XSnDcqKnIYJA8xm/2eTJ7OCc nypK8p6vy8TTqsLoT0Uq4Ezaz8igb28z/DgehbIXYeA5Z/kfgibz5dv+ip0QnpJilRUQwz c2ngtPJkRkh0/LTYhuO28eFeddC9Gbo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692014150; 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=eEyKWEV49JtEdl1DYURZo9RW0RDOuBmS/jGSdWXcXwE=; b=h8b1DK2e1i7M2w1Uu/TRpxJvQx7WcE8h/sHgEX6Rn9t2wgT+X74UF8i78WaVCoZ1/iKAci Yvr4pJOsmaSYutDg== 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 04609138EE; Mon, 14 Aug 2023 11:55:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SLmGO0UW2mRnMAAAMHmgww (envelope-from ); Mon, 14 Aug 2023 11:55:49 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Takashi Iwai Subject: [PATCH 12/25] ALSA: hdsp: Convert to generic PCM copy ops Date: Mon, 14 Aug 2023 13:55:10 +0200 Message-Id: <20230814115523.15279-13-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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774208066108036453 X-GMAIL-MSGID: 1774208066108036453 This patch converts the hdsp 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/pci/rme9652/hdsp.c | 42 ++++++---------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 65add92c88aa..960cc75608cb 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -3961,7 +3961,7 @@ static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp, static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int channel, unsigned long pos, - void __user *src, unsigned long count) + struct iov_iter *src, unsigned long count) { struct hdsp *hdsp = snd_pcm_substream_chip(substream); signed char *channel_buf; @@ -3972,28 +3972,14 @@ static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); if (snd_BUG_ON(!channel_buf)) return -EIO; - if (copy_from_user(channel_buf + pos, src, count)) + if (!copy_from_iter(channel_buf + pos, count, src)) return -EFAULT; return 0; } -static int snd_hdsp_playback_copy_kernel(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void *src, unsigned long count) -{ - struct hdsp *hdsp = snd_pcm_substream_chip(substream); - signed char *channel_buf; - - channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); - if (snd_BUG_ON(!channel_buf)) - return -EIO; - memcpy(channel_buf + pos, src, count); - return 0; -} - static int snd_hdsp_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 hdsp *hdsp = snd_pcm_substream_chip(substream); signed char *channel_buf; @@ -4004,25 +3990,11 @@ static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); if (snd_BUG_ON(!channel_buf)) return -EIO; - if (copy_to_user(dst, channel_buf + pos, count)) + if (!copy_to_iter(channel_buf + pos, count, dst)) return -EFAULT; return 0; } -static int snd_hdsp_capture_copy_kernel(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void *dst, unsigned long count) -{ - struct hdsp *hdsp = snd_pcm_substream_chip(substream); - signed char *channel_buf; - - channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); - if (snd_BUG_ON(!channel_buf)) - return -EIO; - memcpy(dst, channel_buf + pos, count); - return 0; -} - static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel, unsigned long pos, unsigned long count) @@ -4950,8 +4922,7 @@ static const struct snd_pcm_ops snd_hdsp_playback_ops = { .prepare = snd_hdsp_prepare, .trigger = snd_hdsp_trigger, .pointer = snd_hdsp_hw_pointer, - .copy_user = snd_hdsp_playback_copy, - .copy_kernel = snd_hdsp_playback_copy_kernel, + .copy = snd_hdsp_playback_copy, .fill_silence = snd_hdsp_hw_silence, }; @@ -4963,8 +4934,7 @@ static const struct snd_pcm_ops snd_hdsp_capture_ops = { .prepare = snd_hdsp_prepare, .trigger = snd_hdsp_trigger, .pointer = snd_hdsp_hw_pointer, - .copy_user = snd_hdsp_capture_copy, - .copy_kernel = snd_hdsp_capture_copy_kernel, + .copy = snd_hdsp_capture_copy, }; static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp)