From patchwork Wed Dec 9 13:22:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58013 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp665209lbb; Wed, 9 Dec 2015 05:22:46 -0800 (PST) X-Received: by 10.98.1.140 with SMTP id 134mr12551332pfb.134.1449667366130; Wed, 09 Dec 2015 05:22:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si12727627pfl.109.2015.12.09.05.22.45; Wed, 09 Dec 2015 05:22:46 -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.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754569AbbLINWo (ORCPT + 4 others); Wed, 9 Dec 2015 08:22:44 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:34988 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754560AbbLINWm (ORCPT ); Wed, 9 Dec 2015 08:22:42 -0500 Received: by lbpu9 with SMTP id u9so29666866lbp.2 for ; Wed, 09 Dec 2015 05:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=uO3LT7ZXAIOK8VeMS2znD0NSjHLFFwnVRPPGf1qDTzY=; b=bjAPOQtYKPfZxY8uURlTuMteOq0gNCGp4FV7O5EnlMrY66+tomCe4zkdg/12FAxytN 1DwKX8k2BRxM8z5/BHKvzGjcTV4m0xTVVfyJmQky16lCkYHGvfgR81S3oM1zXMcRXK8h eHLJ3+ugOunCriV2cWPiXZ2t8xG7WLryrumPLVYN00Db8M/VQ7jdXSuxzMgboR+gl+Cw CsobWa1FOEmaUkcPZQOYXrgA1vTjCTif4iyZIN0MJeOPOnmH0om1Cyvpax/4hECQT14/ X3NlN8RnkQahNdvU95GcTySPp1Oh1H+VSF7RcI/kxZJeySSbR1I2c6cJwlDFflYCbtVU IG1w== 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=uO3LT7ZXAIOK8VeMS2znD0NSjHLFFwnVRPPGf1qDTzY=; b=U6w0kkEa92YGhheNQGLqdZVkpNqod7arQB0WFWN3a6ALgai4VFyD4ljtG6sNnXq7Td OTt5kR0hDtaLEplFwKe54X4F6fAOLs7s1tT6SF1KYkBYNFvjTRqVziEUX8bTVk8l3P1w C4zkTIL1DWE2QnZ2bYqXcW/b+kmTA6vvGs+d05FhSSp1K9gO9XRPwg55nENe72xbeXWz Wt6Xv9NLdWYt3ROIoYH+qUbPAP6MJC+Wy10Vu8QEUv041DmR1tJLwUN8mUgb1L+tiAtX qSaMNu+MHXqYE2xnvu5XDluYkDWAYIAlUOeUzZf2YKHUPS+qe6Klqkr0B/qv3sGqYsEs 0vQA== X-Gm-Message-State: ALoCoQmg4dx8hD+KBBhCtKWg29Bis86gCdleOnoL1i83CqrpRFIjYcigtND0+ymCZ9YZ2RTKls5RtmcGRcue3UBCRmTJSFKUuw== X-Received: by 10.112.168.106 with SMTP id zv10mr2370467lbb.127.1449667361011; Wed, 09 Dec 2015 05:22:41 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id pd9sm1395977lbc.48.2015.12.09.05.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:22:40 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Bruno Randolf Subject: [PATCH 058/182] gpio: sch311x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:22:37 +0100 Message-Id: <1449667357-32529-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 This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Bruno Randolf Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sch311x.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 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/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index b454792de778..1cbd77a04e7b 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -93,13 +93,6 @@ static struct sch311x_gpio_block_def sch311x_gpio_blocks[] = { }, }; -static inline struct sch311x_gpio_block * -to_sch311x_gpio_block(struct gpio_chip *chip) -{ - return container_of(chip, struct sch311x_gpio_block, chip); -} - - /* * Super-IO functions */ @@ -142,7 +135,7 @@ static inline void sch311x_sio_outb(int sio_config_port, int reg, int val) static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); if (block->config_regs[offset] == 0) /* GPIO is not available */ return -ENODEV; @@ -158,7 +151,7 @@ static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset) static void sch311x_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); if (block->config_regs[offset] == 0) /* GPIO is not available */ return; @@ -168,7 +161,7 @@ static void sch311x_gpio_free(struct gpio_chip *chip, unsigned offset) static int sch311x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); unsigned char data; spin_lock(&block->lock); @@ -192,7 +185,7 @@ static void __sch311x_gpio_set(struct sch311x_gpio_block *block, static void sch311x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); __sch311x_gpio_set(block, offset, value); @@ -201,7 +194,7 @@ static void sch311x_gpio_set(struct gpio_chip *chip, unsigned offset, static int sch311x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); outb(SCH311X_GPIO_CONF_IN, block->runtime_reg + @@ -214,7 +207,7 @@ static int sch311x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int sch311x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); @@ -267,7 +260,7 @@ static int sch311x_gpio_probe(struct platform_device *pdev) block->data_reg = sch311x_gpio_blocks[i].data_reg; block->runtime_reg = pdata->runtime_reg; - err = gpiochip_add(&block->chip); + err = gpiochip_add_data(&block->chip, block); if (err < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", err);