Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp582880pxk; Wed, 2 Sep 2020 09:19:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbO7sOeolYaLYNqg/s7UIMaladSwzG1hxy97W1pERcMYa934JlpQqjoDEhjWc353KMcZ7G X-Received: by 2002:a50:9b5e:: with SMTP id a30mr820886edj.49.1599063540698; Wed, 02 Sep 2020 09:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599063540; cv=none; d=google.com; s=arc-20160816; b=gKZKgtWFKjkuLnGCIg7jQU4t1SVtDpyyXlD1iOkQhbnoQ+q+2C5+OCBphLUYO181H7 O/FE1yOg3gGmCBEhfOnay20YNowLEnCi8YIgY4tOY/ai4vrU5P0BKLRwn1hgkEHlkYu+ qY4e3RibM+iKWckJyUrDb832C6eddhQsHxP7V9rfZQo8ICjmWYhM3A9/JhjFzdMtKqYX yZeav2nmtd9sZ9X5gdK/O2AGsXZhACJED6J1LqPjC1y7QDE6B1zpF+xtSp1z//3MoVVk XUfE/k2hnpntXtXPIOFLNg02uCQFJEeyxJkpSXSZLAyjwzPJCzhSCNWAYVvCvxyIYGdK h+JQ== 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=TtJS+HIXNquG/4RotPjKkCWhjDhR7eI0A8TOlVPI5TE=; b=Pe2IQltuDAnA6x39HHhYkBKtqGCr6bJ8lXWronAiyRxq9MaQ+gBAiHXjEbXlc/MySU NL80NqbtoQhhDLcIZQchfzs+4jn6WpAAHpUL+ZD24N96F54StO7BxUtqLJgSOs3xNNQ7 5Ou2Uo98K2e4SrvGElXyQbgbxEhO9nhIVRAQFU+htLtmBVetqkSTQeBRyXMPL/nD5+bB YafcOVyVB4DG5PAMv+GN7IkJgB8quWuokEtCbntSOKCO9YT8NcmAbx1+AvM/+0Oovvrn dHKz5B+7RGkbVam2ETQaiv0VDejUGTol5oqLDLzwz3MXgMwv6CIw8+JCaf3uKEqHu5+S NB0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=nQ4KIhzm; 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 s23si2728184edi.84.2020.09.02.09.18.36; Wed, 02 Sep 2020 09:19:00 -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=nQ4KIhzm; 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 S1728481AbgIBQQj (ORCPT + 99 others); Wed, 2 Sep 2020 12:16:39 -0400 Received: from mx3.wp.pl ([212.77.101.9]:46386 "EHLO mx3.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbgIBQQZ (ORCPT ); Wed, 2 Sep 2020 12:16:25 -0400 Received: (wp-smtpd smtp.wp.pl 12462 invoked from network); 2 Sep 2020 18:16:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1599063380; bh=TtJS+HIXNquG/4RotPjKkCWhjDhR7eI0A8TOlVPI5TE=; h=From:To:Cc:Subject; b=nQ4KIhzmDDfe4a/FvrHXxX3BvSkcD1f0JOrSU2NzeRDhYMzWYtozjemW9vO+aF26X NYOsP0Ovy5kM6pPXCagjhWLy7AFu4C4yW7MK9SoHc0M35Zl+QFTe+jWeDqP5rCfOok Tj2dW2HGeJQFpTCGFM/4g+M5bqg2yHHaH3rG6Y74= 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 ; 2 Sep 2020 18:16:20 +0200 From: Antoni Przybylik To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Antoni Przybylik Subject: [PATCH v2 1/2] staging: gdm724x: gdm_tty: replaced macro with a function Date: Wed, 2 Sep 2020 18:16:16 +0200 Message-Id: <20200902161616.64638-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: a67d8e816817753c22be7aa74a62fbd1 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0100004 [sdei] 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..34a13d98c029 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(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