From patchwork Tue Apr 21 15:42:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 463372 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B7EA714011D for ; Wed, 22 Apr 2015 01:47:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=kaOUVShJ; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932619AbbDUPn0 (ORCPT ); Tue, 21 Apr 2015 11:43:26 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:33946 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbbDUPnV (ORCPT ); Tue, 21 Apr 2015 11:43:21 -0400 Received: by laat2 with SMTP id t2so154325530laa.1; Tue, 21 Apr 2015 08:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PMECOWtAw8hWhKj9E83og5xk/TnpCHbRUHNScpC0rKw=; b=kaOUVShJXgoIdSJfym0uPjEELkse9Szk+MeqflpyFEC/STwuYv3zbXhekiQjfmmOJY MHOidjalgP4H0f6lXBMTXLDL0QtXQgQOR4ocpMt+NiBNx0s509Wx3Pm/MCBSMLBBJeHO df65FfFea494pKaIaEAfpV1lFxTezSz7gjMkMsIHjli/OUgEyAcax/M01XlLNzYtfKCk L/7au0YKQGWtncqaYTywlHdDNPmZJbk322gvHKKcMiOrFwINyJCTttGAyeRikWOLc42u OKsEeE8PYHp+ZK+zHptpPWcXcvKLNdTNoCX3tfJjlsWBmnO3kEC5D1DP8E68JzE+Avlz 5WNg== X-Received: by 10.152.5.72 with SMTP id q8mr20422889laq.73.1429630999871; Tue, 21 Apr 2015 08:43:19 -0700 (PDT) Received: from xi.terra (c193-14-96-226.cust.tele2.se. [193.14.96.226]) by mx.google.com with ESMTPSA id wl9sm487891lbb.11.2015.04.21.08.43.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Apr 2015 08:43:16 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.84) (envelope-from ) id 1YkaKN-00075X-Gn; Tue, 21 Apr 2015 17:43:11 +0200 From: Johan Hovold To: Linus Walleij Cc: Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 22/23] gpio: sysfs: remove FLAG_SYSFS_DIR Date: Tue, 21 Apr 2015 17:42:30 +0200 Message-Id: <1429630951-27082-23-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1429630951-27082-1-git-send-email-johan@kernel.org> References: <1429630951-27082-1-git-send-email-johan@kernel.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Remove FLAG_SYSFS_DIR, which is sysfs-interface specific, and store it in the class-device data instead. Note that the flag is only used during export. Signed-off-by: Johan Hovold --- drivers/gpio/gpiolib-sysfs.c | 15 +++++++-------- drivers/gpio/gpiolib.h | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 00609e197f50..27a8c84fc241 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -16,6 +16,8 @@ struct gpiod_data { struct mutex mutex; struct kernfs_node *value_kn; int irq; + + bool direction_can_change; }; /* @@ -339,7 +341,7 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, struct gpiod_data *data = dev_get_drvdata(dev); struct gpio_desc *desc = data->desc; umode_t mode = attr->mode; - bool show_direction = test_bit(FLAG_SYSFS_DIR, &desc->flags); + bool show_direction = data->direction_can_change; if (attr == &dev_attr_direction.attr) { if (!show_direction) @@ -568,12 +570,6 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) status = -EPERM; goto err_unlock; } - - if (chip->direction_input && chip->direction_output && - direction_may_change) { - set_bit(FLAG_SYSFS_DIR, &desc->flags); - } - spin_unlock_irqrestore(&gpio_lock, flags); data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -584,6 +580,10 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) data->desc = desc; mutex_init(&data->mutex); + if (chip->direction_input && chip->direction_output) + data->direction_can_change = direction_may_change; + else + data->direction_can_change = false; offset = gpio_chip_hwgpio(desc); if (chip->names && chip->names[offset]) @@ -678,7 +678,6 @@ void gpiod_unexport(struct gpio_desc *desc) data = dev_get_drvdata(dev); - clear_bit(FLAG_SYSFS_DIR, &desc->flags); clear_bit(FLAG_EXPORT, &desc->flags); device_unregister(dev); diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 4deb71d2bd01..591257a4359a 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -87,7 +87,6 @@ struct gpio_desc { #define FLAG_OPEN_DRAIN 7 /* Gpio is open drain type */ #define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */ #define FLAG_USED_AS_IRQ 9 /* GPIO is connected to an IRQ */ -#define FLAG_SYSFS_DIR 10 /* show sysfs direction attribute */ #define FLAG_IS_HOGGED 11 /* GPIO is hogged */ #define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE))