From patchwork Thu Feb 11 10:39:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 61718 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp110316lbl; Thu, 11 Feb 2016 02:39:53 -0800 (PST) X-Received: by 10.66.132.81 with SMTP id os17mr64559476pab.98.1455187193844; Thu, 11 Feb 2016 02:39:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kw9si11860119pab.63.2016.02.11.02.39.53; Thu, 11 Feb 2016 02:39:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750956AbcBKKjx (ORCPT + 4 others); Thu, 11 Feb 2016 05:39:53 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:35245 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbcBKKjw (ORCPT ); Thu, 11 Feb 2016 05:39:52 -0500 Received: by mail-lb0-f169.google.com with SMTP id bc4so25286432lbc.2 for ; Thu, 11 Feb 2016 02:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=0VaICNcgVjUYaSloe3OqTTJFKTwuklt/hwZKBb1j2PI=; b=fezn+f5hb/Ywb1DmW/tbJIkQ02bE2hB4GsXiX2s5nVeFo+li9eUFszuLuz3yd9qaX8 UkbVIW3SF5DO5Ehqv9EKFBg48kFLxZpH5EUm+bVAiFC+VdoafPLja9jinMcT64zoM43c i7nFgVnXhYZZ72HJr1/HzhysbUSwlA30OyFFk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0VaICNcgVjUYaSloe3OqTTJFKTwuklt/hwZKBb1j2PI=; b=a4KruAdRROJhIhlsjwu8vKMMFethCoH/pmsCzYxMb9kIaeC5zLaZhp+IqfRdb2LcJC 0jPWzTsiSqEVrCsgy3rj4xSiVkvoizo1VsyHv4ZUeHgfoiHL0aggE46DTmhbMOoak2nT x8l/qX+X4/7hCKxBtM0HVM0yroCt3IYF5JL2uBXeorLMgmQqXXfeicoPJrMDqZPKFSup R7wi1X5X4fVvz1PyCBnnHqOsxuhX6bBlNIaRKs/MM1GkF9IteVl/q3sLoTjgmS0vNmIa /UGkIFltX8S1U6A5nLGmSpHNbTvS+VCCiogT7jM9MinKfEfRAWGfMYh1YtNDWbszaue+ ToKA== X-Gm-Message-State: AG10YOTM8R8qj5tBHctFq1wJPJ68MIx98/L4GzJc6OX+8jamJsBaqk34ZR4J9eQk6Lj8n0hh X-Received: by 10.112.84.232 with SMTP id c8mr5313245lbz.136.1455187190677; Thu, 11 Feb 2016 02:39:50 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id g5sm1146204lfe.42.2016.02.11.02.39.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 02:39:49 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot , Johan Hovold , Michael Welling , Markus Pargmann Cc: Bamvor Jian Zhang , Grant Likely , Linus Walleij Subject: [PATCH] gpio: move the subdriver data pointer into gpio_device Date: Thu, 11 Feb 2016 11:39:43 +0100 Message-Id: <1455187183-29299-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We move to manage this pointer under gpiolib control rather than leave it in the subdevice's gpio_chip. We can not NULL it after gpiochip_remove so at to keep things tight. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 17 +++++++++++++++-- drivers/gpio/gpiolib.h | 2 ++ include/linux/gpio/driver.h | 7 +------ 3 files changed, 18 insertions(+), 8 deletions(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 08e93857a7d5..8d5e36635d43 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -480,8 +480,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) goto err_free_gdev; } gdev->ngpio = chip->ngpio; - /* FIXME: move driver data into gpio_device dev_set_drvdata() */ - chip->data = data; + gdev->data = data; spin_lock_irqsave(&gpio_lock, flags); @@ -603,6 +602,15 @@ err_free_gdev: EXPORT_SYMBOL_GPL(gpiochip_add_data); /** + * gpiochip_get_data() - get per-subdriver data for the chip + */ +void *gpiochip_get_data(struct gpio_chip *chip) +{ + return chip->gpiodev->data; +} +EXPORT_SYMBOL_GPL(gpiochip_get_data); + +/** * gpiochip_remove() - unregister a gpio_chip * @chip: the chip to unregister * @@ -626,6 +634,11 @@ void gpiochip_remove(struct gpio_chip *chip) gpiochip_remove_pin_ranges(chip); gpiochip_free_hogs(chip); of_gpiochip_remove(chip); + /* + * We accept no more calls into the driver from this point, so + * NULL the driver data pointer + */ + gdev->data = NULL; spin_lock_irqsave(&gpio_lock, flags); for (i = 0; i < gdev->ngpio; i++) { diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 5a36908fd39d..ddbe409ad48f 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -37,6 +37,7 @@ struct acpi_device; * of the @descs array. * @base: GPIO base in the DEPRECATED global Linux GPIO numberspace, assigned * at device creation time. + * @data: per-instance data assigned by the driver * @list: links gpio_device:s together for traversal * * This state container holds most of the runtime variable data @@ -54,6 +55,7 @@ struct gpio_device { struct gpio_desc *descs; int base; u16 ngpio; + void *data; struct list_head list; #ifdef CONFIG_PINCTRL diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 1babd000bbbe..363bf0eab6d0 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -25,7 +25,6 @@ struct gpio_device; * @gpiodev: the internal state holder, opaque struct * @parent: optional parent device providing the GPIOs * @owner: helps prevent removal of modules exporting active GPIOs - * @data: per-instance data assigned by the driver * @request: optional hook for chip-specific activation, such as * enabling module power and clock; may sleep * @free: optional hook for chip-specific deactivation, such as @@ -109,7 +108,6 @@ struct gpio_chip { struct gpio_device *gpiodev; struct device *parent; struct module *owner; - void *data; int (*request)(struct gpio_chip *chip, unsigned offset); @@ -201,10 +199,7 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); /* get driver data */ -static inline void *gpiochip_get_data(struct gpio_chip *chip) -{ - return chip->data; -} +void *gpiochip_get_data(struct gpio_chip *chip); struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);