From patchwork Sun Dec 27 09:25:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7923141 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 70D909F318 for ; Sun, 27 Dec 2015 09:28:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83CB320253 for ; Sun, 27 Dec 2015 09:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A71122024D for ; Sun, 27 Dec 2015 09:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754639AbbL0J2p (ORCPT ); Sun, 27 Dec 2015 04:28:45 -0500 Received: from m50-134.163.com ([123.125.50.134]:33320 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbbL0J0n (ORCPT ); Sun, 27 Dec 2015 04:26:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=37zwr3Nomt/X+KycWO O7AEUkAmiGB9tmiIGyUaXhzYY=; b=gt7LYeavr86hJy3HUTBWdMVpJos0Lig0yi bZtTbhBZFPnQzPEh9Ub1dc4B4NqHJVgvRCHm5RHIhDc2eTvhlPHngXTKGOeg+fSY glHC2u5vnyKYReXM3c/kVCAGDIFDq2rhKVUDYuHatgS2YLwGW8vEm0q3pq470lot jJqe4WZsg= Received: from localhost (unknown [116.77.145.148]) by smtp4 (Coremail) with SMTP id DtGowED5EVeMrn9WgV14AA--.7090S3; Sun, 27 Dec 2015 17:25:33 +0800 (CST) From: Geliang Tang To: Jiri Kosina , Benjamin Tissoires Cc: Geliang Tang , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] HID: add a new helper to_hid_driver() Date: Sun, 27 Dec 2015 17:25:22 +0800 Message-Id: <1f3f9887783a36170a5972e6819c7841db95d888.1451206516.git.geliangtang@163.com> 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: <3c9a720e58ea32c5df098cbe744c6b5821a756a6.1451206516.git.geliangtang@163.com> References: <3490fef13d9af010ff2da07012eed189c46ee3fa.1451206516.git.geliangtang@163.com> <3c9a720e58ea32c5df098cbe744c6b5821a756a6.1451206516.git.geliangtang@163.com> X-CM-TRANSID: DtGowED5EVeMrn9WgV14AA--.7090S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF15urW7KrykKFyfAr1rCrg_yoW8ZrW3pF 4DAa93ArW7Kr4Igw13JrykAFy3t3WDA34Igr1xGw1FgF1FkFyUGF93ta4jywn8ZrWjkF9r KF4Utry8Gayjqr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UGPfLUUUUU= X-Originating-IP: [116.77.145.148] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMA7dmVWBTXxRUQAAsf 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 Add a new helper to_hid_driver() and use it in hid-core.c. Signed-off-by: Geliang Tang --- drivers/hid/hid-core.c | 7 +++---- include/linux/hid.h | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3abff97..ecf614b 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2071,7 +2071,7 @@ struct hid_dynid { static ssize_t store_new_id(struct device_driver *drv, const char *buf, size_t count) { - struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); + struct hid_driver *hdrv = to_hid_driver(drv); struct hid_dynid *dynid; __u32 bus, vendor, product; unsigned long driver_data = 0; @@ -2133,7 +2133,7 @@ static const struct hid_device_id *hid_match_device(struct hid_device *hdev, static int hid_bus_match(struct device *dev, struct device_driver *drv) { - struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); + struct hid_driver *hdrv = to_hid_driver(drv); struct hid_device *hdev = to_hid_device(dev); return hid_match_device(hdev, hdrv) != NULL; @@ -2141,8 +2141,7 @@ static int hid_bus_match(struct device *dev, struct device_driver *drv) static int hid_device_probe(struct device *dev) { - struct hid_driver *hdrv = container_of(dev->driver, - struct hid_driver, driver); + struct hid_driver *hdrv = to_hid_driver(dev->driver); struct hid_device *hdev = to_hid_device(dev); const struct hid_device_id *id; int ret = 0; diff --git a/include/linux/hid.h b/include/linux/hid.h index 1472026..75b66ec 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -717,6 +717,9 @@ struct hid_driver { struct device_driver driver; }; +#define to_hid_driver(pdrv) \ + container_of(pdrv, struct hid_driver, driver) + /** * hid_ll_driver - low level driver callbacks * @start: called on probe to start the device