introduce ALS sysfs class
PATCH v6 1/2 introduce ALS sysfs class
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read Documentation/ABI/testing/sysfs-class-als for detailed sysfs designs.
CC: Pavel Machek <[email protected]>
--- Documentation/ABI/testing/sysfs-class-als | 23 +++ MAINTAINERS | 6 drivers/Kconfig | 2 drivers/Makefile | 1 drivers/als/Kconfig | 10 + drivers/als/Makefile | 5 drivers/als/als_sys.c | 200 ++++++++++++++++++++++++++++++ include/linux/als_sys.h | 51 +++++++ 8 files changed, 298 insertions(+)
drivers/Kconfig +2 -0
@@ -62,6 +62,8 @@ source "drivers/power/Kconfig" source "drivers/hwmon/Kconfig" +source "drivers/als/Kconfig" + source "drivers/thermal/Kconfig" source "drivers/watchdog/Kconfig"
drivers/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_PPS) += pps/ obj-$(CONFIG_W1) += w1/ obj-$(CONFIG_POWER_SUPPLY) += power/ obj-$(CONFIG_HWMON) += hwmon/ +obj-$(CONFIG_ALS) += als/ obj-$(CONFIG_THERMAL) += thermal/ obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_PHONE) += telephony/
drivers/als/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +# +# Ambient Light Sensor sysfs device configuration +# + +menuconfig ALS + tristate "Ambient Light Sensor sysfs device" + help + This framework provides a generic sysfs interface for + Ambient Light Sensor devices. + If you want this support, you should say Y or M here.
drivers/als/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for Ambient Light Sensor device drivers. +# + +obj-$(CONFIG_ALS) += als_sys.o
drivers/als/als_sys.c new file +200 -0
200 lines not on this page · raw message
include/linux/als_sys.h new file +51 -0
51 lines not on this page · raw message
Documentation/ABI/testing/sysfs-class-als new file +23 -0
@@ -0,0 +1,23 @@ +What: /sys/class/als/.../illuminance +Date: Aug. 2009 +KernelVersion: 2.6.32 +Contact: Zhang Rui <[email protected]> +Description: Current Ambient Light Illuminance reported by + native ALS driver + Unit: lux (lumens per square meter) + RO + +What: /sys/class/als/.../display_adjustment +Date: Aug. 2009 +KernelVersion: 2.6.32 +Contact: Zhang Rui <[email protected]> +Description: a relative percentages in order to simplify the means + by which these adjustments are applied in lieu of + changes to the user’s display brightness preference. + A value of 100% is used to indicate no display + brightness adjustment. + Values less than 100% indicate a negative adjustment + (dimming); values greater than 100% indicate a positive + adjustment (brightening). + RO +
MAINTAINERS +6 -0
@@ -399,6 +399,12 @@ S: Maintained for 2.4; PCI support for 2 L: [email protected] F: arch/alpha/ +AMBIENT LIGHT SENSOR +M: Zhang Rui <[email protected]> +S: Supported +F: include/linux/als_sys.h +F: drivers/als/ + AMD GEODE CS5536 USB DEVICE CONTROLLER DRIVER M: Thomas Dahlmann <[email protected]> L: [email protected] (moderated for non-subscribers)
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi!
Quoted 7 lines
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.
Thanks for fixing the interface!
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+static ssize_t +illuminance_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result;
drivers/als/als_sys.c line 59
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+ +if (!illuminance) +return sprintf (buf,"Illuminance below the supported range\n" ); +else if (illuminance ==-1 ) +return sprintf (buf,"Illuminance above the supported range\n" ); +else if (illuminance <-1 ) +return -ERANGE ; +else +return sprintf (buf,"%d\n" , illuminance); +}
that's nor particulary clean. One value per file and all that. Could we simply return errnos in _all_ the error cases? (Docs would suggest this contains integer so string is definitely unexpected).
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+static ssize_t +adjustment_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance, adjustment; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result;
drivers/als/als_sys.c line 80
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+ +if (illuminance <0 && illuminance !=-1 ) +return sprintf (buf,"Current illuminance invalid\n" ); + + result =als_get_adjustment (als, illuminance, &adjustment); +if (result) +return result; + +return sprintf (buf,"%d%%\n" , adjustment); +}
You should not return strings... and in this case it is not clear how the code works. You fill the buf, but then return...? Better stick to integers.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 28 lines · Pavel Machek
Hi!
Quoted 7 lines
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.Thanks for fixing the interface!
Quoted 16 lines
drivers/als/als_sys.c new file +16
-0+static ssize_t +illuminance_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result; + +if (!illuminance) +return sprintf (buf,"Illuminance below the supported range\n" ); +else if (illuminance ==-1 ) +return sprintf (buf,"Illuminance above the supported range\n" ); +else if (illuminance <-1 )
Quoted 9 lines
drivers/als/als_sys.c line 59
Quoted 4 lines
drivers/als/als_sys.c new file +4
-0+return -ERANGE ; + else + return sprintf(buf, "%d\n", illuminance); +}that's nor particulary clean. One value per file and all that. Could we simply return errnos in _all_ the error cases? (Docs would suggest this contains integer so string is definitely unexpected).
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?
Quoted 16 lines
Quoted 16 lines
drivers/als/als_sys.c new file +15
-0+static ssize_t +adjustment_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance, adjustment; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result; + +if (illuminance <0 && illuminance !=-1 ) +return sprintf (buf,"Current illuminance invalid\n" ); + + result =als_get_adjustment (als, illuminance, &adjustment);
Quoted 8 lines
drivers/als/als_sys.c line 80
Quoted 5 lines
drivers/als/als_sys.c new file +5
-0+if (result) +return result; + +return sprintf (buf,"%d%%\n" , adjustment); +}You should not return strings... and in this case it is not clear how the code works. You fill the buf, but then return...?
As the adjustment is a percentage value, I added a '%' postfix so that users won't be confused.
yes, it's okay to just export the integer, e.g. "100" instead of "100%".
thanks,
rui
Quoted 38 lines · Zhang Rui
Quoted 28 lines · Pavel Machek
Hi!
Quoted 7 lines
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.Thanks for fixing the interface!
Quoted 16 lines
drivers/als/als_sys.c new file +16
-0+static ssize_t +illuminance_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result; + +if (!illuminance) +return sprintf (buf,"Illuminance below the supported range\n" ); +else if (illuminance ==-1 ) +return sprintf (buf,"Illuminance above the supported range\n" ); +else if (illuminance <-1 )Quoted 9 lines
drivers/als/als_sys.c line 59
Quoted 4 lines
drivers/als/als_sys.c new file +4
-0+return -ERANGE ; + else + return sprintf(buf, "%d\n", illuminance); +}that's nor particulary clean. One value per file and all that. Could we simply return errnos in _all_ the error cases? (Docs would suggest this contains integer so string is definitely unexpected).
Quoted 4 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
drivers/als/als_sys.c new file +15
-0+static ssize_t +adjustment_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance, adjustment; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result; + +if (illuminance <0 && illuminance !=-1 ) +return sprintf (buf,"Current illuminance invalid\n" ); + + result =als_get_adjustment (als, illuminance, &adjustment);Quoted 8 lines
drivers/als/als_sys.c line 80
Quoted 5 lines
drivers/als/als_sys.c new file +5
-0+if (result) +return result; + +return sprintf (buf,"%d%%\n" , adjustment); +}You should not return strings... and in this case it is not clear how the code works. You fill the buf, but then return...?
Quoted 3 lines
As the adjustment is a percentage value, I added a '%' postfix so that users won't be confused.
yes, it's okay to just export the integer, e.g. "100" instead of "100%".
The "%" postfix is okay, but returning "Current illuminance invalid" is ugly. Better return -EINVAL or -EIO or something.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 39 lines · Pavel Machek
Quoted 38 lines · Zhang Rui
Quoted 37 lines · Pavel Machek
Hi!
Quoted 7 lines
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.Thanks for fixing the interface!
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+static ssize_t +illuminance_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct als_device *als =to_als_device (dev); +int illuminance; +int result; + + result = als->ops->get_illuminance (als, &illuminance); +if (result) +return result;drivers/als/als_sys.c line 59
Quoted 10 lines
drivers/als/als_sys.c new file +10
-0+ +if (!illuminance) +return sprintf (buf,"Illuminance below the supported range\n" ); +else if (illuminance ==-1 ) +return sprintf (buf,"Illuminance above the supported range\n" ); +else if (illuminance <-1 ) +return -ERANGE ; +else +return sprintf (buf,"%d\n" , illuminance); +}that's nor particulary clean. One value per file and all that. Could we simply return errnos in _all_ the error cases? (Docs would suggest this contains integer so string is definitely unexpected).
Quoted 7 lines
Quoted 4 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Best,
Rafael
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?
Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 9 lines · Pavel Machek
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Quoted 6 lines
Quoted 3 lines
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
Rafael
Quoted 12 lines · Rafael J. Wysocki
Quoted 11 lines · Pavel Machek
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Thanks,
Rafael
Quoted 29 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
Quoted 7 lines
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 34 lines · Pavel Machek
Quoted 33 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Quoted 7 lines
Quoted 3 lines
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether or not to pass the values defined by the interface directly to the user space, which I think is the right thing to do, because we have no reason _whatsoever_ to change them to anything else.
Thanks,
Rafael
Quoted 39 lines · Rafael J. Wysocki
Quoted 38 lines · Pavel Machek
Quoted 36 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Quoted 9 lines
Quoted 3 lines
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether or not to pass the values defined by the interface directly to the user space, which I think is the right thing to do, because we have no reason _whatsoever_ to change them to anything else.
I agree.
For environment illuminance, "-1" is surely an invalid value. IMO, users would rather look for what it actually means than interpret it to a value lower than 0.
thanks,
rui
Quoted 49 lines · Zhang Rui
Quoted 39 lines · Rafael J. Wysocki
Quoted 38 lines · Pavel Machek
Quoted 36 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Quoted 9 lines
Quoted 3 lines
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether or not to pass the values defined by the interface directly to the user space, which I think is the right thing to do, because we have no reason _whatsoever_ to change them to anything else.
Quoted 4 lines
I agree.
For environment illuminance, "-1" is surely an invalid value. IMO, users would rather look for what it actually means than interpret it to a value lower than 0.
Yes, you'd have to look that up. With 1000000000 for overflow, you would not have to do any lookups...
(Plus, if you use -1 for overflow... you need 0 for underflow, but 0 lumen is pretty valid value. Actually I'm thinking if this should maybe not on the log scale or something).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 55 lines · Pavel Machek
Quoted 49 lines · Zhang Rui
Quoted 39 lines · Rafael J. Wysocki
Quoted 38 lines · Pavel Machek
Quoted 36 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Quoted 9 lines
Quoted 3 lines
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether or not to pass the values defined by the interface directly to the user space, which I think is the right thing to do, because we have no reason _whatsoever_ to change them to anything else.
Quoted 4 lines
I agree.
For environment illuminance, "-1" is surely an invalid value. IMO, users would rather look for what it actually means than interpret it to a value lower than 0.
Quoted 6 lines
Yes, you'd have to look that up. With 1000000000 for overflow, you would not have to do any lookups...
(Plus, if you use -1 for overflow... you need 0 for underflow, but 0 lumen is pretty valid value. Actually I'm thinking if this should maybe not on the log scale or something).
Let's make the "-1 corresponds to all ones" rule and stop losing time for discussing that any more. I don't think it's worth it. :-)
Thanks,
Rafael
Quoted 39 lines · Rafael J. Wysocki
Quoted 38 lines · Pavel Machek
Quoted 36 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Quoted 6 lines
Quoted 3 lines
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether
No, I don't think it is "already defined". Yes the patches float around, but as nothing is merged we can still fix it easily.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 40 lines · Pavel Machek
Quoted 39 lines · Rafael J. Wysocki
Quoted 38 lines · Pavel Machek
Quoted 36 lines · Rafael J. Wysocki
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
IMO, 0 and -1 are not errors. they just suggest that the Ambient Light illuminance is beyond the device support range, while the device is still working normally.
what about exporting these values (0 and -1) to user space directly?Quoted 6 lines
Quoted 2 lines
Returning 0 for "below" range and 99999999 for "above" range would be nice, yes.
Why not 0 and "all ones" or 0 and -1.
Is there anything wrong with -1 in particular?
Normal people expect -1 to be less than 123, and output is in ascii. If you make it ((unsigned) ~0) I guess that becomes acceptable.
Quoted 6 lines
Quoted 3 lines
Well, "-1" is a perfectly valid alphanumerical representation of an int. I don't really see the problem with the "-", unless we're talking about some broken user space, that is.
No. But if you see illumination value of -1 lumen, do you really expect a *lot* of light?
Not really. I'd rather intrepret it as "the number is not to be trusted", which is what it means.
The problem with "all ones" is that it depends on the size of the underlying data type, which is not nice. Also, if you want that to be a "big number", there's no clear rule to tell what the number should actually be.
Anyway, this really is a matter of definition. If we document the attribute to read as "-1" in specific circumstances, the user space will have to take that into account.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Well, I'd prefer to specify -1 as "underflow" and 1000000000 as "overflow". Any numbers should work, but ... lets make the interface logical if we can.
The interface is already defined, isn't it? And we're now considering whether
No, I don't think it is "already defined".
ACPI Specification 4.0, Section 9.2.2, p. 335, defines the interface quite clearly. It actually is defined as "Ones (-1)", but as I said previously, the "all ones" version is not really convenient for sysfs.
I don't think the attribute should return anything other than the values defined by the spec, because anyone searching for documentation will first look into the spec.
As I said before, I don't think we have any reason _whatsoever_ to translate the spec-defined values to anything else.
Thanks,
Rafael
Quoted 16 lines · Zhang Rui
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.CC: Pavel Machek <[email protected]>
Signed-off-by Zhang Rui <[email protected]>---
+++ linux-2.6/drivers/als/Kconfig
drivers/als/Kconfig line 10
Quoted 10 lines
drivers/als/Kconfig new file +10
-0@@ -0,0 +1,10 @@ +# +# Ambient Light Sensor sysfs device configuration +# + +menuconfig ALS + tristate "Ambient Light Sensor sysfs device" + help + This framework provides a generic sysfs interface for + Ambient Light Sensor devices. + If you want this support, you should say Y or M here.
Gratuitous nitpick:
Can this option be made non-visible (or hidden behind CONFIG_EMBEDDED)?
Maybe you copied the pattern of the thermal sysfs interface - but the ACPI thermal driver is useful to keep your computer cool even without the sysfs interface. ALS drivers are useless without the sysfs interface, no?
Regards
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 31 lines · Alan Jenkins
Quoted 16 lines · Zhang Rui
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.CC: Pavel Machek <[email protected]>
Signed-off-by Zhang Rui <[email protected]>---
+++ linux-2.6/drivers/als/Kconfig
drivers/als/Kconfig line 10
Quoted 10 lines
drivers/als/Kconfig new file +10
-0@@ -0,0 +1,10 @@ +# +# Ambient Light Sensor sysfs device configuration +# + +menuconfig ALS + tristate "Ambient Light Sensor sysfs device" + help + This framework provides a generic sysfs interface for + Ambient Light Sensor devices. + If you want this support, you should say Y or M here.Gratuitous nitpick:
Can this option be made non-visible (or hidden behindCONFIG_EMBEDDED)?
Quoted 5 lines
Maybe you copied the pattern of the thermal sysfs interface - but the ACPI thermal driver is useful to keep your computer cool even without the sysfs interface. ALS drivers are useless without the sysfs interface, no?
ACPI ALS device driver is the first user of this sysfs class. I think there will be more native ALS device drivers in the future, which locate at drivers/als/ and depends on CONFIG_ALS.
thanks,
rui
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 37 lines · Zhang Rui
Quoted 31 lines · Alan Jenkins
Quoted 16 lines · Zhang Rui
Introduce ALS sysfs class.
ALS sysfs class provides a standard sysfs interface for Ambient Light Sensor devices.
please read
Documentation/ABI/testing/sysfs-class-alsfor detailed sysfs designs.CC: Pavel Machek <[email protected]>
Signed-off-by Zhang Rui <[email protected]>---
+++ linux-2.6/drivers/als/Kconfig
drivers/als/Kconfig line 10
Quoted 10 lines
drivers/als/Kconfig new file +10
-0@@ -0,0 +1,10 @@ +# +# Ambient Light Sensor sysfs device configuration +# + +menuconfig ALS + tristate "Ambient Light Sensor sysfs device" + help + This framework provides a generic sysfs interface for + Ambient Light Sensor devices. + If you want this support, you should say Y or M here.Gratuitous nitpick:
Can this option be made non-visible (or hidden behindCONFIG_EMBEDDED)?Quoted 5 lines
Maybe you copied the pattern of the thermal sysfs interface - but the ACPI thermal driver is useful to keep your computer cool even without the sysfs interface. ALS drivers are useless without the sysfs interface, no?
Quoted 6 lines
ACPI ALS device driver is the first user of this sysfs class. I think there will be more native ALS device drivers in the future, which locate at
drivers/als/and depends onCONFIG_ALS.thanks,
rui
Oh! So it may become a menu like e.g. hwmon.
Thanks for the explanation
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html