From patchwork Fri Feb 17 07:57:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= X-Patchwork-Id: 9579039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1013F6049F for ; Fri, 17 Feb 2017 07:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01A7D283B4 for ; Fri, 17 Feb 2017 07:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7238286AC; Fri, 17 Feb 2017 07:58:39 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 5BC91283B4 for ; Fri, 17 Feb 2017 07:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601AbdBQH6Z (ORCPT ); Fri, 17 Feb 2017 02:58:25 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34108 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755551AbdBQH6L (ORCPT ); Fri, 17 Feb 2017 02:58:11 -0500 Received: by mail-lf0-f68.google.com with SMTP id q89so3184187lfi.1 for ; Thu, 16 Feb 2017 23:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0lpjZMpbA/Z87iaoncV9vBACxWF61l53ZBccOA259ac=; b=b88wkpLv2/NPQjxjWLt1eGVyjQiC+s2gW2v0W3x6x23B0L0mpbRbveuhKof/68VzM+ xLxYGYPsCJS+l6ywsAJUVX0GhLu0rwSDjA7AcB2dLVTI7It4PBlgo5cofkV2CAAkC6cJ XAQJVY38dHEZuFtf1Use1JBN9d/duC1j85UrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0lpjZMpbA/Z87iaoncV9vBACxWF61l53ZBccOA259ac=; b=TdZpbQpdtjDZqP1Hh6kvolPyusoupOwXAHDkaz5qs8JppCSqEsYwTQEjiV1W/iss4Y zyEZZovpXjcz+usCSBdea6j/1j1Fv/XkHtlbf8nCXrbjq/kK4AOSWLqubNOINmTX7vkM oxCdtjIljN3DUGwKWqusTl+SsZInoohKyTtaDfopgoV9DUcIr0/YHigprY1IkRlYqViQ nXPQcqQjccrKcjJ1PCjBXCVVcyIv7zCUdwNud+37ItNptwaafZNnAHzUtYL+PmvGZ5NT /ynSxX7B61OUjEqI3+Z+VMTG45Ijbczarmh7Yqks4Er+ZdKaZGA57rrh188w+3+r2Po8 E00g== X-Gm-Message-State: AMke39npD4pfEmnf/z2SLaMh4JI4OeHbG5cvRDyhT+AwIHebwmnqrn2QXCbzI+U7oooY/g== X-Received: by 10.46.20.27 with SMTP id u27mr1774648ljd.103.1487318289555; Thu, 16 Feb 2017 23:58:09 -0800 (PST) Received: from ozzy.nask.waw.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id 206sm2336457ljf.35.2017.02.16.23.58.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 23:58:08 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Richard Purdie , Jacek Anaszewski , Pavel Machek , Matthew Garrett , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Darren Hart , Andy Shevchenko , Jaroslav Kysela , Takashi Iwai Cc: Alex Hung , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 7/7] platform/x86: dell-wmi-led: fix coding style issues Date: Fri, 17 Feb 2017 08:57:53 +0100 Message-Id: <20170217075753.12702-8-kernel@kempniu.pl> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170217075753.12702-1-kernel@kempniu.pl> References: <20170217075753.12702-1-kernel@kempniu.pl> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix coding style issues in dell-wmi-led to make sure the module gets a clean start in the x86 platform driver subsystem. Signed-off-by: Michał Kępień --- drivers/platform/x86/dell-wmi-led.c | 66 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/drivers/platform/x86/dell-wmi-led.c b/drivers/platform/x86/dell-wmi-led.c index d0232c7f1909..a0c7e99530ef 100644 --- a/drivers/platform/x86/dell-wmi-led.c +++ b/drivers/platform/x86/dell-wmi-led.c @@ -46,37 +46,29 @@ struct bios_args { unsigned char off_time; }; -static int dell_led_perform_fn(u8 length, - u8 result_code, - u8 device_id, - u8 command, - u8 on_time, - u8 off_time) +static int dell_led_perform_fn(u8 length, u8 result_code, u8 device_id, + u8 command, u8 on_time, u8 off_time) { - struct bios_args *bios_return; - u8 return_code; - union acpi_object *obj; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + struct bios_args *bios_return; struct acpi_buffer input; + union acpi_object *obj; acpi_status status; + u8 return_code; - struct bios_args args; - args.length = length; - args.result_code = result_code; - args.device_id = device_id; - args.command = command; - args.on_time = on_time; - args.off_time = off_time; + struct bios_args args = { + .length = length, + .result_code = result_code, + .device_id = device_id, + .command = command, + .on_time = on_time, + .off_time = off_time + }; input.length = sizeof(struct bios_args); input.pointer = &args; - status = wmi_evaluate_method(DELL_LED_BIOS_GUID, - 1, - 1, - &input, - &output); - + status = wmi_evaluate_method(DELL_LED_BIOS_GUID, 1, 1, &input, &output); if (ACPI_FAILURE(status)) return status; @@ -84,7 +76,7 @@ static int dell_led_perform_fn(u8 length, if (!obj) return -EINVAL; - else if (obj->type != ACPI_TYPE_BUFFER) { + if (obj->type != ACPI_TYPE_BUFFER) { kfree(obj); return -EINVAL; } @@ -117,8 +109,7 @@ static int led_off(void) 0); /* not used */ } -static int led_blink(unsigned char on_eighths, - unsigned char off_eighths) +static int led_blink(unsigned char on_eighths, unsigned char off_eighths) { return dell_led_perform_fn(5, /* Length of command */ INTERFACE_ERROR, /* Init to INTERFACE_ERROR */ @@ -129,7 +120,7 @@ static int led_blink(unsigned char on_eighths, } static void dell_led_set(struct led_classdev *led_cdev, - enum led_brightness value) + enum led_brightness value) { if (value == LED_OFF) led_off(); @@ -138,27 +129,22 @@ static void dell_led_set(struct led_classdev *led_cdev, } static int dell_led_blink(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) + unsigned long *delay_on, unsigned long *delay_off) { unsigned long on_eighths; unsigned long off_eighths; - /* The Dell LED delay is based on 125ms intervals. - Need to round up to next interval. */ + /* + * The Dell LED delay is based on 125ms intervals. + * Need to round up to next interval. + */ - on_eighths = (*delay_on + 124) / 125; - if (0 == on_eighths) - on_eighths = 1; - if (on_eighths > 255) - on_eighths = 255; + on_eighths = DIV_ROUND_UP(*delay_on, 125); + on_eighths = clamp_t(unsigned long, on_eighths, 1, 255); *delay_on = on_eighths * 125; - off_eighths = (*delay_off + 124) / 125; - if (0 == off_eighths) - off_eighths = 1; - if (off_eighths > 255) - off_eighths = 255; + off_eighths = DIV_ROUND_UP(*delay_off, 125); + off_eighths = clamp_t(unsigned long, off_eighths, 1, 255); *delay_off = off_eighths * 125; led_blink(on_eighths, off_eighths);