Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1856375pxk; Tue, 1 Sep 2020 09:20:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo2yhVulwPLuFLwUG7c9aimNF8XnFuvhMmuk9wUrunVZe9fU7NpC3BWwbeLWAibOMMzm3J X-Received: by 2002:a50:fc87:: with SMTP id f7mr2393388edq.162.1598977229593; Tue, 01 Sep 2020 09:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598977229; cv=none; d=google.com; s=arc-20160816; b=CHZx2pKLfg4UQ80HpIWrjQq000WyaHofBjw5AP3CBr95/mVfErOI3ZZAf+o0ixXxP3 b+x1ZaKdOGX+zfxRM4WUNYAzvEPbD0WtyT61/ZmaA/ExjGjRzq9q4rkxXYtG34uvxmtY C7tBhia5SqFBu+lFBowY0xJ/pZWqLtLjeVpqp3TbE5priZkC2iklPCMbYbnVO/atfoSH 9S4PDwpf7lQ16RKwoxh73+lgKR0z8B53lu7C9dkA26a0bDOfKaSZWLIqkHZvYsWkmMZV IgOyZHvaIoa5DYEeTwPpU+NrhVKHUa/xSK8yhjxsApR7FBbASg8PAt1Blf/kVB44+UpH dpSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bRRXZ9zEebGS55d1yTbvxveQzuUz/SLo7FYLLNKiwCQ=; b=FwASGaFIeP9c9X+tUClMZubrSXFD9GyS0vU7g9XRo2OY9DUz9pgZ1dZNi+YcwJCOwn dVGM1RQ3Y9I3zq/3ksJoO7MIj0e7Z7vGtYWCnpzHdRVh0XM+GMe/IVKu4ARoYB6Peuo9 GSjLolw53twS+Oesg4uMmvAprJGr0FkSiKgZCRjBmM9kcmwYNdipGvg0IGmTXAkNhD9L qam7FA/SakwBHghfRM4Z4qioY8wDCS33Mt1mVhTy+fjGiGTk4jhrdZDEia/0wDKlxxcV Go84s5IUFOv7HJCOLmvs/tPZmIBWBM+IvSO+rQI+ZMSCTBa6Trq/2krIy4O9az5VuHVP iXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=qRUydLAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id br19si833472ejb.151.2020.09.01.09.20.06; Tue, 01 Sep 2020 09:20:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=qRUydLAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbgIAQTj (ORCPT + 99 others); Tue, 1 Sep 2020 12:19:39 -0400 Received: from mx4.wp.pl ([212.77.101.12]:39859 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731843AbgIAQSw (ORCPT ); Tue, 1 Sep 2020 12:18:52 -0400 Received: (wp-smtpd smtp.wp.pl 3688 invoked from network); 1 Sep 2020 18:18:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1598977130; bh=bRRXZ9zEebGS55d1yTbvxveQzuUz/SLo7FYLLNKiwCQ=; h=From:To:Cc:Subject; b=qRUydLAf/Ok/Rb1fL/kzJAmPy0MhUcxoRGGvUxViA5TLckKTfNaGIbQI0gyVT+g1S 2qeq8KQoVgkwBfAjvGiEl4G8nTmbNlpPdWsM2Vb3jKTSDsetMUWIaR666RnDL6maMT XYa2WF1lzmbx4jDJOfGxBBsj9u+SksQ5avMLm+SU= Received: from 188.146.109.197.nat.umts.dynamic.t-mobile.pl (HELO localhost) (antoni.przybylik@wp.pl@[188.146.109.197]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 1 Sep 2020 18:18:50 +0200 From: Antoni Przybylik To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Antoni Przybylik Subject: [PATCH] staging: gdm724x: gdm_tty: replaced macro with a function Date: Tue, 1 Sep 2020 18:18:46 +0200 Message-Id: <20200901161846.111486-1-antoni.przybylik@wp.pl> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-WP-DKIM-Status: good (id: wp.pl) X-WP-MailID: 9251091d3f6526f767815a022d7d0293 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000002 [wREB] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This approach is more elegant and prevents some problems related to macros such as operator precedence in expanded expression. Signed-off-by: Antoni Przybylik --- drivers/staging/gdm724x/gdm_tty.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 6e813693a766..a7db0672e81d 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -27,8 +27,6 @@ #define MUX_TX_MAX_SIZE 2048 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count) - static struct tty_driver *gdm_driver[TTY_MAX_COUNT]; static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; static DEFINE_MUTEX(gdm_table_lock); @@ -36,6 +34,11 @@ static DEFINE_MUTEX(gdm_table_lock); static const char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; +static int gdm_tty_ready(gdm *gdm) +{ + return (gdm && gdm->tty_dev && gdm->port.count); +} + static void gdm_port_destruct(struct tty_port *port) { struct gdm *gdm = container_of(port, struct gdm, port); @@ -119,7 +122,7 @@ static int gdm_tty_recv_complete(void *data, { struct gdm *gdm = tty_dev->gdm[index]; - if (!GDM_TTY_READY(gdm)) { + if (!gdm_tty_ready(gdm)) { if (complete == RECV_PACKET_PROCESS_COMPLETE) gdm->tty_dev->recv_func(gdm->tty_dev->priv_dev, gdm_tty_recv_complete); @@ -146,7 +149,7 @@ static void gdm_tty_send_complete(void *arg) { struct gdm *gdm = arg; - if (!GDM_TTY_READY(gdm)) + if (!gdm_tty_ready(gdm)) return; tty_port_tty_wakeup(&gdm->port); @@ -160,7 +163,7 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, int sent_len = 0; int sending_len = 0; - if (!GDM_TTY_READY(gdm)) + if (!gdm_tty_ready(gdm)) return -ENODEV; if (!len) @@ -187,7 +190,7 @@ static int gdm_tty_write_room(struct tty_struct *tty) { struct gdm *gdm = tty->driver_data; - if (!GDM_TTY_READY(gdm)) + if (!gdm_tty_ready(gdm)) return -ENODEV; return WRITE_SIZE; -- 2.28.0