From patchwork Mon Aug 5 00:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13752905 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 alsa0.perex.cz (unknown [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F933C3DA7F for ; Mon, 5 Aug 2024 00:42:22 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0C7B749DE; Mon, 5 Aug 2024 02:41:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0C7B749DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722818496; bh=IOPZXeXsgRX0h0cqxnL7z7k/O8y0MVDDzhFsYovbWaI=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FV93E3qpNpp31eaIyTUGtlq5rdhv4rO6RMLOoKv9Evmpf4XmPn8pY2r90cWHbqIJc zjqyXIuos66aO/9ycKSuh7uovYeBTuYJv3NUjXhwa0xJ9EY9nE5DNhcSG25mPCmUYC kFvaOVxJPVbRCEWQsKod33FlHv4SrgVBZ7Z0mEBk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DFA06F806A8; Mon, 5 Aug 2024 02:38:57 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A6A45F80720; Mon, 5 Aug 2024 02:38:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 508E3F802DB; Mon, 5 Aug 2024 02:35:14 +0200 (CEST) Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c406::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 457CDF800BF for ; Mon, 5 Aug 2024 02:35:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 457CDF800BF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=e23+TJCc ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hD2Bl8wJySkfsn/QE/1cenPyy009TL4jGLuke7ojO6HMRHgkFCJJ/tGeKYhipLv0NEoLno6s10SMVg4WBCI3f9pTtQ3J1IFpntjvBelQWmWfo4kJpkoWgjUmfYNHhL3MbSXRM/E3lVu8NdQFtnHlZKKdURGNrInu689YkadpAtLye9kmtD5JKPEiRYifCcRn04O93jFFZU3GUU1fkq+X0TO9P73tCaxZYF+9L0UV4J8Ym5eQ7vd8N4f8AxOEvB7Y+JpF7l8jprD3QcdfpP8FpLTYRFNp4UmRBH8cBMUoRvEePg5nar/kQNYx6ZycXvJcnU3j43jx0KWO8HVm9bOitw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m0gbCarOVeR5u5TuhQk5OH0N9gggorU44pKSD2LyuT4=; b=TxF9Di4Rl8thXF4BCIKNXRYCYHg/56VmfAA7+oKsXGKggCuFZcfEvvKwC9Pnka0fqGz8E4d137uzgVvyBacoUwtGausLJwX/cKsGozVLx9eOx2TAfNVHZHzpWghVHeA1QeZMgw5R6wh3uCwzdU6Fe2p69MkJa2SPAt23Xue+4C/sGi3bOX7W96z0jRFNIRKUuc3rnrYCRRxteNiyHASHhfbCknhKGYY/ydkwuRKMftMDQRpke/yIKyhA0IwBlFs3PlXPwB/0gIolHh5ABOGtg58cnukr/xVm5FXNgd7Iaq6lAflXPLHOByMYflfI4a8IbKvS2jMfYH6IInHcHyKAjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m0gbCarOVeR5u5TuhQk5OH0N9gggorU44pKSD2LyuT4=; b=e23+TJCcEU1nNfqUEKpjhfJPsHbCBT1TYKnn34HoH3OZoTH9goJcKrSOBpDa0ylWRbkgbmOsaPoU5j+PPEudc+W8llwsmEEs0XqLyuU9sOu1sn4Eh9enuMpGZxPl2QhVMApq7kTXsLUfK+BeUNIhuaQjZXLsKH96ha2Iy+IJslI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by OS3PR01MB7994.jpnprd01.prod.outlook.com (2603:1096:604:163::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Mon, 5 Aug 2024 00:35:06 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 00:35:06 +0000 Message-ID: <87r0b324ee.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 009/113] usb: gadget: use snd_pcm_is_playback/capture() User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-staging@lists.linux.dev, Linux-ALSA In-Reply-To: <874j7z3j1a.wl-kuninori.morimoto.gx@renesas.com> References: <874j7z3j1a.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 5 Aug 2024 00:35:06 +0000 X-ClientProxiedBy: TYAPR04CA0016.apcprd04.prod.outlook.com (2603:1096:404:15::28) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OS3PR01MB7994:EE_ X-MS-Office365-Filtering-Correlation-Id: 20d65098-8b78-482c-0c77-08dcb4e67432 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: t3NQ4zrAMWlSW47m9y+rDUM8OE6Lgb/a0iL80wYmnPO3yWeULGofCczHSRrqqKYrVdoDub2MNKq+zrAQqnAZpn2uH7maCu+0IjaSwpd28RT2o2e5u2YNb7wa9oHY8+GtMOCtktBjo2kdWLp/kWxIRVjRs39kpT1i2gOlzozGoxjbtm8EAodMKAnggZxecOKy8ldUbycWI8qvRffegBm9WzyaEj/e+EDZ/8+c34FGuMy3wnVc7Y17lTQhNal2Psfg6tS+aBA7j741i4sY+fsr/St5cZl37TzHr3Ot8OiPyYVyBqZKnu/yWXm9YaG+X3MLni8v8nOburRrG/uZnsSbKeImA/3gE/7VM4PUk4wRUboUBe2V31LdJx9PJ7/PHKPGKy3+D4mDB/wKAIVIZBJf1ubt/XtTFBoOLnULZd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YCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fpTkmae9ilUm80L1DFB88uWutoeOHV/EThl0gGB0TzydxiHLIfLsnoOyxg1dOoX6TPNJDlfeTN/p6wtbMVkDhLwtrLDOKDwb4uIBCo5NNpDwW710RJu6jcNDisJmNPlFj+UkNbNQPQxYYHoR7K4RD7fx57M8EH0cN5SQIfvsXpZa3fEmpzK5C4zIGFkGHdsXSKGQVevuUW/D5S8CPrHCP11JzlMeVoE0Ff2E0oBBwrS+k/JEMs1vxCDaqSqaqp3s73Jx/aUqPHXcgbfoOucT0uV+TYy5ysso6tp0O5XdvDcDR20KGE+ZAcrA6fWaEANxHR9TgN0v2HNzybWFr46mh+suqMh3P4lsibRShugEkZKncP+7C+C6h4NliLIVrLEezVcBGIOrSDEj86iPh9EuhJE2IS8Fy5paFbtVcHPtw9H9+e+Eu478cu5uOLNbzb9HgM4TFHOApCKZY8gQNfbxwJbKv6zJEeYUPdAeg2DEh6B1fHB70qnue7kNVYsrmFdQajpIPa5Rqy+UHMUQ4WWI9+qk0iWX8KrqXedsIsC3Yv8UcLEXNqHjmowcr6qXEHnK3QCLN9gPzSZhdvaRYBc4zNbvTWbS19kZW+cm0f1egm37NZusjtv/BvyNZu6NiZXFjHFeDz1sgKC86fuRp9DapJ4Q1T/nj85u4OsEXE5LaCVieB2IyuhMykI6ZXP02Ok1xxY9D53rhrHw2+h8JYYzXZ6+ird4myyrotzFEgXkJpbXx8VGn1FO4v+9jFDNirxYaIgqLL9UX8OlxzmqdFuPi1rwn1dXKyAnUDTc2TU7RqoZeE3UwEdeEv27+GgbAdIrn0QMo7ymj0PJbkJh9N1WbUN/F/hUgcJZaFrfwnior/enqcJKkqBCKJmsgtykpqRzxpvzwKCo6cfosoLpKYupr5fjYCMOILxx0nSCerOcrnDbYQolWNcqb3GjNKH/ys8l3WkWRHrEHFkUAC5sFHZSEfQMwAyStG9KZt1JYBmJaMIfAz7QyQg3laMlZusEFKRm/eNzUcljvxexc/wZPcN87CogTqisUH/j8K7g0w625GlLKzIFRfrLhHutYppV3y+5eiVHlEBXQjUjOKOs3YzRX0zj7A+mtAgPezUeNWabujgHGreS6EwFlzINhm54+dKu8ikp/e4sF94aeHfHRkUdPRS6sl4sQU+EiGMVVvqaHv5bw9xcsSf2YkZniR4OTDuepkssjVpwDx4i2mIuxCuaa4l4aS32ZxTQZydjLnBGu9Hh6GgzDmkewl1V76SCaiKzU7ElkCumkKf0TYPwLsqUvMipqszbgiicZGqq21pMJyjdzTuHjDCiRyJIhJ8eq22PFqjDrO4vbtSMSl1b64W2d9sixNT1ppc7nVxVnzm2zXg8bmQ3biYknsV5j4dnb7yVpvKCRrzoxVgQpkpLUI8kECUo5jm5njUuCVDrANBBthZKcaMKCyHdvMPt2h2F4hq0wGr57WNpGFRF9SSvo934LzCVzAFGtnM3W6DeZwGlJ9uDNcnljnABojdZo0UsP6Qfs6CsbSXi/OAFltYdQmRJmyVamEnmPcuZWSUs4wNXc6qQJ8790zmeTA6sEcpFR3r+BKL/L4COL0YKRYxc77EUCi0GtJeRdWjroXbe1H3fGFY= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20d65098-8b78-482c-0c77-08dcb4e67432 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 00:35:06.5435 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zK75Gnthdj02EOMWpEFzkaYDM7sqS2k4evPg9GSxdka/j0IEdjuAcCmRE2PTKUHLw3xBUk7L0r66XDxvwHRvSv/Oepd0DQp+TuLaHGeceMPkOBARFg4InxRX7O7T2s/L X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB7994 Message-ID-Hash: WBUSMPLZ74HLKNVUGR46S6EMLCMUJHXM X-Message-ID-Hash: WBUSMPLZ74HLKNVUGR46S6EMLCMUJHXM X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We can use snd_pcm_is_playback/capture(). Let's use it. Signed-off-by: Kuninori Morimoto --- drivers/usb/gadget/function/u_audio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index 40093fa1093d3..09fbae35aea25 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -190,7 +190,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) goto exit; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { /* * For each IN packet, take the quotient of the current data * rate and the endpoint's interval as the base packet size. @@ -244,7 +244,7 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) /* Pack USB load in ALSA ring buffer */ pending = runtime->dma_bytes - hw_ptr; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { if (unlikely(pending < req->actual)) { memcpy(req->buf, runtime->dma_area + hw_ptr, pending); memcpy(req->buf + pending, runtime->dma_area, @@ -322,7 +322,7 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) audio_dev = uac->audio_dev; params = &audio_dev->params; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) prm = &uac->p_prm; else prm = &uac->c_prm; @@ -344,7 +344,7 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) } /* Clear buffer after Play stops */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !prm->ss) + if (snd_pcm_is_playback(substream) && !prm->ss) memset(prm->rbuf, 0, prm->max_psize * params->req_number); return err; @@ -355,7 +355,7 @@ static snd_pcm_uframes_t uac_pcm_pointer(struct snd_pcm_substream *substream) struct snd_uac_chip *uac = snd_pcm_substream_chip(substream); struct uac_rtd_params *prm; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) prm = &uac->p_prm; else prm = &uac->c_prm; @@ -402,7 +402,7 @@ static int uac_pcm_open(struct snd_pcm_substream *substream) runtime->hw = uac_pcm_hardware; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { runtime->hw.formats = uac_ssize_to_fmt(p_ssize); runtime->hw.channels_min = num_channels(p_chmask); prm = &uac->p_prm; @@ -1299,7 +1299,7 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name, if (!pcm->streams[i].substream_count) continue; - if (i == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(i)) { prm = &uac->p_prm; fu = ¶ms->p_fu; direction = "Playback";