lkml.org 
[lkml]   [2019]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: fieldbus: anybuss: force address space conversion
On Tue, May 21, 2019 at 11:53:15AM -0400, Sven Van Asbroeck wrote:
> On Tue, May 21, 2019 at 11:42 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > Ick, if you are using __force, almost always something is wrong.
> >
>
> What if I create a separate structure for the regmap context ?
>
> struct anybus_regmap_context {
> void __iomem *base;
> };
>
> Then just store the base pointer inside the struct, and pass the struct
> as the regmap context:
>
> ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> ctx->base = base;
> devm_regmap_init(..., ctx);
>
> static int write_reg_bus(void *context, unsigned int reg,
> unsigned int val)
> {
> struct anybus_regmap_context *ctx = context;
> <now access ctx->base>
> }

Ick, no.

> Penalty is an additional dynamic pointer-size
> allocation. Pro: it'll be formally correct ?

what is so odd about this code that makes you have to jump through
strange hoops that no other driver has to?

Just set your pointer types up properly to start with, and all should be
fine. Why are you trying to cast anything here?

thanks,

greg k-h

\
 
 \ /
  Last update: 2019-05-21 18:25    [W:0.200 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site