static ssize_t usb_otg_ctrl_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int gpiovalue = 0;
int rlt;
printk("usb_otg_ctrl_store entered %s\n",buf);
rlt = sscanf(buf,"%d",&gpiovalue);
printk("gpio value %d",gpiovalue);
if(gpiovalue)
power_supply_set_usb_otg(usb->usb_psy, 1);
else
{
power_supply_set_usb_otg(usb->usb_psy, 0);
}
printk("power_supply_set_usb_otg set\n");
return count;
}
static ssize_t usb_otg_ctrl_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s %d\n","usb_otg_status is:",host_status);
}
static DEVICE_ATTR(usb_otg_ctrl, S_IRUGO | S_IWUSR, usb_otg_ctrl_show, usb_otg_ctrl_store);
static struct class *usb_otg_ctrl_class;
static struct device *usb_otg_ctrl_dev;
static int detect_probe(struct platform_device *pdev)
{
usb_otg_ctrl_class = class_create(THIS_MODULE,"usbotg_class");
if(IS_ERR(usb_otg_ctrl_class))
{
printk(" failed in creating otg class.\n");
}
usb_otg_ctrl_dev = device_create( usb_otg_ctrl_class,NULL,MKDEV(240,10),NULL,"usbotg");
if (IS_ERR(usb_otg_ctrl_dev)) {
printk("usbotg device_create failed \n");
}
rc = device_create_file(usb_otg_ctrl_dev, &dev_attr_usb_otg_ctrl);
if (rc != 0) {
printk("usb_otg_ctrl device_create_file failed \n");
}
}