Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ->*_handlers fields #1357

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions sys/arm/allwinner/aw_nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ aw_nmi_setup_intr(device_t dev, struct intr_irqsrc *isrc,
return (EINVAL);

/* Compare config if this is not first setup. */
if (isrc->isrc_handlers != 0) {
if (nmi_intr->pol != INTR_POLARITY_INVALID ||
nmi_intr->tri != INTR_TRIGGER_INVALID) {
if (pol != nmi_intr->pol || trig != nmi_intr->tri)
return (EINVAL);
else
Expand Down Expand Up @@ -290,9 +291,9 @@ aw_nmi_teardown_intr(device_t dev, struct intr_irqsrc *isrc,

sc = device_get_softc(dev);

if (isrc->isrc_handlers == 0) {
sc->intr.pol = INTR_POLARITY_CONFORM;
sc->intr.tri = INTR_TRIGGER_CONFORM;
if (ISRC_NO_HANDLER(isrc)) {
sc->intr.pol = INTR_POLARITY_INVALID;
sc->intr.tri = INTR_TRIGGER_INVALID;

SC_NMI_WRITE(sc, sc->cfg->enable_reg, ~NMI_IRQ_ENABLE);
}
Expand Down Expand Up @@ -371,8 +372,8 @@ aw_nmi_attach(device_t dev)
xref = OF_xref_from_node(ofw_bus_get_node(dev));
/* Register our isrc */
sc->intr.irq = 0;
sc->intr.pol = INTR_POLARITY_CONFORM;
sc->intr.tri = INTR_TRIGGER_CONFORM;
sc->intr.pol = INTR_POLARITY_INVALID;
sc->intr.tri = INTR_TRIGGER_INVALID;
if (intr_isrc_register(&sc->intr.isrc, sc->dev, 0, "%s,%u",
device_get_nameunit(sc->dev), sc->intr.irq) != 0)
goto error;
Expand Down
15 changes: 8 additions & 7 deletions sys/arm/arm/gic.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ arm_gic_register_isrcs(struct arm_gic_softc *sc, uint32_t num)
name = device_get_nameunit(sc->gic_dev);
for (irq = 0; irq < num; irq++) {
irqs[irq].gi_irq = irq;
irqs[irq].gi_pol = INTR_POLARITY_CONFORM;
irqs[irq].gi_trig = INTR_TRIGGER_CONFORM;
irqs[irq].gi_pol = INTR_POLARITY_INVALID;
irqs[irq].gi_trig = INTR_TRIGGER_INVALID;

isrc = &irqs[irq].gi_isrc;
if (irq <= GIC_LAST_SGI) {
Expand Down Expand Up @@ -291,7 +291,7 @@ arm_gic_reserve_msi_range(device_t dev, u_int start, u_int count)
("%s: Trying to allocate too many MSI IRQs: %d + %d > %d", __func__,
start, count, sc->nirqs));
for (i = 0; i < count; i++) {
KASSERT(sc->gic_irqs[start + i].gi_isrc.isrc_handlers == 0,
KASSERT(ISRC_NO_HANDLER(&sc->gic_irqs[start + i].gi_isrc),
("%s: MSI interrupt %d already has a handler", __func__,
count + i));
KASSERT(sc->gic_irqs[start + i].gi_pol == INTR_POLARITY_CONFORM,
Expand Down Expand Up @@ -867,7 +867,8 @@ arm_gic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
}

/* Compare config if this is not first setup. */
if (isrc->isrc_handlers != 0) {
if (gi->gi_pol != INTR_POLARITY_INVALID ||
gi->gi_trig != INTR_TRIGGER_INVALID) {
if ((pol != INTR_POLARITY_CONFORM && pol != gi->gi_pol) ||
(trig != INTR_TRIGGER_CONFORM && trig != gi->gi_trig))
return (EINVAL);
Expand Down Expand Up @@ -911,9 +912,9 @@ arm_gic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
{
struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;

if (isrc->isrc_handlers == 0 && (gi->gi_flags & GI_FLAG_MSI) == 0) {
gi->gi_pol = INTR_POLARITY_CONFORM;
gi->gi_trig = INTR_TRIGGER_CONFORM;
if (ISRC_NO_HANDLER(isrc) && (gi->gi_flags & GI_FLAG_MSI) == 0) {
gi->gi_pol = INTR_POLARITY_INVALID;
gi->gi_trig = INTR_TRIGGER_INVALID;
}
return (0);
}
Expand Down
6 changes: 3 additions & 3 deletions sys/arm/broadcom/bcm2835/bcm2835_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ bcm_gpio_pic_attach(struct bcm_gpio_softc *sc)
for (irq = 0; irq < sc->sc_maxpins; irq++) {
sc->sc_isrcs[irq].bgi_irq = irq;
sc->sc_isrcs[irq].bgi_mask = BCM_GPIO_MASK(irq);
sc->sc_isrcs[irq].bgi_mode = GPIO_INTR_CONFORM;
sc->sc_isrcs[irq].bgi_mode = GPIO_INTR_INVALID;

error = intr_isrc_register(&sc->sc_isrcs[irq].bgi_isrc,
sc->sc_dev, 0, "%s,%u", name, irq);
Expand Down Expand Up @@ -1211,7 +1211,7 @@ bcm_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
* If this is a setup for another handler,
* only check that its configuration match.
*/
if (isrc->isrc_handlers != 0)
if (bgi->bgi_mode == GPIO_INTR_INVALID)
return (bgi->bgi_mode == mode ? 0 : EINVAL);

bcm_gpio_pic_config_intr(sc, bgi, mode);
Expand All @@ -1225,7 +1225,7 @@ bcm_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
struct bcm_gpio_softc *sc = device_get_softc(dev);
struct bcm_gpio_irqsrc *bgi = (struct bcm_gpio_irqsrc *)isrc;

if (isrc->isrc_handlers == 0)
if (ISRC_NO_HANDLER(isrc))
bcm_gpio_pic_config_intr(sc, bgi, GPIO_INTR_CONFORM);
return (0);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/arm/broadcom/bcm2835/bcm2836.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bcm_lintc_setup_intr(device_t dev, struct intr_irqsrc *isrc,
{
struct bcm_lintc_softc *sc;

if (isrc->isrc_handlers == 0 && isrc->isrc_flags & INTR_ISRCF_PPI) {
if (ISRC_NO_HANDLER(isrc) && isrc->isrc_flags & INTR_ISRCF_PPI) {
sc = device_get_softc(dev);
BCM_LINTC_LOCK(sc);
CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu);
Expand Down
8 changes: 4 additions & 4 deletions sys/arm/freescale/imx/imx_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
struct gpio_irqsrc *gi;

sc = device_get_softc(dev);
if (isrc->isrc_handlers == 0) {
if (ISRC_NO_HANDLER(isrc)) {
gi = (struct gpio_irqsrc *)isrc;
gi->gi_mode = GPIO_INTR_CONFORM;
gi->gi_mode = GPIO_INTR_INVALID;

// XXX Not sure this is necessary
mtx_lock_spin(&sc->sc_mtx);
Expand Down Expand Up @@ -338,7 +338,7 @@ gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
return (EINVAL);

/* Compare config if this is not first setup. */
if (isrc->isrc_handlers != 0)
if (gi->gi_mode == GPIO_INTR_INVALID)
return (gi->gi_mode == mode ? 0 : EINVAL);
gi->gi_mode = mode;

Expand Down Expand Up @@ -497,7 +497,7 @@ gpio_pic_register_isrcs(struct imx51_gpio_softc *sc)
name = device_get_nameunit(sc->dev);
for (irq = 0; irq < NGPIO; irq++) {
sc->gpio_pic_irqsrc[irq].gi_irq = irq;
sc->gpio_pic_irqsrc[irq].gi_mode = GPIO_INTR_CONFORM;
sc->gpio_pic_irqsrc[irq].gi_mode = GPIO_INTR_INVALID;

error = intr_isrc_register(&sc->gpio_pic_irqsrc[irq].gi_isrc,
sc->dev, 0, "%s,%u", name, irq);
Expand Down
9 changes: 7 additions & 2 deletions sys/arm/mv/mvebu_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct mvebu_gpio_irqsrc {
u_int irq;
bool is_level;
bool is_inverted;
bool is_setup;
};

struct mvebu_gpio_softc;
Expand Down Expand Up @@ -359,6 +360,7 @@ mvebu_gpio_pic_attach(struct mvebu_gpio_softc *sc)
sc->isrcs[irq].irq = irq;
sc->isrcs[irq].is_level = false;
sc->isrcs[irq].is_inverted = false;
sc->isrcs[irq].is_setup = false;
rv = intr_isrc_register(&sc->isrcs[irq].isrc,
sc->dev, 0, "%s,%u", name, irq);
if (rv != 0)
Expand Down Expand Up @@ -597,13 +599,14 @@ mvebu_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
* If this is a setup for another handler,
* only check that its configuration match.
*/
if (isrc->isrc_handlers != 0)
if (mgi->is_setup)
return (
mgi->is_level == level && mgi->is_inverted == inverted ?
0 : EINVAL);

mgi->is_level = level;
mgi->is_inverted = inverted;
mgi->is_setup = true;

GPIO_LOCK(sc);
intr_modify(sc, GPIO_DATA_IN_POL, mgi, inverted ? 1 : 0);
Expand All @@ -623,8 +626,10 @@ mvebu_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
sc = device_get_softc(dev);
mgi = (struct mvebu_gpio_irqsrc *)isrc;

if (isrc->isrc_handlers == 0)
if (ISRC_NO_HANDLER(isrc)) {
mvebu_gpio_isrc_mask(sc, mgi, 0);
mgi->is_setup = false;
}
return (0);
}

Expand Down
14 changes: 7 additions & 7 deletions sys/arm/nvidia/tegra_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
#define GPIO_MSK_INT_ENB 0xD0
#define GPIO_MSK_INT_LVL 0xE0

#define GPIO_UNSET 0xFFFFFFFF

char *tegra_gpio_port_names[] = {
"A", "B", "C", "D", /* Bank 0 */
"E", "F", "G", "H", /* Bank 1 */
Expand Down Expand Up @@ -443,7 +445,7 @@
name = device_get_nameunit(sc->dev);
for (irq = 0; irq < sc->gpio_npins; irq++) {
sc->isrcs[irq].irq = irq;
sc->isrcs[irq].cfgreg = 0;
sc->isrcs[irq].cfgreg = GPIO_UNSET;
error = intr_isrc_register(&sc->isrcs[irq].isrc,
sc->dev, 0, "%s,%u", name, irq);
if (error != 0)
Expand Down Expand Up @@ -672,28 +674,26 @@
* If this is a setup for another handler,
* only check that its configuration match.
*/
if (isrc->isrc_handlers != 0)
if (tgi->cfgreg != GPIO_UNSET)
return (tgi->cfgreg == cfgreg ? 0 : EINVAL);

tgi->cfgreg = cfgreg;
intr_write_modify(sc, GPIO_INT_LVL, tgi, cfgreg, GPIO_INT_LVL_MASK);
tegra_gpio_pic_enable_intr(dev, isrc);

return (0);
}

static int
tegra_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
struct resource *res, struct intr_map_data *data)

Check failure on line 688 in sys/arm/nvidia/tegra_gpio.c

View workflow job for this annotation

GitHub Actions / Style Checker

if this code is redundant consider removing it
{
struct tegra_gpio_softc *sc;
struct tegra_gpio_irqsrc *tgi;

sc = device_get_softc(dev);
tgi = (struct tegra_gpio_irqsrc *)isrc;

if (isrc->isrc_handlers == 0)
tegra_gpio_isrc_mask(sc, tgi, 0);
if (ISRC_NO_HANDLER(isrc))
tgi->cfgreg = GPIO_UNSET;

return (0);
}

Expand Down
23 changes: 4 additions & 19 deletions sys/arm/nvidia/tegra_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,33 +709,17 @@
{
}

#if defined(WITNESS) || defined(INVARIANTS)
static int
tegra_pcib_msi_setup_intr(device_t dev, struct intr_irqsrc *isrc,
struct resource *res, struct intr_map_data *data)
{
if (data == NULL || data->type != INTR_MAP_DATA_MSI)
return (ENOTSUP);

if (isrc->isrc_handlers == 0)
tegra_pcib_msi_enable_intr(dev, isrc);

return (0);
}

static int
tegra_pcib_msi_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
struct resource *res, struct intr_map_data *data)
{
struct tegra_pcib_softc *sc;
struct tegra_pcib_irqsrc *tgi;

sc = device_get_softc(dev);
tgi = (struct tegra_pcib_irqsrc *)isrc;

if (isrc->isrc_handlers == 0)
tegra_pcib_isrc_mask(sc, tgi, 0);
return (0);
}
#endif

static int
tegra_pcib_msi_alloc_msi(device_t dev, device_t child, int count, int maxcount,
Expand Down Expand Up @@ -1602,11 +1586,12 @@
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, tegra_pcib_msi_disable_intr),
DEVMETHOD(pic_enable_intr, tegra_pcib_msi_enable_intr),
#if defined(WITNESS) || defined(INVARIANTS)
DEVMETHOD(pic_setup_intr, tegra_pcib_msi_setup_intr),
DEVMETHOD(pic_teardown_intr, tegra_pcib_msi_teardown_intr),
#endif
DEVMETHOD(pic_post_filter, tegra_pcib_msi_post_filter),
DEVMETHOD(pic_post_ithread, tegra_pcib_msi_post_ithread),
DEVMETHOD(pic_pre_ithread, tegra_pcib_msi_pre_ithread),

Check warning on line 1594 in sys/arm/nvidia/tegra_pcie.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
#endif

/* OFW bus interface */
Expand Down
15 changes: 8 additions & 7 deletions sys/arm64/arm64/gic_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ gic_v3_reserve_msi_range(device_t dev, u_int start, u_int count)
("%s: Trying to allocate too many MSI IRQs: %d + %d > %d", __func__,
start, count, sc->gic_nirqs));
for (i = 0; i < count; i++) {
KASSERT(sc->gic_irqs[start + i].gi_isrc.isrc_handlers == 0,
KASSERT(ISRC_NO_HANDLER(&sc->gic_irqs[start + i].gi_isrc),
("%s: MSI interrupt %d already has a handler", __func__,
count + i));
KASSERT(sc->gic_irqs[start + i].gi_pol == INTR_POLARITY_CONFORM,
Expand Down Expand Up @@ -360,8 +360,8 @@ gic_v3_attach(device_t dev)
struct intr_irqsrc *isrc;

sc->gic_irqs[irq].gi_irq = irq;
sc->gic_irqs[irq].gi_pol = INTR_POLARITY_CONFORM;
sc->gic_irqs[irq].gi_trig = INTR_TRIGGER_CONFORM;
sc->gic_irqs[irq].gi_pol = INTR_POLARITY_INVALID;
sc->gic_irqs[irq].gi_trig = INTR_TRIGGER_INVALID;

isrc = &sc->gic_irqs[irq].gi_isrc;
if (irq <= GIC_LAST_SGI) {
Expand Down Expand Up @@ -913,7 +913,8 @@ gic_v3_setup_intr(device_t dev, struct intr_irqsrc *isrc,
return (EINVAL);

/* Compare config if this is not first setup. */
if (isrc->isrc_handlers != 0) {
if (gi->gi_pol != INTR_POLARITY_INVALID ||
gi->gi_trig != INTR_TRIGGER_INVALID) {
if (pol != gi->gi_pol || trig != gi->gi_trig)
return (EINVAL);
else
Expand Down Expand Up @@ -950,9 +951,9 @@ gic_v3_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
{
struct gic_v3_irqsrc *gi = (struct gic_v3_irqsrc *)isrc;

if (isrc->isrc_handlers == 0 && (gi->gi_flags & GI_FLAG_MSI) == 0) {
gi->gi_pol = INTR_POLARITY_CONFORM;
gi->gi_trig = INTR_TRIGGER_CONFORM;
if (ISRC_NO_HANDLER(isrc) && (gi->gi_flags & GI_FLAG_MSI) == 0) {
gi->gi_pol = INTR_POLARITY_INVALID;
gi->gi_trig = INTR_TRIGGER_INVALID;
}

return (0);
Expand Down
2 changes: 1 addition & 1 deletion sys/arm64/qoriq/qoriq_gpio_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ qoriq_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
sc = device_get_softc(dev);
qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc;

if (isrc->isrc_handlers > 0)
if (!ISRC_NO_HANDLER(isrc))
return (0);

GPIO_LOCK(&sc->base);
Expand Down
8 changes: 4 additions & 4 deletions sys/arm64/rockchip/rk_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ rk_gpio_attach(device_t dev)

for (i = 0; i < RK_GPIO_MAX_PINS; i++) {
sc->isrcs[i].irq = i;
sc->isrcs[i].mode = GPIO_INTR_CONFORM;
sc->isrcs[i].mode = GPIO_INTR_INVALID;
if ((err = intr_isrc_register(RK_GPIO_ISRC(sc, i),
dev, 0, "%s", device_get_nameunit(dev)))) {
device_printf(dev, "Can not register isrc %d\n", err);
Expand Down Expand Up @@ -697,7 +697,7 @@ rk_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
return (EINVAL);
}

if (isrc->isrc_handlers != 0) {
if (rkisrc->mode == GPIO_INTR_INVALID) {
device_printf(dev, "Handler already attached\n");
return (rkisrc->mode == mode ? 0 : EINVAL);
}
Expand Down Expand Up @@ -762,8 +762,8 @@ rk_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,

irqsrc = (struct rk_pin_irqsrc *)isrc;

if (isrc->isrc_handlers == 0) {
irqsrc->mode = GPIO_INTR_CONFORM;
if (ISRC_NO_HANDLER(isrc)) {
irqsrc->mode = GPIO_INTR_INVALID;
RK_GPIO_LOCK(sc);
rk_gpio_write_bit(sc, RK_GPIO_INTEN, irqsrc->irq, 0);
rk_gpio_write_bit(sc, RK_GPIO_INTMASK, irqsrc->irq, 0);
Expand Down
8 changes: 4 additions & 4 deletions sys/dev/gpio/pl061.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
return (EINVAL);
}

if (isrc->isrc_handlers != 0) {
if (irqsrc->mode == GPIO_INTR_INVALID) {
dprintf("%s: handler already attached\n", __func__);
return (irqsrc->mode == mode ? 0 : EINVAL);
}
Expand Down Expand Up @@ -363,8 +363,8 @@
dprintf("%s: calling teardown interrupt %#x\n", __func__, mask);

sc = device_get_softc(dev);
if (isrc->isrc_handlers == 0) {
irqsrc->mode = GPIO_INTR_CONFORM;
if (ISRC_NO_HANDLER(isrc)) {
irqsrc->mode = GPIO_INTR_INVALID;
PL061_LOCK(sc);
mask_and_set(sc, PL061_INTMASK, mask, 0);
PL061_UNLOCK(sc);
Expand Down Expand Up @@ -478,10 +478,10 @@
"trying to register pin %d name %s\n", irq, name);
}
sc->sc_isrcs[irq].irq = irq;
sc->sc_isrcs[irq].mode = GPIO_INTR_CONFORM;
sc->sc_isrcs[irq].mode = GPIO_INTR_INVALID;
ret = intr_isrc_register(PIC_INTR_ISRC(sc, irq), dev, 0,
"%s", name);
if (ret) {

Check warning on line 484 in sys/dev/gpio/pl061.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
device_printf(dev, "can't register isrc %d\n", ret);
goto free_isrc;
}
Expand Down
Loading
Loading