Commit 031366ea authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman

staging: rts5208: Remove TRACE_RET and TRACE_GOTO macros

Remove these flow hiding macros.

Miscellanea:

o Add a macro and function to replace a large inline
o Simplify #includes
o Add trace.c and update Makefile
o Remove static inline filename function and use kbasename instead

This reduces object size quite a lot: ~350KB (x86-64 allyesconfig)

$ size drivers/staging/rts5208/built-in.o*
   text	   data	    bss	    dec	    hex	filename
 248385	  36728	  77888	 363001	  589f9	drivers/staging/rts5208/built-in.o.new
 506691	  83352	 115896	 705939	  ac593	drivers/staging/rts5208/built-in.o.old

Done via coccinelle script and some typing.

@@
expression chip;
expression ret;
@@

-	TRACE_RET(chip, ret);
+	rtsx_trace(chip);
+	return ret;

@@
expression chip;
identifier label;
@@

-	TRACE_GOTO(chip, label);
+	rtsx_trace(chip);
+	goto label;
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da3c8dee
......@@ -3,4 +3,4 @@ obj-$(CONFIG_RTS5208) := rts5208.o
ccflags-y := -Idrivers/scsi
rts5208-y := rtsx.o rtsx_chip.o rtsx_transport.o rtsx_scsi.o \
rtsx_card.o general.o sd.o xd.o ms.o spi.o
rtsx_card.o general.o sd.o xd.o ms.o spi.o trace.o
This diff is collapsed.
......@@ -26,12 +26,6 @@
#include <linux/workqueue.h>
#include "rtsx.h"
#include "rtsx_chip.h"
#include "rtsx_transport.h"
#include "rtsx_scsi.h"
#include "rtsx_card.h"
#include "general.h"
#include "ms.h"
#include "sd.h"
#include "xd.h"
......
......@@ -46,9 +46,6 @@
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>
#include "trace.h"
#include "general.h"
#define CR_DRIVER_NAME "rts5208"
#define pci_get_bus_and_slot(bus, devfn) \
......@@ -181,4 +178,14 @@ enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF};
int rtsx_read_pci_cfg_byte(u8 bus, u8 dev, u8 func, u8 offset, u8 *val);
#define _MSG_TRACE
#include "trace.h"
#include "rtsx_chip.h"
#include "rtsx_transport.h"
#include "rtsx_scsi.h"
#include "rtsx_card.h"
#include "rtsx_sys.h"
#include "general.h"
#endif /* __REALTEK_RTSX_H */
......@@ -27,13 +27,6 @@
#include <linux/kernel.h>
#include "rtsx.h"
#include "rtsx_transport.h"
#include "rtsx_scsi.h"
#include "rtsx_card.h"
#include "rtsx_sys.h"
#include "general.h"
#include "sd.h"
#include "xd.h"
#include "ms.h"
......@@ -657,8 +650,10 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
dev_dbg(rtsx_dev(chip), "Switch SSC clock to %dMHz (cur_clk = %d)\n",
clk, chip->cur_clk);
if ((clk <= 2) || (N > max_N))
TRACE_RET(chip, STATUS_FAIL);
if ((clk <= 2) || (N > max_N)) {
rtsx_trace(chip);
return STATUS_FAIL;
}
mcu_cnt = (u8)(125/clk + 3);
if (mcu_cnt > 7)
......@@ -697,8 +692,10 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
}
retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
if (retval < 0)
TRACE_RET(chip, STATUS_ERROR);
if (retval < 0) {
rtsx_trace(chip);
return STATUS_ERROR;
}
udelay(10);
RTSX_WRITE_REG(chip, CLK_CTL, CLK_LOW_FREQ, 0);
......@@ -790,7 +787,8 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
default:
dev_dbg(rtsx_dev(chip), "Try to switch to an illegal clock (%d)\n",
clk);
TRACE_RET(chip, STATUS_FAIL);
rtsx_trace(chip);
return STATUS_FAIL;
}
RTSX_WRITE_REG(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
......@@ -893,8 +891,10 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
if (retval != STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
udelay(chip->pmos_pwr_on_interval);
......@@ -902,8 +902,10 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
if (retval != STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
......@@ -932,8 +934,10 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
unsigned int lun = SCSI_LUN(srb);
int i;
if (chip->rw_card[lun] == NULL)
TRACE_RET(chip, STATUS_FAIL);
if (chip->rw_card[lun] == NULL) {
rtsx_trace(chip);
return STATUS_FAIL;
}
for (i = 0; i < 3; i++) {
chip->rw_need_retry = 0;
......@@ -942,11 +946,14 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
if (retval != STATUS_SUCCESS) {
if (rtsx_check_chip_exist(chip) != STATUS_SUCCESS) {
rtsx_release_chip(chip);
TRACE_RET(chip, STATUS_FAIL);
rtsx_trace(chip);
return STATUS_FAIL;
}
if (detect_card_cd(chip, chip->cur_card) !=
STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
if (!chip->rw_need_retry) {
dev_dbg(rtsx_dev(chip), "RW fail, but no need to retry\n");
......@@ -975,8 +982,10 @@ int card_share_mode(struct rtsx_chip *chip, int card)
value = CARD_SHARE_48_MS;
else if (card == XD_CARD)
value = CARD_SHARE_48_XD;
else
TRACE_RET(chip, STATUS_FAIL);
else {
rtsx_trace(chip);
return STATUS_FAIL;
}
} else if (CHECK_PID(chip, 0x5288)) {
mask = 0x03;
......@@ -986,11 +995,14 @@ int card_share_mode(struct rtsx_chip *chip, int card)
value = CARD_SHARE_BAROSSA_MS;
else if (card == XD_CARD)
value = CARD_SHARE_BAROSSA_XD;
else
TRACE_RET(chip, STATUS_FAIL);
else {
rtsx_trace(chip);
return STATUS_FAIL;
}
} else {
TRACE_RET(chip, STATUS_FAIL);
rtsx_trace(chip);
return STATUS_FAIL;
}
RTSX_WRITE_REG(chip, CARD_SHARE_MODE, mask, value);
......@@ -1014,15 +1026,19 @@ int select_card(struct rtsx_chip *chip, int card)
mod = XD_MOD_SEL;
else if (card == SPI_CARD)
mod = SPI_MOD_SEL;
else
TRACE_RET(chip, STATUS_FAIL);
else {
rtsx_trace(chip);
return STATUS_FAIL;
}
RTSX_WRITE_REG(chip, CARD_SELECT, 0x07, mod);
chip->cur_card = card;
retval = card_share_mode(chip, card);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
if (retval != STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
}
return STATUS_SUCCESS;
......@@ -1067,12 +1083,15 @@ int detect_card_cd(struct rtsx_chip *chip, int card)
card_cd = XD_EXIST;
} else {
dev_dbg(rtsx_dev(chip), "Wrong card type: 0x%x\n", card);
TRACE_RET(chip, STATUS_FAIL);
rtsx_trace(chip);
return STATUS_FAIL;
}
status = rtsx_readl(chip, RTSX_BIPR);
if (!(status & card_cd))
TRACE_RET(chip, STATUS_FAIL);
if (!(status & card_cd)) {
rtsx_trace(chip);
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
......
This diff is collapsed.
......@@ -989,19 +989,21 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len);
int rtsx_check_chip_exist(struct rtsx_chip *chip);
#define RTSX_WRITE_REG(chip, addr, mask, data) \
do { \
int retval = rtsx_write_register((chip), (addr), (mask), (data)); \
if (retval != STATUS_SUCCESS) { \
TRACE_RET((chip), retval); \
} \
} while (0)
do { \
int retval = rtsx_write_register(chip, addr, mask, data); \
if (retval != STATUS_SUCCESS) { \
rtsx_trace(chip); \
return retval; \
} \
} while (0)
#define RTSX_READ_REG(chip, addr, data) \
do { \
int retval = rtsx_read_register((chip), (addr), (data)); \
if (retval != STATUS_SUCCESS) { \
TRACE_RET((chip), retval); \
} \
} while (0)
do { \
int retval = rtsx_read_register(chip, addr, data); \
if (retval != STATUS_SUCCESS) { \
rtsx_trace(chip); \
return retval; \
} \
} while (0)
#endif /* __REALTEK_RTSX_CHIP_H */
This diff is collapsed.
......@@ -25,10 +25,6 @@
#include <linux/sched.h>
#include "rtsx.h"
#include "rtsx_scsi.h"
#include "rtsx_transport.h"
#include "rtsx_chip.h"
#include "rtsx_card.h"
/***********************************************************************
* Scatter-gather transfer buffer access routines
......@@ -276,7 +272,8 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout)
dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
chip->int_reg);
err = -ETIMEDOUT;
TRACE_GOTO(chip, finish_send_cmd);
rtsx_trace(chip);
goto finish_send_cmd;
}
spin_lock_irq(&rtsx->reg_lock);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment