Thread (11 messages) 11 messages, 2 authors, 2020-08-19

Re: [PATCH v7 1/3] devres: provide devm_krealloc()

From: Bartosz Golaszewski <hidden>
Date: 2020-08-18 16:29:19
Also in: linux-iio, lkml

On Tue, Aug 18, 2020 at 10:40 AM Andy Shevchenko
[off-list ref] wrote:
On Mon, Aug 17, 2020 at 10:02:05PM +0200, Bartosz Golaszewski wrote:
quoted
On Mon, Aug 17, 2020 at 7:43 PM Andy Shevchenko
[off-list ref] wrote:
quoted
On Mon, Aug 17, 2020 at 07:05:33PM +0200, Bartosz Golaszewski wrote:
quoted
From: Bartosz Golaszewski <redacted>
...
quoted
quoted
quoted
+static struct devres *to_devres(void *data)
+{
+     return (struct devres *)((u8 *)data - ALIGN(sizeof(struct devres),
+                                                 ARCH_KMALLOC_MINALIGN));
Do you really need both explicit castings?
Yeah, we can probably drop the (struct devres *) here.
void * -> u8 * here is also not needed, it is considered byte access IIRC.
Actually it turns out that while we don't need the (void *) -> (u8 *)
casting, we must cast to (struct devres *) or the following error is
produced:

drivers/base/devres.c: In function ‘to_devres’:
drivers/base/devres.c:41:21: error: returning ‘u8 *’ {aka ‘unsigned
char *’} from a function with incompatible return type ‘struct devres
*’ [-Werror=incompatible-pointer-types]
  return ((u8 *)data - ALIGN(sizeof(struct devres),
         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ARCH_KMALLOC_MINALIGN));
        ~~~~~~~~~~~~~~~~~~~~~~~

Bart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help