From patchwork Fri Jan 20 18:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brent Pappas X-Patchwork-Id: 46564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp361951wrn; Fri, 20 Jan 2023 10:36:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXvJKDqsrSQg908Gq9uwGjg9vv7bxhPbJUOq0DncAekcbYCfQ16qVJS1eLBONvoT8rKB0guf X-Received: by 2002:a17:906:7050:b0:872:b17a:9b59 with SMTP id r16-20020a170906705000b00872b17a9b59mr15273216ejj.38.1674239796845; Fri, 20 Jan 2023 10:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674239796; cv=none; d=google.com; s=arc-20160816; b=Y9QgsoBzM29FPTn4ONbfrChsbFi8QyOWUTYYdP98hpKSG45g4Jx0EIIpx5bJTdPoZp +7JUVPNUCXMKIae0vfEefwnS5RfOpRnGUPmp17jygMbhr6pDMTFWgMpF3bqXKYWPXvJl K88onmI3a+T63Fo7k0Si+47FxaXZPHrAzSLThYlBLM418P5W1rqFNfHGiRd6/zjOd7cF ODNCE06G/S6BclAR+5xdYdar2CXkgyYH4XIMLBfL2+ETREcLo4C1UTRFo1u6eJ2zhtIK RyZ5qu8HEjkp4jILBBgnotFj7yx30Y+oFhMH2NuPMvfNMLCaW5CoGFbmOQ9LI6IwpM2K Huaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CTTCHy0JPJARyS2U5LqqRMs0+6ayWCLJjfjN3JqaCr0=; b=KXHrl/dhfUhvzKLmCp/H6GoHsbduJR8nKMGoOBtlk2+N9YwAhFW18Uh9qTmSt9G9zF GEOWIDc9fxxm2Gy7sD/+jus3y6t4tP0y/n4zGkx8W4Tso2nLINIDE9pusaCm9/8SrEjj 2aKjkbY3bo7mysPrQ2dwAyZajQnR+PYJUU5azte1qH7H6ZPjmfcQW3zwYy1iurhu/95B 0ZsejsIC0HMf7NLJJsQwrla36p3gfso2XWiqJB9QPEx8bfIV6LWinb6KnwpCbVud0rPe 78wS1gsTARyReoXwyHgrFEkT/R33VLqjQcVfaGfZiN5wOAYAQYcDBoWkTYtqkPb4IImu Whqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pappasbrent.com header.s=default header.b=D8RTm9mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs11-20020a170906dc8b00b00877876d372fsi4931994ejc.411.2023.01.20.10.36.13; Fri, 20 Jan 2023 10:36:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@pappasbrent.com header.s=default header.b=D8RTm9mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbjATS0m (ORCPT + 99 others); Fri, 20 Jan 2023 13:26:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjATS0k (ORCPT ); Fri, 20 Jan 2023 13:26:40 -0500 Received: from MTA-12-4.privateemail.com (mta-12-4.privateemail.com [198.54.127.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FEA378ABC; Fri, 20 Jan 2023 10:26:39 -0800 (PST) Received: from mta-12.privateemail.com (localhost [127.0.0.1]) by mta-12.privateemail.com (Postfix) with ESMTP id 3B6EB18000AE; Fri, 20 Jan 2023 13:26:38 -0500 (EST) Received: from bpappas-XPS-13-9310.. (rrcs-24-173-168-34.se.biz.rr.com [24.173.168.34]) by mta-12.privateemail.com (Postfix) with ESMTPA id BE92018000B1; Fri, 20 Jan 2023 13:26:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pappasbrent.com; s=default; t=1674239198; bh=254NmRTKKpoPDDbLe8JkEKobrM4zw72lP3QGnoDEAjA=; h=From:To:Cc:Subject:Date:From; b=D8RTm9mcholnkiKBj+Nepe6m4W+9L8jfvSJmEtJ+XlCZIyPNzKmup55Iua8wD/LVf tEs9v3nLPKGjuPputi28LHngKkiQ+EhMrx1mel4A1sLat38J332en/kXtNrpPTwLQN csGcOM7UP8X6EHy5V3JEE1N+JYEcBTeBPZs2HDRk7W+Zp58QW9E1o48hsOBUWsLNS2 hMO/zkYf1DwJRnhuEBA3vmIr0/36vkPzFc0rSNdiUd/nz7w8+OwJofv+zr7z0973Hw 91JxTA7mljja5Q/NyLLInwbX3btYABuqkiW6rNsOHFFzGs6TxakIe9Gd3QukmiDXGs tDq5ZxeTAl00Q== From: Brent Pappas To: hdegoede@redhat.com Cc: mchehab@kernel.org, sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Brent Pappas Subject: [PATCH] media: atomisp: pci: hive_isp_css_common: host: vmem: Replace SUBWORD macros with functions Date: Fri, 20 Jan 2023 13:26:25 -0500 Message-Id: <20230120182625.23227-1-bpappas@pappasbrent.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755567669451076122?= X-GMAIL-MSGID: =?utf-8?q?1755567669451076122?= Replace the macros SUBWORD() and INV_SUBWORD() with functions to comply with Linux coding style standards. Signed-off-by: Brent Pappas --- I am not sure if it would better to inline SUBWORD() or turn it into a function. On the one hand, SUBWORD() is only invoked once, so it may be better to to inline it. On the other hand, the macro defined beside it, INV_SUBWORD() should be turned into to a function because it is invoked multiple times, so it may make sense to turn SUBWORD() into a function as well. I have opted to turn SUBWORD() into a function. .../pci/hive_isp_css_common/host/vmem.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c index 6620f091442f..316abfb72a83 100644 --- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c @@ -28,10 +28,19 @@ typedef hive_uedge *hive_wide; /* Copied from SDK: sim_semantics.c */ /* subword bits move like this: MSB[____xxxx____]LSB -> MSB[00000000xxxx]LSB */ -#define SUBWORD(w, start, end) (((w) & (((1ULL << ((end) - 1)) - 1) << 1 | 1)) >> (start)) +static inline hive_uedge +subword(hive_uedge w, unsigned int start, unsigned int end) +{ + return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start; +} /* inverse subword bits move like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */ -#define INV_SUBWORD(w, start, end) ((w) & (~(((1ULL << ((end) - 1)) - 1) << 1 | 1) | ((1ULL << (start)) - 1))) +static inline hive_uedge +inv_subword(hive_uedge w, unsigned int start, unsigned int end) +{ + return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | + ((1ULL << start) - 1)); +} #define uedge_bits (8 * sizeof(hive_uedge)) #define move_lower_bits(target, target_bit, src, src_bit) move_subword(target, target_bit, src, 0, src_bit) @@ -50,18 +59,18 @@ move_subword( unsigned int start_bit = target_bit % uedge_bits; unsigned int subword_width = src_end - src_start; - hive_uedge src_subword = SUBWORD(src, src_start, src_end); + hive_uedge src_subword = subword(src, src_start, src_end); if (subword_width + start_bit > uedge_bits) { /* overlap */ hive_uedge old_val1; - hive_uedge old_val0 = INV_SUBWORD(target[start_elem], start_bit, uedge_bits); + hive_uedge old_val0 = inv_subword(target[start_elem], start_bit, uedge_bits); target[start_elem] = old_val0 | (src_subword << start_bit); - old_val1 = INV_SUBWORD(target[start_elem + 1], 0, + old_val1 = inv_subword(target[start_elem + 1], 0, subword_width + start_bit - uedge_bits); target[start_elem + 1] = old_val1 | (src_subword >> (uedge_bits - start_bit)); } else { - hive_uedge old_val = INV_SUBWORD(target[start_elem], start_bit, + hive_uedge old_val = inv_subword(target[start_elem], start_bit, start_bit + subword_width); target[start_elem] = old_val | (src_subword << start_bit);