X86 platform drivers
 help / color / mirror / Atom feed
From: Ike Panhc <ike.pan@canonical.com>
To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org
Cc: Matthew Garrett <mjg@redhat.com>, corentin.chary@gmail.com
Subject: [PATCH 2/3] ideapad: let camera_power node invisiable if no camera
Date: Wed, 22 Jun 2011 16:06:37 +0800	[thread overview]
Message-ID: <1308729997-2658-1-git-send-email-ike.pan@canonical.com> (raw)
In-Reply-To: <1308729781-2590-1-git-send-email-ike.pan@canonical.com>

Signed-off-by: Ike Panhc <ike.pan@canonical.com>
---
 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 51d4144..678bbf7 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
 };
 
-- 
1.7.4.1

  parent reply	other threads:[~2011-06-22  8:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22  8:03 [PATCH 0/3 v2] ideapad: add backlight driver and changes of sysfs nodes Ike Panhc
2011-06-22  8:05 ` [PATCH 1/3] ideapad: define cfg bits and create sysfs node for cfg Ike Panhc
2011-06-22 19:35   ` Matthew Garrett
2011-06-30 10:59     ` Ike Panhc
2011-06-22  8:06 ` Ike Panhc [this message]
2011-06-22  8:07 ` [PATCH 3/3] ideapad: add backlight driver Ike Panhc
2011-06-22  9:20   ` Corentin Chary
2011-06-22 19:40   ` Matthew Garrett
2011-06-23  3:38     ` Ike Panhc
2011-06-23  5:52     ` Ike Panhc
  -- strict thread matches above, loose matches on Subject: below --
2011-06-30 11:49 [PATCH 0/3 v3] ideapad: add backlight driver and changes of sysfs nodes Ike Panhc
2011-06-30 11:50 ` [PATCH 2/3] ideapad: let camera_power node invisiable if no camera Ike Panhc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1308729997-2658-1-git-send-email-ike.pan@canonical.com \
    --to=ike.pan@canonical.com \
    --cc=corentin.chary@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox