Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2991743imu; Sun, 9 Dec 2018 14:30:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/XPq+bSoGgDw8kEmKPvYOQVNJ11JTgl2Lv890u6y+PCAgUADeIowis5Od4G26hIslH7XIE1 X-Received: by 2002:a63:d005:: with SMTP id z5mr8906008pgf.64.1544394615385; Sun, 09 Dec 2018 14:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544394615; cv=none; d=google.com; s=arc-20160816; b=LnCOaB3rQ4b0zkNV2O0M7M9Sqc2mpdftHuRd74HnPenQWpTTRXHD11+fD43XQJ3hyO S1ZcFkhOsEDN4LYlnBouDz5/Fj0vDNa8mfTV/bSpUyAbpVJYjgyC3/FQctHVMrxp68w7 7ll4zk5lBi7u1nm8RNbPlW7s+Xv5HpVkv+yrvBeHmxR5dk/0B5EORDBB91ZFv4rimDRE OC6v6gogbvo+0g+74BlaRWbXJ/5pJu9Sw/tUeMcpGYsqWx0VODB9BahGogs9kREUF7D4 VTPxc3a0wsma2FFo9p8RT9X0a9ZO3sVoZBnzpaU7t/92yqEo6j5nb/SnTjJ7mdljbrcZ WjsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=JmDz4j0DMfguTH/fPSyDHXLAILCzoyMu2fpqOpZaFMg=; b=dGzgbklu1QhZtXwMfoVDEsf76GgLwsV3ypQXk3nNRFXMUbUD6T9RmYvYQLvriQtUkW ccUBFmG8QH78kIkmf4o46MxryM446s+WrtgXk4aUwqQeJrzEoZhkPvvodKc6n909tI+0 ZN7qGwXAZ1+ete+ZivSz9jnUZz6fNZ5mD7//tS3Nx+vkdLt2VBI3llvU6BNNsgUNhq5M j8QyIGQecF/wcqF3OMbHLtjlRxQIRsttZuAkR/TbskLqe3s4lVnUmmrWmr42pqaHQ7i2 PuUDWJY/g8pBRWVn6PEeuZo6Dvtz9KZNPO0UHSfzUQSXxh197Uh8TvthwmK/MGHd2YKJ c7OQ== 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 j61si8669879plb.232.2018.12.09.14.30.00; Sun, 09 Dec 2018 14:30:15 -0800 (PST) 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 S1728828AbeLIW1b (ORCPT + 99 others); Sun, 9 Dec 2018 17:27:31 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34664 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbeLIVzL (ORCPT ); Sun, 9 Dec 2018 16:55:11 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72b-0002ia-KZ; Sun, 09 Dec 2018 21:55:09 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72Y-0003EB-QO; Sun, 09 Dec 2018 21:55:06 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Sebastian Reichel" , "H. Nikolaus Schaller" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 026/328] power: generic-adc-battery: check for duplicate properties copied from iio channels In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "H. Nikolaus Schaller" commit a427503edaaed9b75ed9746a654cece7e93e60a8 upstream. If an iio channel defines a basic property, there are duplicate entries in /sys/class/power/*/uevent. So add a check to avoid duplicates. Since all channels may be duplicates, we have to modify the related error check. Signed-off-by: H. Nikolaus Schaller Fixes: e60fea794e6e ("power: battery: Generic battery driver using IIO") Signed-off-by: Sebastian Reichel [bwh: Backported to 3.16: - s/psy_desc/psy/ - Adjust filename] Signed-off-by: Ben Hutchings --- drivers/power/generic-adc-battery.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/drivers/power/generic-adc-battery.c +++ b/drivers/power/generic-adc-battery.c @@ -244,6 +244,7 @@ static int gab_probe(struct platform_dev int ret = 0; int chan; int index = ARRAY_SIZE(gab_props); + bool any = false; adc_bat = devm_kzalloc(&pdev->dev, sizeof(*adc_bat), GFP_KERNEL); if (!adc_bat) { @@ -288,12 +289,22 @@ static int gab_probe(struct platform_dev adc_bat->channel[chan] = NULL; } else { /* copying properties for supported channels only */ - psy->properties[index++] = gab_dyn_props[chan]; + int index2; + + for (index2 = 0; index2 < index; index2++) { + if (psy->properties[index2] == + gab_dyn_props[chan]) + break; /* already known */ + } + if (index2 == index) /* really new */ + psy->properties[index++] = + gab_dyn_props[chan]; + any = true; } } /* none of the channels are supported so let's bail out */ - if (index == ARRAY_SIZE(gab_props)) { + if (!any) { ret = -ENODEV; goto second_mem_fail; }