Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1246084iog; Tue, 14 Jun 2022 02:11:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdi5Bvx8p6p4Um2xeKK2UIE/Fl6USdItOTWLpHd626M7owomA2Py1580P+zHMyZ82sta0V X-Received: by 2002:a17:906:37c6:b0:70c:f9f:f0c5 with SMTP id o6-20020a17090637c600b0070c0f9ff0c5mr3169700ejc.743.1655197874348; Tue, 14 Jun 2022 02:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655197874; cv=none; d=google.com; s=arc-20160816; b=H1M6rirflvlaXQ9LE30vPnPpLumvRLsHjl1rTO+xpvFOPIBWm24G9rCGhgelzkQQeK P/KpOVZ68R6wcs8JspPwHa2PYY8rEhIkrz6HAr0Cv89v7n2Ah6eJcG6VMkoLoKpLX3Ur +j5q4KpJwVut9KJjCKSf/+rJWcBnOvtDY104+QCHQzXi+PrXrqYxGpy1mWk7JjWUvPqQ Xz9XbrOgkacGhJ0CHvNQ6pGnwxvsyqGYDpVMSxtmq/elNmDwpodj10NhVybaPVxbqrDM T1A8IoQXeq48ZgOLnaaDiokzusjz91jw/bCmtssXoiQ+b5uOFYiNCCVtylv5ddWycX+k 3Qig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=xe6GvvsoQamREKSFfsgIANQWYjRr6/747QxLbv2QSJo=; b=BaIRi2AIMKPRN9108h804crwftr1ixJEv1gM4hEdeOh13bcEu5dAMgVWhEMfyHu1sM TrtsGY20yRDE2IjcyTH7N0G6Q8Gk6Jphj7xghO14xFN6CZ47ItdY61Eojfr/bFtybeeo HoTR4NgS8k8PERUbjXvX6I7+mhBQdOTbSFrsi0Uy7t1x90NZuKZmz7uxYkGPher0Z8QJ 7CxLwSshGoOsMODYTsYMMtUUuP3KgsNElmjDlK0JpPy1NnefsQZcOTSdrYHGyzk4l8jz bnCOi/gN+thpk1yrDB0OdlpWCaZ1qhoJKqsVfOvOZvY01CBa4WS02yxbdjKyf/TxMToC SyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=aXu3B88y; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a170906795300b0070337fc0e1asi11480683ejo.27.2022.06.14.02.10.48; Tue, 14 Jun 2022 02:11:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=aXu3B88y; dkim=neutral (no key) header.i=@suse.cz; 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 S1352324AbiFNJGF (ORCPT + 99 others); Tue, 14 Jun 2022 05:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239679AbiFNJFn (ORCPT ); Tue, 14 Jun 2022 05:05:43 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D353DDE6; Tue, 14 Jun 2022 02:05:43 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C1DD01F94B; Tue, 14 Jun 2022 09:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655197541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xe6GvvsoQamREKSFfsgIANQWYjRr6/747QxLbv2QSJo=; b=aXu3B88ylDNDHoEvkGwIY2Jm9hwwQvV6l9t4H4+6pXmRJLWiQ2tumFZ3W9aNEXS1qKN18A ayw5g1SrjaPS543gFuEwQxYrfPNHqQHXk2pUKZzNz/YyRud+Jax9gbRt7p/tAd5YoLifTb bs3J5kOux9vCk++sdfltl54ErA/nsJI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655197541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xe6GvvsoQamREKSFfsgIANQWYjRr6/747QxLbv2QSJo=; b=N2y7uQUlK6S0Mfwd+9E4LSIU2Zs+EF9Me0FeBW7KkG7EBZCR8GEzl99eAZW7bJu7WnA/AS YtvpLI/B6K64w3CQ== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 97A302C141; Tue, 14 Jun 2022 09:05:41 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 6/8] tty/vt: consolemap: improve UNI_*() macros definitions Date: Tue, 14 Jun 2022 11:05:35 +0200 Message-Id: <20220614090537.15557-6-jslaby@suse.cz> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220614090537.15557-1-jslaby@suse.cz> References: <20220614075713.32767-1-jslaby@suse.cz> <20220614090537.15557-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Use FIELD_GET() and GENMASK() helpers instead of direct shifts and ANDs. This makes the code even more obvious. I didn't know about the helpers at the time of writing the macros. Suggested-by: Ilpo Järvinen Reviewed-by: Ilpo Järvinen Signed-off-by: Jiri Slaby --- drivers/tty/vt/consolemap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 16d0d8f04f0e..9e94ec0e0f83 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -23,6 +23,8 @@ * stack overflow. */ +#include +#include #include #include #include @@ -190,10 +192,17 @@ static enum translation_map inv_translate[MAX_NR_CONSOLES]; #define UNI_DIR_ROWS 32U #define UNI_ROW_GLYPHS 64U -#define UNI_DIR(uni) ( (uni) >> 11) -#define UNI_ROW(uni) (((uni) & GENMASK(10, 6)) >> 6) -#define UNI_GLYPH(uni) ( (uni) & GENMASK( 5, 0)) -#define UNI(dir, row, glyph) (((dir) << 11) | ((row) << 6) | (glyph)) +#define UNI_DIR_BITS GENMASK(15, 11) +#define UNI_ROW_BITS GENMASK(10, 6) +#define UNI_GLYPH_BITS GENMASK( 5, 0) + +#define UNI_DIR(uni) FIELD_GET(UNI_DIR_BITS, (uni)) +#define UNI_ROW(uni) FIELD_GET(UNI_ROW_BITS, (uni)) +#define UNI_GLYPH(uni) FIELD_GET(UNI_GLYPH_BITS, (uni)) + +#define UNI(dir, row, glyph) (FIELD_PREP(UNI_DIR_BITS, (dir)) | \ + FIELD_PREP(UNI_ROW_BITS, (row)) | \ + FIELD_PREP(UNI_GLYPH_BITS, (glyph))) /** * struct uni_pagedict -- unicode directory -- 2.36.1