Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2190305imu; Thu, 10 Jan 2019 09:43:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4+TUyPKTNGd08H/1e5W9qq6wWR4ZzJelwuLCI2+JD4kcmPUxF1AwMji+4yqTlm4OfqxC4b X-Received: by 2002:a17:902:5a5:: with SMTP id f34mr11298437plf.161.1547142239473; Thu, 10 Jan 2019 09:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142239; cv=none; d=google.com; s=arc-20160816; b=bFC8XiwV4l5mE7y8/pqiJlB5mfeKJR3CvO5EwL34KdrxwT0advQ+oBp9WkMJAPlGj/ Y6ThqI20PquRcLpJB4579EXoQ3yyHnGYTbDKPDhg3hp4V5Pl0kyXbomf7m0+gFIdk6J0 n4f8Pqet4GCvaFtKMr3xZpbf/5w/lOcwfJo6McRo68ug1Q5X14cAAJECiklxvAeLCoLd oKnA6Odgr9XgKWNG+p3O0nM41ilS91QVAWL/GIbrJIeg1aqAj7AF23q74Cz2OSz41Nt6 cYmFE2El3fWG+kZ7yyBDSD+CWLI/K5+BcUaelTqNNYVV55Et6djn3YosMahgGIIGBSwI VpuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=44+W+X8qj41LYNpKmgc/nJAJ4fMBHfx44j0NE3cVnrs=; b=0TgJRiLkwOljvnZoRCxqDeZEZa/SQ6SeCDdhQw4mdZtKlemKNcZ8gvpX3iHs9SwWKW 967mlXla0nWZ1szeXI/lKPVGu7JUys9a5c/igKCjvuzkAdE1ZTsl58O6tyQLAsbbkOmn NA/zRumYr5Rs325Dtm/cCeqP47lA/753VWTc7a4KD8lgZHXTWmusbp1i2SpxlcvD+RLF sd1XS0oUS0dfck22G4ueErCGtR+nD1cFszcu7VNKi1XKK9CEqpSoIUgo8MNqLg9o9hbN ZXP6Y+QCfYcV5qau8ZNK06uxzD5Fd8crCWA4+wfSp6YHNcS2rGm/7T6YU7bPey+09H7Z SncQ== 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 p22si70394741pgl.340.2019.01.10.09.43.44; Thu, 10 Jan 2019 09:43:59 -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 S1730697AbfAJRmW (ORCPT + 99 others); Thu, 10 Jan 2019 12:42:22 -0500 Received: from shell.v3.sk ([90.176.6.54]:58379 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730651AbfAJRmU (ORCPT ); Thu, 10 Jan 2019 12:42:20 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id EEDF510018D; Thu, 10 Jan 2019 18:42:16 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tBrZKTBpArwR; Thu, 10 Jan 2019 18:42:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id AA5F91002E8; Thu, 10 Jan 2019 18:42:06 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LVvp3G1PdY_8; Thu, 10 Jan 2019 18:42:03 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id CE5781002E5; Thu, 10 Jan 2019 18:42:02 +0100 (CET) From: Lubomir Rintel To: Sebastian Reichel Cc: Rob Herring , Mark Rutland , x86@kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel , Pavel Machek Subject: [PATCH v5 2/7] x86, olpc: Use a correct version when making up a battery node Date: Thu, 10 Jan 2019 18:40:00 +0100 Message-Id: <20190110174005.1202564-3-lkundrak@v3.sk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110174005.1202564-1-lkundrak@v3.sk> References: <20190110174005.1202564-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The XO-1 and XO-1.5 batteries apparently differ in an ability to report ambient temperature. Add a different compatible string to the 1.5 battery. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Avoid splitting string literals arch/x86/platform/olpc/olpc_dt.c | 84 +++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/ol= pc_dt.c index b4ab779f1d47..8557add82752 100644 --- a/arch/x86/platform/olpc/olpc_dt.c +++ b/arch/x86/platform/olpc/olpc_dt.c @@ -217,10 +217,28 @@ static u32 __init olpc_dt_get_board_revision(void) return be32_to_cpu(rev); } =20 -void __init olpc_dt_fixup(void) +int olpc_dt_compatible_match(phandle node, const char *compat) { - int r; char buf[64]; + int plen; + char *p; + int len; + + plen =3D olpc_dt_getproperty(node, "compatible", buf, sizeof(buf)); + if (plen <=3D 0) + return 0; + + len =3D strlen(compat); + for (p =3D buf; p < buf + plen; p +=3D strlen(p) + 1) { + if (strcmp(p, compat) =3D=3D 0) + return 1; + } + + return 0; +} + +void __init olpc_dt_fixup(void) +{ phandle node; u32 board_rev; =20 @@ -228,41 +246,51 @@ void __init olpc_dt_fixup(void) if (!node) return; =20 - /* - * If the battery node has a compatible property, we are running a new - * enough firmware and don't have fixups to make. - */ - r =3D olpc_dt_getproperty(node, "compatible", buf, sizeof(buf)); - if (r > 0) - return; - - pr_info("PROM DT: Old firmware detected, applying fixes\n"); - - /* Add olpc,xo1-battery compatible marker to battery node */ - olpc_dt_interpret("\" /battery@0\" find-device" - " \" olpc,xo1-battery\" +compatible" - " device-end"); - board_rev =3D olpc_dt_get_board_revision(); if (!board_rev) return; =20 if (board_rev >=3D olpc_board_pre(0xd0)) { + if (olpc_dt_compatible_match(node, "olpc,xo1.5-battery")) + return; + + /* Add olpc,xo1.5-battery compatible marker to battery node */ + olpc_dt_interpret("\" /battery@0\" find-device"); + olpc_dt_interpret(" \" olpc,xo1.5-battery\" +compatible"); + olpc_dt_interpret("device-end"); + + /* We're running a very old firmware if this is missing. */ + if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) + return; + /* XO-1.5: add dcon device */ - olpc_dt_interpret("\" /pci/display@1\" find-device" - " new-device" - " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible" - " finish-device device-end"); + olpc_dt_interpret("\" /pci/display@1\" find-device"); + olpc_dt_interpret(" new-device"); + olpc_dt_interpret(" \" dcon\" device-name"); + olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible"); + olpc_dt_interpret(" finish-device"); + olpc_dt_interpret("device-end"); } else { + /* We're running a very old firmware if this is missing. */ + if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) + return; + /* XO-1: add dcon device, mark RTC as olpc,xo1-rtc */ - olpc_dt_interpret("\" /pci/display@1,1\" find-device" - " new-device" - " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible" - " finish-device device-end" - " \" /rtc\" find-device" - " \" olpc,xo1-rtc\" +compatible" - " device-end"); + olpc_dt_interpret("\" /pci/display@1,1\" find-device"); + olpc_dt_interpret(" new-device"); + olpc_dt_interpret(" \" dcon\" device-name"); + olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible"); + olpc_dt_interpret(" finish-device"); + olpc_dt_interpret("device-end"); + olpc_dt_interpret("\" /rtc\" find-device"); + olpc_dt_interpret(" \" olpc,xo1-rtc\" +compatible"); + olpc_dt_interpret("device-end"); } + + /* Add olpc,xo1-battery compatible marker to battery node */ + olpc_dt_interpret("\" /battery@0\" find-device"); + olpc_dt_interpret(" \" olpc,xo1-battery\" +compatible"); + olpc_dt_interpret("device-end"); } =20 void __init olpc_dt_build_devicetree(void) --=20 2.20.1