On Fri, May 12, 2023 at 11:58 AM Jiawen Wu <jiawenwu@xxxxxxxxxxxxxx> wrote: ... > > > + switch (type) { > > > + case IRQ_TYPE_EDGE_BOTH: > > > + level |= BIT(hwirq); > > > + break; > > > + case IRQ_TYPE_EDGE_RISING: > > > + level |= BIT(hwirq); > > > + polarity |= BIT(hwirq); > > > + break; > > > + case IRQ_TYPE_EDGE_FALLING: > > > + level |= BIT(hwirq); > > > > > + polarity &= ~BIT(hwirq); > > > > This... > > > > > + break; > > > + case IRQ_TYPE_LEVEL_HIGH: > > > + level &= ~BIT(hwirq); > > > > ...and this can be done outside of the switch-case. Then you simply set certain > > bits where it's needed. > > > > > + polarity |= BIT(hwirq); > > > + break; > > > + case IRQ_TYPE_LEVEL_LOW: > > > + level &= ~BIT(hwirq); > > > + polarity &= ~BIT(hwirq); > > > + break; > > > > default? > > Do you mean that treat IRQ_TYPE_LEVEL_LOW as default case, clear level and > polarity firstly, then set the bits in other needed case? level &= ... polarity &= ... switch () { case X: level |= ... break; case Y: polarity |= ... break; case Z: ... break; default: ...handle error... } -- With Best Regards, Andy Shevchenko