Ejemplo n.º 1
0
static ssize_t class_set_enabled(struct device *device, struct device_attribute *attr, const char *buf, size_t count)
{
	struct asus_oled_dev *odev = (struct asus_oled_dev *) dev_get_drvdata(device);

	int temp = simple_strtoul(buf, NULL, 10);

	enable_oled(odev, temp);

	return count;
}
Ejemplo n.º 2
0
static ssize_t set_enabled(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	struct usb_interface *intf = to_usb_interface(dev);
	struct asus_oled_dev *odev = usb_get_intfdata(intf);
	int temp = simple_strtoul(buf, NULL, 10);

	enable_oled(odev, temp);

	return count;
}
Ejemplo n.º 3
0
static int asus_oled_resume(struct usb_interface *intf)
{
	struct asus_oled_dev *odev;

	odev = usb_get_intfdata(intf);
	if (!odev)
		return -ENODEV;

	enable_oled(odev, odev->enabled_post_resume);

	return 0;
}
Ejemplo n.º 4
0
static ssize_t set_enabled(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{
	struct usb_interface *intf = to_usb_interface(dev);
	struct asus_oled_dev *odev = usb_get_intfdata(intf);
	unsigned long value;
	if (strict_strtoul(buf, 10, &value))
		return -EINVAL;

	enable_oled(odev, value);

	return count;
}
Ejemplo n.º 5
0
static int asus_oled_suspend(struct usb_interface *intf, pm_message_t message)
{
	struct asus_oled_dev *odev;

	odev = usb_get_intfdata(intf);
	if (!odev)
		return -ENODEV;

	odev->enabled_post_resume = odev->enabled;
	enable_oled(odev, 0);

	return 0;
}
Ejemplo n.º 6
0
static int asus_oled_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
	struct usb_device *udev = interface_to_usbdev(interface);
	struct asus_oled_dev *odev = NULL;
	int retval = -ENOMEM;

	odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL);
	
	if (odev == NULL) {
		dev_err(&interface->dev, "Out of memory\n");
		goto error_mem;
	}

	odev->udev = usb_get_dev(udev);
	odev->pic_mode = ASUS_OLED_STATIC;
	odev->height = 0;
	odev->width = 0;
	odev->x_shift = 0;
	odev->y_shift = 0;
	odev->buf_offs = 0;
	odev->buf_size = 0;
	odev->last_val = 0;
	odev->buf = NULL;
	
	usb_set_intfdata (interface, odev);

	if ((retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled)))) {
		device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
		goto error;
	}

	if ((retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture)))) {
		device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));
		goto error;
	}

	dev_info(&interface->dev, "Attached Asus OLED device\n");
	
	if (start_off)
		enable_oled(odev, 0);
	
	return 0;

error:
	usb_set_intfdata (interface, NULL);
	usb_put_dev(odev->udev);
	kfree(odev);
	
error_mem:
	return retval;
}
Ejemplo n.º 7
0
static ssize_t class_set_enabled(struct device *device,
				 struct device_attribute *attr,
				 const char *buf, size_t count)
{
	struct asus_oled_dev *odev =
		(struct asus_oled_dev *) dev_get_drvdata(device);
	unsigned long value;

	if (strict_strtoul(buf, 10, &value))
		return -EINVAL;

	enable_oled(odev, value);

	return count;
}
Ejemplo n.º 8
0
static int asus_oled_probe(struct usb_interface *interface,
			   const struct usb_device_id *id)
{
	struct usb_device *udev = interface_to_usbdev(interface);
	struct asus_oled_dev *odev = NULL;
	int retval = -ENOMEM;
	uint16_t dev_width = 0;
	enum oled_pack_mode pack_mode = PACK_MODE_LAST;
	const struct oled_dev_desc_str *dev_desc = oled_dev_desc_table;
	const char *desc = NULL;

	if (!id) {
		/* Even possible? Just to make sure...*/
		dev_err(&interface->dev, "No usb_device_id provided!\n");
		return -ENODEV;
	}

	for (; dev_desc->idVendor; dev_desc++) {
		if (dev_desc->idVendor == id->idVendor
		    && dev_desc->idProduct == id->idProduct) {
			dev_width = dev_desc->devWidth;
			desc = dev_desc->devDesc;
			pack_mode = dev_desc->packMode;
			break;
		}
	}

	if (!desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) {
		dev_err(&interface->dev,
			"Missing or incomplete device description!\n");
		return -ENODEV;
	}

	odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL);

	if (odev == NULL) {
		dev_err(&interface->dev, "Out of memory\n");
		return -ENOMEM;
	}

	odev->udev = usb_get_dev(udev);
	odev->pic_mode = ASUS_OLED_STATIC;
	odev->dev_width = dev_width;
	odev->pack_mode = pack_mode;
	odev->height = 0;
	odev->width = 0;
	odev->x_shift = 0;
	odev->y_shift = 0;
	odev->buf_offs = 0;
	odev->buf_size = 0;
	odev->last_val = 0;
	odev->buf = NULL;
	odev->enabled = 1;
	odev->dev = NULL;

	usb_set_intfdata(interface, odev);

	retval = device_create_file(&interface->dev,
				    &ASUS_OLED_DEVICE_ATTR(enabled));
	if (retval)
		goto err_files;

	retval = device_create_file(&interface->dev,
				    &ASUS_OLED_DEVICE_ATTR(picture));
	if (retval)
		goto err_files;

	odev->dev = device_create(oled_class, &interface->dev, MKDEV(0, 0),
				  NULL, "oled_%d", ++oled_num);

	if (IS_ERR(odev->dev)) {
		retval = PTR_ERR(odev->dev);
		goto err_files;
	}

	dev_set_drvdata(odev->dev, odev);

	retval = device_create_file(odev->dev, &dev_attr_enabled);
	if (retval)
		goto err_class_enabled;

	retval = device_create_file(odev->dev, &dev_attr_picture);
	if (retval)
		goto err_class_picture;

	dev_info(&interface->dev,
		 "Attached Asus OLED device: %s [width %u, pack_mode %d]\n",
		 desc, odev->dev_width, odev->pack_mode);

	if (start_off)
		enable_oled(odev, 0);

	return 0;

err_class_picture:
	device_remove_file(odev->dev, &dev_attr_picture);

err_class_enabled:
	device_remove_file(odev->dev, &dev_attr_enabled);
	device_unregister(odev->dev);

err_files:
	device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
	device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));

	usb_set_intfdata(interface, NULL);
	usb_put_dev(odev->udev);
	kfree(odev);

	return retval;
}