Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2010679pxk; Tue, 1 Sep 2020 13:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvwC2qMrYGOGN03oxpmiP4AqIF5Yj4oxizBR2QWaz0myeRx53zHlKeRlrjxa7ABmT8NAv0 X-Received: by 2002:aa7:cb0a:: with SMTP id s10mr3523180edt.134.1598991532245; Tue, 01 Sep 2020 13:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598991532; cv=none; d=google.com; s=arc-20160816; b=crA5+iuTcvWBBST7Dm/kjpImBed0m1BEptEEcC33UtqMjMS3T8adfAa0HwaxQepVS2 nmdbDu0SBtjoDm467XLv6JUWGFJSqMrN8nM+z0xte2P6R2DJ6RElz0haGZJxyFbq5JHN O9CgOCkfbBXMR0iZeXrhn20/42dFnTPi7xfKY4C9+4Lb2suCZxNvi1yAKzuWc08+agHQ 1RfekPks+9M2x1hX8O3B11dISlX6rTqa2pi+y0t51YAtqE907EM4l/dgMz8IgWq1ioe6 2t+BQGi9bCE+7lmkXI4zrIxYKsDc9XFGtjX6L093/q5IGRP5tmMU/dYY89DRTqI4TSye 9owg== 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=VolP2AdWJDNHJUxzl2uH3Tf1xodNxV4v/c7KNG3s6dM=; b=e/j8QRjgZ/x5QfGu3i8AdMjD7iznIEncGye6dsYlqq7c0usCfwCXimLCve4DFB1TkR 5nRS3CzeRUby6aEdi7SEvpv38wXUBpX7zE36OE6uSsEa36BUtRzwQc8VpAC4Hhk87D78 HE+EcW23C0Pg6hbfrkToNi9nLOeib2/GcFUVwHF/lND4V7EbfxRM8imDHpyL3QtWNwji lg2VU5hW0LpPgdTe4LANn6Abf0U3laV1zS5oE1iQz8QK6avyso8M0E3VbBRnXhmni7ip 4qwp8i8OxLj8U+CCVaKcIlRM1hHXBO009tPd+RxVDOpSq4wu5/L1CmUAFENitIb6q+pu cfrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=MGUliN1V; 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 gy3si1306742ejb.268.2020.09.01.13.18.29; Tue, 01 Sep 2020 13:18:52 -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=MGUliN1V; 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 S1728911AbgIAUQ4 (ORCPT + 99 others); Tue, 1 Sep 2020 16:16:56 -0400 Received: from mx4.wp.pl ([212.77.101.11]:13869 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728580AbgIAUQ4 (ORCPT ); Tue, 1 Sep 2020 16:16:56 -0400 Received: (wp-smtpd smtp.wp.pl 21030 invoked from network); 1 Sep 2020 22:16:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1598991413; bh=VolP2AdWJDNHJUxzl2uH3Tf1xodNxV4v/c7KNG3s6dM=; h=From:To:Cc:Subject; b=MGUliN1VCS1LL2fiONrnIleoysVx67v0G6wvxQ0gZK6rZ9NfHeXyja5+YFH5sQAHq FOc3Tw/3w/d21nYMGzpW+UPDiwscf0dcKMms4oiddJWZcJIXtRs7j9b9eTgilBg+zk M6ksyD1h/ayE8jaQGCtcuL0/qAXmE/xXKzp9G4ds= Received: from 188.146.102.178.nat.umts.dynamic.t-mobile.pl (HELO localhost) (antoni.przybylik@wp.pl@[188.146.102.178]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 1 Sep 2020 22:16:53 +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 22:16:26 +0200 Message-Id: <20200901201626.75405-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: 44cd1ac88d72e20bcf7ed632bb54e9df X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000002 [cXER] 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..c19d82a6f25e 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(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