Re: asmc: constify global product table

2022-10-20 Thread Joerg Jung
On Wed, Oct 19, 2022 at 02:39:33PM +, Klemens Nanni wrote:
> Looking at symbols in /bsd .data again for .rodata candidates:
> 82281b70 l O .data  1688 asmc_prods
> 
> amsc(4) never writes, but a const table requires a const softc member:
> 
> 263 for (i = 0; asmc_prods[i].pr_name && !sc->sc_prod; i++)
> 264 if (!strncasecmp(asmc_prods[i].pr_name, hw_prod,
> 265 strlen(asmc_prods[i].pr_name)))
> 266 sc->sc_prod = _prods[i];
> 267 if (!sc->sc_prod)
> 268 return;
> 
> Builds fine on amd64.  I don't have Apple hardware to test:
> 820ce550 l O .rodata1688 asmc_prods
> 
> 
> Feedback? Objection? OK?

Tested and works for me.

ok jung@

 
> Index: dev/acpi/asmc.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/asmc.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 asmc.c
> --- dev/acpi/asmc.c   21 Dec 2021 20:53:46 -  1.4
> +++ dev/acpi/asmc.c   19 Oct 2022 14:10:01 -
> @@ -75,7 +75,7 @@ struct asmc_softc {
>   bus_space_tag_t  sc_iot;
>   bus_space_handle_t   sc_ioh;
>  
> - struct asmc_prod*sc_prod;
> + const struct asmc_prod  *sc_prod;
>   uint8_t  sc_nfans;  /* number of fans */
>   uint8_t  sc_lightlen;   /* light data len */
>   uint8_t  sc_backlight;  /* keyboard backlight value */
> @@ -119,7 +119,7 @@ const char *asmc_hids[] = {
>   "APP0001", NULL
>  };
>  
> -static struct asmc_prod asmc_prods[] = {
> +static const struct asmc_prod asmc_prods[] = {
>   { "MacBookAir", 1, {
>   "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TBXT", "TC0C", "TC0D",
>   "TC0E", "TC0F", "TC0P", "TC1C", "TC1E", "TC2C", "TCFP", "TCGC",
> 



asmc: constify global product table

2022-10-19 Thread Klemens Nanni
Looking at symbols in /bsd .data again for .rodata candidates:
82281b70 l O .data  1688 asmc_prods

amsc(4) never writes, but a const table requires a const softc member:

263 for (i = 0; asmc_prods[i].pr_name && !sc->sc_prod; i++)
264 if (!strncasecmp(asmc_prods[i].pr_name, hw_prod,
265 strlen(asmc_prods[i].pr_name)))
266 sc->sc_prod = _prods[i];
267 if (!sc->sc_prod)
268 return;

Builds fine on amd64.  I don't have Apple hardware to test:
820ce550 l O .rodata1688 asmc_prods


Feedback? Objection? OK?

Index: dev/acpi/asmc.c
===
RCS file: /cvs/src/sys/dev/acpi/asmc.c,v
retrieving revision 1.4
diff -u -p -r1.4 asmc.c
--- dev/acpi/asmc.c 21 Dec 2021 20:53:46 -  1.4
+++ dev/acpi/asmc.c 19 Oct 2022 14:10:01 -
@@ -75,7 +75,7 @@ struct asmc_softc {
bus_space_tag_t  sc_iot;
bus_space_handle_t   sc_ioh;
 
-   struct asmc_prod*sc_prod;
+   const struct asmc_prod  *sc_prod;
uint8_t  sc_nfans;  /* number of fans */
uint8_t  sc_lightlen;   /* light data len */
uint8_t  sc_backlight;  /* keyboard backlight value */
@@ -119,7 +119,7 @@ const char *asmc_hids[] = {
"APP0001", NULL
 };
 
-static struct asmc_prod asmc_prods[] = {
+static const struct asmc_prod asmc_prods[] = {
{ "MacBookAir", 1, {
"TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TBXT", "TC0C", "TC0D",
"TC0E", "TC0F", "TC0P", "TC1C", "TC1E", "TC2C", "TCFP", "TCGC",