Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3694475imm; Mon, 1 Oct 2018 02:59:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61iKPVxYiBQ95i5KBq+t/E1suo8eObLVhpnu/Y9zZyeC1sqODwfP4+m3MRJXRH8EzR/Ic3O X-Received: by 2002:a62:1b45:: with SMTP id b66-v6mr10690178pfb.94.1538387969121; Mon, 01 Oct 2018 02:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538387969; cv=none; d=google.com; s=arc-20160816; b=VWzAlXvW9sDUCryExcl3vjODFRr2L8AYIbjMxibYaoU/vGNdjyPpEytR6I5ktOifG5 9Ut3vyy2lS0mbPoW/r3okQ8OgjNZLlktQn5zBmNyO6NvA+DiB4hCTGeSJuIxGuom5im8 heE6l7QDQg3xXLcAxQTuOfZWLxsBdh6dV2+PDwk1PIhMqQMG6jDMUd4M1tnW6rDXlcTk 0/PvRKZRg73fAR6Yna/l9riP1lOdu/3kxZv/FXNO/6tGOoSrRxIdU4ZBF94TgTD3Foiq m664ZO7i2KiSeLliTfq3Izrn8B6oIAk8p+NsIhQu0KVHg61IzLdGHXCD1rScIU6VZWS3 8T+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aoxUv1amQS309vw9heAFYM23S2w200754FaqxEoKKV0=; b=gefIk5+bNB691vJNeOOwAIgP3aqX+HPGtgIXuAKOn00DPIwqTtghcfQE61rHheZ8Pj MF79b25LXNtvxtC8AmNYBUDd9qGi/VgLwbGAB/BAswKsVUS/Mgcb7hdIuApRfa0eMXIT XRlCtNiG0RDvgAklcfxiTp2ICzpmc5+SDnw5LOPRNF0dVBuGEDNkUdC/wGiDkNBpGqor MG5eLT+jp7ktO1acaLhIdeA70MxD7rQsyqQ3JZp46Ihp2yNLvo+k944kUU9KT0c4u5ln ejvbJwfRabmAVs3BL/2XW9vGxj6fAZbJrRerJ2T7U7LsLjc0k5xjFs3VT+8jjmaSBBK+ s2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SEwsT+4e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10-v6si11971256pgr.291.2018.10.01.02.59.14; Mon, 01 Oct 2018 02:59:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SEwsT+4e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729112AbeJAQgH (ORCPT + 99 others); Mon, 1 Oct 2018 12:36:07 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34827 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729035AbeJAQgH (ORCPT ); Mon, 1 Oct 2018 12:36:07 -0400 Received: by mail-lf1-f66.google.com with SMTP id r191-v6so9390054lff.2 for ; Mon, 01 Oct 2018 02:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=aoxUv1amQS309vw9heAFYM23S2w200754FaqxEoKKV0=; b=SEwsT+4e3zDgNhWF2iBlvAd1cItsk/L4aTIh5E4rc7dkTPJmtprL4VV3FtM2HkA9XO Ae23U4r0IvyTVUuOrDK892WJh+tWvmZL/U7diyBYy/U+pZJlQm+3VjxD1mtJj60iucYo Xh3GmzkNTVk/C/n6xB2O/Pfamd0D1fWKkgMlQbGKlCDvIGPDEYvAaFZDvsuzGJyW32Y8 8S7Js1BxZj0fVGaSujJUR8NoIBtvUaHEC8zpUpa2DbZHKsXv0dNzxVDXu+y6jb2/Okqg UwX1qp8IVK3C5z9oeskxLlJ/AClTh13KxSJQLSHOd+V1sFXEIjA0y4Prba9odPeHOWKq OAVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=aoxUv1amQS309vw9heAFYM23S2w200754FaqxEoKKV0=; b=RhblNO/EXAKMOC10XP+4ByMOhY3H2XqMWND7yVxEgyCEbPZ7xHayhD4f9bDc6vN3t8 Z5gW8MPwUOiGic2PiKW5ZQCp5IaPyAFVVDzJK5aOjCiqwz2PvJvmzOMFqzS4H7fw7Ot9 wSWK9ljbN6OAd2LSAYGLPYQm9HzihKJ+n8RpvAoPjeno/W89Kt4+ZvyZ+dK/7/byXzzM l7Q2GHjgBTpVUiTwwUaQ6boUt4h99bijPZUjBdr/07xoedX2zwDrqXuMChWtT1BGLVRw ZQokHKare6TV8FgMt1YgRmn48+6QY/hY3/HLj31n2QuRAlbcPET7y+BvgBEzB/D3DjEX OpCA== X-Gm-Message-State: ABuFfohiWMeIBivMHNk6k2AWXzkvQxjuWvwimd0FAdUIue5lSaw+EtnP r7ftUKpGYk6V7cKdP9ag3RM4OGIF9USiwzyYw44= X-Received: by 2002:a19:7411:: with SMTP id v17-v6mr4918784lfe.49.1538387946091; Mon, 01 Oct 2018 02:59:06 -0700 (PDT) MIME-Version: 1.0 References: <20180905143643.9871-1-ricardo.ribalda@gmail.com> <20180905143643.9871-7-ricardo.ribalda@gmail.com> In-Reply-To: <20180905143643.9871-7-ricardo.ribalda@gmail.com> From: Ricardo Ribalda Delgado Date: Mon, 1 Oct 2018 11:58:49 +0200 Message-ID: Subject: Re: [PATCH v2 6/8] mtd: maps: gpio-addr-flash: Split allocation in two To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris PLEASE do not apply this one! There is a bug, value from gpio->addr is lost. On Wed, Sep 5, 2018 at 4:37 PM Ricardo Ribalda Delgado wrote: > > Instead of making one allocation and then calculating the addresses of > those two pointers in that area make two allocations. This simplifies > the code. > > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/mtd/maps/gpio-addr-flash.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c > index 8f5e3dce9be3..9455a8448064 100644 > --- a/drivers/mtd/maps/gpio-addr-flash.c > +++ b/drivers/mtd/maps/gpio-addr-flash.c > @@ -205,7 +205,7 @@ static const char * const part_probe_types[] = { > */ > static int gpio_flash_probe(struct platform_device *pdev) > { > - size_t i, arr_size; > + size_t i; > struct physmap_flash_data *pdata; > struct resource *memory; > struct resource *gpios; > @@ -218,8 +218,7 @@ static int gpio_flash_probe(struct platform_device *pdev) > if (!memory || !gpios || !gpios->end) > return -EINVAL; > > - arr_size = sizeof(state->gpio_addrs[0]) * gpios->end; > - state = devm_kzalloc(&pdev->dev, sizeof(*state) + arr_size, GFP_KERNEL); > + state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL); > if (!state) > return -ENOMEM; > > @@ -228,7 +227,12 @@ static int gpio_flash_probe(struct platform_device *pdev) > * away their pointer types here to the known types (gpios->xxx). > */ > state->gpio_count = gpios->end; > - state->gpio_addrs = (void *)(unsigned long)gpios->start; > + state->gpio_addrs = devm_kzalloc(&pdev->dev, > + sizeof(state->gpio_addrs[0]) * > + gpios->end, > + GFP_KERNEL); > + if (!state->gpio_addrs) > + return -ENOMEM; > state->win_order = get_bitmask_order(resource_size(memory)) - 1; > > state->map.name = DRIVER_NAME; > -- > 2.18.0 > -- Ricardo Ribalda