From patchwork Sun Dec 27 09:25:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7923131 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DB4C69F318 for ; Sun, 27 Dec 2015 09:28:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EA6320253 for ; Sun, 27 Dec 2015 09:28:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CA442024D for ; Sun, 27 Dec 2015 09:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751589AbbL0J0o (ORCPT ); Sun, 27 Dec 2015 04:26:44 -0500 Received: from m50-132.163.com ([123.125.50.132]:41958 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbbL0J0j (ORCPT ); Sun, 27 Dec 2015 04:26:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=mF6GHDi7v7TRSydmM+ lwMEUsaicu5MZZkTAza7Gahlc=; b=Qc0iDDC11rNJ4uecAbe8IEJVZ5yPGo8ekl zDgjdFTT1TduN2y8qga3h0W4XhXLTp7j7jVFGVQk9xRhuRjAr/5w2YaPXnpJC0u9 4cnHXmS8Aq4RJKTdOdoSO9fxAwFjWIO2kwefPyJdUIfmI14Sike7b75spgnavgRs 10yxM205w= Received: from localhost (unknown [116.77.145.148]) by smtp2 (Coremail) with SMTP id DNGowEDJmkKOrn9WPLILAA--.4136S3; Sun, 27 Dec 2015 17:25:35 +0800 (CST) From: Geliang Tang To: David Herrmann , Jiri Kosina , Benjamin Tissoires Cc: Geliang Tang , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] HID: wiimote: use dev_to_wii() Date: Sun, 27 Dec 2015 17:25:23 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: <3490fef13d9af010ff2da07012eed189c46ee3fa.1451206516.git.geliangtang@163.com> References: <3490fef13d9af010ff2da07012eed189c46ee3fa.1451206516.git.geliangtang@163.com> In-Reply-To: <1f3f9887783a36170a5972e6819c7841db95d888.1451206516.git.geliangtang@163.com> References: <3490fef13d9af010ff2da07012eed189c46ee3fa.1451206516.git.geliangtang@163.com> <3c9a720e58ea32c5df098cbe744c6b5821a756a6.1451206516.git.geliangtang@163.com> <1f3f9887783a36170a5972e6819c7841db95d888.1451206516.git.geliangtang@163.com> X-CM-TRANSID: DNGowEDJmkKOrn9WPLILAA--.4136S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7KFWxJrykXF1kCr4kCFW5Awb_yoW8XryDpF W7W3WYkrWxXr1Du3W8Xw1DuFy3ta4kAas2vry5Cw1SvFy5ZFyUtFyxtFyYqFWrAaykuFsr WF15XryjkFyUKwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U3UUbUUUUU= X-Originating-IP: [116.77.145.148] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbioxDdmVUL3ns1ggAAs7 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, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Use dev_to_wii() instead of open-coding it. Signed-off-by: Geliang Tang --- drivers/hid/hid-wiimote-modules.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c index 05e23c4..4390eee 100644 --- a/drivers/hid/hid-wiimote-modules.c +++ b/drivers/hid/hid-wiimote-modules.c @@ -296,14 +296,12 @@ static const struct wiimod_ops wiimod_battery = { static enum led_brightness wiimod_led_get(struct led_classdev *led_dev) { - struct wiimote_data *wdata; struct device *dev = led_dev->dev->parent; + struct wiimote_data *wdata = dev_to_wii(dev); int i; unsigned long flags; bool value = false; - wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); - for (i = 0; i < 4; ++i) { if (wdata->leds[i] == led_dev) { spin_lock_irqsave(&wdata->state.lock, flags); @@ -319,14 +317,12 @@ static enum led_brightness wiimod_led_get(struct led_classdev *led_dev) static void wiimod_led_set(struct led_classdev *led_dev, enum led_brightness value) { - struct wiimote_data *wdata; struct device *dev = led_dev->dev->parent; + struct wiimote_data *wdata = dev_to_wii(dev); int i; unsigned long flags; __u8 state, flag; - wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); - for (i = 0; i < 4; ++i) { if (wdata->leds[i] == led_dev) { flag = WIIPROTO_FLAG_LED(i + 1);