From patchwork Sat Mar 1 03:58:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Praznik X-Patchwork-Id: 3746181 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7EAF7BF13A for ; Sat, 1 Mar 2014 03:59:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75A272012B for ; Sat, 1 Mar 2014 03:59:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6749720265 for ; Sat, 1 Mar 2014 03:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbaCAD71 (ORCPT ); Fri, 28 Feb 2014 22:59:27 -0500 Received: from cdptpa-omtalb.mail.rr.com ([75.180.132.120]:39036 "EHLO cdptpa-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbaCAD70 (ORCPT ); Fri, 28 Feb 2014 22:59:26 -0500 X-Authority-Analysis: v=2.0 cv=GMaK45xK c=1 sm=0 a=N8gH7sxzIWrJto1iYJUVbg==:17 a=ERU4koquoh4A:10 a=05ChyHeVI94A:10 a=Cvmq5WjI5q8A:10 a=ayC55rCoAAAA:8 a=KGjhK52YXX0A:10 a=RH8Q9tPhs7iWTJCuLioA:9 a=N8gH7sxzIWrJto1iYJUVbg==:117 X-Cloudmark-Score: 0 X-Authenticated-User: X-Originating-IP: 24.29.232.96 Received: from [24.29.232.96] ([24.29.232.96:34106] helo=localhost.localdomain) by cdptpa-oedge01.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id E3/FB-00728-A1B51135; Sat, 01 Mar 2014 03:59:22 +0000 From: Frank Praznik To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, dh.herrmann@gmail.com, Frank Praznik Subject: [PATCH 2/6] HID: sony: Convert startup and shutdown functions to use a uniform parameter type Date: Fri, 28 Feb 2014 22:58:57 -0500 Message-Id: <1393646341-16947-3-git-send-email-frank.praznik@oh.rr.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393646341-16947-1-git-send-email-frank.praznik@oh.rr.com> References: <1393646341-16947-1-git-send-email-frank.praznik@oh.rr.com> 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Convert all of the initialization and shutdown functions to take a parameter type of struct sony_sc instead of using a mix of struct sony_sc and struct hid_device. sony_set_leds() was converted as well as it was just pulling the sony_sc struct out of the hid_device. Signed-off-by: Frank Praznik --- drivers/hid/hid-sony.c | 66 ++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 31ba01a..233c094 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1106,19 +1106,18 @@ static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds) hid_hw_request(hdev, report, HID_REQ_SET_REPORT); } -static void sony_set_leds(struct hid_device *hdev, const __u8 *leds, int count) +static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count) { - struct sony_sc *drv_data = hid_get_drvdata(hdev); int n; BUG_ON(count > MAX_LEDS); - if (drv_data->quirks & BUZZ_CONTROLLER && count == 4) { - buzz_set_leds(hdev, leds); + if (sc->quirks & BUZZ_CONTROLLER && count == 4) { + buzz_set_leds(sc->hdev, leds); } else { for (n = 0; n < count; n++) - drv_data->led_state[n] = leds[n]; - schedule_work(&drv_data->state_worker); + sc->led_state[n] = leds[n]; + schedule_work(&sc->state_worker); } } @@ -1141,7 +1140,7 @@ static void sony_led_set_brightness(struct led_classdev *led, if (led == drv_data->leds[n]) { if (value != drv_data->led_state[n]) { drv_data->led_state[n] = value; - sony_set_leds(hdev, drv_data->led_state, drv_data->led_count); + sony_set_leds(drv_data, drv_data->led_state, drv_data->led_count); } break; } @@ -1170,30 +1169,28 @@ static enum led_brightness sony_led_get_brightness(struct led_classdev *led) return LED_OFF; } -static void sony_leds_remove(struct hid_device *hdev) +static void sony_leds_remove(struct sony_sc *sc) { - struct sony_sc *drv_data; struct led_classdev *led; int n; - drv_data = hid_get_drvdata(hdev); - BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT)); + BUG_ON(!(sc->quirks & SONY_LED_SUPPORT)); - for (n = 0; n < drv_data->led_count; n++) { - led = drv_data->leds[n]; - drv_data->leds[n] = NULL; + for (n = 0; n < sc->led_count; n++) { + led = sc->leds[n]; + sc->leds[n] = NULL; if (!led) continue; led_classdev_unregister(led); kfree(led); } - drv_data->led_count = 0; + sc->led_count = 0; } -static int sony_leds_init(struct hid_device *hdev) +static int sony_leds_init(struct sony_sc *sc) { - struct sony_sc *drv_data; + struct hid_device *hdev = sc->hdev; int n, ret = 0; int max_brightness; int use_colors; @@ -1205,11 +1202,10 @@ static int sony_leds_init(struct hid_device *hdev) static const char * const color_str[] = { "red", "green", "blue" }; static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 }; - drv_data = hid_get_drvdata(hdev); - BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT)); + BUG_ON(!(sc->quirks & SONY_LED_SUPPORT)); - if (drv_data->quirks & BUZZ_CONTROLLER) { - drv_data->led_count = 4; + if (sc->quirks & BUZZ_CONTROLLER) { + sc->led_count = 4; max_brightness = 1; use_colors = 0; name_len = strlen("::buzz#"); @@ -1217,14 +1213,14 @@ static int sony_leds_init(struct hid_device *hdev) /* Validate expected report characteristics. */ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) return -ENODEV; - } else if (drv_data->quirks & DUALSHOCK4_CONTROLLER) { - drv_data->led_count = 3; + } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { + sc->led_count = 3; max_brightness = 255; use_colors = 1; name_len = 0; name_fmt = "%s:%s"; } else { - drv_data->led_count = 4; + sc->led_count = 4; max_brightness = 1; use_colors = 0; name_len = strlen("::sony#"); @@ -1236,11 +1232,11 @@ static int sony_leds_init(struct hid_device *hdev) * only relevant if the driver is loaded after somebody actively set the * LEDs to on */ - sony_set_leds(hdev, initial_values, drv_data->led_count); + sony_set_leds(sc, initial_values, sc->led_count); name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; - for (n = 0; n < drv_data->led_count; n++) { + for (n = 0; n < sc->led_count; n++) { if (use_colors) name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2; @@ -1270,13 +1266,13 @@ static int sony_leds_init(struct hid_device *hdev) goto error_leds; } - drv_data->leds[n] = led; + sc->leds[n] = led; } return ret; error_leds: - sony_leds_remove(hdev); + sony_leds_remove(sc); return ret; } @@ -1366,9 +1362,9 @@ static int sony_play_effect(struct input_dev *dev, void *data, return 0; } -static int sony_init_ff(struct hid_device *hdev) +static int sony_init_ff(struct sony_sc *sc) { - struct hid_input *hidinput = list_entry(hdev->inputs.next, + struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, struct hid_input, list); struct input_dev *input_dev = hidinput->input; @@ -1377,7 +1373,7 @@ static int sony_init_ff(struct hid_device *hdev) } #else -static int sony_init_ff(struct hid_device *hdev) +static int sony_init_ff(struct sony_sc *sc) { return 0; } @@ -1697,7 +1693,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_stop; if (sc->quirks & SONY_LED_SUPPORT) { - ret = sony_leds_init(hdev); + ret = sony_leds_init(sc); if (ret < 0) goto err_stop; } @@ -1716,7 +1712,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) } if (sc->quirks & SONY_FF_SUPPORT) { - ret = sony_init_ff(hdev); + ret = sony_init_ff(sc); if (ret < 0) goto err_close; } @@ -1726,7 +1722,7 @@ err_close: hid_hw_close(hdev); err_stop: if (sc->quirks & SONY_LED_SUPPORT) - sony_leds_remove(hdev); + sony_leds_remove(sc); if (sc->quirks & SONY_BATTERY_SUPPORT) sony_battery_remove(sc); if (sc->worker_initialized) @@ -1741,7 +1737,7 @@ static void sony_remove(struct hid_device *hdev) struct sony_sc *sc = hid_get_drvdata(hdev); if (sc->quirks & SONY_LED_SUPPORT) - sony_leds_remove(hdev); + sony_leds_remove(sc); if (sc->quirks & SONY_BATTERY_SUPPORT) { hid_hw_close(hdev);