On Mon, Oct 24, 2016 at 10:50:00PM +0300, Paul Irofti wrote:
> On Mon, Oct 24, 2016 at 07:46:33PM +0200, Mark Kettenis wrote:
> > > From: Paul Irofti <[email protected]>
> > > Date: Mon, 24 Oct 2016 17:12:01 +0300
> > >
> > > Any thoughts on this?
> >
> > Sorry, yes. Adding the crs "index" as the last argument of the
> > callback function seems a bit non-intuitive to me. I'd say the void *
> > argument should remain the last argument, and the crs "number" should
> > be the first, although I could live with it being the second.
> >
> > I feel a bit bad though for not suggesting that earlier.
>
> Sure, makes sense. I thought about doing that too, but I did not know
> how much breakage I could do to the original function.
>
> What about crsno, do you prefer it to be called crsidx? That might be
> a better name...
Like this?
Index: acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.316
diff -u -p -u -p -r1.316 acpi.c
--- acpi.c 18 Sep 2016 23:56:45 -0000 1.316
+++ acpi.c 24 Oct 2016 20:00:30 -0000
@@ -513,10 +513,10 @@ TAILQ_HEAD(, acpi_pci) acpi_pcirootdevs
TAILQ_HEAD_INITIALIZER(acpi_pcirootdevs);
int acpi_getpci(struct aml_node *node, void *arg);
-int acpi_getminbus(union acpi_resource *crs, void *arg);
+int acpi_getminbus(int crsidx, union acpi_resource *crs, void *arg);
int
-acpi_getminbus(union acpi_resource *crs, void *arg)
+acpi_getminbus(int crsidx, union acpi_resource *crs, void *arg)
{
int *bbn = arg;
int typ = AML_CRSTYPE(crs);
Index: acpiprt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpiprt.c,v
retrieving revision 1.47
diff -u -p -u -p -r1.47 acpiprt.c
--- acpiprt.c 14 Mar 2015 03:38:46 -0000 1.47
+++ acpiprt.c 24 Oct 2016 20:00:31 -0000
@@ -60,8 +60,8 @@ SIMPLEQ_HEAD(, acpiprt_map) acpiprt_map_
int acpiprt_match(struct device *, void *, void *);
void acpiprt_attach(struct device *, struct device *, void *);
-int acpiprt_getirq(union acpi_resource *crs, void *arg);
-int acpiprt_chooseirq(union acpi_resource *, void *);
+int acpiprt_getirq(int, union acpi_resource *, void *);
+int acpiprt_chooseirq(int, union acpi_resource *, void *);
struct acpiprt_softc {
struct device sc_dev;
@@ -137,7 +137,7 @@ acpiprt_attach(struct device *parent, st
}
int
-acpiprt_getirq(union acpi_resource *crs, void *arg)
+acpiprt_getirq(int crsidx, union acpi_resource *crs, void *arg)
{
struct acpiprt_irq *irq = arg;
int typ, len;
@@ -190,7 +190,7 @@ acpiprt_pri[16] = {
};
int
-acpiprt_chooseirq(union acpi_resource *crs, void *arg)
+acpiprt_chooseirq(int crsidx, union acpi_resource *crs, void *arg)
{
struct acpiprt_irq *irq = arg;
int typ, len, i, pri = -1;
Index: bytgpio.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/bytgpio.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 bytgpio.c
--- bytgpio.c 8 May 2016 11:08:01 -0000 1.11
+++ bytgpio.c 24 Oct 2016 20:00:31 -0000
@@ -104,7 +104,7 @@ const int byt_sus_pins[] = {
56, 54, 49, 55, 48, 57, 50, 58, 52, 53, 59, 40
};
-int bytgpio_parse_resources(union acpi_resource *, void *);
+int bytgpio_parse_resources(int, union acpi_resource *, void *);
int bytgpio_read_pin(void *, int);
void bytgpio_write_pin(void *, int, int);
void bytgpio_intr_establish(void *, int, int, int (*)(), void *);
@@ -238,7 +238,7 @@ free:
}
int
-bytgpio_parse_resources(union acpi_resource *crs, void *arg)
+bytgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg)
{
struct bytgpio_softc *sc = arg;
int type = AML_CRSTYPE(crs);
Index: chvgpio.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/chvgpio.c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 chvgpio.c
--- chvgpio.c 8 May 2016 18:18:42 -0000 1.5
+++ chvgpio.c 24 Oct 2016 20:00:31 -0000
@@ -143,7 +143,7 @@ const int chv_southeast_pins[] = {
8, 12, 6, 8, 10, 11, -1
};
-int chvgpio_parse_resources(union acpi_resource *, void *);
+int chvgpio_parse_resources(int, union acpi_resource *, void *);
int chvgpio_check_pin(struct chvgpio_softc *, int);
int chvgpio_read_pin(void *, int);
void chvgpio_write_pin(void *, int, int);
@@ -264,7 +264,7 @@ unmap:
}
int
-chvgpio_parse_resources(union acpi_resource *crs, void *arg)
+chvgpio_parse_resources(int crsidx, union acpi_resource *crs, void *arg)
{
struct chvgpio_softc *sc = arg;
int type = AML_CRSTYPE(crs);
Index: dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.225
diff -u -p -u -p -r1.225 dsdt.c
--- dsdt.c 27 Sep 2016 10:04:19 -0000 1.225
+++ dsdt.c 24 Oct 2016 20:00:31 -0000
@@ -1621,14 +1621,14 @@ aml_mapresource(union acpi_resource *crs
int
aml_parse_resource(struct aml_value *res,
- int (*crs_enum)(union acpi_resource *, void *), void *arg)
+ int (*crs_enum)(int, union acpi_resource *, void *), void *arg)
{
- int off, rlen;
+ int off, rlen, crsidx;
union acpi_resource *crs;
if (res->type != AML_OBJTYPE_BUFFER || res->length < 5)
return (-1);
- for (off = 0; off < res->length; off += rlen) {
+ for (off = 0, crsidx = 0; off < res->length; off += rlen, crsidx++) {
crs = (union acpi_resource *)(res->v_buffer+off);
rlen = AML_CRSLEN(crs);
@@ -1639,7 +1639,7 @@ aml_parse_resource(struct aml_value *res
#ifdef ACPI_DEBUG
aml_print_resource(crs, NULL);
#endif
- crs_enum(crs, arg);
+ crs_enum(crsidx, crs, arg);
}
return (0);
@@ -1746,7 +1746,7 @@ int aml_compare(struct aml_value *, str
struct aml_value *aml_concat(struct aml_value *, struct aml_value *);
struct aml_value *aml_concatres(struct aml_value *, struct aml_value *);
struct aml_value *aml_mid(struct aml_value *, int, int);
-int aml_ccrlen(union acpi_resource *, void *);
+int aml_ccrlen(int, union acpi_resource *, void *);
void aml_store(struct aml_scope *, struct aml_value *, int64_t,
struct aml_value *);
@@ -2140,7 +2140,7 @@ aml_concat(struct aml_value *a1, struct
/* Calculate length of Resource Template */
int
-aml_ccrlen(union acpi_resource *rs, void *arg)
+aml_ccrlen(int crsidx, union acpi_resource *rs, void *arg)
{
int *plen = arg;
Index: dsdt.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.h,v
retrieving revision 1.72
diff -u -p -u -p -r1.72 dsdt.h
--- dsdt.h 2 Sep 2016 13:59:51 -0000 1.72
+++ dsdt.h 24 Oct 2016 20:00:31 -0000
@@ -290,7 +290,8 @@ union acpi_resource {
int aml_print_resource(union acpi_resource *, void *);
int aml_parse_resource(struct aml_value *,
- int (*)(union acpi_resource *, void *), void *);
+ int (*)(int, union acpi_resource *, void *),
+ void *);
#define ACPI_E_NOERROR 0x00
#define ACPI_E_BADVALUE 0x01
Index: dwiic.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dwiic.c,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 dwiic.c
--- dwiic.c 7 Sep 2016 15:31:41 -0000 1.21
+++ dwiic.c 24 Oct 2016 20:00:31 -0000
@@ -176,7 +176,7 @@ void * dwiic_i2c_intr_establish(void *,
int (*)(void *), void *, const char *);
const char * dwiic_i2c_intr_string(void *, void *);
-int dwiic_acpi_parse_crs(union acpi_resource *, void *);
+int dwiic_acpi_parse_crs(int, union acpi_resource *, void *);
int dwiic_acpi_found_hid(struct aml_node *, void *);
int dwiic_acpi_found_ihidev(struct dwiic_softc *,
struct aml_node *, char *, struct dwiic_crs);
@@ -385,7 +385,7 @@ dwiic_activate(struct device *self, int
}
int
-dwiic_acpi_parse_crs(union acpi_resource *crs, void *arg)
+dwiic_acpi_parse_crs(int crsidx, union acpi_resource *crs, void *arg)
{
struct dwiic_crs *sc_crs = arg;
struct aml_node *node;
Index: sdhc_acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/sdhc_acpi.c,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 sdhc_acpi.c
--- sdhc_acpi.c 30 Apr 2016 11:32:23 -0000 1.8
+++ sdhc_acpi.c 24 Oct 2016 20:00:31 -0000
@@ -69,7 +69,7 @@ const char *sdhc_hids[] = {
NULL
};
-int sdhc_acpi_parse_resources(union acpi_resource *, void *);
+int sdhc_acpi_parse_resources(int, union acpi_resource *, void *);
int sdhc_acpi_card_detect(struct sdhc_softc *);
int sdhc_acpi_card_detect_intr(void *);
@@ -141,7 +141,7 @@ sdhc_acpi_attach(struct device *parent,
}
int
-sdhc_acpi_parse_resources(union acpi_resource *crs, void *arg)
+sdhc_acpi_parse_resources(int crsidx, union acpi_resource *crs, void *arg)
{
struct sdhc_acpi_softc *sc = arg;
int type = AML_CRSTYPE(crs);
Index: tpm.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/tpm.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 tpm.c
--- tpm.c 3 Aug 2016 17:23:38 -0000 1.1
+++ tpm.c 24 Oct 2016 20:00:31 -0000
@@ -158,7 +158,7 @@ const struct {
int tpm_match(struct device *, void *, void *);
void tpm_attach(struct device *, struct device *, void *);
int tpm_activate(struct device *, int);
-int tpm_parse_crs(union acpi_resource *, void *);
+int tpm_parse_crs(int, union acpi_resource *, void *);
int tpm_probe(bus_space_tag_t, bus_space_handle_t);
int tpm_init(struct tpm_softc *);
@@ -272,7 +272,7 @@ tpm_attach(struct device *parent, struct
}
int
-tpm_parse_crs(union acpi_resource *crs, void *arg)
+tpm_parse_crs(int crsidx, union acpi_resource *crs, void *arg)
{
struct tpm_crs *sc_crs = arg;