From patchwork Wed Jan 18 21:23:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 9524801 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 C86EF601B7 for ; Wed, 18 Jan 2017 21:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7752284F7 for ; Wed, 18 Jan 2017 21:24:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC21C28623; Wed, 18 Jan 2017 21:24:11 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 31F51284F7 for ; Wed, 18 Jan 2017 21:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546AbdARVYK (ORCPT ); Wed, 18 Jan 2017 16:24:10 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:36538 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbdARVYJ (ORCPT ); Wed, 18 Jan 2017 16:24:09 -0500 Received: by mail-wj0-f194.google.com with SMTP id kq3so407481wjc.3; Wed, 18 Jan 2017 13:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Nt14GC253VNgXM/bKRA+88cQg65NMnc2CrMI/m6iAOE=; b=iYqwcuJN+MhQMOEu158rQirHI3XluB4sIO4y4N9nAvXlgBK6IwSSMYURTcQtpK5woy zRGChKBPmFzEgaXYVjYrfRTkrPXRUV5kPBxWfUH90U/aNdwoPW4vphs6ufLOj+Us/ULu TxhH4K/nOr5tZJ0hkPTDrpX7VMbnombSfpcWhd+HI2g9WLjicd4+Z+KcR6MNxgzYe/q9 MVyuJzgK1ReAmRVXBDqjZUWUlgb6+hgjzwKyCjb2ZFXhZERNlqLTqvmGyfnHvgegQGZq A/7GS7xSJF6vfQNQZ2oazmrxRSvHNhuk0UHXjw8ikJK+i+h4rB4g3UH5/FgGee8yFpGM wOWQ== 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; bh=Nt14GC253VNgXM/bKRA+88cQg65NMnc2CrMI/m6iAOE=; b=imkjqCWpYppC2EqHyiBciWxAhnk50k+FjM/wvSO69BSVSvmTZiTuSDUetQDZqA5V6J eRj3KZ7ba2x+d7U5Su8aAeFK8MYCDLGtob3GjMVDVkotD+JphKMdGmJWEBqN96lyWysp zb6ySMl8I4nZiMiz2edr87s5w2J5k6BFVFBixgPhRxTSSSRX1y5+0zTmogsP61Sx/1hm 8YyqI1Msg71bdTJXSjIIUTzafeROOi4wey87oojvrgwLCGG+OT3GGbhlTNHzg9JzOVxE fNoa+Rr9O31i3TeuLm/IjyS5kn3P3oWsAxEt3YgqQxNGgW2SDbaiTjhogctARXGOx9d4 5+VA== X-Gm-Message-State: AIkVDXJupDgMnQC4dz0FNqQiQxlJXTP45jpyoj1/rldSJ2PlQFnRh/rFiZpXevgK+cZTNA== X-Received: by 10.223.177.195 with SMTP id r3mr4659763wra.147.1484774635492; Wed, 18 Jan 2017 13:23:55 -0800 (PST) Received: from localhost.localdomain (cpc101300-bagu16-2-0-cust362.1-3.cable.virginm.net. [86.21.41.107]) by smtp.gmail.com with ESMTPSA id 135sm7536388wmh.14.2017.01.18.13.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 13:23:55 -0800 (PST) From: Sudip Mukherjee To: Jingoo Han , Lee Jones , Bartlomiej Zolnierkiewicz Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] backlight: report error on failure Date: Wed, 18 Jan 2017 21:23:50 +0000 Message-Id: <1484774630-4228-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is possible to update the backlight power and the brightness using the sysfs and on writing it either returns the count or if the callback function does not exist then returns the error code 'ENXIO'. We have a situation where the userspace client is writing to the sysfs to update the power and since the callback function exists the client receives the return value as count and considers the operation to be successful. That is correct as the write to the sysfs was successful. But there is no way to know if the actual operation was done or not. backlight_update_status() returns the error code if it fails. Pass that to the userspace client who is trying to update the power so that the client knows that the operation failed. Signed-off-by: Sudip Mukherjee --- drivers/video/backlight/backlight.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 288318a..74b72b5 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -146,9 +146,9 @@ static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr, pr_debug("set power to %lu\n", power); if (bd->props.power != power) { bd->props.power = power; - backlight_update_status(bd); + rc = backlight_update_status(bd); } - rc = count; + rc = rc ? rc : count; } mutex_unlock(&bd->ops_lock); @@ -176,8 +176,7 @@ int backlight_device_set_brightness(struct backlight_device *bd, else { pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; - backlight_update_status(bd); - rc = 0; + rc = backlight_update_status(bd); } } mutex_unlock(&bd->ops_lock);