From: Richard Knutsson <ricknu-0@student.ltu.se>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] BIT macro cleanup
Date: Wed, 21 Feb 2007 16:07:38 +0000 [thread overview]
Message-ID: <45DC6E4A.5090903@student.ltu.se> (raw)
In-Reply-To: <45CADD09.70809@bfs.de>
Milind Choudhary wrote:
> there are some setbit & resetbit macros scattered here n there
> e.g.
> ./drivers/net/irda/Via-ircc.h
>
> #define SetBit(val,bit) val= (unsigned char ) (val | (0x1 << bit))
> // Sets bit to 1
> #define ResetBit(val,bit) val= (unsigned char ) (val & ~(0x1 << bit))
> // Sets bit to 0
>
> if we move these somewhere near BIT
>
> #define SETBIT(data,mask) (data |= mask)
> #define RESETBIT(data,mask) (data &= ~mask)
Sounds good! But I think Håkon got a point, both on RESET -> CLEAR and
that mask can be more then one bit.
>
> usually the mask would be generated with BIT
>
> we can use the new ones to get rid of above code
> by using "cr" as data & "uartbit" as mask
>
> what say
Mmm, so what about this?
(This I actually compile-tested ;) (after removing <asm/sizes.h> and
defining SZ_4K))
(mctrl & TIOCM_RTS) ?
SETBITS(cr, UART011_CR_DTR) : CLRBITS(cr, UART011_CR_DTR);
(mctrl & TIOCM_DTR) ?
SETBITS(cr, UART011_CR_DTR) : CLRBITS(cr, UART011_CR_DTR);
(mctrl & TIOCM_OUT1) ?
SETBITS(cr, UART011_CR_OUT1) : CLRBITS(cr, UART011_CR_OUT1);
(mctrl & TIOCM_OUT2) ?
SETBITS(cr, UART011_CR_OUT2) : CLRBITS(cr, UART011_CR_OUT2);
(mctrl & TIOCM_LOOP) ?
SETBITS(cr, UART011_CR_LBE) : CLRBITS(cr, UART011_CR_LBE);
(I just set them to SETBITS and CLRBITS 'cause I think it looks alright)
Richard Knutsson
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-02-21 16:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 8:19 [KJ] BIT macro cleanup walter harms
2007-02-09 17:45 ` Milind Choudhary
2007-02-09 17:55 ` Jaco Kroon
2007-02-20 18:28 ` Milind Choudhary
2007-02-20 19:33 ` Richard Knutsson
2007-02-20 20:30 ` Milind Choudhary
2007-02-21 5:56 ` Richard Knutsson
2007-02-21 9:24 ` Milind Choudhary
2007-02-21 9:39 ` Richard Knutsson
2007-02-21 10:46 ` Milind Choudhary
2007-02-21 11:28 ` Richard Knutsson
2007-02-21 11:59 ` Richard Knutsson
2007-02-21 12:02 ` Darren Jenkins
2007-02-21 12:04 ` Darren Jenkins
2007-02-21 13:26 ` Milind Choudhary
2007-02-21 14:02 ` Milind Choudhary
2007-02-21 14:45 ` Håkon Løvdal
2007-02-21 16:07 ` Richard Knutsson [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-02-07 15:30 Milind Choudhary
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45DC6E4A.5090903@student.ltu.se \
--to=ricknu-0@student.ltu.se \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.