Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3132357ybi; Thu, 18 Jul 2019 21:39:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhcMkS9dim+8y6OXa6iQazwTMOaqS5yC29kvKxQkp2KrMQ7/9nyZrgfK3OxWyxh+JPk3UR X-Received: by 2002:a63:608c:: with SMTP id u134mr50837801pgb.274.1563511185112; Thu, 18 Jul 2019 21:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511185; cv=none; d=google.com; s=arc-20160816; b=rp/M/YbDusKGKEkQGNbGPoB5wW/kQylkEiurHDjXOXgL66NpdF3SzRjU1qzEId0gcH DuNpGDpSI8aaG67/pqLIcYRXGYkIqMZdlIKosOBt/9CnyNATIgy3Ic2WkQylQRgdrTKn coLH5I20l1PTtbGR3clmqY5DqUG78oBlv+o6HNH/MUq70A2H2GZ6Y4bavHSRoOeqDinH wk3yDlIyRN8MNKKKzMO2QysWFkANvNFSAhCtnPzD3qb2eEO4fFmzo/p+w9iutm6l/2mn N0GRsXWhnEOy1c46U5w6PJOEuwPbB/X/wfmG0G3sRzyf28MZgFori1rnEyOpZ1BJWEVc BYXg== 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 :dkim-signature; bh=YKXha9AwVk1l6bou1cz0KwpLEu3HZJ+1ookiq6Wi5f4=; b=HieaD6N75pFGnniZ8xpPfkBh2vzfK4XQwaPTrxxaNKJkutq5NeEtdbL7OD8skn7t4z xmNU49dG1w6KNvS7rAJH+r4iCV/uPVwp/ddtvIRusIjU9+mTlLVZgpf/ltkUFLpnQNKj HrQdYh7AHmvA24ulYM3V6jh8b61cD50Z82tpLfInM/Tp3yY9LrKYu5rOr/jiWGVvlpcK iq3KK82EKPJg3fP7YOUA2RzjdjqblmKXg4ldTMNIJFJH8xh20y+wXQ1k+hoCCb+XlAUf scZMnEacuaIE6fBF4/apNct8abMvXVT3dkE9aMlparymDWfWyKb023MwivHQQQ4vj6eI DsMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nB8wot62; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t30si849578pgk.19.2019.07.18.21.39.29; Thu, 18 Jul 2019 21:39:45 -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=nB8wot62; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388770AbfGSEhY (ORCPT + 99 others); Fri, 19 Jul 2019 00:37:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:59912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbfGSEAC (ORCPT ); Fri, 19 Jul 2019 00:00:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E248021852; Fri, 19 Jul 2019 04:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508802; bh=pt8XGc4ezTpV+Nyv9h7GEUXBaeOU/GLNHqOHSE746uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nB8wot62T1gqgkVyhwrQwJ5h4OcUkEQ7aI8NmApp6ndCvRVMYF3m9nW7RxNoL+AvY fS79PmvF8FT0b97Z/BCACBlansm9vxnuE0zvN8LsnZJgWHUpySJDvF2P8uTnXtfN7D +KMcHanaZPRuybkFb0AB+gX9u3Vc4PKcKC3aqFwg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gwendal Grignou , Lee Jones , Sasha Levin Subject: [PATCH AUTOSEL 5.2 097/171] mfd: cros_ec: Register cros_ec_lid_angle driver when presented Date: Thu, 18 Jul 2019 23:55:28 -0400 Message-Id: <20190719035643.14300-97-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gwendal Grignou [ 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