> From: Paul Irofti <p...@irofti.net>
> 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.

> -----Mesaj original-----
> De la: "Paul Irofti" <p...@irofti.net>
> Trimis: ‎22.‎10.‎2016 15:34
> Către: "Mark Kettenis" <mark.kette...@xs4all.nl>
> Cc: "guent...@gmail.com" <guent...@gmail.com>; "tech@openbsd.org" 
> <tech@openbsd.org>
> Subiect: Re: acpiec on acer aspire S7 with CURRENT
> 
> > I'm not really happy about the use of the static variable in the
> > resource parsing function.  It feels like the aml_parse_resource API
> > should be changed to pass the resource number to the callback
> > function.
> 
> I hated doing that as well, but I was afraid it wouldn't be justified to
> change the prototype and all the callers for this particular use case.
> Glad you suggested it. Here is a diff to add support for that in the
> current code.
> 
> 
> 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    22 Oct 2016 12:29:11 -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(union acpi_resource *crs, void *arg, int crsno);
>  
>  int
> -acpi_getminbus(union acpi_resource *crs, void *arg)
> +acpi_getminbus(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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 22 Oct 2016 12:29:11 -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(union acpi_resource *crs, void *arg, int crsno);
> +int  acpiprt_chooseirq(union acpi_resource *, void *, int);
>  
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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 22 Oct 2016 12:29:11 -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(union acpi_resource *, void *, int crsno);
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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 22 Oct 2016 12:29:11 -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(union acpi_resource *, void *, int);
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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    22 Oct 2016 12:29:12 -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)(union acpi_resource *, void *, int), void *arg)
>  {
> -     int off, rlen;
> +     int off, rlen, crsno;
>       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, crsno = 0; off < res->length; off += rlen, crsno++) {
>               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(crs, arg, crsno);
>       }
>  
>       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(union acpi_resource *, void *, int);
>  
>  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(union acpi_resource *rs, void *arg, int crsno)
>  {
>       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    22 Oct 2016 12:29:12 -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 (*)(union acpi_resource *, void *, int),
> +                         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   22 Oct 2016 12:29:12 -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(union acpi_resource *, void *, int);
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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       22 Oct 2016 12:29:12 -0000
> @@ -69,7 +69,7 @@ const char *sdhc_hids[] = {
>       NULL
>  };
>  
> -int  sdhc_acpi_parse_resources(union acpi_resource *, void *);
> +int  sdhc_acpi_parse_resources(union acpi_resource *, void *, int);
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       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     22 Oct 2016 12:29:12 -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(union acpi_resource *, void *, int);
>  
>  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(union acpi_resource *crs, void *arg, int crsno)
>  {
>       struct tpm_crs *sc_crs = arg;
>  
> 
> --_C0CDC1F2-E707-4938-9F0C-D26F362CD5FB_
> Content-Transfer-Encoding: 7bit
> X-Former-Content-Transfer-Encoding: quoted-printable
> Content-Type: text/plain; charset=us-ascii
> X-Former-Content-Type: text/html; charset="utf-8"
> 
> [file:/home/kettenis/detached/paul_irofti.net_.html]
> --_C0CDC1F2-E707-4938-9F0C-D26F362CD5FB_--
> 
> 

Reply via email to