From patchwork Wed Feb 6 18:08:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10799837 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 A3BB4746 for ; Wed, 6 Feb 2019 18:09:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91F5E2BDAE for ; Wed, 6 Feb 2019 18:09:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F8472C267; Wed, 6 Feb 2019 18:09:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 0FB852BDAE for ; Wed, 6 Feb 2019 18:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbfBFSJA (ORCPT ); Wed, 6 Feb 2019 13:09:00 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33963 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfBFSJA (ORCPT ); Wed, 6 Feb 2019 13:09:00 -0500 Received: by mail-pf1-f193.google.com with SMTP id h3so3444626pfg.1; Wed, 06 Feb 2019 10:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=6nJURJ4r/iJ7dJytgwY+6iLCpLFguSmIjCgEe0Lraf4=; b=CX9qkTpSPWYIhphSfmRUdXLrgLmlbaKzOftqHnWN/uEZ+574Od5BHx5eGFl7JK+Kgc V71UTnYtks8orwnbDX37EomRWbqUQJ9iJz+MkMdKMVrM+X5MwFgXwqHYMTlPkmjms3G3 bxJMEwqE8JT+nVUYzTFV1jbMffn6J2w1cJwge0586eFSXI7GEJAjEzPsK8KPTXsmeYfk gtS7qcvh1d51WMe62YP6Ub+22OM2hIQlGp2ur/l0zY5Okz0oQofNb8dcc7ph5vbkktqc FRyPOtkbdI4/paj0OZ+h+DhcwP/khOlUX/0YYKUZ23y1kXZEWsJTqNQvMd2Z/VC5cmFX TmwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=6nJURJ4r/iJ7dJytgwY+6iLCpLFguSmIjCgEe0Lraf4=; b=c6sSdvCowdFiIAjbZ+6lr0bYcAYGuSVIhViz75p/KfjlkQIoO4fb/5qLPb/1+cAEzT +fkrLbu6Jk71NlioGaZPT52/2aGS9ul1TVkeif/lSwjq6ZsDjsw7BkgcZDjp/gpwwBZC sbC3xiLZxDx3Rv6hdjRetDRq4vGaXp4yyQZzaLZe6ouQoBH3/A+/pJLP6OohzJlDDWEV AS0w+huXACYdeB4S3IiETx5dWKsSaRF/aRy/RXTzTLvDD3lKNdLKV6HauGhPRa6k8dhH 0YXx9al6o6UOGkVEmGduSY1LEMr2NP08acuzmVf7Ypcrfe80oGwHS6CizCpGGYQxGe6v qHAA== X-Gm-Message-State: AHQUAuYqHrVg0czL+Jq1ZBzjYzkxAhFNxfjoCrHZXA5ApAxGzt+cuzTA FdG63eghWUl6g8hGvrDWisANq30r X-Google-Smtp-Source: AHgI3IYov8k9udyigdeSHw/oTZigWam/SVQ74ajGgWhMSpG3YhAsKmXtujg6yJV6u9gA0vecaPFaSg== X-Received: by 2002:a63:f552:: with SMTP id e18mr865806pgk.239.1549476538510; Wed, 06 Feb 2019 10:08:58 -0800 (PST) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id h128sm8875408pgc.15.2019.02.06.10.08.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 10:08:57 -0800 (PST) Date: Wed, 6 Feb 2019 10:08:56 -0800 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Chris Healy Subject: [PATCH] Input: ims-pcu - switch to using brightness_set_blocking() Message-ID: <20190206180856.GA199121@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that LEDs core allows "blocking" flavor of "set brightness" method we can use it and get rid of private work item. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ims-pcu.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 3d51175c4d72..74cf3b612f05 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -39,8 +39,6 @@ struct ims_pcu_gamepad { struct ims_pcu_backlight { struct led_classdev cdev; - struct work_struct work; - enum led_brightness desired_brightness; char name[32]; }; @@ -949,14 +947,14 @@ static void ims_pcu_process_async_firmware(const struct firmware *fw, #define IMS_PCU_MAX_BRIGHTNESS 31998 -static void ims_pcu_backlight_work(struct work_struct *work) +static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev, + enum led_brightness value) { struct ims_pcu_backlight *backlight = - container_of(work, struct ims_pcu_backlight, work); + container_of(cdev, struct ims_pcu_backlight, cdev); struct ims_pcu *pcu = container_of(backlight, struct ims_pcu, backlight); - int desired_brightness = backlight->desired_brightness; - __le16 br_val = cpu_to_le16(desired_brightness); + __le16 br_val = cpu_to_le16(value); int error; mutex_lock(&pcu->cmd_mutex); @@ -966,19 +964,11 @@ static void ims_pcu_backlight_work(struct work_struct *work) if (error && error != -ENODEV) dev_warn(pcu->dev, "Failed to set desired brightness %u, error: %d\n", - desired_brightness, error); + value, error); mutex_unlock(&pcu->cmd_mutex); -} -static void ims_pcu_backlight_set_brightness(struct led_classdev *cdev, - enum led_brightness value) -{ - struct ims_pcu_backlight *backlight = - container_of(cdev, struct ims_pcu_backlight, cdev); - - backlight->desired_brightness = value; - schedule_work(&backlight->work); + return error; } static enum led_brightness @@ -1015,14 +1005,14 @@ static int ims_pcu_setup_backlight(struct ims_pcu *pcu) struct ims_pcu_backlight *backlight = &pcu->backlight; int error; - INIT_WORK(&backlight->work, ims_pcu_backlight_work); snprintf(backlight->name, sizeof(backlight->name), "pcu%d::kbd_backlight", pcu->device_no); backlight->cdev.name = backlight->name; backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness; - backlight->cdev.brightness_set = ims_pcu_backlight_set_brightness; + backlight->cdev.brightness_set_blocking = + ims_pcu_backlight_set_brightness; error = led_classdev_register(pcu->dev, &backlight->cdev); if (error) { @@ -1040,7 +1030,6 @@ static void ims_pcu_destroy_backlight(struct ims_pcu *pcu) struct ims_pcu_backlight *backlight = &pcu->backlight; led_classdev_unregister(&backlight->cdev); - cancel_work_sync(&backlight->work); }