staging: most: Fix coding style problems.
Subsystems (2)
PATCH 1/4 staging: most: Fix coding style problems.
Makes two very minor changes indicated by checkpatch:
1) Add a newline after components_show() definition.
2) Fix a line over the 80 character limit.
--- drivers/staging/most/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/most/core.c +4 -1
@@ -583,6 +583,7 @@ static ssize_t components_show(struct device_driver *drv, char *buf) }return offs; } +/** * split_string - parses buf and extracts ':' separated substrings. *
@@ -1474,7 +1475,9 @@ void most_deregister_interface(struct most_interface *iface)int i;struct most_channel *c; -pr_info ("deregistering device %s (%s)\n" ,dev_name (&iface->dev), iface->description); +pr_info ("deregistering device %s (%s)\n" , +dev_name (&iface->dev), + iface->description);for (i =0 ; i < iface->num_channels; i++) { c = iface->p->channel[i];if (c->pipe0.comp)
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 2/4 staging: most: Replace calls to BUG_ON() with WARN_ONCE() and return.
Replace calls to BUG_ON() used to check for NULL pointers with WARN_ONCE() followed by a return.
--- drivers/staging/most/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/staging/most/core.c +10 -3
@@ -916,7 +916,11 @@ static void arm_mbo(struct mbo *mbo)unsigned long flags;struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); +if (WARN_ONCE (!mbo || !mbo->context, +"Bad mbo or missing channel reference.\n" )) { +return ; + } + c = mbo->context;if (c->is_poisoned) {
@@ -1001,7 +1005,7 @@ static int arm_mbo_chain(struct most_channel *c, int dir,void most_submit_mbo (struct mbo *mbo) {if (WARN_ONCE (!mbo || !mbo->context, -"bad mbo or missing channel reference\n" )) +"Bad mbo or missing channel reference.\n" ))return ;nq_hdm_mbo (mbo);
@@ -1019,7 +1023,10 @@ static void most_write_completion(struct mbo *mbo) {struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); +if (WARN_ONCE (!mbo || !mbo->context, +"Bad mbo or missing channel reference.\n" )) { +return ; + } c = mbo->context;if (mbo->status ==MBO_E_INVAL )
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Greg KH
maintainerRe: [PATCH 2/4] staging: most: Replace calls to BUG_ON() with WARN_ONCE() and return.
Quoted 2 lines · Quytelda Kahja
Replace calls to
BUG_ON()used to check for NULL pointers withWARN_ONCE()followed by a return.
Are you sure this will work?
Quoted 11 lines
Signed-off-by Quytelda Kahja <[email protected]>--- drivers/staging/most/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)drivers/staging/most/core.c +0
-0
drivers/staging/most/core.c static void arm_mbo(struct mbo *mbo) · line 921
Quoted 7 lines
drivers/staging/most/core.c +3
-1@@ -916,7 +916,11 @@ static void arm_mbo(struct mbo *mbo)unsigned long flags;struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); +if (WARN_ONCE (!mbo || !mbo->context, +"Bad mbo or missing channel reference.\n" )) { +return ;
How is the code supposed to recover from this major problem?
drivers/staging/most/core.c static int arm_mbo_chain(struct most_channel *c, int dir, · line 1008
Quoted 11 lines
drivers/staging/most/core.c +3
-1+ } + c = mbo->context;if (c->is_poisoned) {@@ -1001,7 +1005,7 @@ static int arm_mbo_chain(struct most_channel *c, int dir,void most_submit_mbo (struct mbo *mbo) {if (WARN_ONCE (!mbo || !mbo->context, -"bad mbo or missing channel reference\n" )) +"Bad mbo or missing channel reference.\n" ))
You did something different here that you did not describe in your changelog :(
thanks,
greg k-h
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/4] staging: most: Replace calls to BUG_ON() with WARN_ONCE() and return.
Quoted 1 line
Are you sure this will work?
Well, my goal was just to replace the code that could crash the kernel and let somebody with a better understanding of this particular driver write the recovery code, if necessary. It seemed from context that the BUG_ON() calls were being used like assert() though, so I assumed there wasn't really much recovery to be made from that problem. If you feel this doesn't improve the behavior of the driver, just drop the patch.
Thank you,
Quytelda Kahja
Quoted 42 lines · Greg KH
Quoted 2 lines · Quytelda Kahja
Replace calls to
BUG_ON()used to check for NULL pointers withWARN_ONCE()followed by a return.Are you sure this will work?
Quoted 11 lines
Signed-off-by Quytelda Kahja <[email protected]>--- drivers/staging/most/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)drivers/staging/most/core.c +0
-0drivers/staging/most/core.c static void arm_mbo(struct mbo *mbo) · line 921
Quoted 7 lines
drivers/staging/most/core.c +3
-1@@ -916,7 +916,11 @@ static void arm_mbo(struct mbo *mbo)unsigned long flags;struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); +if (WARN_ONCE (!mbo || !mbo->context, +"Bad mbo or missing channel reference.\n" )) { +return ;How is the code supposed to recover from this major problem?
drivers/staging/most/core.c static int arm_mbo_chain(struct most_channel *c, int dir, · line 1008
Quoted 11 lines
drivers/staging/most/core.c +3
-1+ } + c = mbo->context;if (c->is_poisoned) {@@ -1001,7 +1005,7 @@ static int arm_mbo_chain(struct most_channel *c, int dir,void most_submit_mbo (struct mbo *mbo) {if (WARN_ONCE (!mbo || !mbo->context, -"bad mbo or missing channel reference\n" )) +"Bad mbo or missing channel reference.\n" ))You did something different here that you did not describe in your changelog :(
Quoted 3 lines
thanks,
greg k-h
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/4] staging: most: Replace calls to BUG_ON() with WARN_ONCE() and return.
Quoted 9 lines · Quytelda Kahja
Quoted 1 line
Are you sure this will work?
Well, my goal was just to replace the code that could crash the kernel and let somebody with a better understanding of this particular driver write the recovery code, if necessary. It seemed from context that the
BUG_ON()calls were being used likeassert()though, so I assumed there wasn't really much recovery to be made from that problem. If you feel this doesn't improve the behavior of the driver, just drop the patch.
mbo is always non-NULL just from a quick glance. I didn't look hard enough to verify that mbo->context was OK.
It's generally best to just check the callers and delete these.
Say you have a BUG_ON() then that prevents memory corruption (not an issue here) but it makes debugging hard. But if you just have a NULL dereference it probably kills the driver but you get an Oops which you can debug. So a NULL dereference is normally better than a BUG_ON().
regards,
dan carpenter
PATCH 1/1 staging: most: Remove unnecessary usage of BUG_ON().
There is no need for the calls to BUG_ON() in this driver, which are used to check if mbo or mbo->context are NULL; mbo is never NULL, and if mbo->context is NULL it would have already been dereferenced and oopsed before reaching the BUG_ON().
--- drivers/staging/most/core.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/most/core.c +0 -3
@@ -915,7 +915,6 @@ static void arm_mbo(struct mbo *mbo)unsigned long flags;struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); c = mbo->context;if (c->is_poisoned) {
@@ -1018,8 +1017,6 @@ static void most_write_completion(struct mbo *mbo) {struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); - c = mbo->context;if (mbo->status ==MBO_E_INVAL )pr_info ("WARN: Tx MBO status: invalid\n" );
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: most: Remove unnecessary usage of BUG_ON().
Quoted 6 lines · Quytelda Kahja
There is no need for the calls to
BUG_ON()in this driver, which are used to check if mbo ormbo->contextare NULL; mbo is never NULL, and ifmbo->contextis NULL it would have already been dereferenced and oopsed before reaching theBUG_ON().Signed-off-by Quytelda Kahja <[email protected]>
Quoted 18 lines
--- drivers/staging/most/core.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/most/core.c +0
-1@@ -915,7 +915,6 @@ static void arm_mbo(struct mbo *mbo)unsigned long flags;struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); c = mbo->context;if (c->is_poisoned) {
drivers/staging/most/core.c static void most_write_completion(struct mbo *mbo) · line 1022
Quoted 8 lines
drivers/staging/most/core.c +0
-2@@ -1018,8 +1017,6 @@ static void most_write_completion(struct mbo *mbo) {struct most_channel *c; -BUG_ON ((!mbo) || (!mbo->context)); - c = mbo->context;if (mbo->status ==MBO_E_INVAL )pr_info ("WARN: Tx MBO status: invalid\n" );
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 3/4 staging: most: Remove unnecessary OOM messages.
In reply to Quytelda KahjaIt isn't necessary for the driver to log out-of-memory errors, so these have been removed and the functions simply return -ENOMEM.
--- drivers/staging/most/core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/most/core.c +0 -2
@@ -1210,7 +1210,6 @@ int most_start_channel(struct most_interface *iface, int id, num_buffer =arm_mbo_chain (c, c->cfg.direction, most_write_completion);if (unlikely (!num_buffer)) { -pr_info ("failed to allocate memory\n" ); ret = -ENOMEM ; goto error; }
@@ -1389,7 +1388,6 @@ int most_register_interface(struct most_interface *iface) iface->p =kzalloc (sizeof (*iface->p),GFP_KERNEL );if (!iface->p) { -pr_info ("Failed to allocate interface instance\n" );ida_simple_remove (&mdev_id, id);return -ENOMEM ; }
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 4/4 staging: most: Fix missing identifier in function definition argument.
In reply to Quytelda KahjaThe function pointer 'complete' in 'struct mbo' should use an identifier for its argument.
--- drivers/staging/most/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/core.h +1 -1
@@ -184,7 +184,7 @@ struct mbo {u16 buffer_length;u16 processed_length;enum mbo_status_flags status; -void (*complete)(struct mbo *); +void (*complete)(struct mbo *mbo); };/**
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Greg KH
maintainerQuoted 3 lines · Quytelda Kahja
Makes two very minor changes indicated by checkpatch:
1) Add a newline aftercomponents_show()definition.
2) Fix a line over the 80 character limit.
Do not do multiple things in the same patch, whenever possible. Please break this up into 2 patches.
thanks,
greg k-h
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/2 staging: most: Fix a coding style problem.
Use a blank line after components_show() function declaration.
--- drivers/staging/most/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/most/core.c +1 -0
@@ -583,6 +583,7 @@ static ssize_t components_show(struct device_driver *drv, char *buf) }return offs; } +/** * split_string - parses buf and extracts ':' separated substrings. *
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 2/2 staging: most: Fix a coding style problem
Indent the parameters for a function call that extends past 80 characters.
--- drivers/staging/most/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/most/core.c +2 -1
@@ -1473,7 +1473,8 @@ void most_deregister_interface(struct most_interface *iface)int i;struct most_channel *c; -pr_info ("deregistering device %s (%s)\n" ,dev_name (&iface->dev), iface->description); +pr_info ("deregistering device %s (%s)\n" ,dev_name (&iface->dev), + iface->description);for (i =0 ; i < iface->num_channels; i++) { c = iface->p->channel[i];if (c->pipe0.comp)
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] staging: most: Fix a coding style problem
You've got two subjects which are the same. That's not allowed, sorry. You could just say:
[PATCH 1/2] staging: most: Add a blank line [PATCH 2/2] staging: most: Silence a long line warning
regards,
dan carpenter
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH v2 1/2 staging: most: Add a blank line.
Use a blank line after components_show() function declaration.
--- drivers/staging/most/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/most/core.c +1 -0
@@ -583,6 +583,7 @@ static ssize_t components_show(struct device_driver *drv, char *buf) }return offs; } +/** * split_string - parses buf and extracts ':' separated substrings. *
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH v2 2/2 staging: most: Indent function parameter.
In reply to Dan CarpenterIndent the parameters for a function call that extends past 80 characters.
--- drivers/staging/most/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/most/core.c +2 -1
@@ -1473,7 +1473,8 @@ void most_deregister_interface(struct most_interface *iface)int i;struct most_channel *c; -pr_info ("deregistering device %s (%s)\n" ,dev_name (&iface->dev), iface->description); +pr_info ("deregistering device %s (%s)\n" ,dev_name (&iface->dev), + iface->description);for (i =0 ; i < iface->num_channels; i++) { c = iface->p->channel[i];if (c->pipe0.comp)
Signature · 6 lines
2.16.2 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel