linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 linux-next] ACPI: processor: use container_of to resolve acpi_madt_local_apic/sapic/x2apic from acpi_subtable_header
@ 2014-09-14 13:12 Fabian Frederick
  2014-09-25 23:48 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2014-09-14 13:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, Rafael J. Wysocki, Len Brown, linux-acpi

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---

Compiled but untested.

 drivers/acpi/processor_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index e32321c..ef58f46 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -16,7 +16,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
 		 u32 acpi_id, int *apic_id)
 {
 	struct acpi_madt_local_apic *lapic =
-		(struct acpi_madt_local_apic *)entry;
+		container_of(entry, struct acpi_madt_local_apic, header);
 
 	if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
 		return -ENODEV;
@@ -32,7 +32,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
 			 int device_declaration, u32 acpi_id, int *apic_id)
 {
 	struct acpi_madt_local_x2apic *apic =
-		(struct acpi_madt_local_x2apic *)entry;
+		container_of(entry, struct acpi_madt_local_x2apic, header);
 
 	if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
 		return -ENODEV;
@@ -49,7 +49,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
 		int device_declaration, u32 acpi_id, int *apic_id)
 {
 	struct acpi_madt_local_sapic *lsapic =
-		(struct acpi_madt_local_sapic *)entry;
+		container_of(entry, struct acpi_madt_local_sapic, header);
 
 	if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
 		return -ENODEV;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1 linux-next] ACPI: processor: use container_of to resolve acpi_madt_local_apic/sapic/x2apic from acpi_subtable_header
  2014-09-14 13:12 [PATCH 1/1 linux-next] ACPI: processor: use container_of to resolve acpi_madt_local_apic/sapic/x2apic from acpi_subtable_header Fabian Frederick
@ 2014-09-25 23:48 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2014-09-25 23:48 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, Len Brown, linux-acpi

On Sunday, September 14, 2014 03:12:43 PM Fabian Frederick wrote:
> Use container_of instead of casting first structure member.
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

Queued up for 3.18, thanks!

> ---
> 
> Compiled but untested.
> 
>  drivers/acpi/processor_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index e32321c..ef58f46 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -16,7 +16,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
>  		 u32 acpi_id, int *apic_id)
>  {
>  	struct acpi_madt_local_apic *lapic =
> -		(struct acpi_madt_local_apic *)entry;
> +		container_of(entry, struct acpi_madt_local_apic, header);
>  
>  	if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
>  		return -ENODEV;
> @@ -32,7 +32,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
>  			 int device_declaration, u32 acpi_id, int *apic_id)
>  {
>  	struct acpi_madt_local_x2apic *apic =
> -		(struct acpi_madt_local_x2apic *)entry;
> +		container_of(entry, struct acpi_madt_local_x2apic, header);
>  
>  	if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
>  		return -ENODEV;
> @@ -49,7 +49,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
>  		int device_declaration, u32 acpi_id, int *apic_id)
>  {
>  	struct acpi_madt_local_sapic *lsapic =
> -		(struct acpi_madt_local_sapic *)entry;
> +		container_of(entry, struct acpi_madt_local_sapic, header);
>  
>  	if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
>  		return -ENODEV;
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-25 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-14 13:12 [PATCH 1/1 linux-next] ACPI: processor: use container_of to resolve acpi_madt_local_apic/sapic/x2apic from acpi_subtable_header Fabian Frederick
2014-09-25 23:48 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).