From patchwork Wed Dec 9 13:44:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58110 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp677551lbb; Wed, 9 Dec 2015 05:44:26 -0800 (PST) X-Received: by 10.66.228.225 with SMTP id sl1mr7991963pac.63.1449668666549; Wed, 09 Dec 2015 05:44:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82si12831734pfq.220.2015.12.09.05.44.26; Wed, 09 Dec 2015 05:44:26 -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 S1754643AbbLINoZ (ORCPT + 4 others); Wed, 9 Dec 2015 08:44:25 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35037 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754148AbbLINoX (ORCPT ); Wed, 9 Dec 2015 08:44:23 -0500 Received: by lfdl133 with SMTP id l133so34354756lfd.2 for ; Wed, 09 Dec 2015 05:44:22 -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=BUHhmKgUtoNitjc7ydjKqvFEOyKLGCb3uiBjMzwRLy0=; b=dxccXrX6MZYi7J48KtkwTj5f2YxHWpka5VOaCZFNizpg1QSELS9UmOpt9P/Z0TgC5q PoZl1HXmaFWqIDy3Mn2EGtQHieEEbFLbG2mC63xQp8VdEw1fGYTskiPZbw53+kjG1E0Q YVTPLJ1eI6bQg7P7BAQJiQ9yXhVHJMfzAJcYRme9ojEI+r2gfn5z327z6MIBjy6II8kS yMkd0NgLLmSdQS5AZGtzjCEAraavi0NSXi1AZRH/GC5gy5fn8u8wALqHfbTQMtJXTDR1 l4GRCuffhU6lmqGUFcdJYDALZ5D9t9VfoWMgzzR1NHKRV3orQ8/4HU3G9C7EDru1lbKj evTA== 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=BUHhmKgUtoNitjc7ydjKqvFEOyKLGCb3uiBjMzwRLy0=; b=Nsg3tjcdQBIrNP9qKsnO3AVQdYwEj530ZtRg/pAdOZttLsSj8iyw8yg1Z5xJ9w9PoB CKnG7VJ/ilv8sdR8tQ90+DPlsosJuWlV1Q15swukBFFwham/ve52hqXjcIBqigKGpPtU iPbFUM3zvUwpBW0K2ILUzuFrDXmqA6Xpd+5+k4ttryIPqHKDiJBBwDaYCtaWIuTTHH9+ lb5eKgn0xXO640I+AsEvMWoMIes2ssyD27UFV/zIRvW+3/pgtUK5efMrJazEi0EB7IXt bL8Wz8AbYblAJFDeohetQalfIVhf6uAXJK8IvzkeTyyYEuE6glDshBMLKpQSqF8UxRBt 1pQA== X-Gm-Message-State: ALoCoQnCsF9dCyXuSVI+PIDgtCo6+kLK/3vfsmHD5Y1LlC6jjTm+CBfJOIO1UjilZm/8q1GFiatQiv8d1Vgdlq6FJoO8nRLLKg== X-Received: by 10.25.44.213 with SMTP id s204mr2213584lfs.37.1449668662009; Wed, 09 Dec 2015 05:44:22 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l67sm1447119lfl.26.2015.12.09.05.44.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:44:21 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Jiri Kosina Cc: Linus Walleij , linux-input@vger.kernel.org Subject: [PATCH 154/182] hid: cp2112: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:44:18 +0100 Message-Id: <1449668658-5642-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: Jiri Kosina Cc: linux-input@vger.kernel.org Signed-off-by: Linus Walleij --- Jiri: please ACK this so I can merge it in the GPIO tree. --- drivers/hid/hid-cp2112.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 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/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index f47954e8fd2c..0ccdd37e121a 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -24,7 +24,7 @@ * http://www.silabs.com/Support%20Documents/TechnicalDocs/AN495.pdf */ -#include +#include #include #include #include @@ -169,8 +169,7 @@ MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask"); static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[5]; int ret; @@ -198,8 +197,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[3]; int ret; @@ -216,8 +214,7 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[2]; int ret; @@ -235,8 +232,7 @@ static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset) static int cp2112_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[5]; int ret; @@ -1106,7 +1102,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.can_sleep = 1; dev->gc.parent = &hdev->dev; - ret = gpiochip_add(&dev->gc); + ret = gpiochip_add_data(&dev->gc, dev); if (ret < 0) { hid_err(hdev, "error registering gpio chip\n"); goto err_free_i2c;