Received: by 10.192.165.156 with SMTP id m28csp1085251imm; Wed, 11 Apr 2018 12:07:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx49YOrw/SsXokNzaFJwUUiPxnHj08Fh57LhPWhlOr06zAWYywZUgRhCrNGFdoZNjbrnt/IpN X-Received: by 10.101.99.66 with SMTP id p2mr2502496pgv.286.1523473670348; Wed, 11 Apr 2018 12:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473670; cv=none; d=google.com; s=arc-20160816; b=mTDJbfQqeH4PZMbFEFCb6ythTFgcZsEgQ7s+Dwk96Mnd5ZPyfvt0ywh4CK+nAtW39E lhhzMVQ+wk9iWntsNERqb9O1Jj46xZ92W3z9XxvGXwTlJ5P/y/c2czB6SZg2VnahL16d LM+M1Kx94qt8O0B4rH39WmnXApyYUtjEvG2Dr+2KmYWo/BWkMwfep6L9Fb3LSjZHI/v7 mMzcphjdPenZtPApC/zmZxS0Q7CeRXlxP0aDIzJQTGWGg21nQ6mnmax8u9qIpK8SvroN 8hFIB1QY9Px4kIsRGqI85VTH1y0UkdcN63lwIyPE6bDtHXtq3LV1i81PSUfX8Y16rG8s zWqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VQEIH7eXAP0KzRe3L2ApzmCIjv5A+rB5kRds3VCbBe8=; b=oMytC6jnILZe5E57ZfZ5sNcw2ezl+S8CMdI1bbXH31/xx8V8QxlBGZIYJNNbPQ6FWN NLgdbnaJTTv7CFm+VUaJ/xWpA8jvot2B7enrL8M81Akc6DRfhYGdbLCrH8hR6v17vJw3 u87nbRl4Malin8HUKzh/7q60zfXY+Uf87CCqcqfuHzVEWSbDFPYGO5pHX3tAeDBQqeFj xxll58kaiiipLFbqMVo2S8+sMt7IQ+0s0O4kXCBjcmEbFy6YYRUFDHtTDBgdvZxuJAWK 94DOjNs9H3sbHrEOzAZO2nGDZ3PbW0SVm6hUYRo+W8kdbEmsjp0cPshwweP/90lgEXCU N7fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si1098904pga.1.2018.04.11.12.07.12; Wed, 11 Apr 2018 12:07:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934138AbeDKS7k (ORCPT + 99 others); Wed, 11 Apr 2018 14:59:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37448 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932894AbeDKS7g (ORCPT ); Wed, 11 Apr 2018 14:59:36 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AEDD6B9E; Wed, 11 Apr 2018 18:59:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudip Mukherjee , Daniel Thompson , Lee Jones , Sasha Levin Subject: [PATCH 4.9 155/310] backlight: Report error on failure Date: Wed, 11 Apr 2018 20:34:54 +0200 Message-Id: <20180411183629.085307545@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sudip Mukherjee [ Upstream commit 7e715c2d9c27c23f3187454157c58cf292ed103e ] 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 Acked-by: Daniel Thompson Signed-off-by: Lee Jones Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/video/backlight/backlight.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -134,7 +134,7 @@ static ssize_t bl_power_store(struct dev { int rc; struct backlight_device *bd = to_backlight_device(dev); - unsigned long power; + unsigned long power, old_power; rc = kstrtoul(buf, 0, &power); if (rc) @@ -145,10 +145,16 @@ static ssize_t bl_power_store(struct dev if (bd->ops) { pr_debug("set power to %lu\n", power); if (bd->props.power != power) { + old_power = bd->props.power; bd->props.power = power; - backlight_update_status(bd); + rc = backlight_update_status(bd); + if (rc) + bd->props.power = old_power; + else + rc = count; + } else { + rc = count; } - rc = count; } mutex_unlock(&bd->ops_lock); @@ -176,8 +182,7 @@ int backlight_device_set_brightness(stru 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);