Commit Graph

267 Commits

Author SHA1 Message Date
Ioana Ciornei a9108b71b1 staging: dgap: add spaces around binary operator '|'
This patch adds spaces around binary operator '|'.
Done with coccinelle semantic patch:

@@
identifier x, y, z;
@@
(
- x|y|z
+ x | y | z
|
- x|y
+ x | y
)

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:33:42 -07:00
Ioana Ciornei 44209c9329 staging: dgap: remove unnecessary brackets
This patch removes unnecessary brackets when dealing with
unary operators like '&'.
Done with coccinelle semantic patch:

@@
expression e;
@@

(
- &(e)
+ &e
)

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:33:42 -07:00
Ioana Ciornei 181225530e staging: dgap: remove unnecessary space after cast
This patch removes unnecessary spaces after the cast.
Patch done with coccinelle semantic patch:

@rule0@
type t;
identifier e;
constant c;
expression expr;
@@

(
- (t) e
+ (t)e
|
- (t) c
+ (t)c
|
- (t) expr
+ (t)expr
)

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:33:42 -07:00
Ioana Ciornei 629c7349a2 staging: dgap: properly indent to match open paranthesis
Indent parameters and arguments passed to function calls to match
open paranthesis

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:33:42 -07:00
Ioana Ciornei fb795c6847 staging: dgap: remove unnecessary blank lines
This patch removes the unnecessary blank lines before a closed
bracket and after an open bracket.

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:33:42 -07:00
Shivani Bhardwaj 258e7af295 Staging: dgap: Remove unnecessary test expression
struct bd is already NULL tested so, any further NULL checks should be
removed.

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-16 23:06:38 -07:00
Sudip Mukherjee 35e942f316 staging: dgap: remove unused configuration
The IO configuration was not used to configure the board. It was only
read from the configuration file. Stop reading it and also remove the
other related variables defined for it.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-12 21:09:47 -07:00
Ronit Halder 5b62408ffe staging: dgap: fix memory leak in dgap_parsefile()
In dgap_parsefile() char pointers are set with kstrdup()
without checking that some string is allocated to that
char pointer before. This patch frees the memory if already allocated
and then set the poniter with kstrdup().

Signed-off-by: Ronit halder <ronit.crj@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-30 12:26:20 +02:00
Javier Martinez Canillas e98631d83c staging: dgap: fix returned errno code in dgap_parsefile()
The driver is using -1 instead of the -ENOMEM defined macro to specify
that a buffer allocation failed. Since the error number is propagated,
the caller will get a -EPERM which is the wrong error condition.

Also, the smatch tool complains with the following warning:

dgap_parsefile() warn: returning -1 instead of -ENOMEM is sloppy

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 04:16:29 +02:00
Alexander Kuleshov b9f7f1d084 staging/dgap: Use strpbrk() instead of dgap_sindex()
The <linux/string.h> provides strpbrk() function that does
the same that the dgap_sindex(). Let's use already defined
function instead of writing custom.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-12 18:24:57 -07:00
Sudip Mukherjee 045ec41231 staging: dgap: remove unused variable
These variables were assigned some values but they were never used.
Removed them but kept one call to ioread8() as it might affect the
hardware.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-12 18:24:57 -07:00
Sudip Mukherjee 39be6b8b0c staging: dgap: fix possible NULL dereference
The return pointer from dgap_getword() is used in strcmp() where it is
dereferenced. But dgap_getword() can return NULL.
Lets put a check there and return 0 as error.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-12 18:24:57 -07:00
Shraddha Barke 6ba4df24bb Staging:dgap :Compression of lines for immediate return
This patch compresses two lines into a single line
if immediate return statement is found. Remove variable rc as
it is no longer needed.

It is done using script Coccinelle. And coccinelle uses the following
semantic patch for this compression function:

@@
type T;
identifier i,f;
constant C;
@@
- T i;
  ...when != i
     when strict
(
  return -C;
|
- i =
+ return
     f(...);
- return i;
)

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-31 16:14:53 -07:00
Sudip Mukherjee b8d1f261fe staging: dgap: remove duplicate code
Remove the duplicate code of dgap_remove_one() and dgap_stop().

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-16 10:19:55 -07:00
Sudip Mukherjee 174b83c0eb staging: dgap: new arguments to dgap_stop
In a later patch we will remove the duplicate codes. But the code also
needs to execute dgap_remove_driver_sysfiles() if it is being called
from dgap_remove_one() but if being called fron the error path of the
dgap_init_module() then the sysfiles should not be removed.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-16 10:19:55 -07:00
Sudip Mukherjee eda03951c3 staging: dgap: rearrange function
Relocate the function dgap_stop() so that in a later patch we can remove
the duplicate codes between dgap_stop() and dgap_remove_one().

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-16 10:19:55 -07:00
Sudip Mukherjee ac4e504a59 staging: dgap: fix error path
The code in dgap_stop() is almost a duplicate of the code that will be
executed on pci_unregister_driver(). So the error code was stopping and
unregistering everything twice.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-16 10:19:55 -07:00
Colin Cronin 469caabe52 Staging: dgap: dgap: Fixed spelling errors
Fixed comment spelling errors

Signed-off-by: Colin Cronin <colinpatrickcronin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-31 11:40:14 +09:00
Sudip Mukherjee 56f40e5210 staging: dgap: remove unused code
dgap_sindex() is being only called from dgap_getword() which searches
for either ' ' or '\t' or '\n'. this part of the code with '^' at the
beginning is never used.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-10 15:17:50 +02:00
Sudip Mukherjee 1397e2fd06 staging: dgap: use remove function
the remove callback will be called in two cases, 1) if the driver is
removed and 2) if the pci device is removed. as of now all the board
cleanups were being done in the module unload section so if the module
is unloaded everything works. But if the pci device is removed then the
loaded driver will be left in an inconsistent state.
So moved the cleanups in the remove callback and since there was no
reference of dgap_driver in remove_one(), so had to define the
pci_driver in the function.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-10 15:12:09 +02:00
Sudip Mukherjee d1c9f3efc4 staging: dgap: move function before remove
move the cleanup function before the remove call as the next patch of
the series is going to use that.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-10 15:12:09 +02:00
Somya Anand 2049f1ea88 Staging: dgap: Use setup_timer to combine initialization
The function setup_timer combines the initialization of a timer with the
initialization of the timer's function and data fields.

So, this patch combines the multiline code for timer initialization using the function
setup_timer. This issue is identified via coccinelle script.

@@
expression E1, E2, E3;
type T;
@@
- init_timer(&E1);
...
(
- E1.function = E2;
...
- E1.data = (T)E3;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.data = (T)E3;
...
- E1.function = E2;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.function = E2;
+ setup_timer(&E1, E2, 0);
)

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-16 16:17:31 +01:00
Haneen Mohammed 6019ee4095 Staging: dgap: Remove unused variable
This patch removes variable that was used to store only the return value of a function call.

The issue was detected and resolved using the following coccinelle script:

@@
expression ret;
identifier f;
@@

-ret =
+return
	f(...);
-return ret;

Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Reviewed-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-09 13:30:40 +01:00
Fabio Estevam 4c1d2dcb64 staging: dgap: Avoid name collision
Building for ARM64 leads to the following build warning:

In file included from drivers/staging/dgap/dgap.c:66:0:
drivers/staging/dgap/dgap.h:124:0: warning: "PCI_IO_SIZE" redefined
 #define PCI_IO_SIZE  0x00200000
 ^
In file included from ./arch/arm64/include/asm/page.h:66:0,
                 from include/linux/mm_types.h:15,
                 from include/linux/sched.h:27,
                 from ./arch/arm64/include/asm/compat.h:25,
                 from ./arch/arm64/include/asm/stat.h:23,
                 from include/linux/stat.h:5,
                 from include/linux/module.h:10,
                 from drivers/staging/dgap/dgap.c:47:
./arch/arm64/include/asm/memory.h:39:0: note: this is the location of the previous definition
 #define PCI_IO_SIZE  SZ_16M
 ^

Use PCI_IO_SIZE_DGAP to avoid the name collision.

Reported-by: Olof's autobuilder <build@lixom.net>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-06 17:06:30 -08:00
Aya Mahfouz e20af8acf1 staging: dgap: remove unused variable
This patch removes a variable that was simply used to
store the return value of a function call before
returning it.

The issue was detected and resolved using the following
coccinelle script:

@@
identifier len,f;
@@

-int len;
 ... when != len
     when strict
-len =
+return
        f(...);
-return len;

Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01 16:57:36 -08:00
Daeseok Youn ce5b615bc2 staging: dgap: fix "if" statement that always evaluates to true
cppcheck warning:
(warnning) Logical disjunction always evaluates to true

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-25 20:08:13 +08:00
Daeseok Youn aa9895da3e staging: dgap: use gotos for handling error in dgap_remap()
Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-17 16:10:48 -08:00
Anjana Sasindran d268b50eb2 Drivers:staging:dgap: Added a blank line after declaration
This patch fixes the checkpatch.pl warning:

WARNING:Missing a blank line after declaration

Signed-off-by: Anjana Sasindran <anjanasasindran123@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 14:00:22 -08:00
Daeseok Youn 48d43be475 staging: dgap: introducing find_board_by_major()
use find_board_by_major function instead of getting a brd from static
arrary. Becasue tty's major number doesn't start zero and we can
find a brd from dgap_board[].

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:30:22 -08:00
Daeseok Youn 4c5dbca65b staging: dgap: remove useless variables for saving tty's major
The board_t has a tty_struct(serial_driver and print_driver)
that has a major number. When major number is compared in
dgap_tty_open(), just use brd->serial_driver{print_driver}->major.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:30:22 -08:00
Daeseok Youn 429161d164 staging: dgap: fix memory leak caused by double allocation of tty_structs
The tty_struct of serial_driver and print_driver were getting
allocated twice. One is allocated in tty_alloc_driver(), the other
is in dgap_tty_register(). So remove these in dgap_tty_register().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:30:22 -08:00
Daeseok Youn dc3cfcd3f4 staging: dgap: set tty's flags by tty_alloc_driver()
tty's flags can be set by calling tty_alloc_driver().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:30:21 -08:00
Daeseok Youn deaa2c2021 staging: dgap: remove unnecessary function
The dgap_init_global() initialize the dgap_board
that is a global variable as static and dgap_poll_timer.
But init_timer() is called twice in dgap_start() and dgap_board
doesn't need to be initialized to NULL.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 14:49:14 -08:00
Daeseok Youn 0b2cf5c840 staging: dgap: re-arrange functions for removing forward declarations
Re-arrange the functions for removing forward declarations.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Tested-by: Mark Hounschell <markh@compro.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:24:56 -08:00
Tapasweni Pathak d8d34a817b staging: dgap: Remove useless cast on NULL
Cast on NULL to a pointer type is not required. This
patch removes NULL casted to some pointer type.

The sematic patch used is:
@r@
type T;
@@
- (T *)NULL
+ NULL

Build tested it.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 13:09:15 -07:00
Tapasweni Pathak d591f5d0e5 staging: dgap: Remove useless cast on void pointer
void pointers do not need to be cast to other pointer types.

The semantic patch used to find this:

@r@
expression x;
void* e;
type T;
identifier f;
@@

(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T *)x)->f
|
- (T *)
  e
)

Build tested it.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 13:05:46 -07:00
Tapasweni Pathak ac2f46c365 staging: dgap: Use unsigned for loop index
The following semantic patch is used to do this

@r exists@ // find anything that might decrement the variable
identifier i;
expression E;
position p;
@@

  int i@p;
  ...
(
  &i
|
  i--
|
  --i
|
  i-=E
|
  i+=E
)

@x disable decl_init@
identifier r.i;
expression E;
position p1 != r.p;
@@

(
  volatile int i = 0;
|
  volatile int i;
|
+ unsigned
  int i@p1 = 0;
|
+ unsigned
  int i@p1;
)
  <... when != i = E
(
  i = 0
|
  i = 1
)
  ...>

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-28 16:19:02 +08:00
Daeseok Youn ebf72ccf53 staging: dgap: introduce dgap_stop()
The dgap_init_module() need to unwind for cleanup variables properly.
Because dgap_init_module() calls dgap_cleanup_module() for freeing
variables but this function is possible to free variables
which are not allocated.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:30:13 +08:00
Daeseok Youn 263bd1cb84 staging: dgap: change function names properly
dgap_do_remap() and dgap_release_remap() names could be
changed to dgap_remap() and dgap_unmap().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:29:26 +08:00
Daeseok Youn 9f2b744475 staging: dgap: remove unnecessary if statement for checking NULL
dgap_release_remap() function is only called after the memory
has been remapped so if statement for checking NULL doesn't
need.

And also release_mem_region() calls are moved after iounmap() calls.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:29:26 +08:00
Rahul Bedarkar 748d9dd1b1 staging: dgap: remove unused variable 'orig_count'
This patch fixes sparse warning
warning: variable ‘orig_count’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Rahul Bedarkar <rahulbedarkar89@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:29:26 +08:00
Daeseok Youn c749201247 staging: dgap: use dgap_release_remap() in dgap_cleanup_board()
Just simply use dgap_release_remap() in dgap_cleanup_board() for
releasing map memory.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-23 23:39:25 -07:00
Daeseok Youn b23e487903 staging: dgap: adds missing iounmap for re_map_port in dgap_release_remap()
Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-23 23:39:25 -07:00
Daeseok Youn 476f6bc80b staging: dgap: remove unused 'runwait' variable
Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-23 23:39:24 -07:00
Daeseok Youn 492a1e7be5 staging: dgap: use schedule_timeout_interruptible() instead of dgap_ms_sleep()
Using schedule_timeout_interruptible() is exactly same as
setting a status of current process and calling  schedule_timeout().

Removes dgap_ms_sleep(), because this function is used
only when closing tty channel on dgap_tty_close().
And also removes ch_close_delay that is always set to 250
on dgap_tty_init().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 16:53:57 -07:00
Piotr Witoslawski 70c0ed9825 drivers: staging: dgap: fix the checkpatch.pl issue "Warning: line over 80 characters"
Break lines exceeding 80 characters

Signed-off-by: Piotr Witoslawski <pwitos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-06 21:46:55 -07:00
Daeseok Youn c643794eb3 staging: dgap: remove useless a variable within board_t
The use_interrupts is used only in dagp_request_irq() for checking
a value from user config file. It doesn't need in board_t struct.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-30 14:04:58 -07:00
Daeseok Youn 9f20ecc51b staging: dgap: remove redundant setting a variable
The brd(board_t) is initialized with zero, so "intr_used"
is not needed to set zero when request_irq() is failed.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-30 14:04:58 -07:00
Daeseok Youn 6c66843dab staging: dgap: cleanup print messages for dgap driver
* use dev_{warn,err} instead of pr_{warn,err}
* removes dgap_err() and just use pr_err(). pr_err() used in
dgap_parsefile() not dev_err() because if dgap_parsefile() is
failed, just one message is printed.
* removes "out of memory" messages.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-16 12:23:06 -07:00
Daeseok Youn 3cfa648b12 staging: dgap: Simplify to set a module type
It is same manner with setting a board type.
After allocating a type of "MNODE", get a token value
set to "module.type".

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-16 12:23:06 -07:00