RE: [Openipmi-developer] [PATCH 11/12] IPMI: Fix BT long busy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Morton wrote:

> Corey Minyard <[email protected]> wrote:

>> +	BT_CONTROL(BT_CLR_WR_PTR);	/* always reset */

> argh.

>> #define BT_STATUS	bt->io->inputb(bt->io, 0)
>> #define BT_CONTROL(x)	bt->io->outputb(bt->io, 0, x)
>>
>> #define BMC2HOST	bt->io->inputb(bt->io, 1)
>> #define HOST2BMC(x)	bt->io->outputb(bt->io, 1, x)
>>
>> #define BT_INTMASK_R	bt->io->inputb(bt->io, 2)
>> #define BT_INTMASK_W(x)	bt->io->outputb(bt->io, 2, x)

> Please don't write macros which require that the caller have a particular
> local variable of a particular name.
>
> In fact, please don't write macros.
>
> All the above would be perfectly nice as
>
> static inline void bt_control(struct si_sm_data *bt, int val)
> {
> 	bt->io->outputb(bt->io, val);
> }

Well, needs an input and an output function to route through `inputb' /
`outputb'.  But the important values here, which _should_ be macros, are the
register offsets:

#define BT_STATUS_REG  0   /* Read-only */
#define BT_CONTROL_REG 0   /* Write-only */
#define BT_DATA_REG    1   /* Read/write */
#define BT_INTMASK_REG 2   /* Read/write */

static inline int bt_control_read(struct si_sm_data *bt, int reg)
{
	return bt->io->inputb(bt->io, reg);
}

static inline void bt_control_write(struct si_sm_data *bt, int reg, int data)
{
	bt->io->outputb(bt->io, reg, data);
}

bt_control_read(bt, BT_STATUS_REG);            /* was BT_STATUS()    */
bt_control_write(bt, BT_CONTROL_REG, data);    /* was BT_CONTROL()   */
bt_control_read(bt, BT_DATA_REG);              /* was BMC2HOST()     */
bt_control_write(bt, BT_DATA_REG, data);       /* was HOST2BMC()     */
bt_control_read(bt, BT_INTMASK_REG);           /* was BT_INTMASK_R() */
bt_control_write(bt, BT_INTMASK_REG, data);    /* was BT_INTMASK_W() */

...

But the old macro names are more readable at the calling point.  What about
making them into inlines (which call the generic _read / _write())?  Maybe
with lowercased versions of the original macro names.

>Bela<
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux