Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6405256rwb; Mon, 14 Nov 2022 20:16:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5tp7AFywfZAQ8JTB6CasYsKPFMYF92JFHfZM2VufC5Bd48kwS5JGfUqVLmxeNR8ugVDbAi X-Received: by 2002:aa7:8a41:0:b0:561:70b3:6a6 with SMTP id n1-20020aa78a41000000b0056170b306a6mr16675044pfa.25.1668485774525; Mon, 14 Nov 2022 20:16:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668485774; cv=none; d=google.com; s=arc-20160816; b=idYsidKA1e2vN7iRatv1KCptSt3Gh22tg6pThjJm16TaMeA67VA17V0k4ol5p5pM7o +oyzaaRXItcVGg24KCiH20xxOD65qc2+bVcViXinu8JvuB59Ndx6s1pUYkJR/2K58qCq s0mOq/MP0VJ2Wn2CazVakvjxgcuzXzvdIn/fCkSSCqXXtwXEhdYJpTWlwMi60lpENSC3 BCb/xVc/UB4p6RSgZ/D39YOVfNT+tUXufWtk0mwIgQbw8QBs1OlboqTj2KcPC4rrcAFL 1k4EU0jStxFWJ9EK0lKsRj4IqFeb5UWipFD+dA8Xwpnz62ZZFToXooaIlqf3LbyKkZsG HfXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IElvyJJPBw9r+gdipVqwpElhrsenjulEC/tqTO1F0KQ=; b=XO2Z1YzBBCcOdsWWyPtk8p3Yc4kTL5JVAIrBLn13xLxM7IS8F5stKNrub+oFYpH59K 0CmGM2Gfu/AqUXPTjW7Y4ie9/CnG7NUOzozliGgAYQnpD/tEYl33pSnmzfJT9CptfTA2 Not7Xln1cC+Xw8cnH9XAcrePDTcS1PA3DarPENOI/JnZ4GZUm3n3m0eOCUedbuHaBNoC M4OBiyiKMdoixbiuGW1ZboHvX5hJ5KQ/qYGmyYUcIcxO97y6jvvKtMhOisHI1nTd4qs+ sKQ4plkPBqzoLqu1k2YUyYJF5D2k4HNgn2gjt7N77Tg1+dZYPMTZlq6DxrQ5QavJnT6r n63A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c5fllgJI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a056a00114a00b0056ba5d8de2fsi12163433pfm.82.2022.11.14.20.16.03; Mon, 14 Nov 2022 20:16:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c5fllgJI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiKOEKp (ORCPT + 89 others); Mon, 14 Nov 2022 23:10:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbiKOEKm (ORCPT ); Mon, 14 Nov 2022 23:10:42 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97134F5AE for ; Mon, 14 Nov 2022 20:10:41 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id g12so21942306wrs.10 for ; Mon, 14 Nov 2022 20:10:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IElvyJJPBw9r+gdipVqwpElhrsenjulEC/tqTO1F0KQ=; b=c5fllgJIvec+jdDG6e5FKyzgRx3R5vhaKAj3ul8IPRhxKBKvIhadw7hIl2ygO5EVIf vkr2jthATA04vEQnY1Lz1OH51YXuvbkNN6nMUVTbFKdr/tebsWAdGov4Vrn15JeLtJVw w+YOv1pz24pxLKlM6e6jPa6e95H+O6C+OLoYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IElvyJJPBw9r+gdipVqwpElhrsenjulEC/tqTO1F0KQ=; b=pFEsUskUcZOvwcKtjes6jd+ge1a6wttm6A74VASOiKHt+a0tznxlsQAJQDERlHC6SS kpJw9odhce8jx8HsXt1Gm7hhslOVC0rAVpPJL74P1KkRbh1RQ8cFCs1XeSuJHTP1E1Fy WAKLaxzbesOpaYTE/CgfkRXDWAI66wXcAe8bIUZ1UNa7dE9iPb2h5Ts6xyqp5epi8DCp qaf15GLVnDyRutc+HLq4wXK2a+61JiN/NcIiAiN5QxF6geP0WhbeFJ4qFMnYcBcaEIfA +i8y7PtxWSMFPPRrA78dAbEYA3uUpPMEOAJR+qcrwoe/EVO+pPwF1IncdrjqghhuQKy4 dsRg== X-Gm-Message-State: ANoB5plZCJX2V1mHHeoPYQua1FVLrcc4UkebUmsMkDmt6tC8JzOawyMu 7is/vpM3R1W/dKzM3g/18075htBLryaNERj5n2fKEg== X-Received: by 2002:adf:f009:0:b0:236:657e:757e with SMTP id j9-20020adff009000000b00236657e757emr9444021wro.350.1668485440108; Mon, 14 Nov 2022 20:10:40 -0800 (PST) MIME-Version: 1.0 References: <20210804213139.4139492-1-gwendal@chromium.org> <20210804213139.4139492-2-gwendal@chromium.org> In-Reply-To: <20210804213139.4139492-2-gwendal@chromium.org> From: Gwendal Grignou Date: Mon, 14 Nov 2022 20:10:29 -0800 Message-ID: Subject: Re: [PATCH v3 1/1] platform/chrome: Poke kb_wake_angle attribute visibility when needed To: dtor@chromium.org, jwerner@chromium.org, bleung@chromium.org, enric.balletbo@collabora.com, groeck@chromium.org Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is still needed to get the attribute to be present on most machines. Putting the attribute in the sensor hub device is more complicated, as that device is not as easily findable as `cros_ec`, present in `/sys/class`. Gwendal. On Wed, Aug 4, 2021 at 2:31 PM Gwendal Grignou wrote: > > When the sensorhub detects 2 accelerometers, kb_wake_angle attribute > in the chromeos EC class device needs to be visible. > When detected, the sensorhub requests the class device to > revisit the visibility of the kb_wake_angle attribute. > Expose the attribute group to alter to close a potiential race between > cros-ec-sensorhub and cros-ec-sysfs (that creates the attribute group > on behalf of the class driver). > > Signed-off-by: Gwendal Grignou > --- > drivers/platform/chrome/cros_ec_sensorhub.c | 6 +++++- > drivers/platform/chrome/cros_ec_sysfs.c | 5 +++-- > include/linux/platform_data/cros_ec_proto.h | 2 ++ > 3 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c > index 9c4af76a9956e..8f24ed90b229c 100644 > --- a/drivers/platform/chrome/cros_ec_sensorhub.c > +++ b/drivers/platform/chrome/cros_ec_sensorhub.c > @@ -106,8 +106,12 @@ static int cros_ec_sensorhub_register(struct device *dev, > sensor_type[sensorhub->resp->info.type]++; > } > > - if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) > + if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) { > ec->has_kb_wake_angle = true; > + if (ec->group && sysfs_update_group(&ec->class_dev.kobj, > + ec->group)) > + dev_warn(dev, "Unable to update cros-ec-sysfs"); > + } > > if (cros_ec_check_features(ec, > EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) { > diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c > index f07eabcf9494c..17fe657f3ffd5 100644 > --- a/drivers/platform/chrome/cros_ec_sysfs.c > +++ b/drivers/platform/chrome/cros_ec_sysfs.c > @@ -341,7 +341,8 @@ static int cros_ec_sysfs_probe(struct platform_device *pd) > struct device *dev = &pd->dev; > int ret; > > - ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); > + ec_dev->group = &cros_ec_attr_group; > + ret = sysfs_create_group(&ec_dev->class_dev.kobj, ec_dev->group); > if (ret < 0) > dev_err(dev, "failed to create attributes. err=%d\n", ret); > > @@ -352,7 +353,7 @@ static int cros_ec_sysfs_remove(struct platform_device *pd) > { > struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); > > - sysfs_remove_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); > + sysfs_remove_group(&ec_dev->class_dev.kobj, ec_dev->group); > > return 0; > } > diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h > index 02599687770c5..c6dca260bbd5d 100644 > --- a/include/linux/platform_data/cros_ec_proto.h > +++ b/include/linux/platform_data/cros_ec_proto.h > @@ -191,6 +191,7 @@ struct cros_ec_platform { > /** > * struct cros_ec_dev - ChromeOS EC device entry point. > * @class_dev: Device structure used in sysfs. > + * @groups: sysfs attributes groups for this EC. > * @ec_dev: cros_ec_device structure to talk to the physical device. > * @dev: Pointer to the platform device. > * @debug_info: cros_ec_debugfs structure for debugging information. > @@ -200,6 +201,7 @@ struct cros_ec_platform { > */ > struct cros_ec_dev { > struct device class_dev; > + const struct attribute_group *group; > struct cros_ec_device *ec_dev; > struct device *dev; > struct cros_ec_debugfs *debug_info; > -- > 2.32.0.554.ge1b32706d8-goog >