Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp548381imm; Mon, 1 Oct 2018 14:21:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63fVvKtuSABXwQ4WxAY1MiYAKBAiHPhMNEbh9IUUDeytzn3S+GvMq0NK/7uFzaW0DcfoATN X-Received: by 2002:a62:2c53:: with SMTP id s80-v6mr13047503pfs.154.1538428876931; Mon, 01 Oct 2018 14:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538428876; cv=none; d=google.com; s=arc-20160816; b=xY30sOHzMZfl3xtmczmHy9/HfHCvW+ATG+uxt2OgDGd5Lgcv1IDvmpt9LVTDGCSyKx tPFmOz2XzgFLeY6499IJEK8tQ/2PGqTyCFtoEu3ye3R2MsPsF7fqu0nVXRXK7mZ5Ypup BJGLNrWpoZh3wa2KACQQ2fR2x2x+OU27lWK0ZWUMTqOCwwLOrMywiEHW6pvHtKHZuJlG uAhtZoo9o9lWEBbgFxpxiP1wpFfckkYrDbRlj5AGKfSAQwAwqGP+uZzqrVFNmMe5NZfZ VJm1tpPBmTpg1RkFu4JmqXTeuGqxqUqAy4EC1cD5QLO68AAXzO4r2MGyN5l5JKX9F0dC kgGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vyboSOFxF8XcZqDE1GI8yEINP0b3eT4WXFPPdhP28hA=; b=ssFlTAr+f9UDQ1hEWwh6afjWjIOUhRXySjppuXxmRJJf/ENK8OQEVNHX7JVpXVoD+p 7HWTe6mSZXZtZnM+Q5uy8LWh2TzefUBVyziwRtty6I2UkNoES6hMYEnP69IGrTdQ2NfT w44dkZO+ajr8SVDIJ1v3cm66zwmccRzaUBgf9Dsh+yPWVoxJ88vfc+rYK/gVrKR8koFd cfo/TSOr1guyQuob6GASVK183N2atUdLnBJTjWHSlU6x9IlXh9nlMptEeboRgruoFqFl oC4S/mPYNU1addl+BlclzQqmMiTL/2Ms2iMhszdIGbg2kih1fNYaMC/WfXBje2aUuTBe U4AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjWlsPAD; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65-v6si12042031pff.276.2018.10.01.14.21.02; Mon, 01 Oct 2018 14:21:16 -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=@linaro.org header.s=google header.b=LjWlsPAD; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725936AbeJBEAT (ORCPT + 99 others); Tue, 2 Oct 2018 00:00:19 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46809 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbeJBEAT (ORCPT ); Tue, 2 Oct 2018 00:00:19 -0400 Received: by mail-io1-f68.google.com with SMTP id t7-v6so3204751ioj.13 for ; Mon, 01 Oct 2018 14:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vyboSOFxF8XcZqDE1GI8yEINP0b3eT4WXFPPdhP28hA=; b=LjWlsPADeCh/d+y5Ikg0HiFACMPVCM5/hSr0H/j8buxruZfIu1rY7mYwQWScEXKbop SmUJXRD0xxtORRewzPexZVvZVk9xQcD7OLsqT0U2uK163UOvYY4a/Hst9mNXV3Pio+ai Ohw8dyUruZaELwtSqLCbHQYXbpYOHnpkNmrBc= 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:cc; bh=vyboSOFxF8XcZqDE1GI8yEINP0b3eT4WXFPPdhP28hA=; b=Ama8iDjRpPP77nAjlVSJ63EJfRKwAjovmGQWs3eU/wCgJHTcnRvVV/zbVHdH9hB0gi Xc7FH96c6aLaveGKnMCwVrseGK1LaPmaglQsrCvqJAJzx/58Xceb2H38sQwm9JkCGNPN 3r/1k/KOcz5yPyP8r5qYOzsjK3pxuKUqZfRu1Kxb/PRCU2HAELqkgMUacGSTL/vtEuUN t8LgqaNrmhMcm/J3KkBRt53WvItk7wpFBn/bHslmYBz4FkKV16AjDIfehS5+13WGrGyL HTebKUx/WFMe4H7msAqRuHr/9BtZCYcfE+rn44Dg85xof0uunkafxjqCdknSCyxQ3WjE cl5Q== X-Gm-Message-State: ABuFfoisQ2TObdD7bYBYrQTaBlw6sUhb008NpE209TSPZl6e7wgt+rYD ZZe6A6MUAxy+xcsoQ4FL5PiaGqyKPJhZNKCyrsoyxw== X-Received: by 2002:a6b:630a:: with SMTP id p10-v6mr8505934iog.175.1538428833928; Mon, 01 Oct 2018 14:20:33 -0700 (PDT) MIME-Version: 1.0 References: <20180921103604.13361-1-ricardo.ribalda@gmail.com> <20180921103604.13361-2-ricardo.ribalda@gmail.com> <153803107307.119890.10052910965015646333@swboyd.mtv.corp.google.com> <3e07cab8-0f3e-7474-8f6d-e6bb16e8f998@codeaurora.org> <5aea282d-6fc9-cd70-cec4-10f28aa819b9@codeaurora.org> In-Reply-To: From: Linus Walleij Date: Mon, 1 Oct 2018 23:20:21 +0200 Message-ID: Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning To: Ricardo Ribalda Delgado Cc: timur@kernel.org, jhugo@codeaurora.org, Stephen Boyd , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" 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 On Mon, Oct 1, 2018 at 3:36 PM Ricardo Ribalda Delgado wrote: > On Mon, Oct 1, 2018 at 1:54 PM Linus Walleij wrote: > > On Fri, Sep 28, 2018 at 9:30 PM Ricardo Ribalda Delgado > > wrote: > > > > > How do we proceed from here? Can you fix your driver somehow to > > > init the valid mask before enabling the gpio? > > > > Just include a hunk to the qcom driver reordering this call > > at the same time. No need to make it separate patches, > > it need to be tested together anyways. > > > > I guess just switch the order of these two: > > > > ret = gpiochip_add_data(&pctrl->chip, pctrl); > > if (ret) { > > dev_err(pctrl->dev, "Failed register gpiochip\n"); > > return ret; > > } > > > > ret = msm_gpio_init_valid_mask(chip, pctrl); > > if (ret) { > > dev_err(pctrl->dev, "Failed to setup irq valid bits\n"); > > gpiochip_remove(&pctrl->chip); > > return ret; > > } > > > > the problem is that valid_mask is not a long/integer, is a struct that > needs to be malloced, and is malloc at gpiochip_add_data :( I don't get it, but maybe I'm not smart enough. gpiochip_add_data() doesn't allocate anything, it just adds a already allocated (or static!) gpio_chip to the gpiolib subsystem. In fact I think it is wrong to set up the mask after calling gpiolob_add_data(), because of exactly the type of problem you're seeing. Don't get confused by the &pctrl->chip vs just chip variables, it's just some sloppiness. Yours, Linus Walleij