diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-10-09 10:05:52 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-10-10 10:21:31 -0500 |
commit | 8502d66d33704d66d29c715ba5e91192b554cef0 (patch) | |
tree | 367c015df61bf243e10a3171a927b2a47a1492eb /drivers/usb/gadget/f_mass_storage.c | |
parent | e9edd199d69034fa163c97ef310ca72dca9cf030 (diff) | |
download | op-kernel-dev-8502d66d33704d66d29c715ba5e91192b554cef0.zip op-kernel-dev-8502d66d33704d66d29c715ba5e91192b554cef0.tar.gz |
usb: gadget: f_mass_storage: create _fsg_common_free_buffers
When configfs is in place, gadgets will have to be able to free
fsg buffers. Add a helper function.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_mass_storage.c')
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 32e5ab7..59a12c1 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2642,6 +2642,18 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } +static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) +{ + if (buffhds) { + struct fsg_buffhd *bh = buffhds; + while (n--) { + kfree(bh->buf); + ++bh; + } + kfree(buffhds); + } +} + struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) @@ -2897,15 +2909,7 @@ static void fsg_common_release(struct kref *ref) kfree(common->luns); } - { - struct fsg_buffhd *bh = common->buffhds; - unsigned i = common->fsg_num_buffers; - do { - kfree(bh->buf); - } while (++bh, --i); - } - - kfree(common->buffhds); + _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); if (common->free_storage_on_release) kfree(common); } |