Skip to contentSkip to conversation

cxl/mbox: Drop extra struct resource cast

PATCH Superseded Jonathan Cameron 3 participants 4 messages Feb 28, 2023 – Mar 1, 2023 CXL

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl/mbox: Drop extra struct resource cast

DEFINE_RES_MEM() is a wrapper around the DEFINE_RES_NAMED() macro which already has the (struct resource) cast.

Fixes warnings with W=1 C=1
CC [M] drivers/cxl/core/mbox.o
CHECK drivers/cxl/core/mbox.c
drivers/cxl/core/mbox.c:1064:18: warning: cast to non-scalar drivers/cxl/core/mbox.c:1064:18: warning: cast from non-scalar

Fixes 52c4d11f1dce ("resource: Convert DEFINE_RES_NAMED() to be compound literal")
Cc Andy Shevchenko <[email protected]>

---

I'm seeing a couple of other instances of this
drivers/acpi/arm64/gtdt.c
arch/arm/mach-shmobile/pm-rcar-gen2.c

Might get around to fixing them but more than happy if someone beats me to it.

 drivers/cxl/core/mbox.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/mbox.c +1 -2
index f2addb457172..dce16088ceee 100644
@@ -1052,8 +1052,7 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
 	struct device *dev = cxlds->dev;
 	int rc;
 
-	cxlds->dpa_res =
-		(struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
+	cxlds->dpa_res = DEFINE_RES_MEM(0, cxlds->total_bytes);
 
 	if (cxlds->partition_align_bytes == 0) {
 		rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
Signature · 1 line
2.37.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jonathan Cameron

DEFINE_RES_MEM() is a wrapper around the DEFINE_RES_NAMED() macro which already has the (struct resource) cast.

Fixes warnings with W=1 C=1
CC [M] drivers/cxl/core/mbox.o
CHECK drivers/cxl/core/mbox.c
drivers/cxl/core/mbox.c:1064:18: warning: cast to non-scalar drivers/cxl/core/mbox.c:1064:18: warning: cast from non-scalar

Quoted 3 lines
Fixes 52c4d11f1dce ("resource: Convert DEFINE_RES_NAMED() to be compound literal")
Cc Andy Shevchenko <[email protected]>
Quoted 25 lines

---

I'm seeing a couple of other instances of this
drivers/acpi/arm64/gtdt.c
arch/arm/mach-shmobile/pm-rcar-gen2.c

Might get around to fixing them but more than happy if someone beats me to it.

  drivers/cxl/core/mbox.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/mbox.c +1 -2
index f2addb457172..dce16088ceee 100644
@@ -1052,8 +1052,7 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
  	struct device *dev = cxlds->dev;
  	int rc;
 
-	cxlds->dpa_res =
-		(struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
+	cxlds->dpa_res = DEFINE_RES_MEM(0, cxlds->total_bytes);
 
  	if (cxlds->partition_align_bytes == 0) {
  		rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jonathan Cameron
Quoted 2 lines · Jonathan Cameron

DEFINE_RES_MEM() is a wrapper around the DEFINE_RES_NAMED() macro which already has the (struct resource) cast.

It's not a cast. As commit message that brought it says: "Converting it to be a compound literal..."

Quoted 5 lines

Fixes warnings with W=1 C=1
CC [M] drivers/cxl/core/mbox.o
CHECK drivers/cxl/core/mbox.c
drivers/cxl/core/mbox.c:1064:18: warning: cast to non-scalar drivers/cxl/core/mbox.c:1064:18: warning: cast from non-scalar

Otherwise it's a correct fix, thank you!
For the corrected version:

Quoted 31 lines
Fixes 52c4d11f1dce ("resource: Convert DEFINE_RES_NAMED() to be compound literal")
Cc Andy Shevchenko <[email protected]>

---

I'm seeing a couple of other instances of this
drivers/acpi/arm64/gtdt.c
arch/arm/mach-shmobile/pm-rcar-gen2.c

Might get around to fixing them but more than happy if someone beats me to it.

 drivers/cxl/core/mbox.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/mbox.c +1 -2
index f2addb457172..dce16088ceee 100644
@@ -1052,8 +1052,7 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
 	struct device *dev = cxlds->dev;
 	int rc;
 
-	cxlds->dpa_res =
-		(struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
+	cxlds->dpa_res = DEFINE_RES_MEM(0, cxlds->total_bytes);
 
 	if (cxlds->partition_align_bytes == 0) {
 		rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
Signature · 1 line
2.37.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Cameron

DEFINE_RES_MEM() is a wrapper around the DEFINE_RES_NAMED() macro which already has the (struct resource) cast.

It's not a cast. As commit message that brought it says: "Converting it to be a compound literal..."

...

Quoted 2 lines

drivers/cxl/core/mbox.c int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) · line 1056

Quoted 2 lines
drivers/cxl/core/mbox.c +0 -2
-	cxlds->dpa_res =
-		(struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);

FWIW, here it's also not a cast.

Signature · 2 lines
With Best Regards,
Andy Shevchenko