Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3799194ybi; Mon, 29 Jul 2019 12:51:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVmaOXNsqk+pPWHjEcUbcOxvvZ5hVD6n22W2xCDxWEm3MoFf1jUZQuGBjpWwZwV/RKO5YY X-Received: by 2002:a17:90a:24ac:: with SMTP id i41mr112314058pje.124.1564429900294; Mon, 29 Jul 2019 12:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429900; cv=none; d=google.com; s=arc-20160816; b=tcE6dcjdbPvC0WuL9F2DoomgZHwJTickfe1r/LBAlLEd8TsEytOb8AqxlJx2uDULeJ 72cNvHqHe6mLvtd+KZTllBsrjQljd466+a8Ws+u4pRAe9OWpvsrnPgXk0IXOXVzrWVe5 Kc30AOv2Bj+bMxw1J1HhCsXpz0r76WhqkOyv1ZxTENzcbRTittbFJDz5+MAcXAdGpTVz RjcUQf3iRNpxs/VL1c8G/Nm0I43Crs3nCvDaUbOZloJxxDPrXQIw6DN4+8rlILk/z9+e MEUXFZIqUidhgOYOb7A5VsoYK1o6cIlaoccQxiX9Tg9ED99iDAiVRcuOAU2McYWTCIz3 tgQg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7cHiyFhUy72jldbiMfxUof04AKbPiDa6On9yG9hdU/Q=; b=nBWX4xngbre23ondiiqQh5DvMqDsJ+wQVd354H2bHjUKRFF8dOXTMb+LLpD52k1Y+p oIbMJoCEFl+wGoBQwVoC2kVoc/TXDQX9dg/sgUR4yPCTjIYsoiGN7iXQlmWVUEf5xmpE brzgwHp+pNfGGw4VaixlvJ/ZMXXwA14Zb95dHz/HQ5ZSmm6eRf3onM0u1qI+gMuRckyb empQtiagxHC20ZkJ79VJ/CNCCELVlePwj8+R8rsp4++W8Iw0YPf+3UMEOLg5QEoVqAzR t7/4Um404SXW1lbfZbH/QpY8ICJ9zE5a4LPZp71ttiQFyPeYIl137OIqK1UmMA87B7aW pHcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iV3j+S2l; 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 x61si27107803plb.336.2019.07.29.12.51.25; Mon, 29 Jul 2019 12:51:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b=iV3j+S2l; 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 S2403753AbfG2Tts (ORCPT + 99 others); Mon, 29 Jul 2019 15:49:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:40502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389840AbfG2Ttr (ORCPT ); Mon, 29 Jul 2019 15:49:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0B5721655; Mon, 29 Jul 2019 19:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429786; bh=jimd+J+7ciZKpnau6npdhpH0c9hsi6H1gm/vd/Sec/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iV3j+S2l6b9AhrFsIio7PtLalxikm9IE+9LVsIpx0lf4KweRwBwqQ6hg/zLydw8EC FBlXJmlotr+GzQH55yo05n2vp+5/6C/Vef4u5GzkWMvpHAowSD30k9XouwcW8ngOhs ZVmHjul1b2dNQuRYLqX3Kolb/Dp8Oe1G6hp712QE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gwendal Grignou , Lee Jones , Sasha Levin Subject: [PATCH 5.2 095/215] mfd: cros_ec: Register cros_ec_lid_angle driver when presented Date: Mon, 29 Jul 2019 21:21:31 +0200 Message-Id: <20190729190755.698209247@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1bb407f17c5316888c3c446e26cb2bb78943f236 ] Register driver when EC indicates has precise lid angle calculation code running. Fix incorrect extra resource allocation in cros_ec_sensors_register(). Signed-off-by: Gwendal Grignou Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/cros_ec_dev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index a5391f96eafd..607383b67cf1 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -285,13 +285,15 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) resp = (struct ec_response_motion_sense *)msg->data; sensor_num = resp->dump.sensor_count; - /* Allocate 1 extra sensors in FIFO are needed */ - sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell), + /* + * Allocate 2 extra sensors if lid angle sensor and/or FIFO are needed. + */ + sensor_cells = kcalloc(sensor_num + 2, sizeof(struct mfd_cell), GFP_KERNEL); if (sensor_cells == NULL) goto error; - sensor_platforms = kcalloc(sensor_num + 1, + sensor_platforms = kcalloc(sensor_num, sizeof(struct cros_ec_sensor_platform), GFP_KERNEL); if (sensor_platforms == NULL) @@ -351,6 +353,11 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) sensor_cells[id].name = "cros-ec-ring"; id++; } + if (cros_ec_check_features(ec, + EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) { + sensor_cells[id].name = "cros-ec-lid-angle"; + id++; + } ret = mfd_add_devices(ec->dev, 0, sensor_cells, id, NULL, 0, NULL); -- 2.20.1