Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755451AbcJNRXr (ORCPT ); Fri, 14 Oct 2016 13:23:47 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33632 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753369AbcJNRXm (ORCPT ); Fri, 14 Oct 2016 13:23:42 -0400 From: Fernando Apesteguia To: lidza.louina@gmail.com Cc: markh@compro.net, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Fernando Apesteguia Subject: [PATCH] staging: dgnc: replace DGNC_VERIFY_BOARD macro Date: Fri, 14 Oct 2016 19:22:57 +0200 Message-Id: <1476465777-720-1-git-send-email-fernando.apesteguia@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4764 Lines: 182 The patch replaces the macro with a function (dgnc_get_board) and substitutes the macro statement with a call to that function and a comparison on the returned value. This removes a checkpatch warning. Signed-off-by: Fernando Apesteguia --- drivers/staging/dgnc/dgnc_sysfs.c | 74 +++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 290bf6e..3ea23a9 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -90,17 +90,21 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) driver_remove_file(driverfs, &driver_attr_pollrate); } -#define DGNC_VERIFY_BOARD(p, bd) \ - do { \ - if (!p) \ - return 0; \ - \ - bd = dev_get_drvdata(p); \ - if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ - return 0; \ - if (bd->state != BOARD_READY) \ - return 0; \ - } while (0) +static struct dgnc_board *dgnc_get_board(struct device *p) +{ + struct dgnc_board *bd; + + if (!p) + return NULL; + + bd = dev_get_drvdata(p); + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return NULL; + if (bd->state != BOARD_READY) + return NULL; + + return bd; +} static ssize_t vpd_show(struct device *p, struct device_attribute *attr, char *buf) @@ -109,7 +113,9 @@ static ssize_t vpd_show(struct device *p, struct device_attribute *attr, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); @@ -130,7 +136,9 @@ static ssize_t serial_number_show(struct device *p, struct dgnc_board *bd; int count = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; if (bd->serial_num[0] == '\0') count += sprintf(buf + count, "\n"); @@ -148,7 +156,9 @@ static ssize_t ports_state_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, @@ -166,7 +176,9 @@ static ssize_t ports_baud_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, @@ -184,7 +196,9 @@ static ssize_t ports_msignals_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { struct channel_t *ch = bd->channels[i]; @@ -215,7 +229,9 @@ static ssize_t ports_iflag_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", @@ -233,7 +249,9 @@ static ssize_t ports_cflag_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", @@ -251,7 +269,9 @@ static ssize_t ports_oflag_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", @@ -269,7 +289,9 @@ static ssize_t ports_lflag_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", @@ -287,7 +309,9 @@ static ssize_t ports_digi_flag_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", @@ -305,7 +329,9 @@ static ssize_t ports_rxcount_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", @@ -323,7 +349,9 @@ static ssize_t ports_txcount_show(struct device *p, int count = 0; int i = 0; - DGNC_VERIFY_BOARD(p, bd); + bd = dgnc_get_board(p); + if (!bd) + return 0; for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", -- 2.7.4