* [PATCH] linux-2.6.32-directemp
@ 2010-02-05 4:47 Chris Verges
2010-02-05 15:45 ` Alan Stern
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Chris Verges @ 2010-02-05 4:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-usb, linux-kernel; +Cc: Rob Owings
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
Hi Linux gurus,
Attached is a patch for the QTI DirecTEMP USB thermometer &
thermometer/hygrometer sensors. This patch is based on linux-2.6.32.
Functionality has been verified against both hardware variants listed in
the driver (0x0002 and 0x0006), as both monolithic and modular.
When the QTI DirecTEMP sensor is connected to a system, the directemp
driver adds appropriate sysfs entries for the sensor type(s) supported.
Examples:
# PID 0x0002 (temp only)
/sys/bus/usb/devices/.../temp
# PID 0x0006 (temp + relative humidity)
/sys/bus/usb/devices/.../temp
/sys/bus/usb/devices/.../rh
Using a standard "cat" will display the value.
An additional "raw" sysfs entry has been added to aid in debugging. If
used, an "echo" will send the data specified in the string to the USB
device, and print back the results. It is not recommended for customer
use except by expert users.
And with that description out of the way, I look forward to your review
of the driver. Please provide any feedback that you may have.
Thanks in advance,
Chris
[-- Attachment #2: linux-2.6.32-directemp.patch --]
[-- Type: application/octet-stream, Size: 10139 bytes --]
Signed-off-by: Chris Verges <chrisv@cyberswitching.com>
Index: drivers/usb/misc/Kconfig
===================================================================
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -135,6 +135,16 @@
To compile this driver as a module, choose M here: the
module will be called cytherm.
+config USB_DIRECTEMP
+ tristate "QTI DirecTEMP USB thermometer/hygrometer driver support"
+ depends on USB
+ help
+ Say Y here if you want to connect a QTI DirecTEMP USB
+ thermometer/hygrometer device to your computer's USB port.
+
+ To compile this driver as a module, choose M here: the
+ module will be called directemp.
+
config USB_IDMOUSE
tristate "Siemens ID USB Mouse Fingerprint sensor support"
depends on USB
@@ -255,4 +265,3 @@
To compile this driver as a module, choose M here: the
module will be called vstusb.
-
Index: drivers/usb/misc/directemp.c
===================================================================
--- a/drivers/usb/misc/directemp.c
+++ b/drivers/usb/misc/directemp.c
@@ -0,0 +1,335 @@
+/*
+ * QTI DirecTEMP USB thermometer/hygrometer driver
+ *
+ * Copyright (c) 2010 Cyber Switching, Inc.
+ * Chris Verges <chrisv@cyberswitching.com>
+ *
+ * Copyright (c) 2010 Quality Thermistor, Inc.
+ *
+ * Using code from:
+ * - directemp.c
+ * Copyright (c) 2004 Erik Rigtorp <erkki@linux.nu> <erik@rigtorp.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ */
+
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#define QTI_VENDOR_ID (0x1DFD)
+
+#define DIRECTEMP_STREAM_DATA (0x31)
+#define DIRECTEMP_SINGLE_POINT (0x32)
+#define DIRECTEMP_INFO (0x33)
+#define DIRECTEMP_BOARD_VER (0x42)
+#define DIRECTEMP_HUMIDITY (0x48)
+#define DIRECTEMP_SERIAL_NUM (0x53)
+#define DIRECTEMP_TEMPERATURE (0x54)
+#define DIRECTEMP_FIRMWARE_REV (0x56)
+
+#define DIRECTEMP_MSG_SIZE (16)
+#define DIRECTEMP_TIMEOUT (1000)
+#define DIRECTEMP_MAX_RETRIES (3)
+
+struct usb_directemp {
+ struct usb_device *udev;
+ struct usb_interface *interface;
+ uint16_t pid;
+
+ uint8_t read_temp;
+};
+
+static int directemp_read(struct usb_device *dev, void *data, int len)
+{
+ int actual_len;
+ int err;
+
+ err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 1),
+ data, len, &actual_len, DIRECTEMP_TIMEOUT);
+ if (err)
+ return err;
+
+ return actual_len;
+}
+
+static int directemp_write(struct usb_device *dev, void *data, int len)
+{
+ int actual_len;
+ int err;
+
+ err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 2),
+ data, len, &actual_len, DIRECTEMP_TIMEOUT);
+ if (err)
+ return err;
+
+ return actual_len;
+}
+
+static ssize_t show_helper(struct device *dev,
+ struct device_attribute *attr,
+ char *tx, char *rx, int len)
+{
+ struct usb_interface *intf = to_usb_interface(dev);
+ struct usb_directemp *directemp = usb_get_intfdata(intf);
+ int err;
+
+ /* Send the command request */
+ dev_dbg(dev, "sending command\n");
+ err = directemp_write(directemp->udev, tx, DIRECTEMP_MSG_SIZE);
+ if (err < 0) {
+ dev_err(dev, "error %d during communication\n", err);
+ return err;
+ } else {
+ dev_dbg(dev, "transferred %d bytes\n", err);
+ }
+
+ /* Read the response */
+ memset(rx, 0, DIRECTEMP_MSG_SIZE * sizeof(char));
+ dev_dbg(dev, "reading response\n");
+ err = directemp_read(directemp->udev, rx, DIRECTEMP_MSG_SIZE);
+ if (err < 0) {
+ dev_err(dev, "error %d during communication\n", err);
+ return err;
+ } else {
+ dev_dbg(dev, "transferred %d bytes\n", err);
+ }
+
+ return err;
+}
+
+static ssize_t show_temp(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct usb_interface *intf = to_usb_interface(dev);
+ struct usb_directemp *directemp = usb_get_intfdata(intf);
+ char data[DIRECTEMP_MSG_SIZE + 1];
+ int err;
+ int i;
+
+ /* Read twice due to a buffer issue on the DirecTEMP */
+ for (i = 0; i < DIRECTEMP_MAX_RETRIES; i++) {
+ memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ data[0] = directemp->read_temp;
+ err = show_helper(dev, attr, data, data, DIRECTEMP_MSG_SIZE);
+ if (err < 0)
+ continue;
+ if (data[0] == directemp->read_temp)
+ break;
+ }
+
+ if (i >= DIRECTEMP_MAX_RETRIES) {
+ dev_err(dev, "exceeded maximum retry count\n");
+ return sprintf(buf, "--.- C\n");
+ }
+
+ /* Sanitize the output */
+ for (i = 1; i < DIRECTEMP_MSG_SIZE; i++)
+ if (!isdigit(data[i]) && data[i] != '.') {
+ data[i] = '\0';
+ break;
+ }
+
+ /* Convert for the user */
+ err = snprintf(buf, DIRECTEMP_MSG_SIZE, "%s C\n", &data[1]);
+ if (err < 0) {
+ dev_err(dev, "unable to convert received output");
+ err = 0;
+ }
+
+ return err;
+}
+
+static DEVICE_ATTR(temp, S_IRUGO, show_temp, NULL);
+
+static ssize_t show_rh(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ char data[DIRECTEMP_MSG_SIZE + 1];
+ int err;
+ int i;
+
+ /* Read twice due to a buffer issue on the DirecTEMP */
+ for (i = 0; i < DIRECTEMP_MAX_RETRIES; i++) {
+ memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ data[0] = DIRECTEMP_HUMIDITY;
+ err = show_helper(dev, attr, data, data, DIRECTEMP_MSG_SIZE);
+ if (err < 0)
+ continue;
+ if (data[0] == DIRECTEMP_HUMIDITY)
+ break;
+ }
+
+ if (i >= DIRECTEMP_MAX_RETRIES) {
+ dev_err(dev, "exceeded maximum retry count\n");
+ return sprintf(buf, "--.-%%\n");
+ }
+
+ /* Sanitize the output */
+ for (i = 1; i < DIRECTEMP_MSG_SIZE; i++)
+ if (!isdigit(data[i]) && data[i] != '.') {
+ data[i] = '\0';
+ break;
+ }
+
+ /* Convert for the user */
+ err = snprintf(buf, DIRECTEMP_MSG_SIZE, "%s%%\n", &data[1]);
+ if (err < 0) {
+ dev_err(dev, "unable to convert received output");
+ err = 0;
+ }
+
+ return err;
+}
+
+static DEVICE_ATTR(rh, S_IRUGO, show_rh, NULL);
+
+static ssize_t set_raw(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ char data[DIRECTEMP_MSG_SIZE + 1];
+ int err;
+ int i;
+
+ if (count > DIRECTEMP_MSG_SIZE)
+ count = DIRECTEMP_MSG_SIZE;
+
+ memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ memcpy(data, buf, count);
+
+ printk("Request:\n");
+ for (i = 0; i < DIRECTEMP_MSG_SIZE; i++)
+ printk(" [%02x] 0x%02X %2u %c\n", i,
+ data[i], data[i], data[i]);
+
+ err = show_helper(dev, attr, data, data, DIRECTEMP_MSG_SIZE);
+ if (err < 0)
+ return 0;
+
+ printk("Response:\n");
+ for (i = 0; i < DIRECTEMP_MSG_SIZE; i++)
+ printk(" [%02x] 0x%02X %2u %c\n", i,
+ data[i], data[i], data[i]);
+
+ return 0;
+}
+
+static DEVICE_ATTR(raw, S_IWUGO, NULL, set_raw);
+
+static int directemp_probe(struct usb_interface *interface,
+ const struct usb_device_id *id)
+{
+ struct usb_device *udev = interface_to_usbdev(interface);
+ struct usb_directemp *dev;
+ int err;
+
+ dev = kzalloc(sizeof(struct usb_directemp), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
+
+ dev->udev = usb_get_dev(udev);
+ usb_set_intfdata(interface, dev);
+ dev->pid = id->idProduct;
+
+ dev_dbg(&interface->dev, "Product: %s (ID 0x%04X)\n",
+ udev->product, dev->pid);
+ dev_dbg(&interface->dev, "Manufacturer: %s\n",
+ udev->manufacturer);
+ dev_dbg(&interface->dev, "Serial Number: %s\n",
+ udev->serial);
+
+ /* raw access to USB protocol via sysfs -- debugging only! */
+ err = device_create_file(&interface->dev, &dev_attr_raw);
+ if (err)
+ goto exit_free_sysfs;
+
+ /* sysfs temperature & humidity value */
+ err = device_create_file(&interface->dev, &dev_attr_temp);
+ if (err)
+ goto exit_free_sysfs;
+
+ switch (dev->pid) {
+ case 0x0002:
+ dev->read_temp = '2';
+ break;
+ case 0x0006:
+ dev->read_temp = 'T';
+ err = device_create_file(&interface->dev, &dev_attr_rh);
+ if (err)
+ goto exit_free_sysfs;
+ break;
+ }
+
+ dev_info(&interface->dev, "DirecTEMP USB now attached\n");
+ return 0;
+
+exit_free_sysfs:
+ dev_err(&interface->dev, "error while initializing driver\n");
+ device_remove_file(&interface->dev, &dev_attr_temp);
+ device_remove_file(&interface->dev, &dev_attr_rh);
+ usb_set_intfdata(interface, NULL);
+ usb_put_dev(dev->udev);
+ kfree(dev);
+ return err;
+}
+
+static void directemp_disconnect(struct usb_interface *interface)
+{
+ struct usb_directemp *dev = usb_get_intfdata(interface);
+
+ device_remove_file(&interface->dev, &dev_attr_temp);
+ device_remove_file(&interface->dev, &dev_attr_rh);
+
+ /* first remove the files, then NULL the pointer */
+ usb_set_intfdata(interface, NULL);
+ usb_put_dev(dev->udev);
+
+ kfree(dev);
+
+ dev_info(&interface->dev, "disconnected\n");
+}
+
+static struct usb_device_id id_table[] = {
+ { USB_DEVICE(QTI_VENDOR_ID, 0x0002) }, /* Thermometer only */
+ { USB_DEVICE(QTI_VENDOR_ID, 0x0006) }, /* Thermo- and Hygrometer */
+ { }
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+static struct usb_driver directemp_driver = {
+ .name = "directemp",
+ .probe = directemp_probe,
+ .disconnect = directemp_disconnect,
+ .id_table = id_table,
+};
+
+static int __init usb_directemp_init(void)
+{
+ int result;
+
+ result = usb_register(&directemp_driver);
+ if (result) {
+ printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! "
+ "Error number: %d\n", result);
+ return result;
+ }
+
+ return 0;
+}
+
+static void __exit usb_directemp_exit(void)
+{
+ usb_deregister(&directemp_driver);
+}
+
+module_init(usb_directemp_init);
+module_exit(usb_directemp_exit);
+
+MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>");
+MODULE_DESCRIPTION("QTI DirecTEMP USB thermometer/hygrometer driver");
+MODULE_LICENSE("GPL");
Index: drivers/usb/misc/Makefile
===================================================================
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -8,6 +8,7 @@
obj-$(CONFIG_USB_BERRY_CHARGE) += berry_charge.o
obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
obj-$(CONFIG_USB_CYTHERM) += cytherm.o
+obj-$(CONFIG_USB_DIRECTEMP) += directemp.o
obj-$(CONFIG_USB_EMI26) += emi26.o
obj-$(CONFIG_USB_EMI62) += emi62.o
obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 4:47 [PATCH] linux-2.6.32-directemp Chris Verges
@ 2010-02-05 15:45 ` Alan Stern
2010-02-05 17:16 ` Greg KH
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Alan Stern @ 2010-02-05 15:45 UTC (permalink / raw)
To: Chris Verges; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Rob Owings
On Thu, 4 Feb 2010, Chris Verges wrote:
> Hi Linux gurus,
>
> Attached is a patch for the QTI DirecTEMP USB thermometer &
> thermometer/hygrometer sensors. This patch is based on linux-2.6.32.
> Functionality has been verified against both hardware variants listed in
> the driver (0x0002 and 0x0006), as both monolithic and modular.
>
> When the QTI DirecTEMP sensor is connected to a system, the directemp
> driver adds appropriate sysfs entries for the sensor type(s) supported.
> Examples:
>
> # PID 0x0002 (temp only)
> /sys/bus/usb/devices/.../temp
>
> # PID 0x0006 (temp + relative humidity)
> /sys/bus/usb/devices/.../temp
> /sys/bus/usb/devices/.../rh
>
> Using a standard "cat" will display the value.
This isn't a big deal... but it's more common for drivers to provide
regular device files for I/O than to rely on sysfs attributes. You end
up with more control and flexibility.
Alan Stern
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 4:47 [PATCH] linux-2.6.32-directemp Chris Verges
2010-02-05 15:45 ` Alan Stern
@ 2010-02-05 17:16 ` Greg KH
2010-02-05 17:32 ` Chris Verges
2010-02-05 20:40 ` Andrew Morton
2010-02-06 9:42 ` Bruno Prémont
3 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2010-02-05 17:16 UTC (permalink / raw)
To: Chris Verges; +Cc: linux-usb, linux-kernel, Rob Owings
On Thu, Feb 04, 2010 at 08:47:05PM -0800, Chris Verges wrote:
> Hi Linux gurus,
>
> Attached is a patch for the QTI DirecTEMP USB thermometer &
> thermometer/hygrometer sensors. This patch is based on linux-2.6.32.
> Functionality has been verified against both hardware variants listed in
> the driver (0x0002 and 0x0006), as both monolithic and modular.
>
> When the QTI DirecTEMP sensor is connected to a system, the directemp
> driver adds appropriate sysfs entries for the sensor type(s) supported.
> Examples:
>
> # PID 0x0002 (temp only)
> /sys/bus/usb/devices/.../temp
>
> # PID 0x0006 (temp + relative humidity)
> /sys/bus/usb/devices/.../temp
> /sys/bus/usb/devices/.../rh
>
> Using a standard "cat" will display the value.
>
> An additional "raw" sysfs entry has been added to aid in debugging. If
> used, an "echo" will send the data specified in the string to the USB
> device, and print back the results. It is not recommended for customer
> use except by expert users.
Is a kernel driver really needed for this device? You could do this all
in userspace with libusb/usbfs and not need a driver, right?
That's what we do for other USB thermometers today.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] linux-2.6.32-directemp
2010-02-05 17:16 ` Greg KH
@ 2010-02-05 17:32 ` Chris Verges
0 siblings, 0 replies; 12+ messages in thread
From: Chris Verges @ 2010-02-05 17:32 UTC (permalink / raw)
To: Greg KH; +Cc: linux-usb, linux-kernel, Rob Owings
> Is a kernel driver really needed for this device? You could do this
all
> in userspace with libusb/usbfs and not need a driver, right?
>
> That's what we do for other USB thermometers today.
Hi Greg,
I assumed that there were few to no USB thermometers in use with Linux.
Looking at the kernel, there seems to be Cypress USB thermometer driver
listed, but it's for a hobby project that isn't actually a product.
Based on the cytherm driver, I figured support was to be added to the
kernel.
I'd be happy to read up on libusb/usbfs. Thanks for introducing it.
For anyone who wants DirecTEMP support before a port to libusb/usbfs is
done (no ETA), feel free to use this driver.
Thanks,
Chris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 4:47 [PATCH] linux-2.6.32-directemp Chris Verges
2010-02-05 15:45 ` Alan Stern
2010-02-05 17:16 ` Greg KH
@ 2010-02-05 20:40 ` Andrew Morton
2010-02-05 21:32 ` Chris Verges
2010-02-06 9:42 ` Bruno Prémont
3 siblings, 1 reply; 12+ messages in thread
From: Andrew Morton @ 2010-02-05 20:40 UTC (permalink / raw)
To: Chris Verges; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Rob Owings
On Thu, 4 Feb 2010 20:47:05 -0800
"Chris Verges" <chrisv@cyberswitching.com> wrote:
> Hi Linux gurus,
>
> Attached is a patch for the QTI DirecTEMP USB thermometer &
> thermometer/hygrometer sensors. This patch is based on linux-2.6.32.
> Functionality has been verified against both hardware variants listed in
> the driver (0x0002 and 0x0006), as both monolithic and modular.
>
> When the QTI DirecTEMP sensor is connected to a system, the directemp
> driver adds appropriate sysfs entries for the sensor type(s) supported.
> Examples:
>
> # PID 0x0002 (temp only)
> /sys/bus/usb/devices/.../temp
>
> # PID 0x0006 (temp + relative humidity)
> /sys/bus/usb/devices/.../temp
> /sys/bus/usb/devices/.../rh
>
> Using a standard "cat" will display the value.
Seems a bit strange that a device driver's only interface is via sysfs.
Once upon a time people used /dev. Ho hum.
It would be useful if the changelog were to describe what the contents
of the sysfs files look like. That's an important part of the user
interface and the user interface is the most important part of the
driver, because we can't change that.
afacit the `temp' file displays something like "44 C", yes? If so,
that's a bit awkward for software parsing. It'd be clearer to rename
`temp' to `temperature_in_centigrade" or simply "centigrade" and then
display "44", and remove the units from the output.
Ditto the "rh" file, which presently contains "42%".
> An additional "raw" sysfs entry has been added to aid in debugging. If
> used, an "echo" will send the data specified in the string to the USB
> device, and print back the results. It is not recommended for customer
> use except by expert users.
>
> And with that description out of the way, I look forward to your review
> of the driver. Please provide any feedback that you may have.
>
Have a review-by-patch:
- `pid' is a well-understood term for a process ID. Rename it.
- clean up some memsets
- Change the `raw' file's permissions to S_IWUSR. We shouldn't permit
unprivileged users to cause a printk spew into the logs.
--- a/drivers/usb/misc/directemp.c~usb-qti-directemp-usb-thermometer-hygrometer-driver-support-fix
+++ a/drivers/usb/misc/directemp.c
@@ -40,7 +40,7 @@
struct usb_directemp {
struct usb_device *udev;
struct usb_interface *interface;
- uint16_t pid;
+ uint16_t product_id;
uint8_t read_temp;
};
@@ -114,7 +114,7 @@ static ssize_t show_temp(struct device *
/* Read twice due to a buffer issue on the DirecTEMP */
for (i = 0; i < DIRECTEMP_MAX_RETRIES; i++) {
- memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ memset(data, 0, sizeof(data));
data[0] = directemp->read_temp;
err = show_helper(dev, attr, data, data, DIRECTEMP_MSG_SIZE);
if (err < 0)
@@ -156,7 +156,7 @@ static ssize_t show_rh(struct device *de
/* Read twice due to a buffer issue on the DirecTEMP */
for (i = 0; i < DIRECTEMP_MAX_RETRIES; i++) {
- memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ memset(data, 0, sizeof(data));
data[0] = DIRECTEMP_HUMIDITY;
err = show_helper(dev, attr, data, data, DIRECTEMP_MSG_SIZE);
if (err < 0)
@@ -199,7 +199,7 @@ static ssize_t set_raw(struct device *de
if (count > DIRECTEMP_MSG_SIZE)
count = DIRECTEMP_MSG_SIZE;
- memset(data, 0, (DIRECTEMP_MSG_SIZE + 1) * sizeof(char));
+ memset(data, 0, sizeof(data));
memcpy(data, buf, count);
printk("Request:\n");
@@ -219,7 +219,7 @@ static ssize_t set_raw(struct device *de
return 0;
}
-static DEVICE_ATTR(raw, S_IWUGO, NULL, set_raw);
+static DEVICE_ATTR(raw, S_IWUSR, NULL, set_raw);
static int directemp_probe(struct usb_interface *interface,
const struct usb_device_id *id)
@@ -234,10 +234,10 @@ static int directemp_probe(struct usb_in
dev->udev = usb_get_dev(udev);
usb_set_intfdata(interface, dev);
- dev->pid = id->idProduct;
+ dev->product_id = id->idProduct;
dev_dbg(&interface->dev, "Product: %s (ID 0x%04X)\n",
- udev->product, dev->pid);
+ udev->product, dev->product_id);
dev_dbg(&interface->dev, "Manufacturer: %s\n",
udev->manufacturer);
dev_dbg(&interface->dev, "Serial Number: %s\n",
@@ -253,7 +253,7 @@ static int directemp_probe(struct usb_in
if (err)
goto exit_free_sysfs;
- switch (dev->pid) {
+ switch (dev->product_id) {
case 0x0002:
dev->read_temp = '2';
break;
_
^ permalink raw reply [flat|nested] 12+ messages in thread* RE: [PATCH] linux-2.6.32-directemp
2010-02-05 20:40 ` Andrew Morton
@ 2010-02-05 21:32 ` Chris Verges
2010-02-05 21:46 ` Andrew Morton
0 siblings, 1 reply; 12+ messages in thread
From: Chris Verges @ 2010-02-05 21:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Rob Owings
> *snip*
Hi Andrew,
Thanks for the technical review. I'll make the changes and send back a
new patch. Would you like a patch against your -mm tree or a fresh
patch against linux-2.6.32?
Chris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 21:32 ` Chris Verges
@ 2010-02-05 21:46 ` Andrew Morton
2010-02-05 23:58 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Morton @ 2010-02-05 21:46 UTC (permalink / raw)
To: Chris Verges; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Rob Owings
On Fri, 5 Feb 2010 13:32:27 -0800
"Chris Verges" <chrisv@cyberswitching.com> wrote:
> > *snip*
>
> Hi Andrew,
>
> Thanks for the technical review. I'll make the changes and send back a
> new patch. Would you like a patch against your -mm tree or a fresh
> patch against linux-2.6.32?
I guess a new patch would be best - #1 was a bit of a mess. Please
give the patch a good title (I chose "usb: QTI DirecTEMP USB
thermometer/hygrometer driver support") and if possible, include it
within the body of the email so more people are likely to look at it.
If your email client can't do that correctly, use a text/plain
attachment.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 21:46 ` Andrew Morton
@ 2010-02-05 23:58 ` Greg KH
2010-02-06 0:26 ` Chris Verges
0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2010-02-05 23:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: Chris Verges, linux-usb, linux-kernel, Rob Owings
On Fri, Feb 05, 2010 at 01:46:00PM -0800, Andrew Morton wrote:
> On Fri, 5 Feb 2010 13:32:27 -0800
> "Chris Verges" <chrisv@cyberswitching.com> wrote:
>
> > > *snip*
> >
> > Hi Andrew,
> >
> > Thanks for the technical review. I'll make the changes and send back a
> > new patch. Would you like a patch against your -mm tree or a fresh
> > patch against linux-2.6.32?
>
> I guess a new patch would be best - #1 was a bit of a mess. Please
> give the patch a good title (I chose "usb: QTI DirecTEMP USB
> thermometer/hygrometer driver support") and if possible, include it
> within the body of the email so more people are likely to look at it.
> If your email client can't do that correctly, use a text/plain
> attachment.
Sorry, but no, this driver will not be accepted, as it can be done just
fine from userspace instead of a kernel driver, as discussed before.
We have removed drivers from the kernel for this very reason, we don't
want to add new ones in with the same problem.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] linux-2.6.32-directemp
2010-02-05 23:58 ` Greg KH
@ 2010-02-06 0:26 ` Chris Verges
2010-02-06 8:55 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: Chris Verges @ 2010-02-06 0:26 UTC (permalink / raw)
To: Greg KH; +Cc: linux-usb, linux-kernel, Rob Owings
> Sorry, but no, this driver will not be accepted, as it can be done
just
> fine from userspace instead of a kernel driver, as discussed before.
Hi Greg,
Sounds good. I'll still be sending out an updated patch for anyone who
is interested in a kernel driver. They're welcome to patch in the
driver themselves.
I may be missing some key piece of information about libusb and usbfs,
but it seems like it pushes a lot of the protocol communication off to
the user app. So if there are several user apps that want to use the
same USB device, they either need a userland library or to re-implement
functionality; is that correct?
What I may be missing is the rationale behind pushing these drivers into
userland libraries and having yet another entity in the FOSS world that
is responsible for managing them. The kernel seems like an obvious
clearinghouse for software/hardware interactions. Yes, there may be
lots of drivers, but at least everyone knows where to go for them. But
like I said before, I may be missing something.
Thanks for the tips about libusb/usbfs!
Chris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] linux-2.6.32-directemp
2010-02-06 0:26 ` Chris Verges
@ 2010-02-06 8:55 ` Greg KH
0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-02-06 8:55 UTC (permalink / raw)
To: Chris Verges; +Cc: linux-usb, linux-kernel, Rob Owings
On Fri, Feb 05, 2010 at 04:26:42PM -0800, Chris Verges wrote:
> > Sorry, but no, this driver will not be accepted, as it can be done
> just
> > fine from userspace instead of a kernel driver, as discussed before.
>
> Hi Greg,
>
> Sounds good. I'll still be sending out an updated patch for anyone who
> is interested in a kernel driver. They're welcome to patch in the
> driver themselves.
That's great.
> I may be missing some key piece of information about libusb and usbfs,
> but it seems like it pushes a lot of the protocol communication off to
> the user app. So if there are several user apps that want to use the
> same USB device, they either need a userland library or to re-implement
> functionality; is that correct?
Yes, that is true.
> What I may be missing is the rationale behind pushing these drivers into
> userland libraries and having yet another entity in the FOSS world that
> is responsible for managing them. The kernel seems like an obvious
> clearinghouse for software/hardware interactions. Yes, there may be
> lots of drivers, but at least everyone knows where to go for them. But
> like I said before, I may be missing something.
No, you are correct. We want a driver in the kernel when it provides a
common interface to a class of devices (network, tty, video, etc.) For
devices like yours, there is no specific class in the kernel (well,
there is for hardware monitoring devices, but not for generic
thermometers.) So for that, you are going to write a custom userspace
program anyway to be reading the temp value from sysfs, so you might as
well just either use a library to talk to your device, or put it within
the application itself.
Hope this helps explain things,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] linux-2.6.32-directemp
2010-02-05 4:47 [PATCH] linux-2.6.32-directemp Chris Verges
` (2 preceding siblings ...)
2010-02-05 20:40 ` Andrew Morton
@ 2010-02-06 9:42 ` Bruno Prémont
[not found] ` <68FBE0F3CE97264395875AC1C468F22C2445C2@mail03.cyberswitching.local>
3 siblings, 1 reply; 12+ messages in thread
From: Bruno Prémont @ 2010-02-06 9:42 UTC (permalink / raw)
To: Chris Verges
Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Rob Owings,
lm-sensors
On Thu, 04 February 2010 "Chris Verges" wrote:
> Attached is a patch for the QTI DirecTEMP USB thermometer &
> thermometer/hygrometer sensors. This patch is based on linux-2.6.32.
> Functionality has been verified against both hardware variants listed
> in the driver (0x0002 and 0x0006), as both monolithic and modular.
>
> When the QTI DirecTEMP sensor is connected to a system, the directemp
> driver adds appropriate sysfs entries for the sensor type(s)
> supported. Examples:
>
> # PID 0x0002 (temp only)
> /sys/bus/usb/devices/.../temp
>
> # PID 0x0006 (temp + relative humidity)
> /sys/bus/usb/devices/.../temp
> /sys/bus/usb/devices/.../rh
>
> Using a standard "cat" will display the value.
Wouldn't it make sense to make use of hardware monitoring interfaces so
lm_sensors could handle the sensor information? (added to CC)
This would also be a good reason to have the driver on kernel side
rather than somewhere in userspace.
Bruno
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-02-06 18:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-05 4:47 [PATCH] linux-2.6.32-directemp Chris Verges
2010-02-05 15:45 ` Alan Stern
2010-02-05 17:16 ` Greg KH
2010-02-05 17:32 ` Chris Verges
2010-02-05 20:40 ` Andrew Morton
2010-02-05 21:32 ` Chris Verges
2010-02-05 21:46 ` Andrew Morton
2010-02-05 23:58 ` Greg KH
2010-02-06 0:26 ` Chris Verges
2010-02-06 8:55 ` Greg KH
2010-02-06 9:42 ` Bruno Prémont
[not found] ` <68FBE0F3CE97264395875AC1C468F22C2445C2@mail03.cyberswitching.local>
2010-02-06 18:01 ` [lm-sensors] " Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox