From patchwork Thu Aug 11 09:28:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ike Panhc X-Patchwork-Id: 109576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id BE590B6F8F for ; Thu, 11 Aug 2011 19:28:41 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QrRZ3-0007bC-81; Thu, 11 Aug 2011 09:28:33 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QrRZ1-0007au-Gk for kernel-team@lists.ubuntu.com; Thu, 11 Aug 2011 09:28:31 +0000 Received: from [210.242.151.101] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1QrRZ0-0008JF-TQ for kernel-team@lists.ubuntu.com; Thu, 11 Aug 2011 09:28:31 +0000 From: Ike Panhc To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4] (drop after 3.0) ideapad: let camera_power node invisiable if no camera Date: Thu, 11 Aug 2011 17:28:27 +0800 Message-Id: <1313054907-3540-1-git-send-email-ike.pan@canonical.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1313054850-3465-1-git-send-email-ike.pan@canonical.com> References: <1313054850-3465-1-git-send-email-ike.pan@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com Signed-off-by: Ike Panhc Signed-off-by: Matthew Garrett (cherry picked from mainline commit a84511f7fbeb37e26aacb9c72f5a21ffc24e909e) --- drivers/platform/x86/ideapad-laptop.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 42b9ba7..1612abd 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -38,6 +38,7 @@ #define CFG_BT_BIT (16) #define CFG_3G_BIT (17) #define CFG_WIFI_BIT (18) +#define CFG_CAMERA_BIT (19) struct ideapad_private { struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; @@ -208,7 +209,24 @@ static struct attribute *ideapad_attributes[] = { NULL }; +static mode_t ideapad_is_visible(struct kobject *kobj, + struct attribute *attr, + int idx) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct ideapad_private *priv = dev_get_drvdata(dev); + bool supported; + + if (attr == &dev_attr_camera_power.attr) + supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg)); + else + supported = true; + + return supported ? attr->mode : 0; +} + static struct attribute_group ideapad_attribute_group = { + .is_visible = ideapad_is_visible, .attrs = ideapad_attributes };