From patchwork Tue Mar 19 16:36:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10860009 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09CE2139A for ; Tue, 19 Mar 2019 16:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4A5829441 for ; Tue, 19 Mar 2019 16:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D84C529852; Tue, 19 Mar 2019 16:36:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E7F4296AE for ; Tue, 19 Mar 2019 16:36:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727898AbfCSQgl (ORCPT ); Tue, 19 Mar 2019 12:36:41 -0400 Received: from sauhun.de ([88.99.104.3]:46116 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727869AbfCSQgl (ORCPT ); Tue, 19 Mar 2019 12:36:41 -0400 Received: from localhost (p5486CE21.dip0.t-ipconnect.de [84.134.206.33]) by pokefinder.org (Postfix) with ESMTPSA id 87FEF4A1350; Tue, 19 Mar 2019 17:36:39 +0100 (CET) From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Wolfram Sang , Jiri Kosina , Jonathan Cameron , Srinivas Pandruvada , Benjamin Tissoires , linux-input@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH 1/1] hid: hid-sensor-custom: simplify getting .driver_data Date: Tue, 19 Mar 2019 17:36:38 +0100 Message-Id: <20190319163638.31003-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should get 'driver_data' from 'struct device' directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang Acked-by: Srinivas Pandruvada Reviewed-by: Simon Horman --- Build tested only. buildbot is happy. drivers/hid/hid-sensor-custom.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c index bb012bc032e0..462e653a7bbb 100644 --- a/drivers/hid/hid-sensor-custom.c +++ b/drivers/hid/hid-sensor-custom.c @@ -157,8 +157,7 @@ static int usage_id_cmp(const void *p1, const void *p2) static ssize_t enable_sensor_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_device *pdev = to_platform_device(dev); - struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev); + struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); return sprintf(buf, "%d\n", sensor_inst->enable); } @@ -237,8 +236,7 @@ static ssize_t enable_sensor_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct platform_device *pdev = to_platform_device(dev); - struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev); + struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); int value; int ret = -EINVAL; @@ -283,8 +281,7 @@ static const struct attribute_group enable_sensor_attr_group = { static ssize_t show_value(struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_device *pdev = to_platform_device(dev); - struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev); + struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); struct hid_sensor_hub_attribute_info *attribute; int index, usage, field_index; char name[HID_CUSTOM_NAME_LENGTH]; @@ -392,8 +389,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr, static ssize_t store_value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct platform_device *pdev = to_platform_device(dev); - struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev); + struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); int index, field_index, usage; char name[HID_CUSTOM_NAME_LENGTH]; int value;