Sarah Bailey wrote: [...] > --- a/drivers/usb/core/endpoint.c > +++ b/drivers/usb/core/endpoint.c [...] > @@ -303,6 +299,19 @@ int usb_create_ep_files(struct device *parent, > ep_dev->dev.class = ep_class->class; > ep_dev->dev.parent = parent; > ep_dev->dev.release = ep_device_release; > + if(usb_endpoint_xfer_control(ep_dev->desc)) > + fops = &usb_endpoint_control_fops; > + else if(usb_endpoint_dir_in(ep_dev->desc)) > + fops = &usb_endpoint_in_fops; > + else > + fops = &usb_endpoint_out_fops; > + cdev_init(&ep_dev->cdev, fops); > + ep_dev->cdev.owner = THIS_MODULE; > + ep_dev->cdev.ops = fops;
No need to make this assignment; cdev_init does so, using the fops you pass it. Also, perhaps you could create a function usb_endpoint_create_cdev, which takes the ep_dev and handles all initialization related to the cdev member. This would allow you to make the endpoint fops static, and not declare them as extern. It would also keep the endpoint device code in one place. [...] > --- /dev/null > +++ b/drivers/usb/core/endpoint_fops.c [...] > +int endpoint_open(struct inode *inode, struct file *filp) You should declare this static. [...] > +ssize_t control_read(struct file * filp, char __user *buff, > + size_t count, loff_t * offp) Likewise. [...] > +struct file_operations usb_endpoint_control_fops = { If you create the usb_endpoint_create_cdev function at the end of this file, you could declare this static. [...] > +struct file_operations usb_endpoint_in_fops = { Likewise. [...] > +struct file_operations usb_endpoint_out_fops = { Likewise. [...] > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -151,3 +151,16 @@ extern void usb_notify_remove_device(struct usb_device > *udev); > extern void usb_notify_add_bus(struct usb_bus *ubus); > extern void usb_notify_remove_bus(struct usb_bus *ubus); > > +/* usb endpoint file operations */ > +extern struct file_operations usb_endpoint_control_fops; > +extern struct file_operations usb_endpoint_in_fops; > +extern struct file_operations usb_endpoint_out_fops; If you create the usb_endpoint_create_cdev function in endpoint_fops.c, you could remove these extern declarations, and replace them with an extern declaration for usb_endpoint_create_cdev. - Josh Triplett
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel