Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1832900pxk; Tue, 1 Sep 2020 08:51:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOM9fsK3AnRvQatRe+yR5U2AXGTXhmtOJ4sE8wx/K5QAfz0fYRPj+lhPobg5GhI53z2/mz X-Received: by 2002:a05:6402:31ba:: with SMTP id dj26mr2291459edb.181.1598975493967; Tue, 01 Sep 2020 08:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598975493; cv=none; d=google.com; s=arc-20160816; b=Fu4vFEPqc/Q+PriG8KX2s1J6vJpIdjvfoY9b8CP3zubOnem2L+/SYnrnHdA+7YQz3t vl1d/tXwFHOTsU6mqfdgMmpZPAhiy2UZGCBw0dknVri57bJwWWABx8ZCL4eKqZIM5QoB 5X6tx3ztmYMfoR9MFWM0CNPCutPLkLKhgZKe40MlfqynYGCnqHnfQ+20DWNCe5cLNZTP PKo6X0gonWNWKA6ggTAjjzFzY9GyBgvlFPVGNC3yVzpIDMjHd2C95v2P6eRZmvoXFAQq eEnodXYUsWjkIlZX5Zr/UkI5G0aWh5TG89ndBXMJPQFKgZhLRfFbREoShzxfcxoDpa5U 1ZQA== 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=0TkTRTTd/MctTe5GI7P3dkE8JPMJ2kvU+Sh6IzYUwwI=; b=WTQ/3LmSXlh04DG0ZY80NOEWr9sSOx0QbrjJ/ZMe89zm7eB0ZIVB3UQz5ok60Jcfpu QhUP4zLcidEbjoofUac7Tf8oY4amjP15wrSZqwDYPBlXsymstsKf3gkMcBVlzn2YemR2 /W3HZDPSo54EkrH1KFQhd4V5LRgoynHkWzf5UMWVcQsOTe1V3GjtiOI2opqFvmXgV9WH 6P0WGJrN0T9nODXAmnlXMLhn8X31XtPSKDnynPzNH8dlOSvB7hpkD90sDeV7Kp0WyxCV viMjF1IDlDlPKYjGZEn4i0Gx1GVqjl0OVd6h+zN+pg66VHWCZ+KuMPjtLUlIWmsgOPgk qZXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=BpZgKGoI; 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 e7si927469ejm.580.2020.09.01.08.51.10; Tue, 01 Sep 2020 08:51:33 -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=BpZgKGoI; 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 S1732017AbgIAPsk (ORCPT + 99 others); Tue, 1 Sep 2020 11:48:40 -0400 Received: from mx4.wp.pl ([212.77.101.12]:32719 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731588AbgIAPo6 (ORCPT ); Tue, 1 Sep 2020 11:44:58 -0400 Received: (wp-smtpd smtp.wp.pl 31785 invoked from network); 1 Sep 2020 17:44:54 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1598975094; bh=0TkTRTTd/MctTe5GI7P3dkE8JPMJ2kvU+Sh6IzYUwwI=; h=From:To:Cc:Subject; b=BpZgKGoI2vxuvDAMOWuwlOaIhaPypqM3wZfW4WsN8OFySN8ssUKax0EwxOmLT7OrA 7DVIpGyzGltoAY8hxvsmL2sG0dZF8boGD/Ay17JtS/JGc2hf6NnookkUNRCrFHu+G0 lTgXrqnY1EUwHgFwxXH4DzjWBfbUJ6e/txb6Aftg= Received: from 188.146.234.2.nat.umts.dynamic.t-mobile.pl (HELO localhost) (antoni.przybylik@wp.pl@[188.146.234.2]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 1 Sep 2020 17:44:54 +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 an inline function Date: Tue, 1 Sep 2020 17:44:37 +0200 Message-Id: <20200901154437.110056-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: f1f5b46372db9c67cbcc3a4a70c1c0b8 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000002 [oTHR] 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..e789b7348dee 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"}; +inline 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