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: 7808761 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CE869BEEE1 for ; Wed, 9 Dec 2015 13:44:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF2FD203DC for ; Wed, 9 Dec 2015 13:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1383D20490 for ; Wed, 9 Dec 2015 13:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754679AbbLINoZ (ORCPT ); Wed, 9 Dec 2015 08:44:25 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:32992 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754643AbbLINoX (ORCPT ); Wed, 9 Dec 2015 08:44:23 -0500 Received: by lfaz4 with SMTP id z4so34532111lfa.0 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=dH8fcnKqVk+3iBHB4PkD+nhnT4nzj59OzUN+Ka3Ad62X6kWL4qdqKGnPnHVcX8TkZ3 +cVU7Xy7eev1DVTyDSb5VWX95QSqh5l6c4UJdu8EbFvoO8SU4DKY286UVHVfmDHLulzv 35uMiHxudCzYbwrrdMV/cBB6mNyJf2B3v87SoR/VL/rvd4hD/iM4ApKk44IhXwnJc56H GQlilZE4hZtKqcll46zr9pb8Tz/lZCo9vKbmhXYrRBUeJbv5cT7rS2rCILWq8BVpSQZV UsxXiqT/GOITI4xqhR2B3qQp9IsYGMUh7cdPtPHzZhEG1aeifjAy7ueG3VHO2y6mJzgL pbTw== X-Gm-Message-State: ALoCoQn9suRfCrHPboxMp/c4dMbRDd4x9tO8Knsxn7TN9tQat5sCNzknRCgg160pj2CDtE/kNAoAUXyqDDiZuQ9hz+VRwR85Zw== 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-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Jiri Kosina --- 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(-) 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;