Received: by 10.223.185.116 with SMTP id b49csp5213764wrg; Wed, 7 Mar 2018 08:06:09 -0800 (PST) X-Google-Smtp-Source: AG47ELvZIRWeCAsPSsZPeMaxF7ePKGoBhaLG4B7oEoowJtiw+vEhojJFq+lG9yiV2/7ofHmakVtA X-Received: by 2002:a17:902:7c87:: with SMTP id y7-v6mr21314084pll.112.1520438769841; Wed, 07 Mar 2018 08:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520438769; cv=none; d=google.com; s=arc-20160816; b=DeQDQIpdLYuJk6en22w7gYHcxpBQOUGj2yr/a1hTTbJH4Njt1iQoLeO58SxsGOW+4A gv0gBNsAVNGm17iajpBb/lnt0ZjYI70MuY4rL79yNfarIPqxAttHStTgyF2de1e0FOPH fOIzZrRI5N90Jybm3xoZIZjHV0BlK7y5oNR6p0V9xe9/M60YDcTx3NQlwY9vyiBtNW70 dJYHoLc1JtCRUvedvMMaXCeJ7GO+L0eHcv/L9nNqE6kVtF+K3FvAJUm7fMPVZwF5RcBH DkN6siEK990voRh//TmFkQ2BZGaOEhxsDmPPby5rurjGX549m67OagQGY7IZ2vNB0x3c pvHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=VRdkmj0ir0XPbaeRqCfYBi88R84+U+qbrx0baX/SHrg=; b=wEFhjlEulshpZYFet958+upCVpEdLJuidlSkIE17vgfFQZj68BPL90Rd01dROVt6zO zkK1h1DiyM/9pKjiyFKdKUc3lLQOm+2ARnR8pnfCXZ8ykU6ZVJJuYkPDAupPGM4C4M8e YoC4bcAm3pXTkbUFWqhfJd6Rt8/RxEHL020D4p5GA+ZZ/rcfP+hAIKMKCzaYfS93RdLI Q434kUAiqMKi0UvGepjn+10GJFsyOxsPa1wglM/XoKIcXduuvWcsl0QqiEJzE4NwQrh2 N0avt4kV/YmwVJ7P5pzv4uPfkCmW9lywcy2FybHp3RIDr/SzgLKdZMaq3FMDhBD73zQD u0lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f9MdT2+8; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5-v6si13010166plo.664.2018.03.07.08.05.55; Wed, 07 Mar 2018 08:06:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b=f9MdT2+8; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933870AbeCGQEh (ORCPT + 99 others); Wed, 7 Mar 2018 11:04:37 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35072 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933655AbeCGQEe (ORCPT ); Wed, 7 Mar 2018 11:04:34 -0500 Received: by mail-wm0-f68.google.com with SMTP id x7so5706806wmc.0 for ; Wed, 07 Mar 2018 08:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=VRdkmj0ir0XPbaeRqCfYBi88R84+U+qbrx0baX/SHrg=; b=f9MdT2+8Owo8/B8CUCrqqCE54xWnmwwfn8yXmSy+5zET9qI+jaSJrIylv6a6VUMWfn V+gEdAVmdA2WOFxf+lSx1lzgJ1BkRH5aKuJRMNHFVpqIiZtDce6ST4SPyL5MCL7fPzwZ GomlTAAV7Z5OYEkEFeQ99ZTPnr0jr//juCB58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=VRdkmj0ir0XPbaeRqCfYBi88R84+U+qbrx0baX/SHrg=; b=MBuPRPIAML3VSP57XZd01ccagfRDPUcj/uWHJ9KbDJuqOVGzcMmKkfzA2LzWLmz3ei 4nxL0Vr+2B38wNwAwUL8/mXcMFqzA19ryosGXar12pJSnaMuiaYBIQyCBdOSLaiVhjvw bmXL8SHg6QAQAvKeYXA388hN6uwVLvsu+HjCR70NlDHsIciw2tqG1xm1MpPMtyyNzgEN kgRf1lTvWSneMvFvfkd+xVLVPTtuYZVxO9Ia30G7fdAKSP8KX1q2U4apaaoZRVEMjOmF eexcckkf4EAudgUjCJyyc6UknlhDrO8XwKlgJXSYDUL2MFTkngmadrXr+fwjklV3VanS BfvQ== X-Gm-Message-State: AElRT7ERra7mBi+XQS0/YVgVh5xthMAw5IdeiX1THC6b3ED/FRvPYISL VFaG3r9hJkDTJbhT2Fzyegz05mdP1fY= X-Received: by 10.28.72.10 with SMTP id v10mr1743125wma.77.1520438672927; Wed, 07 Mar 2018 08:04:32 -0800 (PST) Received: from dell ([2.27.35.218]) by smtp.gmail.com with ESMTPSA id f127sm10136186wmg.46.2018.03.07.08.04.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Mar 2018 08:04:31 -0800 (PST) Date: Wed, 7 Mar 2018 16:04:30 +0000 From: Lee Jones To: Enric Balletbo i Serra Cc: groeck@chromium.org, andy.shevchenko@gmail.com, kernel@collabora.com, gwendal@chromium.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/8] mfd: cros_ec_dev: Register cros_ec_accel_legacy driver as a subdevice. Message-ID: <20180307160430.yjkhlhyenpzk37pr@dell> References: <20180226102606.15093-1-enric.balletbo@collabora.com> <20180226102606.15093-6-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180226102606.15093-6-enric.balletbo@collabora.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Feb 2018, Enric Balletbo i Serra wrote: > With this patch, the cros_ec_ctl driver will register the legacy > accelerometer driver (named cros_ec_accel_legacy) if it fails to > register sensors through the usual path cros_ec_sensors_register(). > This legacy device is present on Chromebook devices with older EC > firmware only supporting deprecated EC commands (Glimmer based devices). > > Tested-by: Gwendal Grignou > Signed-off-by: Enric Balletbo i Serra > Reviewed-by: Gwendal Grignou > Reviewed-by: Andy Shevchenko > --- > > Changes in v3: > - [5/8] Add the Reviewed-by Andy Shevchenko. > > Changes in v2: > - [5/8] Add the Reviewed-by Gwendal. > > drivers/mfd/cros_ec_dev.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 33fe1b439ee2..fd7f0068fb45 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -389,6 +389,63 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) > kfree(msg); > } > > +#define CROS_EC_SENSOR_LEGACY_NUM 2 > +static struct mfd_cell cros_ec_accel_legacy_cells[CROS_EC_SENSOR_LEGACY_NUM]; > + > +static void cros_ec_accel_legacy_register(struct cros_ec_dev *ec) > +{ > + struct cros_ec_device *ec_dev = ec->ec_dev; > + u8 status; > + int i, ret; > + struct cros_ec_sensor_platform > + sensor_platforms[CROS_EC_SENSOR_LEGACY_NUM]; I wish I had seen this struct before. Yuk! Why do you even need to know what 'number' the sensor is? > + /* > + * EC that need legacy support are the main EC, directly connected to Nit: "ECs" or "needs". If you choose "needs" you need to s/are/is/ as well. > + * the AP. > + */ > + if (ec->cmd_offset != 0) > + return; > + > + /* > + * Check if EC supports direct memory reads and if EC has > + * accelerometers. > + */ > + if (!ec_dev->cmd_readmem) > + return; > + > + ret = ec_dev->cmd_readmem(ec_dev, EC_MEMMAP_ACC_STATUS, 1, &status); > + if (ret < 0) { Is ret > 0 valid? > + dev_warn(ec->dev, "EC does not support direct reads.\n"); > + return; > + } > + > + /* Check if EC has accelerometers. */ > + if (!(status & EC_MEMMAP_ACC_STATUS_PRESENCE_BIT)) { > + dev_info(ec->dev, "EC does not have accelerometers.\n"); > + return; > + } > + > + /* > + * Register 2 accelerometers > + */ > + for (i = 0; i < CROS_EC_SENSOR_LEGACY_NUM; i++) { > + cros_ec_accel_legacy_cells[i].name = "cros-ec-accel-legacy"; > + sensor_platforms[i].sensor_num = i; > + cros_ec_accel_legacy_cells[i].id = i; > + cros_ec_accel_legacy_cells[i].platform_data = > + &sensor_platforms[i]; > + cros_ec_accel_legacy_cells[i].pdata_size = > + sizeof(struct cros_ec_sensor_platform); There is no dynamic information here. I'd rather you did this all statically. > + } > + ret = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO, > + cros_ec_accel_legacy_cells, > + CROS_EC_SENSOR_LEGACY_NUM, ARRAY_SIZE() is less fragile. > + NULL, 0, NULL); > + if (ret) > + dev_err(ec_dev->dev, "failed to add EC sensors\n"); > +} > + > static const struct mfd_cell cros_ec_rtc_cell = { > .name = "cros-ec-rtc", > }; > @@ -440,6 +497,9 @@ static int ec_device_probe(struct platform_device *pdev) > /* check whether this EC is a sensor hub. */ > if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE)) > cros_ec_sensors_register(ec); > + else > + /* Workaroud for older EC firmware */ > + cros_ec_accel_legacy_register(ec); > > /* check whether this EC instance has RTC host command support */ > if (cros_ec_check_features(ec, EC_FEATURE_RTC)) { -- Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog