From patchwork Wed Dec 9 13:23:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58016 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp665439lbb; Wed, 9 Dec 2015 05:23:11 -0800 (PST) X-Received: by 10.98.65.2 with SMTP id o2mr12808894pfa.99.1449667390184; Wed, 09 Dec 2015 05:23:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66si12740587pfb.179.2015.12.09.05.23.09; Wed, 09 Dec 2015 05:23:10 -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 S1754289AbbLINXG (ORCPT + 4 others); Wed, 9 Dec 2015 08:23:06 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:33656 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753156AbbLINXF (ORCPT ); Wed, 9 Dec 2015 08:23:05 -0500 Received: by lfaz4 with SMTP id z4so34112982lfa.0 for ; Wed, 09 Dec 2015 05:23:03 -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=dMK6nwP8XrvA1/QCBTWYuRIdErHaGV3gYuHWPbtFx7Y=; b=g0E/DU5emxpZV9cC/LtW2pA6CIaW2N/gICSyisVcoHx9wFk0+LU0wiU4ncGNCzD0Ua +wAo4JL/lMuw7EuDixNcZZwtN4w0RrXoHzdPBlFrDZPTzODPvdzK0v6APmaupaYN+BMk pvaZtp+HyKDEQ1mpKqiRGPojieu1RGQ61jmi0DEqjA1JVDw2cUKiyNjkSFNkXurZ+HTR kpgbdfgJZCNY9sU9lm9N7CntEnUs42/w3PZSI8VV24j/I9uomVhtb4sTkEQDZ6Kdr9CQ f8UaysbNzNd3KfrMfAvOi1Gv45lnRTkGeDlAdJJxNfjGKLtcfWVIZZWSJMZcPmd/PRS9 7qLw== 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=dMK6nwP8XrvA1/QCBTWYuRIdErHaGV3gYuHWPbtFx7Y=; b=kVnkoQGj+FeBlsGESlyruP2PHQ0UjvFIKesZ3byXfd9KvWahWcJQ0LRjimv75b5CYD yNL7yUXbbYYdE7jvApjb7CNgv+Y84BjKJhGRidKjto3xPD9EPpBqp3/nyfIMyYV/yEaI SyOSMPJNOkX6Hyyd+FEfpsqA43KQnWUNIRll655KDAaCDNzatqb+4mx0YIXLYp7hlf/G +oPJkY8jJvgE2RrL0+0dzH/E2L2E2IgHU8ZndrrUkxWwZtY1RHr931RHRxMlEry9pPHw k22S0dbVwp2HoTr3Gg3Fx/QwfOOIHHuGmWekUWDHgfhDdWk/89AH/CvV3X2dZGiUp0nU Xnrg== X-Gm-Message-State: ALoCoQkHGWyP3iQ6IthdI95jpQGLZ90np+0o4ZAG/5Lrb+txIY/X3qENUSfqVmWEbCMOTDKpNJXNX12TpTRR6b/8L/cAB54gnQ== X-Received: by 10.25.23.42 with SMTP id n42mr2341302lfi.42.1449667383564; Wed, 09 Dec 2015 05:23:03 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s185sm1421107lfe.24.2015.12.09.05.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:23:02 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Bhupesh Sharma Subject: [PATCH 061/182] gpio: stmpe: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:23:00 +0100 Message-Id: <1449667380-32673-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: Bhupesh Sharma Signed-off-by: Linus Walleij --- drivers/gpio/gpio-stmpe.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 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-stmpe.c b/drivers/gpio/gpio-stmpe.c index 9e471979aa9e..5197edf1acfd 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -36,14 +36,9 @@ struct stmpe_gpio { u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; }; -static inline struct stmpe_gpio *to_stmpe_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct stmpe_gpio, chip); -} - static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -58,7 +53,7 @@ static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset) static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; int which = val ? STMPE_IDX_GPSR_LSB : STMPE_IDX_GPCR_LSB; u8 reg = stmpe->regs[which] - (offset / 8); @@ -77,7 +72,7 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -90,7 +85,7 @@ static int stmpe_gpio_direction_output(struct gpio_chip *chip, static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -100,7 +95,7 @@ static int stmpe_gpio_direction_input(struct gpio_chip *chip, static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; if (stmpe_gpio->norequest_mask & (1 << offset)) @@ -123,7 +118,7 @@ static struct gpio_chip template_chip = { static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -151,7 +146,7 @@ static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type) static void stmpe_gpio_irq_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); mutex_lock(&stmpe_gpio->irq_lock); } @@ -159,7 +154,7 @@ static void stmpe_gpio_irq_lock(struct irq_data *d) static void stmpe_gpio_irq_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); static const u8 regmap[] = { @@ -193,7 +188,7 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d) static void stmpe_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -204,7 +199,7 @@ static void stmpe_gpio_irq_mask(struct irq_data *d) static void stmpe_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -216,7 +211,7 @@ static void stmpe_dbg_show_one(struct seq_file *s, struct gpio_chip *gc, unsigned offset, unsigned gpio) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; const char *label = gpiochip_is_requested(gc, offset); int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); @@ -375,7 +370,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) if (ret) goto out_free; - ret = gpiochip_add(&stmpe_gpio->chip); + ret = gpiochip_add_data(&stmpe_gpio->chip, stmpe_gpio); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); goto out_disable;