Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp467320pxk; Wed, 2 Sep 2020 06:37:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/4tbKv8OIL+BChlsnztEdZirNb15qQjZ3C/TThTv7QlpXIl0a74mHGGaiY+jILP/B2Cby X-Received: by 2002:a17:906:3acb:: with SMTP id z11mr48246ejd.530.1599053876743; Wed, 02 Sep 2020 06:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599053876; cv=none; d=google.com; s=arc-20160816; b=CGodSJZKqmBXT3awnlW1bqB5mDcqdaIUTdLjL9cr1MyA0K56uJf+H1XNbA18gz4ih2 /CNhzyma4QQs4/ecPqrZ393hkU4fZMSpbWp95/pM7a41KkZq8ap7thd+1zeCsvX2WVVu ooPGehaXwzDl52pEc1u5IS/UJ/2wHUSekmLbcI/z1kDwUlv1RnM8tszNDYeA67wllF/x tvWBapbhXbuvKGrWhAbAubQJUc9O23ugsV7ah9+8lXn7ZGbO0Hx72KS4RMp5HA5Yx61u nXyAqvl4Z1QTmgusIbQkMF3RWxdWm/1L1Uij+Es8FQpVaZgGITbQFKqOt7bEq+TbHd5A /DqQ== 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=G8wT2xsxFQGcxLMSyMItSjCCDSZ7QEW2M+j2fLIpSHo=; b=WCStmfyzLICASwgzORSCEflJkV/iAMQIFWMA3i+9yE10GB3OkgjGsuqN8kFYQYC3VX XdThJ7wCWBh4wA0woLYyKAdp015gLo329f3XQyYZ1c8LplDQ/4+dFUVX9Z1bb/nV3W9S 9XgJr3XnOmbbmM2KGSEuKtYqsigBI6sBTnZFrjppyLP5AToPqyXFx/623kNQuV1mRFfO cnHFqeRDkkKaiFtvyPMZpJz7m/IUiedf/nC9wVNoCDwNTdcu8JgUPFrnfh8Cs6nBEE2P jezaIXKNyadk+uXoVVuFiA78ci5EaF0AimY3uahrcHDtWQySAGQYjvrKc2SpD8j0E+PJ iQeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=eLO3vgAU; 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 c6si2704799edq.397.2020.09.02.06.37.33; Wed, 02 Sep 2020 06:37:56 -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=eLO3vgAU; 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 S1726984AbgIBNdd (ORCPT + 99 others); Wed, 2 Sep 2020 09:33:33 -0400 Received: from mx4.wp.pl ([212.77.101.12]:45071 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbgIBNbf (ORCPT ); Wed, 2 Sep 2020 09:31:35 -0400 Received: (wp-smtpd smtp.wp.pl 20456 invoked from network); 2 Sep 2020 15:24:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1599053061; bh=G8wT2xsxFQGcxLMSyMItSjCCDSZ7QEW2M+j2fLIpSHo=; h=From:To:Cc:Subject; b=eLO3vgAU2BsU7IjAtRnGmfcvY97FVSmHO9siIRejPiMKmoKoMB6tDWFUIGIeHOStP WGpdbdyi4OJQuJhJudyjs03ruwMfaFN1nOIXZUPilIcwvnpj7p/Dirl399MgvIS8Ml 9ixh/iECJhYRO44kySY9HJtI3V6Ghc5WJWyOwOF4= Received: from nat-0.staszic.waw.pl (HELO localhost) (antoni.przybylik@wp.pl@[94.240.45.201]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 2 Sep 2020 15:24:21 +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: Wed, 2 Sep 2020 15:24:19 +0200 Message-Id: <20200902132419.61220-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: d17dd52168d66c6852a2c5cf02c92270 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [gbO8] 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. ------------------------------------------------------------------- Changed return type to bool and removed inline sepcifier. 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..179fc9b9400b 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 bool gdm_tty_ready(struct 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