Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1040502imm; Tue, 2 Oct 2018 01:28:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Va5S5ZbodGd2T614Jn7Dko4mUsEkVuc9dKf78pmyaGRPte3mbkcbZawdnCg4JLFB3RrZ1 X-Received: by 2002:a17:902:8a4:: with SMTP id 33-v6mr15587945pll.65.1538468880596; Tue, 02 Oct 2018 01:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538468880; cv=none; d=google.com; s=arc-20160816; b=YwQf8L6bCLvFuQQ1Tq3NsVTuVLjmMy+oF+GbvuWanyoRerOQZNBkUAelJRNlAZCKFc YA0L+WHwHMv5manozUNG9JFQDAKAETvQ6FzeeEN7OFe20ADUVOEmDZQOgrEEV6F1am09 aXnrmfwkc859VKdNdXNBSIpPv3WzdN2x/MxgyjLGm1gg6aw56zMuHna7+sh8WI0hQl8L OBeV6e9Iv6RBI5xAU+FfW9q2wmnHZJ4m0k+I0Ex5Rz7KUdtK5kMHKFyW5n8QNFCheC58 PcIP9EfHKNYWz4TcWol9Xh87SzBft52SuWsBuMOYbFUC2wa6Yv2ffZdwSx0PSxaP7y+9 EzqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DAh2lGFM/YZYv7K7xmYxg/bmzfyJfL49NJ9CLn66MIA=; b=W89TdpqJfQwFnCwsjaGQ/Q30f81Uhc8iFSCb20+XTUqgaHLI8ExyDy+zVb4kYrqUn6 JTimif+EQ9tMFEJpkKqpe1GYxwt3Y55wzE/r8Yk0VDpuzfT8B4Z6eC4nkowZunVraLoE sCrQNTQ2QIZvqM1A5gaJcMpOllp+l5mABDe9OlCCkKC5ybdwv/wtw1dtF08Lk+6DfFCX fPbTEkhJZE4gCyUpEN7TFvpq91Jn3Bc/FFbG1vwsLbEbZmMZo0H9LkUCfF/HpaFPkKPJ 63iOq/LYPFE7gld5sm3prWPWr3UXRUhXWmDlsR/mcdH9T6LYEEfW9/dqs0FMAmxiLbW/ vYTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gqZbFTAD; 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 b41-v6si16312541pla.306.2018.10.02.01.27.45; Tue, 02 Oct 2018 01:28:00 -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=gqZbFTAD; 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 S1727379AbeJBPJl (ORCPT + 99 others); Tue, 2 Oct 2018 11:09:41 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36289 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727006AbeJBPJk (ORCPT ); Tue, 2 Oct 2018 11:09:40 -0400 Received: by mail-lf1-f65.google.com with SMTP id d4-v6so780912lfa.3; Tue, 02 Oct 2018 01:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DAh2lGFM/YZYv7K7xmYxg/bmzfyJfL49NJ9CLn66MIA=; b=gqZbFTAD4iVUHsbJQJ19At9LFZ8wBnG1d7OtK2Ve6qoV8mcOL9BOApdXatfGVkzBbU T0LWW5q4TuviCVeGb3TDumGAH3T+azR7Dhoikm3Svq53S7DFPHqv6Gi9nn/N9vb7pumv FWiOGwkgG84phd56/+2IamAAky/p4zSWjUUjtvWdidmV6QSNRWV6Wt+AVAcNXEjK2kGf 5c2FrL4cd5Qrw+7D6efZ7Q7tGs+e5XQWaXBFVlOResQkoB/Nw6Jz7hJ5XaHsbkLJ5ib4 +eH7fS2lm643oWSb2pa7p0+Tk7oxNuWueOxzLmXH057uDcTNpBpIJmA+9NUQ/Ayzaqhz 7evA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DAh2lGFM/YZYv7K7xmYxg/bmzfyJfL49NJ9CLn66MIA=; b=b5W+egX8EbQaCgw3zGD2dGYJTZeecWgY3+ko4XmHLz84h5Hwb10PLVOLB0qsmaCd/W gAiFlio6PRGmSDbKl3DVxTauqn2EiEMK+HKaZwJTl9szomDo3ibG8ABT4coeVsanQp1D 0fsAJhEdOYAumS4I41Zay39F+RSR+5r6so7mnxXskCyiGm9xB2d6U3uTDzv/XLtAr/hO GCkobjwbissV+f07CFbgx83OZfF3wguPzRbUlE6B39YlurjJVdAg7xJge1dcAEDSDG41 MnqcGY+bw5fOd3RwdIdZhSh7Wvqc9dBXHAiviCyEwovsX3/+t5BDylSAS5RDk3aKqmsi 2qRw== X-Gm-Message-State: ABuFfog41DgydBInMgnSuy/TZ/MMLccdYC9Ox6jWTLdbtsCmiQBLsby9 ck/ExSM5Z6DyURfyCv/3Qdo= X-Received: by 2002:a19:541d:: with SMTP id i29-v6mr8245572lfb.30.1538468854056; Tue, 02 Oct 2018 01:27:34 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id p11-v6sm1493531lji.87.2018.10.02.01.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 01:27:32 -0700 (PDT) From: Ricardo Ribalda Delgado To: Linus Walleij , Timur Tabi , swboyd@chromium.org, linux-gpio@vger.kernel.org, LKML , Jeffrey Hugo Cc: Ricardo Ribalda Delgado Subject: [PATCH v3 1/3] gpiolib: Add init_valid_mask exported function Date: Tue, 2 Oct 2018 10:27:29 +0200 Message-Id: <20181002082731.20141-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a function that allows initializing the valid_mask from gpiochip_add_data. This prevents race conditions during gpiochip initialization. If the function is not exported, then the old behaviour is respected, this is, set all gpios as valid. Signed-off-by: Ricardo Ribalda Delgado --- drivers/gpio/gpiolib.c | 3 +++ include/linux/gpio/driver.h | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e8f8a1999393..6925196136ce 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -377,6 +377,9 @@ static int gpiochip_init_valid_mask(struct gpio_chip *gpiochip) if (!gpiochip->valid_mask) return -ENOMEM; + if (gpiochip->init_valid_mask) + return gpiochip->init_valid_mask(gpiochip); + return 0; } diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0ea328e71ec9..df09749269ff 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -256,6 +256,9 @@ struct gpio_chip { void (*dbg_show)(struct seq_file *s, struct gpio_chip *chip); + + int (*init_valid_mask)(struct gpio_chip *chip); + int base; u16 ngpio; const char *const *names; @@ -294,7 +297,9 @@ struct gpio_chip { /** * @need_valid_mask: * - * If set core allocates @valid_mask with all bits set to one. + * If set core allocates @valid_mask with all its values initialized + * with init_valid_mask() or set to one if init_valid_mask() is not + * defined */ bool need_valid_mask; -- 2.19.0