Thread (11 messages) 11 messages, 5 authors, 2011-03-16

Re: [PATCH] Add a driver to support InvenSense mpu3050 gyroscope chip.

From: Alan Cox <hidden>
Date: 2011-03-14 18:25:10

It is a slim sysfs interface so for once I'm not going to moan  (much...)
I'd prefer something with actual units rather than adc
counts but can live with having this interface alongside something more
generalizable.
It's not even ADC counts - the mpu3050 has its own processing.

quoted
+/* Methods for the sysfs attributes */
+static ssize_t mpu3050_show_power_mode(struct device *dev,
+		struct device_attribute *att, char *buf)
+{
+	struct mpu3050_sensor *sensor = dev_get_drvdata(dev);
+	int is_suspended = mpu3050_get_power_mode(sensor->client);
!is_suspended is cleaner.
Agreed - fixed
quoted
+	return sprintf(buf, "%d\n", is_suspended ? 0 : 1);
+}
+
+static ssize_t mpu3050_store_power_mode(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct mpu3050_sensor *sensor = dev_get_drvdata(dev);
+
+	if (!count || !(buf[0] == '1' || buf[0] == '0'))
+		return count;
+
+	mutex_lock(&sensor->lock);
Could use the sysfs_streq function to deal with leading white space
and other fun.  Also do we need the trinary operator?
Or just use strict_strtoul like other methods - Done

quoted
+static int mpu3050_runtime_resume(struct device *dev)
+{
+	struct mpu3050_sensor *sensor = dev_get_drvdata(dev);
+	mpu3050_set_power_mode(sensor->client, 1);
+	msleep(100);  /* wait for gyro chip resume */
Could perhaps make the obvious connection between this and the non runtime
versions more explicit? Just a thought...
I'll have a think about that at some point. There are some further long
term tweaks and those are probably going to make the two diverge however.

I'll post either a new driver or patches for the other tidying up
depending upon whether Dmitry merges the current submission.

Alan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help