From patchwork Fri Mar 10 10:50:33 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: 9615977 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 6FB6F60415 for ; Fri, 10 Mar 2017 10:52:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52AA22851A for ; Fri, 10 Mar 2017 10:52:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47688285B6; Fri, 10 Mar 2017 10:52:09 +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=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 C588F2851A for ; Fri, 10 Mar 2017 10:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935177AbdCJKur (ORCPT ); Fri, 10 Mar 2017 05:50:47 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:32883 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935047AbdCJKup (ORCPT ); Fri, 10 Mar 2017 05:50:45 -0500 Received: by mail-lf0-f67.google.com with SMTP id r36so6580194lfi.0 for ; Fri, 10 Mar 2017 02:50:43 -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=+dkrUbxyPkKHEod5giB8odU8vebTDw2rWjBBIvFSKHA=; b=a9U0CwngUZ6vj1rJOYz6cW6jdBlDljq5kgzdWbQcJAZMkikZn8bvMqxxLAduL3L+iT uL2soXCA/KDn0WckkBFoksuHcxT4ZBfIm9BZy4MRJU+swDUCeZDTj3EOznIQtDEheta2 arn/M549fwqNLf1y5Uz3Hf8b8VrOWC864SoLU= 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=+dkrUbxyPkKHEod5giB8odU8vebTDw2rWjBBIvFSKHA=; b=WTS5kgNBNKt6Xoikvc+WlmHv719mcwSGuVWYxQfZgEhWAlB3BfHqw5NcqybfCKUWtz hnw098Y7b1nKNMTvKNVWFWc4LhlpPCT8x82ELPSaHJzZbvRpGyQpvP6KdoCMoelXoNNf qfjj5g7qBLQ9mHsL6DAdS2bov3PGJ5vsspU4z7NWW7mo6MfmGns5c9dQpvXC4KF2KwwC GPD5mdHjS46l6OYY1ve/XxfIBZR5IQ2nHPqER9Hh5ee9gute3P3r/SbDErykrs2Ot2J+ +vD6pOGWOXbSMq7+wTOb7J1XIg6Ti5zWkWKLABdQuo1uL75VWkDSzZt45d1RHTFPMhVG T08w== X-Gm-Message-State: AMke39kYiwuYvrr0zSQGWUK5OWQfFu4Xr7D+kKwGP/fhfB+nhHOhByc53yxO7oyRC2j6Gg== X-Received: by 10.25.31.141 with SMTP id f135mr3176753lff.56.1489143042808; Fri, 10 Mar 2017 02:50:42 -0800 (PST) Received: from ozzy.hq.kempniu.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id r10sm500865ljd.54.2017.03.10.02.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 02:50:42 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] platform/x86: fujitsu-laptop: register backlight device in a separate function Date: Fri, 10 Mar 2017 11:50:33 +0100 Message-Id: <20170310105036.26899-2-kernel@kempniu.pl> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170310105036.26899-1-kernel@kempniu.pl> References: <20170310105036.26899-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 Move code responsible for backlight device registration to a separate function in order to simplify error handling and decrease indentation. Simplify initialization of struct backlight_properties. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index e12cc3504d48..5ec596c5053d 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -685,6 +685,25 @@ static const struct dmi_system_id fujitsu_dmi_table[] __initconst = { /* ACPI device for LCD brightness control */ +static int fujitsu_backlight_register(void) +{ + struct backlight_properties props = { + .brightness = fujitsu_bl->brightness_level, + .max_brightness = fujitsu_bl->max_brightness - 1, + .type = BACKLIGHT_PLATFORM + }; + struct backlight_device *bd; + + bd = backlight_device_register("fujitsu-laptop", NULL, NULL, + &fujitsu_bl_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + + fujitsu_bl->bl_device = bd; + + return 0; +} + static int acpi_fujitsu_bl_add(struct acpi_device *device) { int state = 0; @@ -1192,7 +1211,7 @@ MODULE_DEVICE_TABLE(acpi, fujitsu_ids); static int __init fujitsu_init(void) { - int ret, max_brightness; + int ret; if (acpi_disabled) return -ENODEV; @@ -1232,22 +1251,9 @@ static int __init fujitsu_init(void) /* Register backlight stuff */ if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { - struct backlight_properties props; - - memset(&props, 0, sizeof(struct backlight_properties)); - max_brightness = fujitsu_bl->max_brightness; - props.type = BACKLIGHT_PLATFORM; - props.max_brightness = max_brightness - 1; - fujitsu_bl->bl_device = backlight_device_register("fujitsu-laptop", - NULL, NULL, - &fujitsu_bl_ops, - &props); - if (IS_ERR(fujitsu_bl->bl_device)) { - ret = PTR_ERR(fujitsu_bl->bl_device); - fujitsu_bl->bl_device = NULL; + ret = fujitsu_backlight_register(); + if (ret) goto fail_sysfs_group; - } - fujitsu_bl->bl_device->props.brightness = fujitsu_bl->brightness_level; } ret = platform_driver_register(&fujitsu_pf_driver);