Module Name: src Committed By: thorpej Date: Tue Jun 19 02:08:12 UTC 2018
Modified Files: src/sys/dev/i2c: axppmic.c Log Message: Use the device_compatible_entry mechanism rather than of_compat_data; all of the OF / FDT data we need is already in the i2c_attach_args. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/axppmic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/axppmic.c diff -u src/sys/dev/i2c/axppmic.c:1.11 src/sys/dev/i2c/axppmic.c:1.12 --- src/sys/dev/i2c/axppmic.c:1.11 Sat Jun 16 21:22:13 2018 +++ src/sys/dev/i2c/axppmic.c Tue Jun 19 02:08:12 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $ */ +/* $NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $ */ /*- * Copyright (c) 2014-2018 Jared McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.11 2018/06/16 21:22:13 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.12 2018/06/19 02:08:12 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -264,6 +264,7 @@ struct axpreg_attach_args { i2c_addr_t reg_addr; }; +static const char *axp803_compatstrings[] = { "x-powers,axp803", NULL }; static const struct axppmic_config axp803_config = { .name = "AXP803", .controls = axp803_ctrls, @@ -282,6 +283,8 @@ static const struct axppmic_config axp80 .chargestirq = AXPPMIC_IRQ(4, __BITS(1,0)), }; +static const char *axp805_compatstrings[] = { "x-powers,axp805", + "x-powers,axp806", NULL }; static const struct axppmic_config axp805_config = { .name = "AXP805/806", .controls = axp805_ctrls, @@ -290,11 +293,10 @@ static const struct axppmic_config axp80 .poklirq = AXPPMIC_IRQ(2, __BIT(0)), }; -static const struct of_compat_data compat_data[] = { - { "x-powers,axp803", (uintptr_t)&axp803_config }, - { "x-powers,axp805", (uintptr_t)&axp805_config }, - { "x-powers,axp806", (uintptr_t)&axp805_config }, - { NULL } +static const struct device_compatible_entry axppmic_compat_data[] = { + DEVICE_COMPAT_ENTRY_WITH_DATA(axp803_compatstrings, &axp803_config), + DEVICE_COMPAT_ENTRY_WITH_DATA(axp805_compatstrings, &axp805_config), + DEVICE_COMPAT_TERMINATOR }; static int @@ -678,22 +680,10 @@ static int axppmic_match(device_t parent, cfdata_t match, void *aux) { struct i2c_attach_args *ia = aux; + int match_result; - /* XXXJRT Gross. */ - if (ia->ia_name != NULL) { - if (ia->ia_cookie) { - int match_result = - of_match_compat_data(ia->ia_cookie, compat_data); - if (match_result) { - match_result = match_result - 1 + - I2C_MATCH_DIRECT_COMPATIBLE; - match_result = MIN(match_result, - I2C_MATCH_DIRECT_COMPATIBLE_MAX); - } - return match_result; - } else - return 0; - } + if (iic_use_direct_match(ia, match, axppmic_compat_data, &match_result)) + return match_result; /* This device is direct-config only. */ @@ -704,6 +694,7 @@ static void axppmic_attach(device_t parent, device_t self, void *aux) { struct axppmic_softc *sc = device_private(self); + const struct device_compatible_entry *dce; const struct axppmic_config *c; struct axpreg_attach_args aaa; struct i2c_attach_args *ia = aux; @@ -711,7 +702,9 @@ axppmic_attach(device_t parent, device_t uint32_t irq_mask; void *ih; - c = (void *)of_search_compatible(ia->ia_cookie, compat_data)->data; + dce = iic_compatible_match(ia, axppmic_compat_data, NULL); + KASSERT(dce != NULL); + c = DEVICE_COMPAT_ENTRY_GET_PTR(dce); sc->sc_dev = self; sc->sc_i2c = ia->ia_tag;