* [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info()
@ 2023-08-04 19:03 alison.schofield
2023-08-07 13:33 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: alison.schofield @ 2023-08-04 19:03 UTC (permalink / raw)
To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Ira Weiny, Dan Williams
Cc: linux-cxl
From: Alison Schofield <alison.schofield@intel.com>
DEFINE_RES_MEM() returns a struct resource so the cast is not needed.
Remove it.
Found using sparse:
drivers/cxl/core/mbox.c:1184:18: warning: cast to non-scalar
drivers/cxl/core/mbox.c:1184:18: warning: cast from non-scalar
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
drivers/cxl/core/mbox.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index d6d067fbee97..01de4b438b2a 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1180,8 +1180,7 @@ int cxl_mem_create_range_info(struct cxl_memdev_state *mds)
return 0;
}
- cxlds->dpa_res =
- (struct resource)DEFINE_RES_MEM(0, mds->total_bytes);
+ cxlds->dpa_res = DEFINE_RES_MEM(0, mds->total_bytes);
if (mds->partition_align_bytes == 0) {
rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
base-commit: fe77cc2e5a6a7c85f5c6ef8a39d7694ffc7f41c9
--
2.37.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info()
2023-08-04 19:03 [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info() alison.schofield
@ 2023-08-07 13:33 ` Jonathan Cameron
2023-08-07 14:28 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2023-08-07 13:33 UTC (permalink / raw)
To: alison.schofield
Cc: Davidlohr Bueso, Dave Jiang, Vishal Verma, Ira Weiny,
Dan Williams, linux-cxl, Andy Shevchenko
On Fri, 4 Aug 2023 12:03:09 -0700
alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> DEFINE_RES_MEM() returns a struct resource so the cast is not needed.
> Remove it.
>
> Found using sparse:
> drivers/cxl/core/mbox.c:1184:18: warning: cast to non-scalar
> drivers/cxl/core/mbox.c:1184:18: warning: cast from non-scalar
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Good to call out this is a result of Andy's cleanup
42c4211f1 ("resource: Convert DEFINE_RES_NAMED() to be a compound literal")
I thought we'd long caught all of these (IIRC there were a few at the time).
Ah well.
Jonathan
> ---
> drivers/cxl/core/mbox.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index d6d067fbee97..01de4b438b2a 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -1180,8 +1180,7 @@ int cxl_mem_create_range_info(struct cxl_memdev_state *mds)
> return 0;
> }
>
> - cxlds->dpa_res =
> - (struct resource)DEFINE_RES_MEM(0, mds->total_bytes);
> + cxlds->dpa_res = DEFINE_RES_MEM(0, mds->total_bytes);
>
> if (mds->partition_align_bytes == 0) {
> rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
>
> base-commit: fe77cc2e5a6a7c85f5c6ef8a39d7694ffc7f41c9
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info()
2023-08-07 13:33 ` Jonathan Cameron
@ 2023-08-07 14:28 ` Andy Shevchenko
2023-08-15 16:46 ` Alison Schofield
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-07 14:28 UTC (permalink / raw)
To: Jonathan Cameron
Cc: alison.schofield, Davidlohr Bueso, Dave Jiang, Vishal Verma,
Ira Weiny, Dan Williams, linux-cxl
On Mon, Aug 07, 2023 at 02:33:34PM +0100, Jonathan Cameron wrote:
> On Fri, 4 Aug 2023 12:03:09 -0700
> alison.schofield@intel.com wrote:
>
> > From: Alison Schofield <alison.schofield@intel.com>
> >
> > DEFINE_RES_MEM() returns a struct resource so the cast is not needed.
> > Remove it.
> Good to call out this is a result of Andy's cleanup
>
> 42c4211f1 ("resource: Convert DEFINE_RES_NAMED() to be a compound literal")
>
> I thought we'd long caught all of these (IIRC there were a few at the time).
> Ah well.
We caught only compile-time errors. The "casting" of the compound literal is
only a warning which doesn't affect code generation.
Btw, Alison, the commit message should really be more clear about those macros.
They are compound literals, which are associated with the corresponding data
type. It's not a cast there, but only on the side of the user. I'm not a native
speaker to suggest on how to amend, maybe Jonathan can help?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info()
2023-08-07 14:28 ` Andy Shevchenko
@ 2023-08-15 16:46 ` Alison Schofield
0 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2023-08-15 16:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, Davidlohr Bueso, Dave Jiang, Vishal Verma,
Ira Weiny, Dan Williams, linux-cxl
On Mon, Aug 07, 2023 at 05:28:00PM +0300, Andy Shevchenko wrote:
> On Mon, Aug 07, 2023 at 02:33:34PM +0100, Jonathan Cameron wrote:
> > On Fri, 4 Aug 2023 12:03:09 -0700
> > alison.schofield@intel.com wrote:
> >
> > > From: Alison Schofield <alison.schofield@intel.com>
> > >
> > > DEFINE_RES_MEM() returns a struct resource so the cast is not needed.
> > > Remove it.
>
> > Good to call out this is a result of Andy's cleanup
> >
> > 42c4211f1 ("resource: Convert DEFINE_RES_NAMED() to be a compound literal")
> >
> > I thought we'd long caught all of these (IIRC there were a few at the time).
> > Ah well.
>
> We caught only compile-time errors. The "casting" of the compound literal is
> only a warning which doesn't affect code generation.
>
> Btw, Alison, the commit message should really be more clear about those macros.
> They are compound literals, which are associated with the corresponding data
> type. It's not a cast there, but only on the side of the user. I'm not a native
> speaker to suggest on how to amend, maybe Jonathan can help?
Thanks Andy. I see the language others used in these. Will send a v2.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-15 16:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 19:03 [PATCH] cxl/mbox: Remove useless cast in cxl_mem_create_range_info() alison.schofield
2023-08-07 13:33 ` Jonathan Cameron
2023-08-07 14:28 ` Andy Shevchenko
2023-08-15 16:46 ` Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox