Re: [PATCH v2 09/21] usb/gadget: f_mass_storage: use fsg_common_setup in fsg_common_init

2013-07-25 Thread Michal Nazarewicz
On Fri, Jul 19 2013, Andrzej Pietrasiewicz wrote:
 fsg_common_init is a lengthy function. Now there are helper functions
 which cover all parts of it. Use them.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

 ---
  drivers/usb/gadget/f_mass_storage.c |   19 +++
  1 files changed, 3 insertions(+), 16 deletions(-)

 diff --git a/drivers/usb/gadget/f_mass_storage.c 
 b/drivers/usb/gadget/f_mass_storage.c
 index f1b0da8..0f40d35 100644
 --- a/drivers/usb/gadget/f_mass_storage.c
 +++ b/drivers/usb/gadget/f_mass_storage.c
 @@ -3019,16 +3019,9 @@ struct fsg_common *fsg_common_init(struct fsg_common 
 *common,
   return ERR_PTR(-EINVAL);
   }
  
 - /* Allocate? */
 - if (!common) {
 - common = kzalloc(sizeof *common, GFP_KERNEL);
 - if (!common)
 - return ERR_PTR(-ENOMEM);
 - common-free_storage_on_release = 1;
 - } else {
 - memset(common, 0, sizeof *common);
 - common-free_storage_on_release = 0;
 - }
 + common = fsg_common_setup(common, !!common);
 + if (IS_ERR(common))
 + return common;
   common-sysfs = true;
   common-state = FSG_STATE_IDLE;
  
 @@ -3068,8 +3061,6 @@ struct fsg_common *fsg_common_init(struct fsg_common 
 *common,
   }
   common-luns = curlun_it;
  
 - init_rwsem(common-filesem);
 -
   for (i = 0, lcfg = cfg-luns; i  nluns; ++i, ++curlun_it, ++lcfg) {
   struct fsg_lun *curlun;
  
 @@ -3169,8 +3160,6 @@ buffhds_first_it:
   common-can_stall = cfg-can_stall 
   !(gadget_is_at91(common-gadget));
  
 - spin_lock_init(common-lock);
 - kref_init(common-ref);
  
   /* Tell the thread to start working */
   common-thread_task =
 @@ -3179,8 +3168,6 @@ buffhds_first_it:
   rc = PTR_ERR(common-thread_task);
   goto error_release;
   }
 - init_completion(common-thread_notifier);
 - init_waitqueue_head(common-fsg_wait);
  
   /* Information */
   INFO(common, FSG_DRIVER_DESC , version:  FSG_DRIVER_VERSION \n);
 -- 
 1.7.0.4


-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

signature.asc
Description: PGP signature


[PATCH v2 09/21] usb/gadget: f_mass_storage: use fsg_common_setup in fsg_common_init

2013-07-19 Thread Andrzej Pietrasiewicz
fsg_common_init is a lengthy function. Now there are helper functions
which cover all parts of it. Use them.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/f_mass_storage.c |   19 +++
 1 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index f1b0da8..0f40d35 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -3019,16 +3019,9 @@ struct fsg_common *fsg_common_init(struct fsg_common 
*common,
return ERR_PTR(-EINVAL);
}
 
-   /* Allocate? */
-   if (!common) {
-   common = kzalloc(sizeof *common, GFP_KERNEL);
-   if (!common)
-   return ERR_PTR(-ENOMEM);
-   common-free_storage_on_release = 1;
-   } else {
-   memset(common, 0, sizeof *common);
-   common-free_storage_on_release = 0;
-   }
+   common = fsg_common_setup(common, !!common);
+   if (IS_ERR(common))
+   return common;
common-sysfs = true;
common-state = FSG_STATE_IDLE;
 
@@ -3068,8 +3061,6 @@ struct fsg_common *fsg_common_init(struct fsg_common 
*common,
}
common-luns = curlun_it;
 
-   init_rwsem(common-filesem);
-
for (i = 0, lcfg = cfg-luns; i  nluns; ++i, ++curlun_it, ++lcfg) {
struct fsg_lun *curlun;
 
@@ -3169,8 +3160,6 @@ buffhds_first_it:
common-can_stall = cfg-can_stall 
!(gadget_is_at91(common-gadget));
 
-   spin_lock_init(common-lock);
-   kref_init(common-ref);
 
/* Tell the thread to start working */
common-thread_task =
@@ -3179,8 +3168,6 @@ buffhds_first_it:
rc = PTR_ERR(common-thread_task);
goto error_release;
}
-   init_completion(common-thread_notifier);
-   init_waitqueue_head(common-fsg_wait);
 
/* Information */
INFO(common, FSG_DRIVER_DESC , version:  FSG_DRIVER_VERSION \n);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html