[PATCH v2] Introduce AcpiOs(Read|Write)Cmos and enable these in AcpiExCmosSpaceHandler
by Adam Goode
This introduces a generic OSL interface for reading and writing
SystemCMOS spaces. It is needed on Linux for registering a generic
handler for SystemCMOS because some firmware accesses CMOS in _INI.
(The first time I sent a somewhat corrupted patch file. This one should
be better).
---
source/components/events/evhandler.c | 1 +
source/components/executer/exregion.c | 23 +++++++++
source/include/acconfig.h | 2 +-
source/include/acpiosxf.h | 18 +++++++
source/os_specific/service_layers/osunixxf.c | 64 +++++++++++++++++++++++
source/os_specific/service_layers/oswinxf.c | 64 +++++++++++++++++++++++
tests/aapits/atosxfctrl.c | 2 +
tests/aapits/atosxfctrl.h | 3 ++
tests/aapits/atosxfwrap.c | 76 ++++++++++++++++++++++++++++
tests/aapits/atosxfwrap.h | 16 ++++++
10 files changed, 268 insertions(+), 1 deletion(-)
diff --git a/source/components/events/evhandler.c b/source/components/events/evhandler.c
index d02ea53..634c18e 100644
--- a/source/components/events/evhandler.c
+++ b/source/components/events/evhandler.c
@@ -139,6 +139,7 @@ UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] =
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
+ ACPI_ADR_SPACE_CMOS,
ACPI_ADR_SPACE_DATA_TABLE
};
diff --git a/source/components/executer/exregion.c b/source/components/executer/exregion.c
index 31bbb60..bd9addd 100644
--- a/source/components/executer/exregion.c
+++ b/source/components/executer/exregion.c
@@ -551,6 +551,29 @@ AcpiExCmosSpaceHandler (
ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-CMOS (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_UINT64(Address)));
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadCmos(Address, Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWriteCmos(Address, *Value, BitWidth);
+ break;
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
return_ACPI_STATUS (Status);
}
diff --git a/source/include/acconfig.h b/source/include/acconfig.h
index 41fa33d..dcecfa7 100644
--- a/source/include/acconfig.h
+++ b/source/include/acconfig.h
@@ -270,7 +270,7 @@
/* Maximum SpaceIds for Operation Regions */
#define ACPI_MAX_ADDRESS_SPACE 255
-#define ACPI_NUM_DEFAULT_SPACES 4
+#define ACPI_NUM_DEFAULT_SPACES 5
/* Array sizes. Used for range checking also */
diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h
index 68d79c7..31523ea 100644
--- a/source/include/acpiosxf.h
+++ b/source/include/acpiosxf.h
@@ -452,6 +452,24 @@ AcpiOsWritePort (
UINT32 Width);
#endif
+/*
+ * Platform and hardware-independent CMOS memory interfaces
+ */
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadCmos
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteCmos
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width);
+#endif
/*
* Platform and hardware-independent physical memory interfaces
diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c
index c48f581..b763ddc 100644
--- a/source/os_specific/service_layers/osunixxf.c
+++ b/source/os_specific/service_layers/osunixxf.c
@@ -1361,6 +1361,70 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+
+ switch (Width)
+ {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+
+ *Value = 0;
+ break;
+
+ default:
+
+ return (AE_BAD_PARAMETER);
+ }
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+
+ return (AE_OK);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c
index 66ce8c8..80086fd 100644
--- a/source/os_specific/service_layers/oswinxf.c
+++ b/source/os_specific/service_layers/oswinxf.c
@@ -1356,6 +1356,70 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+
+ switch (Width)
+ {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+
+ *Value = 0;
+ break;
+
+ default:
+
+ return (AE_BAD_PARAMETER);
+ }
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+
+ return (AE_OK);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/tests/aapits/atosxfctrl.c b/tests/aapits/atosxfctrl.c
index fe8b562..9a6b41c 100644
--- a/tests/aapits/atosxfctrl.c
+++ b/tests/aapits/atosxfctrl.c
@@ -160,6 +160,8 @@ const char *OsxfNames[] = {
"AcpiOsDerivePciId",
"AcpiOsReadPort",
"AcpiOsWritePort",
+ "AcpiOsReadCmos",
+ "AcpiOsWriteCmos",
"AcpiOsReadMemory",
"AcpiOsWriteMemory",
"AcpiOsSignal"};
diff --git a/tests/aapits/atosxfctrl.h b/tests/aapits/atosxfctrl.h
index 66a361d..2c8b9e5 100644
--- a/tests/aapits/atosxfctrl.h
+++ b/tests/aapits/atosxfctrl.h
@@ -162,6 +162,8 @@ typedef enum
AcpiOsDerivePciIdC,
AcpiOsReadPortC,
AcpiOsWritePortC,
+ AcpiOsReadCmosC,
+ AcpiOsWriteCmosC,
AcpiOsReadMemoryC,
AcpiOsWriteMemoryC,
AcpiOsSignalC,
@@ -229,6 +231,7 @@ typedef struct acpi_os_emul_reg
*/
#define EMUL_REG_SYS 0x01
#define EMUL_REG_IO 0x02
+#define EMUL_REG_CMOS 0x03
/*
* Fixed ACPI h/w emulated registers numbers
diff --git a/tests/aapits/atosxfwrap.c b/tests/aapits/atosxfwrap.c
index 7c5de39..0088212 100644
--- a/tests/aapits/atosxfwrap.c
+++ b/tests/aapits/atosxfwrap.c
@@ -1272,6 +1272,82 @@ AcpiOsWritePort (
}
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiOsReadCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to read
+ * Value - Where value is placed
+ * Width - Number of bits
+ *
+ * RETURN: Value read from CMOS memory
+ *
+ * DESCRIPTION: Read data from CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width)
+{
+ AT_CTRL_DECL(AcpiOsReadCmos);
+
+ AT_CHCK_RET_STATUS(AcpiOsReadCmos);
+
+ if (!EMUL_REG_MODE) {
+ Status = AcpiOsActualReadCmos(Address, Value, Width);
+ }
+ else
+ {
+ Status = OsxfCtrlReadReg(EMUL_REG_CMOS, Address, Value, Width);
+ }
+
+ AT_CTRL_SUCCESS(AcpiOsReadCmos);
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsWriteCmos
+ *
+ * PARAMETERS: Address - Address of CMOS memory to write
+ * Value - Value to write
+ * Width - Number of bits
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write data to CMOS memory
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width)
+{
+ AT_CTRL_DECL(AcpiOsWriteCmos);
+
+ AT_CHCK_RET_STATUS(AcpiOsWriteCmos);
+
+ if (!EMUL_REG_MODE) {
+ Status = AcpiOsActualWriteCmos(Address, Value, Width);
+ }
+ else
+ {
+ Status = OsxfCtrlWriteReg(EMUL_REG_CMOS, Address, Value, Width);
+ }
+
+ AT_CTRL_SUCCESS(AcpiOsWriteCmos);
+
+ return (Status);
+}
+
+
/******************************************************************************
*
* FUNCTION: AcpiOsReadMemory
diff --git a/tests/aapits/atosxfwrap.h b/tests/aapits/atosxfwrap.h
index 27224d0..48e2100 100644
--- a/tests/aapits/atosxfwrap.h
+++ b/tests/aapits/atosxfwrap.h
@@ -324,6 +324,22 @@ AcpiOsActualWritePort (
/*
+ * Platform and hardware-independent CMOS memory interfaces
+ */
+ACPI_STATUS
+AcpiOsActualReadCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 *Value,
+ UINT32 Width);
+
+ACPI_STATUS
+AcpiOsActualWriteCmos (
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT64 Value,
+ UINT32 Width);
+
+
+/*
* Platform and hardware-independent physical memory interfaces
*/
ACPI_STATUS
--
2.3.7
6 years, 2 months
Re: [Devel] [PATCH] acpi: set return value to const char for some functions
by Moore, Robert
You may have missed this, from last week:
> All that being said, I went ahead and made the actual ACPICA changes
> corresponding to your patches. There were no pollution issues, and it
> actually simplified the code by eliminating the need for some uses of
> ACPI_CAST_PTR.
>
> The only issue I found was here, so we won't do this one:
>
> const char
> AcpiUtHexToAsciiChar
>
> \acpica\source\include\acutils.h(322) :
> warning C4180: qualifier applied to function type has no meaning;
> ignored
>
> -----Original Message-----
> From: Moore, Robert
> Sent: Monday, October 19, 2015 10:05 AM
> To: 'LABBE Corentin'
> Cc: LABBE Corentin; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org; linux-
> acpi(a)vger.kernel.org; devel(a)acpica.org; linux-kernel(a)vger.kernel.org
> Subject: RE: [PATCH] acpi: set return value to const char for some
> functions
>
> Actually, I thought I got most of the changes.
>
> Again, ACPICA code is in a different format than the Linux version of the
> code, so your patch cannot be directly applied.
>
> Bob
>
>
> > -----Original Message-----
> > From: LABBE Corentin [mailto:montjoie.mailing@gmail.com]
> > Sent: Monday, October 19, 2015 5:03 AM
> > To: Moore, Robert
> > Cc: LABBE Corentin; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org;
> > linux- acpi(a)vger.kernel.org; devel(a)acpica.org;
> > linux-kernel(a)vger.kernel.org
> > Subject: Re: [PATCH] acpi: set return value to const char for some
> > functions
> >
> > On Wed, Oct 14, 2015 at 08:53:19PM +0000, Moore, Robert wrote:
> > > In ACPICA, we tend to be very careful concerning the "const" keyword
> > > in
> > order to avoid a phenomenon known as "const pollution".
> > >
> > > That is not to say that we won't use const in some limited cases.
> > >
> > > Bob
> > >
> >
> > Hello
> >
> > The problem is that all function in this patch return a pointer to
> > string literal without giving that information.
> > I am sad to see that you seems to agree with that but, for resuming
> > your conversation with Joe Perches, you reject this patch just because
> > you worry that perhaps in the future it will make you more works do
> > deal with it.
> >
> > Does you will accept the subset of this patch for adding const to
> > "static char xxx[] = {}" ?
> >
> > Regards
> >
> > >
> > > > -----Original Message-----
> > > > From: LABBE Corentin [mailto:clabbe.montjoie@gmail.com]
> > > > Sent: Wednesday, October 14, 2015 12:07 PM
> > > > To: Moore, Robert; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org
> > > > Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org; linux-
> > > > kernel(a)vger.kernel.org; LABBE Corentin
> > > > Subject: [PATCH] acpi: set return value to const char for some
> > > > functions
> > > >
> > > > This patch set some array of const char as const.
> > > > In the same time, some function return pointer to thoses array
> > > > without properly giving the information that the data is const.
> > > > This patch set the return type of thoses functions as const char *
> > > >
> > > > Signed-off-by: LABBE Corentin <clabbe.montjoie(a)gmail.com>
> > > > ---
> > > > drivers/acpi/acpica/acutils.h | 12 ++++++------
> > > > drivers/acpi/acpica/utdecode.c | 24 ++++++++++++------------
> > > > drivers/acpi/acpica/uthex.c | 4 ++--
> > > > drivers/acpi/tables.c | 6 ++++--
> > > > 4 files changed, 24 insertions(+), 22 deletions(-)
> > > >
> > > > diff --git a/drivers/acpi/acpica/acutils.h
> > > > b/drivers/acpi/acpica/acutils.h index fb2aa50..e5d9d4f 100644
> > > > --- a/drivers/acpi/acpica/acutils.h
> > > > +++ b/drivers/acpi/acpica/acutils.h
> > > > @@ -189,21 +189,21 @@ char *acpi_ut_get_mutex_name(u32 mutex_id);
> > > > const char *acpi_ut_get_notify_name(u32 notify_value,
> > > > acpi_object_type type); #endif
> > > >
> > > > -char *acpi_ut_get_type_name(acpi_object_type type);
> > > > +const char *acpi_ut_get_type_name(acpi_object_type type);
> > > >
> > > > char *acpi_ut_get_node_name(void *object);
> > > >
> > > > -char *acpi_ut_get_descriptor_name(void *object);
> > > > +const char *acpi_ut_get_descriptor_name(void *object);
> > > >
> > > > const char *acpi_ut_get_reference_name(union acpi_operand_object
> > > > *object);
> > > >
> > > > -char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > > *obj_desc);
> > > > +const char *acpi_ut_get_object_type_name(union
> > > > +acpi_operand_object *obj_desc);
> > > >
> > > > -char *acpi_ut_get_region_name(u8 space_id);
> > > > +const char *acpi_ut_get_region_name(u8 space_id);
> > > >
> > > > -char *acpi_ut_get_event_name(u32 event_id);
> > > > +const char *acpi_ut_get_event_name(u32 event_id);
> > > >
> > > > -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
> > > > +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
> > > >
> > > > u8 acpi_ut_ascii_char_to_hex(int hex_char);
> > > >
> > > > diff --git a/drivers/acpi/acpica/utdecode.c
> > > > b/drivers/acpi/acpica/utdecode.c index 988e23b..e08cdb1 100644
> > > > --- a/drivers/acpi/acpica/utdecode.c
> > > > +++ b/drivers/acpi/acpica/utdecode.c
> > > > @@ -114,7 +114,7 @@ const char
> > > > *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
> > > > "PCC" /* 0x0A */
> > > > };
> > > >
> > > > -char *acpi_ut_get_region_name(u8 space_id)
> > > > +const char *acpi_ut_get_region_name(u8 space_id)
> > > > {
> > > >
> > > > if (space_id >= ACPI_USER_REGION_BEGIN) { @@ -127,7 +127,7 @@
> > > > char
> > > > *acpi_ut_get_region_name(u8 space_id)
> > > > return ("InvalidSpaceId");
> > > > }
> > > >
> > > > - return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
> > > > + return (ACPI_CAST_PTR(const char,
> > > > +acpi_gbl_region_types[space_id]));
> > > > }
> > > >
> > > >
> > > > /*****************************************************************
> > > > **
> > > > ******
> > > > ******
> > > > @@ -152,14 +152,14 @@ static const char
> > > > *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
> > > > "RealTimeClock",
> > > > };
> > > >
> > > > -char *acpi_ut_get_event_name(u32 event_id)
> > > > +const char *acpi_ut_get_event_name(u32 event_id)
> > > > {
> > > >
> > > > if (event_id > ACPI_EVENT_MAX) {
> > > > return ("InvalidEventID");
> > > > }
> > > >
> > > > - return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
> > > > + return (ACPI_CAST_PTR(const char,
> > > > +acpi_gbl_event_types[event_id]));
> > > > }
> > > >
> > > >
> > > > /*****************************************************************
> > > > **
> > > > ******
> > > > ******
> > > > @@ -220,17 +220,17 @@ static const char *acpi_gbl_ns_type_names[] =
> {
> > > > /* 30 */ "Invalid"
> > > > };
> > > >
> > > > -char *acpi_ut_get_type_name(acpi_object_type type)
> > > > +const char *acpi_ut_get_type_name(acpi_object_type type)
> > > > {
> > > >
> > > > if (type > ACPI_TYPE_INVALID) {
> > > > - return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
> > > > + return (ACPI_CAST_PTR(const char, acpi_gbl_bad_type));
> > > > }
> > > >
> > > > - return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
> > > > + return (ACPI_CAST_PTR(const char,
> > > > +acpi_gbl_ns_type_names[type]));
> > > > }
> > > >
> > > > -char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > > *obj_desc)
> > > > +const char *acpi_ut_get_object_type_name(union
> > > > +acpi_operand_object
> > > > +*obj_desc)
> > > > {
> > > >
> > > > if (!obj_desc) {
> > > > @@ -318,7 +318,7 @@ static const char *acpi_gbl_desc_type_names[] =
> {
> > > > /* 15 */ "Node"
> > > > };
> > > >
> > > > -char *acpi_ut_get_descriptor_name(void *object)
> > > > +const char *acpi_ut_get_descriptor_name(void *object)
> > > > {
> > > >
> > > > if (!object) {
> > > > @@ -329,7 +329,7 @@ char *acpi_ut_get_descriptor_name(void *object)
> > > > return ("Not a Descriptor");
> > > > }
> > > >
> > > > - return (ACPI_CAST_PTR(char,
> > > > + return (ACPI_CAST_PTR(const char,
> > > >
> acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
> > > > (object)]));
> > > >
> > > > @@ -400,7 +400,7 @@ const char *acpi_ut_get_reference_name(union
> > > > acpi_operand_object *object)
> > > >
> > > > /* Names for internal mutex objects, used for debug output */
> > > >
> > > > -static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> > > > +static const char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> > > > "ACPI_MTX_Interpreter",
> > > > "ACPI_MTX_Namespace",
> > > > "ACPI_MTX_Tables",
> > > > @@ -411,7 +411,7 @@ static char
> > > > *acpi_gbl_mutex_names[ACPI_NUM_MUTEX]
> > = {
> > > > "ACPI_MTX_CommandReady"
> > > > };
> > > >
> > > > -char *acpi_ut_get_mutex_name(u32 mutex_id)
> > > > +const char *acpi_ut_get_mutex_name(u32 mutex_id)
> > > > {
> > > >
> > > > if (mutex_id > ACPI_MAX_MUTEX) { diff --git
> > > > a/drivers/acpi/acpica/uthex.c b/drivers/acpi/acpica/uthex.c index
> > > > fda8b3d..9239711 100644
> > > > --- a/drivers/acpi/acpica/uthex.c
> > > > +++ b/drivers/acpi/acpica/uthex.c
> > > > @@ -48,7 +48,7 @@
> > > > ACPI_MODULE_NAME("uthex")
> > > >
> > > > /* Hex to ASCII conversion table */ -static char
> > > > acpi_gbl_hex_to_ascii[] = {
> > > > +static const char acpi_gbl_hex_to_ascii[] = {
> > > > '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
> 'C',
> > > > 'D',
> > > > 'E', 'F'
> > > > };
> > > > @@ -67,7 +67,7 @@ static char acpi_gbl_hex_to_ascii[] = {
> > > > *
> > > >
> > > > ******************************************************************
> > > > **
> > > > ******
> > > > ****/
> > > >
> > > > -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> > > > +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> > > > {
> > > >
> > > > return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
> > > > diff
> > > > -- git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index
> > > > 17a6fa0..7c8a037
> > > > 100644
> > > > --- a/drivers/acpi/tables.c
> > > > +++ b/drivers/acpi/tables.c
> > > > @@ -35,8 +35,10 @@
> > > >
> > > > #define ACPI_MAX_TABLES 128
> > > >
> > > > -static char *mps_inti_flags_polarity[] = { "dfl", "high", "res",
> > > > "low" }; -static char *mps_inti_flags_trigger[] = { "dfl", "edge",
> > "res", "level"
> > > > };
> > > > +static const char * const mps_inti_flags_polarity[] = {
> > > > + "dfl", "high", "res", "low" };
> > > > +static const char * const mps_inti_flags_trigger[] = {
> > > > + "dfl", "edge", "res", "level" };
> > > >
> > > > static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES]
> > > > __initdata;
> > > >
> > > > --
> > > > 2.4.9
> > >
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe
> > > linux-kernel" in the body of a message to majordomo(a)vger.kernel.org
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
6 years, 8 months
Re: [Devel] [PATCH] acpi: set return value to const char for some functions
by Moore, Robert
Actually, I thought I got most of the changes.
Again, ACPICA code is in a different format than the Linux version of the code, so your patch cannot be directly applied.
Bob
> -----Original Message-----
> From: LABBE Corentin [mailto:montjoie.mailing@gmail.com]
> Sent: Monday, October 19, 2015 5:03 AM
> To: Moore, Robert
> Cc: LABBE Corentin; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org; linux-
> acpi(a)vger.kernel.org; devel(a)acpica.org; linux-kernel(a)vger.kernel.org
> Subject: Re: [PATCH] acpi: set return value to const char for some
> functions
>
> On Wed, Oct 14, 2015 at 08:53:19PM +0000, Moore, Robert wrote:
> > In ACPICA, we tend to be very careful concerning the "const" keyword in
> order to avoid a phenomenon known as "const pollution".
> >
> > That is not to say that we won't use const in some limited cases.
> >
> > Bob
> >
>
> Hello
>
> The problem is that all function in this patch return a pointer to string
> literal without giving that information.
> I am sad to see that you seems to agree with that but, for resuming your
> conversation with Joe Perches, you reject this patch just because you
> worry that perhaps in the future it will make you more works do deal with
> it.
>
> Does you will accept the subset of this patch for adding const to "static
> char xxx[] = {}" ?
>
> Regards
>
> >
> > > -----Original Message-----
> > > From: LABBE Corentin [mailto:clabbe.montjoie@gmail.com]
> > > Sent: Wednesday, October 14, 2015 12:07 PM
> > > To: Moore, Robert; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org
> > > Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org; linux-
> > > kernel(a)vger.kernel.org; LABBE Corentin
> > > Subject: [PATCH] acpi: set return value to const char for some
> > > functions
> > >
> > > This patch set some array of const char as const.
> > > In the same time, some function return pointer to thoses array
> > > without properly giving the information that the data is const.
> > > This patch set the return type of thoses functions as const char *
> > >
> > > Signed-off-by: LABBE Corentin <clabbe.montjoie(a)gmail.com>
> > > ---
> > > drivers/acpi/acpica/acutils.h | 12 ++++++------
> > > drivers/acpi/acpica/utdecode.c | 24 ++++++++++++------------
> > > drivers/acpi/acpica/uthex.c | 4 ++--
> > > drivers/acpi/tables.c | 6 ++++--
> > > 4 files changed, 24 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/drivers/acpi/acpica/acutils.h
> > > b/drivers/acpi/acpica/acutils.h index fb2aa50..e5d9d4f 100644
> > > --- a/drivers/acpi/acpica/acutils.h
> > > +++ b/drivers/acpi/acpica/acutils.h
> > > @@ -189,21 +189,21 @@ char *acpi_ut_get_mutex_name(u32 mutex_id);
> > > const char *acpi_ut_get_notify_name(u32 notify_value,
> > > acpi_object_type type); #endif
> > >
> > > -char *acpi_ut_get_type_name(acpi_object_type type);
> > > +const char *acpi_ut_get_type_name(acpi_object_type type);
> > >
> > > char *acpi_ut_get_node_name(void *object);
> > >
> > > -char *acpi_ut_get_descriptor_name(void *object);
> > > +const char *acpi_ut_get_descriptor_name(void *object);
> > >
> > > const char *acpi_ut_get_reference_name(union acpi_operand_object
> > > *object);
> > >
> > > -char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > *obj_desc);
> > > +const char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > +*obj_desc);
> > >
> > > -char *acpi_ut_get_region_name(u8 space_id);
> > > +const char *acpi_ut_get_region_name(u8 space_id);
> > >
> > > -char *acpi_ut_get_event_name(u32 event_id);
> > > +const char *acpi_ut_get_event_name(u32 event_id);
> > >
> > > -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
> > > +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
> > >
> > > u8 acpi_ut_ascii_char_to_hex(int hex_char);
> > >
> > > diff --git a/drivers/acpi/acpica/utdecode.c
> > > b/drivers/acpi/acpica/utdecode.c index 988e23b..e08cdb1 100644
> > > --- a/drivers/acpi/acpica/utdecode.c
> > > +++ b/drivers/acpi/acpica/utdecode.c
> > > @@ -114,7 +114,7 @@ const char
> > > *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
> > > "PCC" /* 0x0A */
> > > };
> > >
> > > -char *acpi_ut_get_region_name(u8 space_id)
> > > +const char *acpi_ut_get_region_name(u8 space_id)
> > > {
> > >
> > > if (space_id >= ACPI_USER_REGION_BEGIN) { @@ -127,7 +127,7 @@ char
> > > *acpi_ut_get_region_name(u8 space_id)
> > > return ("InvalidSpaceId");
> > > }
> > >
> > > - return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
> > > + return (ACPI_CAST_PTR(const char,
> > > +acpi_gbl_region_types[space_id]));
> > > }
> > >
> > >
> > > /*******************************************************************
> > > ******
> > > ******
> > > @@ -152,14 +152,14 @@ static const char
> > > *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
> > > "RealTimeClock",
> > > };
> > >
> > > -char *acpi_ut_get_event_name(u32 event_id)
> > > +const char *acpi_ut_get_event_name(u32 event_id)
> > > {
> > >
> > > if (event_id > ACPI_EVENT_MAX) {
> > > return ("InvalidEventID");
> > > }
> > >
> > > - return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
> > > + return (ACPI_CAST_PTR(const char,
> > > +acpi_gbl_event_types[event_id]));
> > > }
> > >
> > >
> > > /*******************************************************************
> > > ******
> > > ******
> > > @@ -220,17 +220,17 @@ static const char *acpi_gbl_ns_type_names[] = {
> > > /* 30 */ "Invalid"
> > > };
> > >
> > > -char *acpi_ut_get_type_name(acpi_object_type type)
> > > +const char *acpi_ut_get_type_name(acpi_object_type type)
> > > {
> > >
> > > if (type > ACPI_TYPE_INVALID) {
> > > - return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
> > > + return (ACPI_CAST_PTR(const char, acpi_gbl_bad_type));
> > > }
> > >
> > > - return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
> > > + return (ACPI_CAST_PTR(const char, acpi_gbl_ns_type_names[type]));
> > > }
> > >
> > > -char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > *obj_desc)
> > > +const char *acpi_ut_get_object_type_name(union acpi_operand_object
> > > +*obj_desc)
> > > {
> > >
> > > if (!obj_desc) {
> > > @@ -318,7 +318,7 @@ static const char *acpi_gbl_desc_type_names[] = {
> > > /* 15 */ "Node"
> > > };
> > >
> > > -char *acpi_ut_get_descriptor_name(void *object)
> > > +const char *acpi_ut_get_descriptor_name(void *object)
> > > {
> > >
> > > if (!object) {
> > > @@ -329,7 +329,7 @@ char *acpi_ut_get_descriptor_name(void *object)
> > > return ("Not a Descriptor");
> > > }
> > >
> > > - return (ACPI_CAST_PTR(char,
> > > + return (ACPI_CAST_PTR(const char,
> > > acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
> > > (object)]));
> > >
> > > @@ -400,7 +400,7 @@ const char *acpi_ut_get_reference_name(union
> > > acpi_operand_object *object)
> > >
> > > /* Names for internal mutex objects, used for debug output */
> > >
> > > -static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> > > +static const char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> > > "ACPI_MTX_Interpreter",
> > > "ACPI_MTX_Namespace",
> > > "ACPI_MTX_Tables",
> > > @@ -411,7 +411,7 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX]
> = {
> > > "ACPI_MTX_CommandReady"
> > > };
> > >
> > > -char *acpi_ut_get_mutex_name(u32 mutex_id)
> > > +const char *acpi_ut_get_mutex_name(u32 mutex_id)
> > > {
> > >
> > > if (mutex_id > ACPI_MAX_MUTEX) {
> > > diff --git a/drivers/acpi/acpica/uthex.c
> > > b/drivers/acpi/acpica/uthex.c index fda8b3d..9239711 100644
> > > --- a/drivers/acpi/acpica/uthex.c
> > > +++ b/drivers/acpi/acpica/uthex.c
> > > @@ -48,7 +48,7 @@
> > > ACPI_MODULE_NAME("uthex")
> > >
> > > /* Hex to ASCII conversion table */ -static char
> > > acpi_gbl_hex_to_ascii[] = {
> > > +static const char acpi_gbl_hex_to_ascii[] = {
> > > '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
> > > 'D',
> > > 'E', 'F'
> > > };
> > > @@ -67,7 +67,7 @@ static char acpi_gbl_hex_to_ascii[] = {
> > > *
> > >
> > > ********************************************************************
> > > ******
> > > ****/
> > >
> > > -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> > > +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> > > {
> > >
> > > return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); diff
> > > -- git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index
> > > 17a6fa0..7c8a037
> > > 100644
> > > --- a/drivers/acpi/tables.c
> > > +++ b/drivers/acpi/tables.c
> > > @@ -35,8 +35,10 @@
> > >
> > > #define ACPI_MAX_TABLES 128
> > >
> > > -static char *mps_inti_flags_polarity[] = { "dfl", "high", "res",
> > > "low" }; -static char *mps_inti_flags_trigger[] = { "dfl", "edge",
> "res", "level"
> > > };
> > > +static const char * const mps_inti_flags_polarity[] = {
> > > + "dfl", "high", "res", "low" };
> > > +static const char * const mps_inti_flags_trigger[] = {
> > > + "dfl", "edge", "res", "level" };
> > >
> > > static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES]
> > > __initdata;
> > >
> > > --
> > > 2.4.9
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> > linux-kernel" in the body of a message to majordomo(a)vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
6 years, 8 months
ACPICA Legal Info
by Moore, Robert
This is the ACPICA legal information posted at: www.acpica.org/Licensing.
It is reproduced here for convenience and wide distribution.
ACPICA Licensing for Source Code and Contributions
Licensing of the ACPICA Source Code
The ACPICA source code is licensed under three different licenses:
1. A non-open source license (the "Intel license").
2. A BSD license.
3. A GPLv2 license.
The user may select which license they wish to use for ACPICA. There are separate source code
downloads (tar/zip) for the Intel license version and for the BSD & GPLv2 license version (called
the "dual license" version). These downloads are available at https://acpica.org/downloads
1. acpica-unix: Intel license.
2. acpica-unix2: GPLv2/BSD dual license.
3. acpica-win: Intel license.
3. acpitests-win and acpitest-unix : GPLv2/BSD dual license.
3. iasl-win: Intel license. (Binary Windows utilities.)
For source code packages that contain the Intel license, only the Intel license applies; for packages
that contain the dual license, the user can choose either the BSD or GPLv2 license they wish to apply
to their use of ACPICA.
The ACPICA test suite is licensed under the GPLv2/BSD license only.
Submitting Contributions to ACPICA
Any contributions (including patches, bug fixes, improvements, or new features) submitted to the
ACPICA project will be governed by the "simplified" BSD license reproduced below. Contributions
are accepted under this license in order to preserve ACPICA's ability to tri-license ACPICA in the
manner described above.
License for Contributions to ACPICA
Copyright (c) 2000 - 2015 Intel Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINES
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
6 years, 8 months
Re: [Devel] [PATCH] acpi: set return value to const char for some functions
by Moore, Robert
If you don't like the quote, just stick with my first assessment.
> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Thursday, October 15, 2015 5:00 PM
> To: Moore, Robert
> Cc: LABBE Corentin; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org; linux-
> acpi(a)vger.kernel.org; devel(a)acpica.org; linux-kernel(a)vger.kernel.org; Box,
> David E
> Subject: Re: [PATCH] acpi: set return value to const char for some
> functions
>
> On Thu, 2015-10-15 at 19:32 +0000, Moore, Robert wrote:
> > if you started to use "const" for some methods you usually forced to
> > use this in most of your code. But the time spent for maintaining
> > (typing, recompiling when some const is missing, etc.) of
> > const-correctness in code seems greater than for fixing of possible
> > (very rare) problems caused by not using of const-correctness at all
>
> c is not c++.
>
> "seems" is a dubious statement.
6 years, 8 months
Re: [Devel] [PATCH] acpi: set return value to const char for some functions
by Moore, Robert
> Please describe the effects of "const pollution".
>
> Why isn't it useful to update the functions that don't modify function
> pointer arguments to const?
It's not that const isn't useful, but it can create problems, especially in existing code. It can bubble up to higher functions, causing lots of changes to existing variables and the definition of existing functions. Not to mention lots of casting and recasting.
Example quote:
"if you started to use "const" for some methods you usually forced to use this in most of your code. But the time spent for maintaining (typing, recompiling when some const is missing, etc.) of const-correctness in code seems greater than for fixing of possible (very rare) problems caused by not using of const-correctness at all."
Also, ACPICA has to be additionally careful because it must compile with many different C compilers.
All that being said, I went ahead and made the actual ACPICA changes corresponding to your patches. There were no pollution issues, and it actually simplified the code by eliminating the need for some uses of ACPI_CAST_PTR.
The only issue I found was here, so we won't do this one:
const char
AcpiUtHexToAsciiChar
\acpica\source\include\acutils.h(322) :
warning C4180: qualifier applied to function type has no meaning; ignored
Here is the current patch to the actual ACPICA code (which is in a different format than the Linux version of the code):
diff --git a/source/components/namespace/nsxfname.c b/source/components/namespace/nsxfname.c
index 51cc4f4..c368c1f 100644
--- a/source/components/namespace/nsxfname.c
+++ b/source/components/namespace/nsxfname.c
@@ -249,7 +249,7 @@ AcpiGetName (
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
- char *NodeName;
+ const char *NodeName;
/* Parameter validation */
diff --git a/source/components/utilities/utdecode.c b/source/components/utilities/utdecode.c
index 580f891..3d927f5 100644
--- a/source/components/utilities/utdecode.c
+++ b/source/components/utilities/utdecode.c
@@ -191,7 +191,7 @@ const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
};
-char *
+const char *
AcpiUtGetRegionName (
UINT8 SpaceId)
{
@@ -213,7 +213,7 @@ AcpiUtGetRegionName (
return ("InvalidSpaceId");
}
- return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
+ return (AcpiGbl_RegionTypes[SpaceId]);
}
@@ -241,7 +241,7 @@ static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
};
-char *
+const char *
AcpiUtGetEventName (
UINT32 EventId)
{
@@ -251,7 +251,7 @@ AcpiUtGetEventName (
return ("InvalidEventID");
}
- return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
+ return (AcpiGbl_EventTypes[EventId]);
}
@@ -316,21 +316,21 @@ static const char *AcpiGbl_NsTypeNames[] =
};
-char *
+const char *
AcpiUtGetTypeName (
ACPI_OBJECT_TYPE Type)
{
if (Type > ACPI_TYPE_INVALID)
{
- return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
+ return (AcpiGbl_BadType);
}
- return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
+ return (AcpiGbl_NsTypeNames[Type]);
}
-char *
+const char *
AcpiUtGetObjectTypeName (
ACPI_OPERAND_OBJECT *ObjDesc)
{
@@ -372,7 +372,7 @@ AcpiUtGetObjectTypeName (
*
******************************************************************************/
-char *
+const char *
AcpiUtGetNodeName (
void *Object)
{
@@ -448,7 +448,7 @@ static const char *AcpiGbl_DescTypeNames[] =
};
-char *
+const char *
AcpiUtGetDescriptorName (
void *Object)
{
@@ -463,9 +463,7 @@ AcpiUtGetDescriptorName (
return ("Not a Descriptor");
}
- return (ACPI_CAST_PTR (char,
- AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
-
+ return (AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]);
}
@@ -542,7 +540,7 @@ AcpiUtGetReferenceName (
/* Names for internal mutex objects, used for debug output */
-static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
+static const char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
{
"ACPI_MTX_Interpreter",
"ACPI_MTX_Namespace",
@@ -552,7 +550,7 @@ static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
"ACPI_MTX_Memory",
};
-char *
+const char *
AcpiUtGetMutexName (
UINT32 MutexId)
{
diff --git a/source/components/utilities/uthex.c b/source/components/utilities/uthex.c
index c652f6a..3a32003 100644
--- a/source/components/utilities/uthex.c
+++ b/source/components/utilities/uthex.c
@@ -122,7 +122,7 @@
/* Hex to ASCII conversion table */
-static char AcpiGbl_HexToAscii[] =
+static const char AcpiGbl_HexToAscii[] =
{
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
};
diff --git a/source/include/acutils.h b/source/include/acutils.h
index 4fc44ff..f9372a2 100644
--- a/source/include/acutils.h
+++ b/source/include/acutils.h
@@ -278,7 +278,7 @@ AcpiUtInitGlobals (
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-char *
+const char *
AcpiUtGetMutexName (
UINT32 MutexId);
@@ -288,15 +288,15 @@ AcpiUtGetNotifyName (
ACPI_OBJECT_TYPE Type);
#endif
-char *
+const char *
AcpiUtGetTypeName (
ACPI_OBJECT_TYPE Type);
-char *
+const char *
AcpiUtGetNodeName (
void *Object);
-char *
+const char *
AcpiUtGetDescriptorName (
void *Object);
@@ -304,15 +304,15 @@ const char *
AcpiUtGetReferenceName (
ACPI_OPERAND_OBJECT *Object);
-char *
+const char *
AcpiUtGetObjectTypeName (
ACPI_OPERAND_OBJECT *ObjDesc);
-char *
+const char *
AcpiUtGetRegionName (
UINT8 SpaceId);
-char *
+const char *
AcpiUtGetEventName (
UINT32 EventId);
6 years, 8 months
Re: [Devel] [PATCH] acpi: set return value to const char for some functions
by Moore, Robert
In ACPICA, we tend to be very careful concerning the "const" keyword in order to avoid a phenomenon known as "const pollution".
That is not to say that we won't use const in some limited cases.
Bob
> -----Original Message-----
> From: LABBE Corentin [mailto:clabbe.montjoie@gmail.com]
> Sent: Wednesday, October 14, 2015 12:07 PM
> To: Moore, Robert; Zheng, Lv; Wysocki, Rafael J; lenb(a)kernel.org
> Cc: linux-acpi(a)vger.kernel.org; devel(a)acpica.org; linux-
> kernel(a)vger.kernel.org; LABBE Corentin
> Subject: [PATCH] acpi: set return value to const char for some functions
>
> This patch set some array of const char as const.
> In the same time, some function return pointer to thoses array without
> properly giving the information that the data is const.
> This patch set the return type of thoses functions as const char *
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie(a)gmail.com>
> ---
> drivers/acpi/acpica/acutils.h | 12 ++++++------
> drivers/acpi/acpica/utdecode.c | 24 ++++++++++++------------
> drivers/acpi/acpica/uthex.c | 4 ++--
> drivers/acpi/tables.c | 6 ++++--
> 4 files changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> index fb2aa50..e5d9d4f 100644
> --- a/drivers/acpi/acpica/acutils.h
> +++ b/drivers/acpi/acpica/acutils.h
> @@ -189,21 +189,21 @@ char *acpi_ut_get_mutex_name(u32 mutex_id); const
> char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type);
> #endif
>
> -char *acpi_ut_get_type_name(acpi_object_type type);
> +const char *acpi_ut_get_type_name(acpi_object_type type);
>
> char *acpi_ut_get_node_name(void *object);
>
> -char *acpi_ut_get_descriptor_name(void *object);
> +const char *acpi_ut_get_descriptor_name(void *object);
>
> const char *acpi_ut_get_reference_name(union acpi_operand_object
> *object);
>
> -char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
> +const char *acpi_ut_get_object_type_name(union acpi_operand_object
> +*obj_desc);
>
> -char *acpi_ut_get_region_name(u8 space_id);
> +const char *acpi_ut_get_region_name(u8 space_id);
>
> -char *acpi_ut_get_event_name(u32 event_id);
> +const char *acpi_ut_get_event_name(u32 event_id);
>
> -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
> +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
>
> u8 acpi_ut_ascii_char_to_hex(int hex_char);
>
> diff --git a/drivers/acpi/acpica/utdecode.c
> b/drivers/acpi/acpica/utdecode.c index 988e23b..e08cdb1 100644
> --- a/drivers/acpi/acpica/utdecode.c
> +++ b/drivers/acpi/acpica/utdecode.c
> @@ -114,7 +114,7 @@ const char
> *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
> "PCC" /* 0x0A */
> };
>
> -char *acpi_ut_get_region_name(u8 space_id)
> +const char *acpi_ut_get_region_name(u8 space_id)
> {
>
> if (space_id >= ACPI_USER_REGION_BEGIN) { @@ -127,7 +127,7 @@ char
> *acpi_ut_get_region_name(u8 space_id)
> return ("InvalidSpaceId");
> }
>
> - return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
> + return (ACPI_CAST_PTR(const char, acpi_gbl_region_types[space_id]));
> }
>
>
> /*************************************************************************
> ******
> @@ -152,14 +152,14 @@ static const char
> *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
> "RealTimeClock",
> };
>
> -char *acpi_ut_get_event_name(u32 event_id)
> +const char *acpi_ut_get_event_name(u32 event_id)
> {
>
> if (event_id > ACPI_EVENT_MAX) {
> return ("InvalidEventID");
> }
>
> - return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
> + return (ACPI_CAST_PTR(const char, acpi_gbl_event_types[event_id]));
> }
>
>
> /*************************************************************************
> ******
> @@ -220,17 +220,17 @@ static const char *acpi_gbl_ns_type_names[] = {
> /* 30 */ "Invalid"
> };
>
> -char *acpi_ut_get_type_name(acpi_object_type type)
> +const char *acpi_ut_get_type_name(acpi_object_type type)
> {
>
> if (type > ACPI_TYPE_INVALID) {
> - return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
> + return (ACPI_CAST_PTR(const char, acpi_gbl_bad_type));
> }
>
> - return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
> + return (ACPI_CAST_PTR(const char, acpi_gbl_ns_type_names[type]));
> }
>
> -char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
> +const char *acpi_ut_get_object_type_name(union acpi_operand_object
> +*obj_desc)
> {
>
> if (!obj_desc) {
> @@ -318,7 +318,7 @@ static const char *acpi_gbl_desc_type_names[] = {
> /* 15 */ "Node"
> };
>
> -char *acpi_ut_get_descriptor_name(void *object)
> +const char *acpi_ut_get_descriptor_name(void *object)
> {
>
> if (!object) {
> @@ -329,7 +329,7 @@ char *acpi_ut_get_descriptor_name(void *object)
> return ("Not a Descriptor");
> }
>
> - return (ACPI_CAST_PTR(char,
> + return (ACPI_CAST_PTR(const char,
> acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
> (object)]));
>
> @@ -400,7 +400,7 @@ const char *acpi_ut_get_reference_name(union
> acpi_operand_object *object)
>
> /* Names for internal mutex objects, used for debug output */
>
> -static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> +static const char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> "ACPI_MTX_Interpreter",
> "ACPI_MTX_Namespace",
> "ACPI_MTX_Tables",
> @@ -411,7 +411,7 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
> "ACPI_MTX_CommandReady"
> };
>
> -char *acpi_ut_get_mutex_name(u32 mutex_id)
> +const char *acpi_ut_get_mutex_name(u32 mutex_id)
> {
>
> if (mutex_id > ACPI_MAX_MUTEX) {
> diff --git a/drivers/acpi/acpica/uthex.c b/drivers/acpi/acpica/uthex.c
> index fda8b3d..9239711 100644
> --- a/drivers/acpi/acpica/uthex.c
> +++ b/drivers/acpi/acpica/uthex.c
> @@ -48,7 +48,7 @@
> ACPI_MODULE_NAME("uthex")
>
> /* Hex to ASCII conversion table */
> -static char acpi_gbl_hex_to_ascii[] = {
> +static const char acpi_gbl_hex_to_ascii[] = {
> '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
> 'D',
> 'E', 'F'
> };
> @@ -67,7 +67,7 @@ static char acpi_gbl_hex_to_ascii[] = {
> *
>
> **************************************************************************
> ****/
>
> -char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> +const char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
> {
>
> return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); diff --
> git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 17a6fa0..7c8a037
> 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -35,8 +35,10 @@
>
> #define ACPI_MAX_TABLES 128
>
> -static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
> -static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level"
> };
> +static const char * const mps_inti_flags_polarity[] = {
> + "dfl", "high", "res", "low" };
> +static const char * const mps_inti_flags_trigger[] = {
> + "dfl", "edge", "res", "level" };
>
> static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
>
> --
> 2.4.9
6 years, 8 months
Re: [Devel] [PATCH] ACPICA: AcpiGetSleepTypeData: Failure to find \_Sx should not result in a loud warning [v2]
by Zheng, Lv
Hi,
> From: Prarit Bhargava [mailto:prarit@redhat.com]
> Sent: Friday, October 09, 2015 7:30 PM
>
> On 10/09/2015 01:26 AM, Zheng, Lv wrote:
> > Please ignore this.
> > The fix is against the caller.
> >
> > Thanks and best regards
> > -Lv
> >
> >> From: Devel [mailto:devel-bounces@acpica.org] On Behalf Of Zheng, Lv
> >> Sent: Friday, October 09, 2015 10:02 AM
> >>
> >> Why don't you fix this in the invoker side?
> >> For example:
> >> If (acpi_get_handle())
> >> acpi_evaluate_object()
>
> That seems like a sloppy workaround an actual bug in ACPICA.
So let me ignore this which is a reply for a useless question.
>
> >> So that the AE_NOT_FOUND warning can still be kept for the real troubles?
>
> The code is warning 100% of the time on something that is optional.
Let me ignore this which is a reply for a useless question.
>
> >> There are really scenarios that such warning is useful for catching bugs.
> >>
>
> What scenario is possible where this causes a problem? Issuing an error on
> something that is optional is not a good idea.
There are several scenarios, let me say some known stuffs about the module level code support.
In AML grammar, module level code (non-object-definition AML opcodes outside of a control method) is legal.
While it is supported in ACPICA in a split way:
1. In the early stage, table loading code only executes those object definition opcodes and links all "if/else/while" AML fragments together.
2. In the late stage, object initialization code will execute such AML fragments before invoking all _INI methods.
1. Since code is not executed in the Windows compliant order during the early table loading stage, some objects are not defined while they should.
2. Even worse, during the early stage, ACPICA may fail the whole table loading process due to AE_NOT_FOUND, leaving us partial initialized objects (the ACPICA AML interpreter implements 2 phases to parse a table to complete the table loading).
Such issue is worked around by deleting the namespace objects created during the early stage if an exception (AE_NOT_FOUND) is encountered.
So you can see, such kind of error is sometime useful for catching AML interpreter issues or BIOS bugs.
Thanks and best regards
-Lv
6 years, 8 months
Re: [Devel] [PATCH] ACPICA: AcpiGetSleepTypeData: Failure to find \_Sx should not result in a loud warning [v2]
by Zheng, Lv
Hi,
> From: Prarit Bhargava [mailto:prarit@redhat.com]
> Sent: Friday, October 09, 2015 7:30 PM
>
> On 10/09/2015 01:26 AM, Zheng, Lv wrote:
> > Please ignore this.
> > The fix is against the caller.
As I said, the previous email is sent due to lack of confirmation.
So you needn't reply the previous message.
Thanks
-Lv
> >
> > Thanks and best regards
> > -Lv
> >
> >> From: Devel [mailto:devel-bounces@acpica.org] On Behalf Of Zheng, Lv
> >> Sent: Friday, October 09, 2015 10:02 AM
> >>
> >> Why don't you fix this in the invoker side?
> >> For example:
> >> If (acpi_get_handle())
> >> acpi_evaluate_object()
>
> That seems like a sloppy workaround an actual bug in ACPICA.
>
> >> So that the AE_NOT_FOUND warning can still be kept for the real troubles?
>
> The code is warning 100% of the time on something that is optional.
>
> >> There are really scenarios that such warning is useful for catching bugs.
> >>
>
> What scenario is possible where this causes a problem? Issuing an error on
> something that is optional is not a good idea.
>
> P.
6 years, 8 months
Re: [Devel] [PATCH] ACPICA: AcpiGetSleepTypeData: Failure to find \_Sx should not result in a loud warning [v2]
by Moore, Robert
I have no issues with the original solution. We don't warn on other ACPI_NOT_FOUND exceptions.
> -----Original Message-----
> From: Prarit Bhargava [mailto:prarit@redhat.com]
> Sent: Friday, October 09, 2015 4:30 AM
> To: Zheng, Lv; Moore, Robert; devel(a)acpica.org
> Cc: linux-acpi(a)vger.kernel.org; Wysocki, Rafael J
> Subject: Re: [PATCH] ACPICA: AcpiGetSleepTypeData: Failure to find \_Sx
> should not result in a loud warning [v2]
>
>
>
> On 10/09/2015 01:26 AM, Zheng, Lv wrote:
> > Please ignore this.
> > The fix is against the caller.
> >
> > Thanks and best regards
> > -Lv
> >
> >> -----Original Message-----
> >> From: Devel [mailto:devel-bounces@acpica.org] On Behalf Of Zheng, Lv
> >> Sent: Friday, October 09, 2015 10:02 AM
> >> To: Prarit Bhargava; Moore, Robert; devel(a)acpica.org
> >> Cc: linux-acpi(a)vger.kernel.org; Wysocki, Rafael J
> >> Subject: Re: [Devel] [PATCH] ACPICA: AcpiGetSleepTypeData: Failure to
> >> find \_Sx should not result in a loud warning [v2]
> >>
> >> Why don't you fix this in the invoker side?
> >> For example:
> >> If (acpi_get_handle())
> >> acpi_evaluate_object()
>
> That seems like a sloppy workaround an actual bug in ACPICA.
>
> >> So that the AE_NOT_FOUND warning can still be kept for the real
> troubles?
>
> The code is warning 100% of the time on something that is optional.
>
> >> There are really scenarios that such warning is useful for catching
> bugs.
> >>
>
> What scenario is possible where this causes a problem? Issuing an error
> on something that is optional is not a good idea.
>
> P.
6 years, 8 months