From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbcCIEh2 (ORCPT ); Tue, 8 Mar 2016 23:37:28 -0500 Received: from mail-io0-f180.google.com ([209.85.223.180]:33348 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbcCIEhV (ORCPT ); Tue, 8 Mar 2016 23:37:21 -0500 From: Clinton Sprain To: olof@lixom.net Cc: gwendal@chromium.org, linux-kernel@vger.kernel.org, Clinton Sprain Subject: [PATCH] platform/chrome: cros_ec_lightbar - use name instead of ID to hide lightbar attributes Date: Tue, 8 Mar 2016 22:36:24 -0600 Message-Id: <1457498184-4170-1-git-send-email-clintonsprain@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lightbar attributes are hidden if the ID of the device is not 0 (the assumption being that 0 = cros_ec = might have a lightbar, 1 = cros_pd = hide); however, sometimes these devices get IDs 1 and 2 (or something else) instead of IDs 0 and 1. This prevents the lightbar attributes from appearing when they should. Proposed change is to instead check whether the name assigned to the device is CROS_EC_DEV_NAME (true for cros_ec, false for cros_pd). Signed-off-by: Clinton Sprain --- drivers/platform/chrome/cros_ec_lightbar.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index ff76405..b6356b3 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -414,7 +414,12 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj, struct cros_ec_dev, class_dev); struct platform_device *pdev = container_of(ec->dev, struct platform_device, dev); - if (pdev->id != 0) + struct cros_ec_platform *pdata = pdev->dev.platform_data; + int is_cros_ec; + + is_cros_ec = strcmp(pdata->ec_name, CROS_EC_DEV_NAME); + + if (is_cros_ec != 0) return 0; /* Only instantiate this stuff if the EC has a lightbar */ -- 2.5.0