From patchwork Wed Dec 23 17:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36D78C433E0 for ; Wed, 23 Dec 2020 17:26:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E41122210 for ; Wed, 23 Dec 2020 17:26:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E41122210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E7E14174E; Wed, 23 Dec 2020 18:25:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E7E14174E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744394; bh=bVPjvGl2aJrmftvy6AH+naYZLiG73n7geMHZqE6bdgY=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=oq5prUb/vVxLxu+QNZ+ntPpxSgwG1Yzw/sA2onjlYRrdTPkaokYeQP3ovRxDVONHa nj29SdOOpb/QWVMM81L3o+bUNOG60OiIiRybe+s3cN/ajwC4wKyQJoGgZpIho6w6dY 5pJjzGtyhzBYjT/ErWzWr1LsSyqtILN3ZU9Cub2c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 17D6EF804D8; Wed, 23 Dec 2020 18:23:27 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 81199F801EB; Wed, 23 Dec 2020 18:23:18 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 CFF23F800BC for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CFF23F800BC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="hKVZbEjQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=fYo0RobiqrqzECasl7opFEvOEWIw54kbWjgJoxjA1dA=; b=hKVZbEjQ11amBy+NDRwkqG6EoC RDqHeKEnCpZW2hXLEPYzpSJ6fznz3MN/jMWrgzB02jGcXf0PRMbmvoVlW6nWbfK2rfUkZQCm6+N3a 8WZUvrITEpu/CzwPOIZz44mFJaCpF8ffWDBIdWdtM1wX6yG9wxm6KQSF53iS6/QoUWhUU5dvvsOBU qnih91ocCKrRuThtmQP0GjPWM6j9gRog2KYq0qOnLsoGSbxMQ7p/Yr8J1lGCg/BLD2cqvWzUE07J2 Cy7KdIPC9ZXFndIQcW2unfxtTLl7fip9LwfZipPskQahG/cHnqNMqXH9ygO2m8/fOJ+9zrXBha+GG p8urzEpg==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000EtM-5Z; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-2O; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 01/18] ALSA: core: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:12 +0100 Message-Id: <20201223172229.781-1-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/core/control.c | 4 ++-- sound/core/seq/seq_memory.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 3b44378b9dec..1571c7f7c43b 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -836,7 +836,7 @@ static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, { size_t offset = value_sizes[info->type] * info->count; - offset = (offset + sizeof(u32) - 1) / sizeof(u32); + offset = DIV_ROUND_UP(offset, sizeof(u32)); memset32((u32 *)control->value.bytes.data + offset, pattern, sizeof(control->value) / sizeof(u32) - offset); } @@ -928,7 +928,7 @@ static int sanity_check_elem_value(struct snd_card *card, /* check whether the remaining area kept untouched */ offset = value_sizes[info->type] * info->count; - offset = (offset + sizeof(u32) - 1) / sizeof(u32); + offset = DIV_ROUND_UP(offset, sizeof(u32)); p = (u32 *)control->value.bytes.data + offset; for (; offset < sizeof(control->value) / sizeof(u32); offset++, p++) { if (*p != pattern) { diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index 65db1a7c77b7..e245bb6ba533 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -290,7 +290,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, extlen = 0; if (snd_seq_ev_is_variable(event)) { extlen = event->data.ext.len & ~SNDRV_SEQ_EXT_MASK; - ncells = (extlen + sizeof(struct snd_seq_event) - 1) / sizeof(struct snd_seq_event); + ncells = DIV_ROUND_UP(extlen, sizeof(struct snd_seq_event)); } if (ncells >= pool->total_elements) return -ENOMEM; From patchwork Wed Dec 23 17:22:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F065C433E6 for ; Wed, 23 Dec 2020 17:25:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65BD422210 for ; Wed, 23 Dec 2020 17:25:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65BD422210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 82B141791; Wed, 23 Dec 2020 18:24:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 82B141791 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744349; bh=SDRhyBj6A/CnkWB+wgoMBIX95pD084nhrniGB0mWfxg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d/+qDKIics0f9Aknzzx/xpF8SRQmF0NVeeQaQT2N8PbxShTjITgtktrtgkbr7OoCx e+Cal5VR+8Rs/pteXhlBtNg3RAarcQQcKylWwsGkaonnqqh1fxfTtHSKptTRiWbM6J MaYMqcnj66HaDIXBY+thURJI8DOxuR6+WFz8nV1w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 07C8AF8028D; Wed, 23 Dec 2020 18:23:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 274ECF80212; Wed, 23 Dec 2020 18:23:18 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 DA3A5F801D5 for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DA3A5F801D5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="Ec7Ihd7X" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=WDDcrSCXs8gV93fKAibxvnLmcru5DbXMuQOl7b/bdsw=; b=Ec7Ihd7XIgSDemEDIAHUBzsgcI xfNrGvmjc7ccvlRWrLnXogHDs5qYLtEQNd4RcjcJFewb498TZx1ozrWVDAMNgqWotX5OarR4665R6 NGJSeByHF3HnZ6EZm1nPa3KcdGiEW5if43DbEDydADO6RKy+XWSn+qTPXdEilYtlZZQjppIBb8Q+Y DIVMJtEJolvjdy/164aoRF5/71YgzoB0d3UuGnmoTo2syRlS6Rb41xaxENhRbTe3/k5tv1vM+nChQ 0lYLwqLIcjHJv4bPMkl9SQsQhZEA28EIoUcME8mfnvsMwEVjfZpfkvN892yuSweXCzeQSV/Ag2u0m 30uZ4Vdw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000EtP-7V; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-4E; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 02/18] ALSA: aloop: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:13 +0100 Message-Id: <20201223172229.781-2-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/drivers/aloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 702f91b9c60f..8a24e5ae7cef 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -219,7 +219,7 @@ static int loopback_jiffies_timer_start(struct loopback_pcm *dpcm) dpcm->period_update_pending = 1; } tick = dpcm->period_size_frac - dpcm->irq_pos; - tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps; + tick = DIV_ROUND_UP(tick, dpcm->pcm_bps); mod_timer(&dpcm->timer, jiffies + tick); return 0; From patchwork Wed Dec 23 17:22:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8E15C433E0 for ; Wed, 23 Dec 2020 17:26:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E04D822210 for ; Wed, 23 Dec 2020 17:26:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E04D822210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6833B17A8; Wed, 23 Dec 2020 18:25:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6833B17A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744402; bh=Vhjs0BvHaeiMJ8cHqeFFcEwKc16hzL4UGSwb0mqcJVQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aKkNVtWWmpH9ag8fRhJ+lg45d5FIRAEl0W1/GPjAdBbhJdufEp5pKBJUkCFI8px3o Cotg9XwiX1hBDz3CXpudu1a40cDonWJG1+q6cN+eKA2G77aWAZ1gh7wJNhlm6MJnoD UaXJWd5hDOV1QpHsfD3ALTE6WdZVxzWxFOuIbMT4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0777BF804E4; Wed, 23 Dec 2020 18:23:28 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CF69F801D5; Wed, 23 Dec 2020 18:23:18 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 D2332F8013F for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D2332F8013F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="BT4hnd98" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=jKMQyt2TgS3ZrFekhZ+P4K2J8NlwhJmJMmgFfZxB0tg=; b=BT4hnd98L3Pdpk7290psveec2a 3GIELhLdWdI7Sx0VqJ0A0H9vJgVb85JKw321ExtV6hvjPtOVSQxsG2DnPH5lqeEuowelmABK9hBI+ 4fyRi3EW4cOl81aVtpit2rJarfQv3aurOZrf+DBGmlpR1Ljgfaw2mW8eXksES0+4YR+sWvAs3lnLW wI4mzGG0xM7uQvQ9yWcB2dbDSOssKKiYAkImt0sivLQeLHD7MNtQ70H73qa0RaolMZq9Bw3Gbpuls uOOPpWH4mgiLL+DZ7wxOVwFjPE+t8WlKSxPrtebufFq/1faQK761yhgQ6vNmhHmJ5dEOpRsZZhJX6 tESDWTWQ==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000EtR-8r; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-60; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 03/18] ALSA: asihpi: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:14 +0100 Message-Id: <20201223172229.781-3-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/pci/asihpi/hpidebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c index f37856ab05f8..9570d9a44fe8 100644 --- a/sound/pci/asihpi/hpidebug.c +++ b/sound/pci/asihpi/hpidebug.c @@ -52,7 +52,7 @@ void hpi_debug_data(u16 *pdata, u32 len) int lines; int cols = 8; - lines = (len + cols - 1) / cols; + lines = DIV_ROUND_UP(len, cols); if (lines > 8) lines = 8; From patchwork Wed Dec 23 17:22:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EBAAC433E0 for ; Wed, 23 Dec 2020 17:25:01 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 737C82220B for ; Wed, 23 Dec 2020 17:25:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 737C82220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5AC971751; Wed, 23 Dec 2020 18:24:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5AC971751 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744296; bh=xeLoH1OD/V0cqdfJ566+2xnYuHJIftlJS0nJE+BjllI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XItOxOD5oODsy655cr2lfgvwc/ONOWFo04NR1aL6jxAmawgLtW81q7fXGs0XFVYWn sqyfNrt1kpeKD4ObrQSIvgd5zUYbgymhdTPXrqx7A2H7I5aCJuZ0fGpNsI6tiSAWFc pGtT3Teu/wFZVq7E2g/yP8A2HqFYXVokP5P4spIA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 24026F800BC; Wed, 23 Dec 2020 18:23:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74A84F804C3; Wed, 23 Dec 2020 18:23:14 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 D78C9F801EB for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D78C9F801EB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="OgZhxd6V" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=P58eCGvh3i4hWZxrddca8XJyC+8GhFjJTL+zu8A1d08=; b=OgZhxd6V9Xoz3jvKeSuluHORuR 1dSlKZHTEFCKV9d/yDFs6Xz4xCERnGNeN+pAOuL4lAl3YrS75KLzCdFjuxnDmxc2gaMOKjnhPGFie VN6Y1URJWgqFiA6Df7Te2X/t3eoFMmcOstfkWi1EMdMvXWeyUfMw5ow9NVFK3+vaJbRDie83t5d5o z38Yk3FAiaBN1dHTJWKhPSv4GfZEERDkdw/GSzQmF+GaniknjrcsNLKFDGkJPC0aTgstPGJNsMquQ Bpyi+aADTjWvdlvK9Ojm1hiIApt0dRrHSzojae3gM/k9jUyOJOZ1tge+a9XgjKx70GKnDSpWPT6SA qk81b4mA==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000Etf-Ar; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-7f; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 04/18] ALSA: bt87x: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:15 +0100 Message-Id: <20201223172229.781-4-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @r1@ expression x; constant C1; constant C2; @@ (x + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) != int(C2) - 1: cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_UP(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/bt87x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 54cb223caa2f..cf9f8d80a0b6 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -327,7 +327,8 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id) current_block = chip->current_line * 16 / chip->lines; irq_block = status >> INT_RISCS_SHIFT; if (current_block != irq_block) - chip->current_line = (irq_block * chip->lines + 15) / 16; + chip->current_line = DIV_ROUND_UP(irq_block * chip->lines, + 16); snd_pcm_period_elapsed(chip->substream); } From patchwork Wed Dec 23 17:22:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67065C433E0 for ; Wed, 23 Dec 2020 17:27:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D88A122210 for ; Wed, 23 Dec 2020 17:27:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D88A122210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6C1A1179E; Wed, 23 Dec 2020 18:26:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6C1A1179E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744462; bh=NM79AciwL6zatIkSpMptnb79Lu4CEWkoVKhJOThlMD0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DkFTXtsHQ0EFia+QyxpYFVTOmDVN8FxKsZmDq/DOg9RPtM1OygmbCGUa0LFHQKMI8 adGxLza+7RsnYnTpPRyepw2rS6DcxxCc2vobTSFkEFSakrTrynj+0eGS9v38nUzX3o de3YeeuiSCjWdR6LneZtlwhTbbmgEaARksl/IaGI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BC617F804FC; Wed, 23 Dec 2020 18:23:37 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B82FF80212; Wed, 23 Dec 2020 18:23:21 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 E3F27F8028D for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E3F27F8028D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="av13vv1F" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=MVEmoHgDV9RzuYnXd+S9/N8ElGep3dHuK5jXmFKJVKU=; b=av13vv1F1pfLXeYGxJzXHWHW/W jO6OY+SBuaP1irWtGyRm27eL+0cXuWXMTusmZndOaV98creocTGe75Q+5Fy1oCxm90hs73Bg46iLU 3r0CYh0fBxRwTCd+FiWCmc04hWGZn4rFQB4t05i74TRePyWfItvgRxVp1g6FVDutXmPxfK8VAHE9l AUgw57C5G8izQKIuW2eKAqCDMYDKkLDfEqo8CwsjX6+7LzNHnnL+Fi5DYkfvceLfR0RMObGMVWk51 XRLCiCrgsUEBxjdhRYtK6gq6jVCxOSQCus+1xk8DAI/j5FcCnc5bg+KN6ZHhPs6JJMpns9943VIj2 bPXxbUvQ==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000Etk-CN; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-9L; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 05/18] ALSA: cx46xx: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:16 +0100 Message-Id: <20201223172229.781-5-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/pci/cs46xx/cs46xx_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 4490dd7469d9..37f516e6a5c2 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -813,7 +813,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned correctionPerGOF = tmp1 / GOF_PER_SEC; tmp1 -= correctionPerGOF * GOF_PER_SEC; correctionPerSec = tmp1; - initialDelay = ((48000 * 24) + rate - 1) / rate; + initialDelay = DIV_ROUND_UP(48000 * 24, rate); /* * Fill in the VariDecimate control block. From patchwork Wed Dec 23 17:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B35FC433E0 for ; Wed, 23 Dec 2020 17:25:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCF2F2220B for ; Wed, 23 Dec 2020 17:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCF2F2220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 776C11799; Wed, 23 Dec 2020 18:25:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 776C11799 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744352; bh=HQ7s6czbSVAqDUr1+bgLa76hgWy3ygMXsEykOJG74Yw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kCChI8GTXKpbsmZ8jK8+UeFz5qFols2kyYqkLtdS9djOlrJZtUtPWIK7D5CWgOnXv g2mih20EW/SieoaEX6H2MpOoe5ZPuIZNXRLFcyEGzph0bqZ3xTzY4lKU4gaj4g8T2D fQjRT4/t5EWvLqrNgeXhoVeRXx4/T4iYNSDZtaHM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3BCA4F804C3; Wed, 23 Dec 2020 18:23:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B34CF801EC; Wed, 23 Dec 2020 18:23:18 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 D4C44F80116 for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D4C44F80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="ldGT0uz9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=VwV5uXdbaPwih+9/NmMxmPLJ1bEssLAvfl+swTX2RsM=; b=ldGT0uz9KZEvk695F+8UZLibBt WLAopmW6zCi2oA1touf14JF18/IPEnuH372RE+yZqbie6TGO1VE/TlVnr5oT/Z+cnopvZV2LjEaJA rk5T1OOQA1PFMgAwJT8m6QMvm5KoEWu/joC08lqOm4rJkhp1QFlC27qnEkDDirDbdCXdwVuP+dkNz v0IJEMwm1NQEWfu/LJTs1YtzojNKE3VU/vQc5JwCz6bdhSRTWThm7r3zWmjOJhvlgSCcjnf28QeSF tWH5rSt/wiTnALN+exLfvdRiOc3MLQJU8t6LnJIiV5l+5F7e2OiXMfOc6Ah14QI23zViQmgI0s05i QRIcULEA==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000Eu2-EW; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-B3; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 06/18] ALSA: ctxfi: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:17 +0100 Message-Id: <20201223172229.781-6-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/pci/ctxfi/ctresource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c index 61e51e35ba16..6d0a01b189e1 100644 --- a/sound/pci/ctxfi/ctresource.c +++ b/sound/pci/ctxfi/ctresource.c @@ -209,7 +209,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, mgr->type = NUM_RSCTYP; - mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); + mgr->rscs = kzalloc(DIV_ROUND_UP(amount, 8), GFP_KERNEL); if (!mgr->rscs) return -ENOMEM; From patchwork Wed Dec 23 17:22:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B803AC433E0 for ; Wed, 23 Dec 2020 17:24:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 096B72220B for ; Wed, 23 Dec 2020 17:24:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 096B72220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 78CF116CE; Wed, 23 Dec 2020 18:23:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78CF116CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744243; bh=h1DjeuziAPWAhXzrZWjO1w2pXJeCBxFyfJelL/xgEOU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YJGwD4aIjs1++rTIdi1pgOKkIY0tXIoGgenZo94CNVrN1KIZCeyh/0yTjkg06NkOG UR4TfO7dIL7He00JqmuKMlpwPd33rZCgJ7CxylQGpysDiw0I7LEZUepxBzvH8C0u3m rL9tQXMC84g3R7EnWEHGunXJG/P3STSCAuBMxgGI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C81AAF804BD; Wed, 23 Dec 2020 18:23:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3069AF804C1; Wed, 23 Dec 2020 18:23:11 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 DD2F8F80212 for ; Wed, 23 Dec 2020 18:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DD2F8F80212 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="dihiTNNZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=pX1LgKhVCtV+QZok7N1fQH9W07X3ZG11IQtJVsDun5Q=; b=dihiTNNZhJ71/ZUhUTQ6OF9POX KWir5k3P9HzaqXxjG+3/gWz7nqyV0vGcBHxgKSD+W8Qav4Q5KJkeuPcnn6TZt9ZUwxpXwFTyck7Qb kO786mfXZLPe+QtciD6+fe1zHZJiKupwI3OwX3+Z4QDhWzZPkvjWHjGapWX+j0F05m1XSgAb96rZM B1YDa7EP6rf9Z8rP4/lRcqTQ7UZWaEPSuhu1LGgepaRCxljsuaa6YiR3FlEEizkKC5SpbJKRywzCI t9cCUoKRYOhmg+V+lYh5b84ppCAG9wAdfKy7Qq41kUBxnaOrwtDk19ocmBB37Vrz4SayAAPGjsoH/ 1o+3FsaQ==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qo-000Eu7-G8; Wed, 23 Dec 2020 18:23:02 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-Cl; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 07/18] ALSA: dummy: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:18 +0100 Message-Id: <20201223172229.781-7-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/drivers/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index b5486de08b97..316c9afadefe 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -236,7 +236,7 @@ struct dummy_systimer_pcm { static void dummy_systimer_rearm(struct dummy_systimer_pcm *dpcm) { mod_timer(&dpcm->timer, jiffies + - (dpcm->frac_period_rest + dpcm->rate - 1) / dpcm->rate); + DIV_ROUND_UP(dpcm->frac_period_rest, dpcm->rate)); } static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm) From patchwork Wed Dec 23 17:22:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC117C433E0 for ; Wed, 23 Dec 2020 17:27:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3B0E2220B for ; Wed, 23 Dec 2020 17:27:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3B0E2220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8CDCD1758; Wed, 23 Dec 2020 18:26:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8CDCD1758 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744439; bh=MXsG7Q3BwM7UmoE6V780l3f6ryR7cmLdrOiB5/Es1aE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aWWq4JWYBCmpOeaUGXJ3d7k4igVBZtT0Xx0ZUt3SjB+ekvz2q4O6PdPKnsyWvVg1L p+r0GmgIkaFsKHqLPMKgtjXcyx5eTsZN13NVWoSGnC4a6IWybbOfdZNW+o/EJTCIQ3 IKSSy88o7TQqOMNryX2xPWN8p3UYAKeyMbL9K+/Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9AE33F804EB; Wed, 23 Dec 2020 18:23:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C43D4F804C3; Wed, 23 Dec 2020 18:23:19 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 BE6AFF8027D for ; Wed, 23 Dec 2020 18:23:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BE6AFF8027D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="VcMtc3v8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=Qih6Acpb9w4ikOh/x6soFx60kNwlnscMxJPMPsz4ZGw=; b=VcMtc3v8ba5+VnJPNEQAskuScm 5doHcB4fmPGgll68LNWI3au8oPY0oaOybJDWQLn5AX25kAXbzjTsDst9qKa0GdGYS0MCPh+oweHZh bsmvu31LNiZBg6sW8/OtG8OeDjxtwdVE/FowCLPlQeAOz2SWJFcrLs/88e+PhHwbl9qQ5s/ulplsl Fq2juUis0kIuUbZMV2og1H8WiJlVLfYPBZz5LAITE4IV+hxDsOoQnlz8A7k2CyK3I9A2qgvZyhTnz 8GUrLlY6wqloia+yFj21e+TGpWZ6b1J7VIGSCVuAio6GE0W3I+QAD5qDiaJPvNVopQdSwzubcZJdw cZCFtqGw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qt-000EuA-Ix; Wed, 23 Dec 2020 18:23:07 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-ER; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 08/18] ALSA: emu10k1: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:19 +0100 Message-Id: <20201223172229.781-8-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/pci/emu10k1/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 94b8d5b08225..288e0fd2e47d 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -375,7 +375,7 @@ int snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size, struct snd_dma_buffer *dmab) { if (emu->iommu_workaround) { - size_t npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; + size_t npages = DIV_ROUND_UP(size, PAGE_SIZE); size_t size_real = npages * PAGE_SIZE; /* From patchwork Wed Dec 23 17:22:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75F03C433DB for ; Wed, 23 Dec 2020 17:25:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C07E2220B for ; Wed, 23 Dec 2020 17:25:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C07E2220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5B4A61779; Wed, 23 Dec 2020 18:24:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5B4A61779 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744301; bh=Kwe3NSnx3ATxR/gkMIQyth8n1zRipBg78/jeVl78FRE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PeOkQ6UnZzkrvF3gOuQw3CGyxnoQPPoNJ7I21RaV8uZMLMUKUEOL5ERVyLXvF9wjo WgxTUc2IzVTsbN56NxHxndDfkUAZPLflKchpGdJkse1s0pZ4+v35DJL2gSZOEzCsV1 dROdvQqB1xod6lj1UazDPpatJH3bmDS/ow2/dHwg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BB3ECF801EB; Wed, 23 Dec 2020 18:23:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C7E1F801EB; Wed, 23 Dec 2020 18:23:16 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 BD862F801EC for ; Wed, 23 Dec 2020 18:23:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BD862F801EC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="gBQ3VvHb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=xSaVLDQrpYlBbROf7yYNwGUWbk/mzpp9ArlhnhNCSJ8=; b=gBQ3VvHb7RH7OBBf7er/5hM1Zv NR6ERBNzxKxsjxMgWqTPGQHdWLLLYzTYsW6R5nmZCd2nstRPrthfUrxj7VYVDCO7CHzdkVTnYHF/6 Ce2esJXA4C/6bL07/j45Cv220fMSoN7C9i2wxpydVGRtDVMl3qBdzFNY/u3cK2dK6TJ4NvAp8iY5g tGlTKUOI8Sz4bctUH20CzNc3atqwZu7NPhURT4Rkw7QJ1AYex0MLHmDEIprSJwOo0GDjDlaP/H8ko jhJ06+HcLcj13np7adMuypjI/OJm/sCNasfeLjY+CXEHvIUS3lVPKHqmdFV4Yw25nriczef6sF/dx YKyyHlVA==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qt-000Eum-Je; Wed, 23 Dec 2020 18:23:07 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-G5; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 09/18] ALSA: hda: Use DIV_ROUND_UP()/roundup() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:20 +0100 Message-Id: <20201223172229.781-9-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() and roundup() instead of open-coding them. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -((((x) + (y) - 1) / (y)) * y) +roundup(x, y) @r1@ expression x; constant C1; constant C2; @@ (x + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ print C1, C2 try: if int(C1) != int(C2) - 1: cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_UP(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/hda/hdac_stream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c index abe7a1b16fe1..a6ed3dc35f7e 100644 --- a/sound/hda/hdac_stream.c +++ b/sound/hda/hdac_stream.c @@ -435,12 +435,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) pos_adj = bus->bdl_pos_adj; if (!azx_dev->no_period_wakeup && pos_adj > 0) { pos_align = pos_adj; - pos_adj = (pos_adj * runtime->rate + 47999) / 48000; + pos_adj = DIV_ROUND_UP(pos_adj * runtime->rate, 48000); if (!pos_adj) pos_adj = pos_align; else - pos_adj = ((pos_adj + pos_align - 1) / pos_align) * - pos_align; + pos_adj = roundup(pos_adj, pos_align); pos_adj = frames_to_bytes(runtime, pos_adj); if (pos_adj >= period_bytes) { dev_warn(bus->dev, "Too big adjustment %d\n", From patchwork Wed Dec 23 17:22:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A918C433E0 for ; Wed, 23 Dec 2020 17:27:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 058272220B for ; Wed, 23 Dec 2020 17:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 058272220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8DA4D175B; Wed, 23 Dec 2020 18:26:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8DA4D175B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608744449; bh=azDgIRXuMzM20wQxMLD89QtpIjKA4ZlUA/AE21j3u8k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pkzW/JrP3PCHb6tXOGArU6BW2IPf2WESMLg3zv4th2kt/vW2Pzqlt0GSxmyMNlxAJ QlKJfHKNDtKQ2vtYB0UL/xOmTmnS6W8Dbg1ymuWFMGJR/rcBLsRdw9J5RlWdWzyXJA KyUk/mUbRsitqxhurFJzwpWRaSz36lq7QCBebBuo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BB40BF804F2; Wed, 23 Dec 2020 18:23:36 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 715BFF801EC; Wed, 23 Dec 2020 18:23:21 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 CD04CF8021C for ; Wed, 23 Dec 2020 18:23:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CD04CF8021C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="as+fadmV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=KBuBNMEHzysXWx241zOq5QF/81jau2QOPh7AB7vvToU=; b=as+fadmVswFvdkuXW+MTRk/dGa vZutXfPbXCvQL3YLPIU3doK8wJPOREJpwAp2Vi/pxiwTxypA4+G459dOTftl2S8x22B1OohNgWv1p wwU8M8c3rki7fw6/l0IyuzZ/R2yeY+DJofJFbzuby4vjAl38OMyB0WB9PrSOenVCScrcGRi8vcNge Qe2x0u+t6mnd1/mgnhC3I+DXG1WcSRwSs1VSkX/GyIp9oxqeqZs1bb3bgn1zH8sfxGObG3McDQUoo ye/g2WqQf/56tbMbfF2TwxcaHhkSRsoUvuvegTx33BoE/0Wb/nd9lOEDUUqDNmtikDXsCszbuiofe iDRPEtkQ==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks7qt-000Euq-LL; Wed, 23 Dec 2020 18:23:07 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-Hi; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 10/18] ALSA: lola: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:21 +0100 Message-Id: <20201223172229.781-10-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @r1@ expression x; constant C1; constant C2; @@ (x + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) != int(C2) - 1: cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_UP(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/lola/lola_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/lola/lola_clock.c b/sound/pci/lola/lola_clock.c index fdb85f256ed5..cafd30e30913 100644 --- a/sound/pci/lola/lola_clock.c +++ b/sound/pci/lola/lola_clock.c @@ -135,7 +135,7 @@ int lola_init_clock_widget(struct lola *chip, int nid) } nitems = chip->clock.items; - nb_verbs = (nitems + 3) / 4; + nb_verbs = DIV_ROUND_UP(nitems, 4); idx = 0; idx_list = 0; for (i = 0; i < nb_verbs; i++) { From patchwork Wed Dec 23 17:22:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13823C433E0 for ; Wed, 23 Dec 2020 17:48:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 326A0207CD for ; Wed, 23 Dec 2020 17:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 326A0207CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A487917E0; Wed, 23 Dec 2020 18:47:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A487917E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745727; bh=Cc2KblsMMsff70upoJ+KBtGICOZZreHb0cXrnvp+UZI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Hglo+X8ZWzd5Hjg8Z+LkycMS7mY9XlLEOl9/hwUuz1dreVtRBPk66BnsRTA8my9Jo sG74vzTMUHSeApu8Z1rX5zNZaFA8BDOW9wWbFlAxXh/ig22kT9sYC9k4PqST4H3fKR lYaIiX18FISPpLBypupr4ATaVJhmzKeXR6Ib4qo4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E0377F804F3; Wed, 23 Dec 2020 18:44:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F72EF804D6; Wed, 23 Dec 2020 18:44:46 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 8EA0DF8021C for ; Wed, 23 Dec 2020 18:44:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8EA0DF8021C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="Oen8ZSg5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=ptErSt0dW5D12UWzQOQGAF3uLKabVk2M4jFCGw0i54c=; b=Oen8ZSg5gWzF0WUD9rTBNXdm4t CR2H4E2rpbCQSqcgaGU2EEzh0EfGPjeBjzO4eTx86Y0szf7NagcZvBtke/GI3byJIpCmsCMggfSvE 7x7e2IGcI+UrwbbTwmc4mU5Oi+DE4vMDLbk35MtogLuMcKIwaWCC/kXChvPatZN+/3oyGDnCFfboW +bDrtIW+IO7o7mni7NNWm6oJsyuBQCuSUuvtCJYr8nDakgWcrTIdmmV2R6jexWU+HcO6mQjDuRM2t UQLNM9Q2tkYjTtW2mMu+Qen2Gn9Jkv35cSNBmJHxw7O/gMdvr0zR8tjt4dwUd4s8QtqwaPhuQxZ6E fgU33xtw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001PU-T9; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-JK; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 11/18] ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:22 +0100 Message-Id: <20201223172229.781-11-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/usb/mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 12b15ed59eaa..412fcd817ecc 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -254,7 +254,7 @@ static int get_relative_value(struct usb_mixer_elem_info *cval, int val) if (val < cval->min) return 0; else if (val >= cval->max) - return (cval->max - cval->min + cval->res - 1) / cval->res; + return DIV_ROUND_UP(cval->max - cval->min, cval->res); else return (val - cval->min) / cval->res; } @@ -1338,7 +1338,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, } uinfo->value.integer.min = 0; uinfo->value.integer.max = - (cval->max - cval->min + cval->res - 1) / cval->res; + DIV_ROUND_UP(cval->max - cval->min, cval->res); } return 0; } From patchwork Wed Dec 23 17:22:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00F3EC433DB for ; Wed, 23 Dec 2020 17:46:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63EE0207A1 for ; Wed, 23 Dec 2020 17:46:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63EE0207A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B9FB516E0; Wed, 23 Dec 2020 18:45:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B9FB516E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745601; bh=tT+kaUYYyFJ2fcve7NDKH3cSAnRi5TZlnIt3GWB5WXs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D45WtA1ScD4/RTj828SI5+tPKKT7/o365uUo/gOGMe9o9IVzWqLClk35hmyQUrj1o CvoQ0PJcqpDPpgcCgnrCWwm08l7FgHzhkQpVGa33xA6oAB69CZU1O9MIPOY9Nedb26 37Bf6hsHmG+B+FQl34fon8roBr3fRzpFyiuAoU2w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 110D0F801EB; Wed, 23 Dec 2020 18:44:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 62CEEF804DF; Wed, 23 Dec 2020 18:44:44 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 4CBB1F801D5 for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4CBB1F801D5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="L+xF5p/k" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=s9rgC9sXQ+9rkZOqKnMTXbao0pZKDn6/mEWQH+x7Rx0=; b=L+xF5p/kVL/2v6HwoinzSnr24t Q7NFtH3p/Q0ylAi7qaIK8qEqVu270+x6L9Y3ilJDvt3X69h5Yn3tHpuN9a/YD6SlKWliRHcdwoHzt 7dmLGMtxAbeX+Ax9j4Kcn05IT/tBcMNuntxkXgW9ReEoE9XcnK2Ad5BS19D4Xevlp2aqdzMGFpMoP SFzDN34iZfN68b43Urst0CRDjqbh0QGtDmZ14WV9D6tzMMH8jE2hO6YcKq8eDX1WzNg2WSNFDdgJW weWO0tTQ9S9v71VLVfEJZDNCV6BOlFKpXUntIhEttmda62elnihGIgI/srCGqgDG4ltlVqKU/R6aj myExuT0A==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001Ou-HG; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-Kt; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 12/18] ALSA: vx: Use roundup() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:23 +0100 Message-Id: <20201223172229.781-12-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use roundup() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -((((x) + (y) - 1) / (y)) * y) +roundup(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/drivers/vx/vx_pcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 3d2e3bcafca8..daffda99b4f7 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -1154,8 +1154,7 @@ static int vx_init_audio_io(struct vx_core *chip) chip->ibl.size = 0; vx_set_ibl(chip, &chip->ibl); /* query the info */ if (preferred > 0) { - chip->ibl.size = ((preferred + chip->ibl.granularity - 1) / - chip->ibl.granularity) * chip->ibl.granularity; + chip->ibl.size = roundup(preferred, chip->ibl.granularity); if (chip->ibl.size > chip->ibl.max_size) chip->ibl.size = chip->ibl.max_size; } else From patchwork Wed Dec 23 17:22:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 449C6C433E0 for ; Wed, 23 Dec 2020 17:46:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD9FF207CD for ; Wed, 23 Dec 2020 17:46:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD9FF207CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E0B7C17B7; Wed, 23 Dec 2020 18:45:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E0B7C17B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745588; bh=x1O5LgcbaHD9MxXgOnWSSaRI6s+WNBNY7Yke+Du5Xeo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ESHnMf8p7kPwIQh0XAjFu0oWlhMDTPEBT/Mn7SYmEk5OLgAjXFbqSmJkSWLmG7S3x 1cmYpp08dq71Rlfxe5UQqPkNSgdICRHRbMRyQSSuvj3fke7ZyESZYbX8Lf5xYmQR/0 JpgLOL8g2NScBpyG5ljDARYSz+Pm8y6U2uBC6smQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7DDCFF804BD; Wed, 23 Dec 2020 18:44:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 54CC8F8028D; Wed, 23 Dec 2020 18:44:38 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 426A9F80116 for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 426A9F80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="muEqi7OX" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=vNAO0qpQTEDAwxeTeFUszTx4l2svQj0M41VpsnGx4uY=; b=muEqi7OX1Dg3vONGHcX9p7VM30 SPDwE2LurcTsiXhMhQng8hqNK/tpxXKc1NaYf+D3W02sfIBe79/+IGq9Ct+7DsRlDgaUcbAl1cJ15 4TM900q0SFxgunP0K5BTvuVqTxaXV3UGwBMe467/JBUZ5CYhI5yFrbq96LQNSIQy3vaSCrAoHoNJT jaDltVsJ376CbFFatpVeOqb+saNRnF8eB/HzVy8t/2ktUtZ/DzyJNfLEcBMF6eMaZ1sKLPPOT+Jw0 au5ABlzR93WRVtOFHJbQMc0jEghjWfq7Xh+dxtdNH0EXYqnMXBOp/ASzTE1+5n1TaV9CQciOOmiLJ iwb1i9AA==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001Oe-Dv; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-MY; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 13/18] ALSA: oss: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:24 +0100 Message-Id: <20201223172229.781-13-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -((x) + ((y) / 2)) / (y) +DIV_ROUND_CLOSEST(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/core/oss/mixer_oss.c | 2 +- sound/core/oss/rate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index f702c96a7478..af5de08f9819 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -418,7 +418,7 @@ static long snd_mixer_oss_conv(long val, long omin, long omax, long nmin, long n if (orange == 0) return 0; - return ((nrange * (val - omin)) + (orange / 2)) / orange + nmin; + return DIV_ROUND_CLOSEST(nrange * (val - omin), orange) + nmin; } /* convert from alsa native to oss values (0-100) */ diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index d381f4c967c9..98269119347f 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c @@ -193,7 +193,7 @@ static snd_pcm_sframes_t rate_src_frames(struct snd_pcm_plugin *plugin, snd_pcm_ if (plugin->src_format.rate < plugin->dst_format.rate) { res = (((frames * data->pitch) + (BITS/2)) >> SHIFT); } else { - res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch); + res = DIV_ROUND_CLOSEST(frames << SHIFT, data->pitch); } if (data->old_src_frames > 0) { snd_pcm_sframes_t frames1 = frames, res1 = data->old_dst_frames; @@ -224,7 +224,7 @@ static snd_pcm_sframes_t rate_dst_frames(struct snd_pcm_plugin *plugin, snd_pcm_ return 0; data = (struct rate_priv *)plugin->extra_data; if (plugin->src_format.rate < plugin->dst_format.rate) { - res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch); + res = DIV_ROUND_CLOSEST(frames << SHIFT, data->pitch); } else { res = (((frames * data->pitch) + (BITS/2)) >> SHIFT); } From patchwork Wed Dec 23 17:22:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 564B4C433E0 for ; Wed, 23 Dec 2020 17:47:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7D832226A for ; Wed, 23 Dec 2020 17:47:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7D832226A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 54C5C17DB; Wed, 23 Dec 2020 18:46:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 54C5C17DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745645; bh=8ODisghaL60nHMJQW4rwgfjvuXW/AElXprKlZ44rHBA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JLLWvkaRw0F+O82JoyR7ZgOhuBietcj6BIbB3EHK68Hd71P2npU1/VVYzeTnNXtT/ QtOKnaLc6Cj/HPNjmVmKXmMEm4p+4d2ytT6iVmgNAtOt+fNTtTlfeqvmAhU7Zj+8op guMA/wqs6oNIgh4jslL5+4sUN8yIy6kDwwsbf0wY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 174ECF804E2; Wed, 23 Dec 2020 18:44:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AE7E2F801D5; Wed, 23 Dec 2020 18:44:44 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 5CCB3F80212 for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5CCB3F80212 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="YLRfcdL3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=ieTQJ9ex0K+jnOpdjzypzgNxjrFrzj00M/WEQDvbzlU=; b=YLRfcdL39bcyCDj43Aw2PEPgoO ryhmZe30YBcd+X+RKoNYNY3CVdVi3uBKrft0YDwn7sE7A9VkFjlrUgp3CUE5n4uDNOOUoHp8ehDgz tQZKbqHKGWjA/AB4s1aJyBl4qFp1RivOuDnO+VaeqU5I/+jzil3CRtWIf7JpJrP5qty0SsKxMsQQ1 eP06eFwLipaRe4uIPJWDlqSh3lkoYLQ2D7U5XPwGF+IZEG5zqKZ7Lul2xFARESgqO93WFTolnDoun ya7FNJzlEYwSA+IYts6/GuUrxzM07vTAw4UrdNnEcKdB12jeOahXboQhXzzR4+sBfOTp9voalv8fV FXsgYPAA==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001P7-Lk; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-OB; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 14/18] ALSA: sonicvibes: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:25 +0100 Message-Id: <20201223172229.781-14-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -((x) + ((y) / 2)) / (y) +DIV_ROUND_CLOSEST(x, y) // Signed-off-by: Lars-Peter Clausen --- sound/pci/sonicvibes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index ecdd54d7a4e1..bd805e416e12 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -570,7 +570,7 @@ static void snd_sonicvibes_set_dac_rate(struct sonicvibes * sonic, unsigned int unsigned int div; unsigned long flags; - div = (rate * 65536 + SV_FULLRATE / 2) / SV_FULLRATE; + div = DIV_ROUND_CLOSEST(rate * 65536, SV_FULLRATE); if (div > 65535) div = 65535; spin_lock_irqsave(&sonic->reg_lock, flags); From patchwork Wed Dec 23 17:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69FEEC433E0 for ; Wed, 23 Dec 2020 17:48:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92FD8207D2 for ; Wed, 23 Dec 2020 17:48:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92FD8207D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3992D17E7; Wed, 23 Dec 2020 18:47:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3992D17E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745691; bh=ILYQBT2VBsJ1aXZek4CMzDy95Z2JOOWDkqg3+MXeMTc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ap5n5mbV6cUU/oXgkwdHGXTKpMHlQ6pNJby9RrThOY3Ugn192V+FnblbesTVzQ3Ph PVf1aqU4ruG19GFGz5RgNRnixw1GEizXKYBLwIXnzI1VVU6+IpS3iVWM7PT84Rt6fs EysItW0iuc1wNrOJVdh9+sMkSq/TNfDKn8MqSSe0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F026EF804ED; Wed, 23 Dec 2020 18:44:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 13189F804E0; Wed, 23 Dec 2020 18:44:45 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 56C4AF801EB for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 56C4AF801EB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="BQBbZpFV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=jas3II4B6NhABFSwerDEfkIJ+sDOaowYWFKzYUUXVK0=; b=BQBbZpFV7130fkbvf4Uj+qdZqs O/RVsMUxQpIAAkV5DIDt0TUKwNZVsBZ55V/Srr7YcjX1gGp6S/DMEENUoPvaP0BlvVAT5i+MzDiE/ ouaKRUwoToRQADdta4Sk30HaXqX9GZ8gcu/TA5sjotjyKkmy1DQilkolOvPERy/ZX/ZIM3c8wRcHW peI+jMmBVDONSB6M+wfxpVdMV5p4E7z/eItac+XYn6RpkFdF4ygUf8Zjfm4G26llErHrBTmpMP1vh iNxYHTsDEL58WKSFrSj3UgAT5kZ0Wu22Yf7Waj064K70obDTvRswc23EbPYEQH6H5/kiUSE9XuWYb jI0tItBw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8BZ-0001O8-Rd; Wed, 23 Dec 2020 18:44:29 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-Pp; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 15/18] ALSA: trident: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:26 +0100 Message-Id: <20201223172229.781-15-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @@ expression x, y; @@ -((x) + ((y) / 2)) / (y) +DIV_ROUND_CLOSEST(x, y) @r1@ expression x; constant C1; constant C2; @@ ((x) + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) * 2 != int(C2): cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_CLOSEST(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/trident/trident_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 6e50376163a2..8d0d0d8335ec 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -678,7 +678,7 @@ static unsigned int snd_trident_convert_rate(unsigned int rate) else if (rate == 48000) delta = 0x1000; else - delta = (((rate << 12) + 24000) / 48000) & 0x0000ffff; + delta = DIV_ROUND_CLOSEST(rate << 12, 48000) & 0x0000ffff; return delta; } @@ -1034,7 +1034,7 @@ static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) ESO_bytes++; // Set channel sample rate, 4.12 format - val = (((unsigned int) 48000L << 12) + (runtime->rate/2)) / runtime->rate; + val = DIV_ROUND_CLOSEST(48000U << 12, runtime->rate); outw(val, TRID_REG(trident, T4D_SBDELTA_DELTA_R)); // Set channel interrupt blk length From patchwork Wed Dec 23 17:22:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AFE6C433E0 for ; Wed, 23 Dec 2020 17:45:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C87C9207A1 for ; Wed, 23 Dec 2020 17:45:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C87C9207A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8F7EA1796; Wed, 23 Dec 2020 18:44:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8F7EA1796 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745531; bh=o/7uheQuGhaaSLaTdHSo+9doItYSZpTUChEonIH7hwE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s4hQdCm1AEFwsoQMzG2LPgtC5/a0+VfLV5kubgnn+G3Q0VZsE/aE9hObloPG0LKya I2eUsjW+DcMGiG0qF6C7gpEzrdqHQYHRgK1C7jHPB90v4lSK3QOv3kU8n4ssnxX+a5 4aEV+o4NmrZCsIxru7/6zeNSLDYwmPfA4BsMCHrM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8AF24F80116; Wed, 23 Dec 2020 18:44:40 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0D89AF804BD; Wed, 23 Dec 2020 18:44:38 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 478BCF8013F for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 478BCF8013F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="WF/tlCt/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=nuZGiQsRLmDtTB9P6tmGfaasfGNWaXjiS5u0zUzEVM0=; b=WF/tlCt/+V6tstz9mt5APMqyBx +MtjY3MXVunhxIBFF9eRz1uZy3o2/lBDv6QBloTIn511mDzPPng0xjgHYPK6u9DCM/yNnCRCHZLNe tgvwQd3QhOwLV5fYygiHsfGyXSFOQM4AzvofjVWS0TUqRHG5K35njZuIfekB0mipyjfpzsybDVDFl ceWZZqBDhp/F2nOZM4E9mGmeC6GSvrC0l7OAs/FDY0Lf+M3Vl5gQGBZu9shtZQ+KtISIllpROOgt6 E1zHMI/nNyxpJOMEfh23obNpJm17anQzw1hqyz9AzNH3REfkvirwt2KMWdFkTmWREOEwn5s3Mg9f6 409D55rw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001OP-4T; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-RX; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 16/18] ALSA: ens1370: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:27 +0100 Message-Id: <20201223172229.781-16-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @r1@ expression x; constant C1; constant C2; @@ ((x) + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) * 2 != int(C2): cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_CLOSEST(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/ens1370.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index d9acef0826a9..93c4fd313311 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -752,7 +752,7 @@ static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate) unsigned int freq, r; mutex_lock(&ensoniq->src_mutex); - freq = ((rate << 15) + 1500) / 3000; + freq = DIV_ROUND_CLOSEST(rate << 15, 3000); r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)) | ES_1371_DIS_P1; @@ -773,7 +773,7 @@ static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate) unsigned int freq, r; mutex_lock(&ensoniq->src_mutex); - freq = ((rate << 15) + 1500) / 3000; + freq = DIV_ROUND_CLOSEST(rate << 15, 3000); r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)) | ES_1371_DIS_P2; From patchwork Wed Dec 23 17:22:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7C26C433E0 for ; Wed, 23 Dec 2020 17:47:16 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06311207A1 for ; Wed, 23 Dec 2020 17:47:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06311207A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9FD5117DF; Wed, 23 Dec 2020 18:46:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9FD5117DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745634; bh=rbLzn8724zW0PT6dPhEL1L70ImPz3rX0us93VXdQ+h4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hNi5ii0/5teq2qf0Mh0ZAnud85gO5Io+W7zOc4DFRwEXez6qiLHLHIpNkn8NIZVST +XnUuGzizhwnA0obYx+EpDrMovBYG6gcMryq0twWJ4DHhxeUskHPauMlJkJwk6OG8y Rf2p9tfZIplJPxQT6eSXrawD0bFHhoW4o4BtA96Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DC0F3F801D5; Wed, 23 Dec 2020 18:44:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 916ABF804D2; Wed, 23 Dec 2020 18:44:44 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 525D2F800BC for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 525D2F800BC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="ie4xv2ZR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=irU4ok4di1n21Jo8y2elJOfnOB0TgpA0rzfahs/6SuU=; b=ie4xv2ZROIcg8qqpziOpr5EW97 KLbvIpcxT+oQFBhqnGK4NRDP8SV3lNqKs+14hM3MguEpVv8sGrSNxpcW04VgYrQFaXp7sIEO9/jHv AQ7nyvNZVUIPnsXI4jsoMidRdcn7Ys1EJRAomT35DTPQ5PiND2rOlx8pddC+koKv4zLQZhJhQV0/U gMTyUAYTXDD7DaOXH3n9CcwbGLFQIap+WXXEiHHZhrkfEiIGblIrb1YYcSqoJReoZVnSpq93+AYhq 6K4xvuKXcEEUEi7mQ3z0/4DE+b1pxN5xv4YCf3OhA1UUSwXEB9mvT4VExzSR3Uu61LuL0cOZk/B0X ge73Su+w==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001PJ-Pf; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-TN; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 17/18] ALSA: sis7019: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:28 +0100 Message-Id: <20201223172229.781-17-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @r1@ expression x; constant C1; constant C2; @@ ((x) + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) * 2 != int(C2): cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_CLOSEST(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/sis7019.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 7bf6059d50fb..8ffa2f53c0b5 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -363,7 +363,7 @@ static u32 sis_rate_to_delta(unsigned int rate) else if (rate == 48000) delta = 0x1000; else - delta = (((rate << 12) + 24000) / 48000) & 0x0000ffff; + delta = DIV_ROUND_CLOSEST(rate << 12, 48000) & 0x0000ffff; return delta; } From patchwork Wed Dec 23 17:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 351459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8776C433E0 for ; Wed, 23 Dec 2020 17:48:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7C342226A for ; Wed, 23 Dec 2020 17:48:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7C342226A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=metafoo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 62E3517D0; Wed, 23 Dec 2020 18:47:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 62E3517D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608745683; bh=JUcrgAyPpdN2k4wqemH/POqxkJlZCJCpm48hsXlLK5k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V7+OVSA+voInijMGtSjAHTD0fkeh44HZlJqUxQs76pFuZsQXhd2yr7ipo9i7HnsqY fGBz9yuvVgvmr0v5bHTguO6N5Dbx2oEtslH8Mqf6lOyOvYhD4x9m8kOqvzOpY5vDIW gVZYcZggc0m0mdsN5y8pZ2OpFpnkXbgMOJ28KERE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 04B06F804E3; Wed, 23 Dec 2020 18:44:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BFB6F800BC; Wed, 23 Dec 2020 18:44:45 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 5F4FFF801EC for ; Wed, 23 Dec 2020 18:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5F4FFF801EC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="T1+8KCkZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=KriTAoR6s1dcVEtgHEufQClJ5rt1sgvqiqogJVEVJXg=; b=T1+8KCkZpJ7AW6VBMB5Hckavjz IG848Cvw3m3ec+NghrKF8eLpLnS4IXMqOBDlxO5nj0JSKakPO57MfjToUyOSwKF7YWwqghmWojcxE 2VWhT7zfIdbeHmjfohxoKIS/6TiHrBLDCMyOas+HbzpLb2lB42zRtCNO4tUrBGN0pHoCsx32KGwgq hgyvaBd77g8vkVAzb2T+lCjf0QUk+CUmJEr7ul3eTCHtyCeMnl3GwW5O7TxpDXFUWAuYC27TCWTwz 4W4ajSJBYVK8lHqtf34Y5hrBLWpdN+ZCC6/fTabDQIyV1pWqVYzJhVxI0nzb2ub7yrtlCbh+A/JVV 8RN5cf7Q==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ks8Ba-0001OD-0O; Wed, 23 Dec 2020 18:44:30 +0100 Received: from [62.216.202.54] (helo=lars-desktop.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks7qo-000Crk-V3; Wed, 23 Dec 2020 18:23:02 +0100 From: Lars-Peter Clausen To: Takashi Iwai Subject: [PATCH 18/18] ALSA: maestro: Use DIV_ROUND_CLOSEST() instead of open-coding it Date: Wed, 23 Dec 2020 18:22:29 +0100 Message-Id: <20201223172229.781-18-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201223172229.781-1-lars@metafoo.de> References: <20201223172229.781-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/26026/Wed Dec 23 13:53:03 2020) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer. Generated using the following the Coccinelle semantic patch. // @r1@ expression x; constant C1; constant C2; @@ ((x) + C1) / C2 @script:python@ C1 << r1.C1; C2 << r1.C2; @@ try: if int(C1) * 2 != int(C2): cocci.include_match(False) except: cocci.include_match(False) @@ expression r1.x; constant r1.C1; constant r1.C2; @@ -(((x) + C1) / C2) +DIV_ROUND_CLOSEST(x, C2) // Signed-off-by: Lars-Peter Clausen --- sound/pci/maestro3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 40232a278b1a..f622c2a6f746 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -1245,7 +1245,7 @@ static void snd_m3_pcm_setup2(struct snd_m3 *chip, struct m3_dma *s, snd_pcm_format_width(runtime->format) == 16 ? 0 : 1); /* set up dac/adc rate */ - freq = ((runtime->rate << 15) + 24000 ) / 48000; + freq = DIV_ROUND_CLOSEST(runtime->rate << 15, 48000); if (freq) freq--;