From 6b5c22d8680573c8a6b259d78ba3c8435514fde9 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Mon, 22 Sep 2008 17:05:21 -0300 Subject: Rework/simplify debug macros. Instead of cut&paste of the name of the current function everywhere, just use cpp's __FUNCTION__ predefined macro. Create two macros to exit a function, named LEAVE() and RETURN(). Functions returning void should call LEAVE() and then explicitly return for now. "Logged" function calls are indented, so a review was done to ensure functions with a ENTER() also have the proper exit macro. The DEBUG macro was changed to have variadic arguments, and this way it is no longer required to prefix arguments with VERBLEV, but now it also is not possible to use another "verbosity value", but it wasn't used in any of the DEBUG macro calls. --- src/smi_i2c.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'src/smi_i2c.c') diff --git a/src/smi_i2c.c b/src/smi_i2c.c index a829463..f38b514 100644 --- a/src/smi_i2c.c +++ b/src/smi_i2c.c @@ -40,31 +40,16 @@ authorization from the XFree86 Project and Silicon Motion. #include "smi.h" -#undef VERBLEV -#undef ENTER_PROC -#undef DEBUG_PROC -#undef LEAVE_PROC -#undef DEBUG -#define VERBLEV 2 -#define ENTER_PROC(PROCNAME) -#define DEBUG_PROC(PROCNAME) -#define LEAVE_PROC(PROCNAME) -#define DEBUG(arg) - static void SMI_I2CPutBits(I2CBusPtr b, int clock, int data) { SMIPtr pSmi = SMIPTR(xf86Screens[b->scrnIndex]); unsigned int reg = 0x30; - ENTER_PROC("SMI_I2CPutBits"); - if (clock) reg |= 0x01; if (data) reg |= 0x02; VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, reg); - - LEAVE_PROC("SMI_I2CPutBits"); } static void @@ -73,12 +58,8 @@ SMI_I2CGetBits(I2CBusPtr b, int *clock, int *data) SMIPtr pSmi = SMIPTR(xf86Screens[b->scrnIndex]); unsigned int reg = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72); - ENTER_PROC("SMI_I2CGetBits"); - *clock = reg & 0x04; *data = reg & 0x08; - - LEAVE_PROC("SMI_I2CGetBits"); } Bool @@ -86,14 +67,10 @@ SMI_I2CInit(ScrnInfoPtr pScrn) { SMIPtr pSmi = SMIPTR(pScrn); - ENTER_PROC("SMI_I2CInit"); - if (pSmi->I2C == NULL) { I2CBusPtr I2CPtr = xf86CreateI2CBusRec(); - if (I2CPtr == NULL) { - LEAVE_PROC("SMI_I2CInit"); + if (I2CPtr == NULL) return FALSE; - } I2CPtr->BusName = "I2C bus"; I2CPtr->scrnIndex = pScrn->scrnIndex; @@ -102,14 +79,12 @@ SMI_I2CInit(ScrnInfoPtr pScrn) if (!xf86I2CBusInit(I2CPtr)) { xf86DestroyI2CBusRec(I2CPtr, TRUE, TRUE); - LEAVE_PROC("SMI_I2CInit"); return FALSE; } pSmi->I2C = I2CPtr; } - LEAVE_PROC("SMI_I2CInit"); return TRUE; } -- cgit v1.2.3