[PATCH 0/6] Fix issues reported by static analysis tool.

2018-05-22 Thread Pankaj Bharadiya
This patch series fixes some of the issues reported by static analysis
tool.

Pankaj Bharadiya (6):
  media: staging: atomisp: remove redundent check
  media: staging: atomisp: Remove useless if statement
  media: staging: atomisp: Remove useless "ifndef ISP2401"
  media: staging: atomisp: Fix potential NULL pointer dereference
  media: staging: atomisp: Fix potential NULL pointer dereference
  media: staging: atomisp: Fix potential NULL pointer dereference

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c   | 14 --
 .../media/atomisp/pci/atomisp2/atomisp_compat_css20.c  |  2 --
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c  |  8 
 .../pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c |  3 ++-
 .../staging/media/atomisp/pci/atomisp2/css2400/sh_css.c|  7 +--
 5 files changed, 7 insertions(+), 27 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] media: staging: atomisp: Fix potential NULL pointer dereference

2018-05-22 Thread Pankaj Bharadiya
In verify_copy_out_frame_format(), "pipe" is being dereferenced before
it is null checked.
Fix it by moving the "pipe" pointer dereference after it has been
properly null checked.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index eb84d51..487e768 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -455,12 +455,14 @@ static enum ia_css_frame_format yuv422_copy_formats[] = {
 static enum ia_css_err
 verify_copy_out_frame_format(struct ia_css_pipe *pipe)
 {
-   enum ia_css_frame_format out_fmt = pipe->output_info[0].format;
+   enum ia_css_frame_format out_fmt;
unsigned int i, found = 0;
 
assert(pipe != NULL);
assert(pipe->stream != NULL);
 
+   out_fmt = pipe->output_info[0].format;
+
switch (pipe->stream->config.input_config.format) {
case ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY:
case ATOMISP_INPUT_FORMAT_YUV420_8:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] media: staging: atomisp: Remove useless "ifndef ISP2401"

2018-05-22 Thread Pankaj Bharadiya
In atomisp_csi2_set_ffmt(), there is no reason to have
"#ifndef ISP2401" condition since code is identical in ifndef and
else sections. Hence remove redudent checks.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c
index fa03b78..606ebdb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c
@@ -90,11 +90,7 @@ int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
 {
struct atomisp_mipi_csi2_device *csi2 = v4l2_get_subdevdata(sd);
struct v4l2_mbus_framefmt *actual_ffmt =
-#ifndef ISP2401
__csi2_get_format(csi2, cfg, which, pad);
-#else
-   __csi2_get_format(csi2, cfg, which, pad);
-#endif
 
if (pad == CSI2_PAD_SINK) {
const struct atomisp_in_fmt_conv *ic;
@@ -121,11 +117,7 @@ int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
 
/* FIXME: DPCM decompression */
*actual_ffmt = *ffmt =
-#ifndef ISP2401
*__csi2_get_format(csi2, cfg, which, CSI2_PAD_SINK);
-#else
-   *__csi2_get_format(csi2, cfg, which, CSI2_PAD_SINK);
-#endif
 
return 0;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/6] media: staging: atomisp: Fix potential NULL pointer dereference

2018-05-22 Thread Pankaj Bharadiya
In ia_css_pipe_get_primary_binarydesc(), "pipe" is being dereferenced
before it is null checked.
Fix it by moving the "pipe" pointer dereference after it has been
properly null checked.

Signed-off-by: Pankaj Bharadiya 
---
 .../atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c
index 98a2a3e..ca86157 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c
@@ -554,7 +554,7 @@ void ia_css_pipe_get_primary_binarydesc(
struct ia_css_frame_info *vf_info,
unsigned int stage_idx)
 {
-   enum ia_css_pipe_version pipe_version = pipe->config.isp_pipe_version;
+   enum ia_css_pipe_version pipe_version;
int mode;
unsigned int i;
struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
@@ -567,6 +567,7 @@ void ia_css_pipe_get_primary_binarydesc(
/*assert(vf_info != NULL);*/
IA_CSS_ENTER_PRIVATE("");
 
+   pipe_version = pipe->config.isp_pipe_version;
if (pipe_version == IA_CSS_PIPE_VERSION_2_6_1)
mode = primary_hq_binary_modes[stage_idx];
else
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] media: staging: atomisp: remove redundent check

2018-05-22 Thread Pankaj Bharadiya
Assignment asd = &isp->asd[i] can never be null hence remove
redundent check.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index f668c68..7a9f3c9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -4592,8 +4592,6 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
 * delete wdt timer. */
for (i = 0; i < isp->num_of_streams; i++) {
asd = &isp->asd[i];
-   if (!asd)
-   continue;
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
continue;
if (!atomisp_buffers_queued(asd))
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] media: staging: atomisp: Remove useless if statement

2018-05-22 Thread Pankaj Bharadiya
Local variable "requeue" is assigned only once to a constant "false"
value so "if(requeue)" condition will never be true.
Thus remove it.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index fa6ea50..c8c4d1d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -883,7 +883,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int 
error,
struct videobuf_buffer *vb = NULL;
struct atomisp_video_pipe *pipe = NULL;
struct atomisp_css_buffer buffer;
-   bool requeue = false;
int err;
unsigned long irqflags;
struct atomisp_css_frame *frame = NULL;
@@ -1223,19 +1222,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
 #ifdef ISP2401
atomic_set(&pipe->wdt_count, 0);
 #endif
-   /*
-* Requeue should only be done for 3a and dis buffers.
-* Queue/dequeue order will change if driver recycles image buffers.
-*/
-   if (requeue) {
-   err = atomisp_css_queue_buffer(asd,
-  stream_id, css_pipe_id,
-  buf_type, &buffer);
-   if (err)
-   dev_err(isp->dev, "%s, q to css fails: %d\n",
-   __func__, err);
-   return;
-   }
if (!error && q_buffers)
atomisp_qbuffers_to_css(asd);
 #ifdef ISP2401
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] media: staging: atomisp: Fix potential NULL pointer dereference

2018-05-22 Thread Pankaj Bharadiya
In sh_css_config_input_network(), "stream" is being dereferenced
before it is null checked.
Fix it by moving the "stream" pointer dereference after it has been
properly null checked.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index c771e4b..eb84d51 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -529,11 +529,12 @@ static enum ia_css_err
 sh_css_config_input_network(struct ia_css_stream *stream)
 {
unsigned int fmt_type;
-   struct ia_css_pipe *pipe = stream->last_pipe;
+   struct ia_css_pipe *pipe;
struct ia_css_binary *binary = NULL;
enum ia_css_err err = IA_CSS_SUCCESS;
 
assert(stream != NULL);
+   pipe = stream->last_pipe;
assert(pipe != NULL);
 
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: audio: Rename cport with intf_id

2016-10-16 Thread Pankaj Bharadiya
gb_audio_manager_module_descriptor's cport field is actually used to
manage and pass interface id to user space.

Thus rename gb_audio_manager_module_descriptor's 'cport' field and
few other things to avoid confusion.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/greybus/audio_manager.h|  2 +-
 drivers/staging/greybus/audio_manager_module.c | 20 ++--
 drivers/staging/greybus/audio_manager_sysfs.c  |  4 ++--
 drivers/staging/greybus/audio_module.c |  2 +-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/greybus/audio_manager.h 
b/drivers/staging/greybus/audio_manager.h
index c4ca097..056088e 100644
--- a/drivers/staging/greybus/audio_manager.h
+++ b/drivers/staging/greybus/audio_manager.h
@@ -21,7 +21,7 @@ struct gb_audio_manager_module_descriptor {
int slot;
int vid;
int pid;
-   int cport;
+   int intf_id;
unsigned int ip_devices;
unsigned int op_devices;
 };
diff --git a/drivers/staging/greybus/audio_manager_module.c 
b/drivers/staging/greybus/audio_manager_module.c
index a10e96a..2bf40a9 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -111,16 +111,16 @@ static ssize_t gb_audio_module_pid_show(
 static struct gb_audio_manager_module_attribute gb_audio_module_pid_attribute =
__ATTR(pid, 0664, gb_audio_module_pid_show, NULL);
 
-static ssize_t gb_audio_module_cport_show(
+static ssize_t gb_audio_module_intf_id_show(
struct gb_audio_manager_module *module,
struct gb_audio_manager_module_attribute *attr, char *buf)
 {
-   return sprintf(buf, "%d", module->desc.cport);
+   return sprintf(buf, "%d", module->desc.intf_id);
 }
 
 static struct gb_audio_manager_module_attribute
-   gb_audio_module_cport_attribute =
-   __ATTR(cport, 0664, gb_audio_module_cport_show, NULL);
+   gb_audio_module_intf_id_attribute =
+   __ATTR(intf_id, 0664, gb_audio_module_intf_id_show, NULL);
 
 static ssize_t gb_audio_module_ip_devices_show(
struct gb_audio_manager_module *module,
@@ -149,7 +149,7 @@ static ssize_t gb_audio_module_op_devices_show(
&gb_audio_module_slot_attribute.attr,
&gb_audio_module_vid_attribute.attr,
&gb_audio_module_pid_attribute.attr,
-   &gb_audio_module_cport_attribute.attr,
+   &gb_audio_module_intf_id_attribute.attr,
&gb_audio_module_ip_devices_attribute.attr,
&gb_audio_module_op_devices_attribute.attr,
NULL,   /* need to NULL terminate the list of attributes */
@@ -167,7 +167,7 @@ static void send_add_uevent(struct gb_audio_manager_module 
*module)
char slot_string[64];
char vid_string[64];
char pid_string[64];
-   char cport_string[64];
+   char intf_id_string[64];
char ip_devices_string[64];
char op_devices_string[64];
 
@@ -176,7 +176,7 @@ static void send_add_uevent(struct gb_audio_manager_module 
*module)
slot_string,
vid_string,
pid_string,
-   cport_string,
+   intf_id_string,
ip_devices_string,
op_devices_string,
NULL
@@ -186,7 +186,7 @@ static void send_add_uevent(struct gb_audio_manager_module 
*module)
snprintf(slot_string, 64, "SLOT=%d", module->desc.slot);
snprintf(vid_string, 64, "VID=%d", module->desc.vid);
snprintf(pid_string, 64, "PID=%d", module->desc.pid);
-   snprintf(cport_string, 64, "CPORT=%d", module->desc.cport);
+   snprintf(intf_id_string, 64, "INTF_ID=%d", module->desc.intf_id);
snprintf(ip_devices_string, 64, "I/P DEVICES=0x%X",
 module->desc.ip_devices);
snprintf(op_devices_string, 64, "O/P DEVICES=0x%X",
@@ -246,13 +246,13 @@ int gb_audio_manager_module_create(
 
 void gb_audio_manager_module_dump(struct gb_audio_manager_module *module)
 {
-   pr_info("audio module #%d name=%s slot=%d vid=%d pid=%d cport=%d i/p 
devices=0x%X o/p devices=0x%X\n",
+   pr_info("audio module #%d name=%s slot=%d vid=%d pid=%d intf_id=%d i/p 
devices=0x%X o/p devices=0x%X\n",
module->id,
module->desc.name,
module->desc.slot,
module->desc.vid,
module->desc.pid,
-   module->desc.cport,
+   module->desc.intf_id,
module->desc.ip_devices,
module->desc.op_devices);
 }
diff --git a/drivers/staging/greybus/audio_manager_sysfs.c 
b/drivers/staging/greybus/audio_manager_sysfs.c
index d8bf859..feb195d 100644
--- a/drivers/staging/greybus/audio_manager_sysfs.c
+++ b/driv

[PATCH] staging: dgnc: Replace CamelCase namings with underscores.

2016-10-16 Thread Pankaj Bharadiya
Replace CamelCase names with underscores to comply with the standard
kernel coding style.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/dgnc/dgnc_tty.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ef9a45b..1a21902 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -45,7 +45,7 @@
 /*
  * internal variables
  */
-static unsigned char   *dgnc_TmpWriteBuf;
+static unsigned char   *dgnc_tmp_write_buf;
 
 /*
  * Default transparent print information.
@@ -69,7 +69,7 @@
  * This defines a raw port at 9600 baud, 8 data bits, no parity,
  * 1 stop bit.
  */
-static struct ktermios DgncDefaultTermios = {
+static struct ktermios dgnc_default_termios = {
.c_iflag =  (DEFAULT_IFLAGS),   /* iflags */
.c_oflag =  (DEFAULT_OFLAGS),   /* oflags */
.c_cflag =  (DEFAULT_CFLAGS),   /* cflags */
@@ -160,9 +160,9 @@ int dgnc_tty_preinit(void)
 * is only called during module load, (not in interrupt context),
 * and with no locks held.
 */
-   dgnc_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_KERNEL);
+   dgnc_tmp_write_buf = kmalloc(WRITEBUFLEN, GFP_KERNEL);
 
-   if (!dgnc_TmpWriteBuf)
+   if (!dgnc_tmp_write_buf)
return -ENOMEM;
 
return 0;
@@ -194,7 +194,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->minor_start = 0;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
-   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->init_termios = dgnc_default_termios;
brd->serial_driver->driver_name = DRVSTR;
 
/*
@@ -233,7 +233,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->print_driver->minor_start = 0x80;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
-   brd->print_driver->init_termios = DgncDefaultTermios;
+   brd->print_driver->init_termios = dgnc_default_termios;
brd->print_driver->driver_name = DRVSTR;
 
/*
@@ -371,8 +371,8 @@ int dgnc_tty_init(struct dgnc_board *brd)
  */
 void dgnc_tty_post_uninit(void)
 {
-   kfree(dgnc_TmpWriteBuf);
-   dgnc_TmpWriteBuf = NULL;
+   kfree(dgnc_tmp_write_buf);
+   dgnc_tmp_write_buf = NULL;
 }
 
 /*
@@ -1543,7 +1543,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
int ret = 0;
unsigned long flags;
 
-   if (!tty || !dgnc_TmpWriteBuf)
+   if (!tty || !dgnc_tmp_write_buf)
return 0;
 
un = tty->driver_data;
@@ -1623,7 +1623,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
ushort tmask;
uint remain;
 
-   if (!tty || !dgnc_TmpWriteBuf)
+   if (!tty || !dgnc_tmp_write_buf)
return 0;
 
un = tty->driver_data;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: audio: remove redundant slot field

2016-10-17 Thread Pankaj Bharadiya
gb_audio_manager_module_descriptor's intf_id field maintains the
information about the interface on which module is connected hence
having an extra slot field is redundant.

Thus remove the slot field and its associated code.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/greybus/audio_codec.h  |  1 -
 drivers/staging/greybus/audio_manager.h|  1 -
 drivers/staging/greybus/audio_manager_module.c | 17 +
 drivers/staging/greybus/audio_manager_sysfs.c  |  7 +++
 drivers/staging/greybus/audio_module.c |  1 -
 5 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/greybus/audio_codec.h 
b/drivers/staging/greybus/audio_codec.h
index ca027bd..62fd939 100644
--- a/drivers/staging/greybus/audio_codec.h
+++ b/drivers/staging/greybus/audio_codec.h
@@ -158,7 +158,6 @@ struct gbaudio_module_info {
int dev_id; /* check if it should be bundle_id/hd_cport_id */
int vid;
int pid;
-   int slot;
int type;
int set_uevent;
char vstr[NAME_SIZE];
diff --git a/drivers/staging/greybus/audio_manager.h 
b/drivers/staging/greybus/audio_manager.h
index 056088e..5ab8f5e 100644
--- a/drivers/staging/greybus/audio_manager.h
+++ b/drivers/staging/greybus/audio_manager.h
@@ -18,7 +18,6 @@
 
 struct gb_audio_manager_module_descriptor {
char name[GB_AUDIO_MANAGER_MODULE_NAME_LEN];
-   int slot;
int vid;
int pid;
int intf_id;
diff --git a/drivers/staging/greybus/audio_manager_module.c 
b/drivers/staging/greybus/audio_manager_module.c
index 2bf40a9..adc1697 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -81,16 +81,6 @@ static ssize_t gb_audio_module_name_show(
 static struct gb_audio_manager_module_attribute gb_audio_module_name_attribute 
=
__ATTR(name, 0664, gb_audio_module_name_show, NULL);
 
-static ssize_t gb_audio_module_slot_show(
-   struct gb_audio_manager_module *module,
-   struct gb_audio_manager_module_attribute *attr, char *buf)
-{
-   return sprintf(buf, "%d", module->desc.slot);
-}
-
-static struct gb_audio_manager_module_attribute gb_audio_module_slot_attribute 
=
-   __ATTR(slot, 0664, gb_audio_module_slot_show, NULL);
-
 static ssize_t gb_audio_module_vid_show(
struct gb_audio_manager_module *module,
struct gb_audio_manager_module_attribute *attr, char *buf)
@@ -146,7 +136,6 @@ static ssize_t gb_audio_module_op_devices_show(
 
 static struct attribute *gb_audio_module_default_attrs[] = {
&gb_audio_module_name_attribute.attr,
-   &gb_audio_module_slot_attribute.attr,
&gb_audio_module_vid_attribute.attr,
&gb_audio_module_pid_attribute.attr,
&gb_audio_module_intf_id_attribute.attr,
@@ -164,7 +153,6 @@ static ssize_t gb_audio_module_op_devices_show(
 static void send_add_uevent(struct gb_audio_manager_module *module)
 {
char name_string[128];
-   char slot_string[64];
char vid_string[64];
char pid_string[64];
char intf_id_string[64];
@@ -173,7 +161,6 @@ static void send_add_uevent(struct gb_audio_manager_module 
*module)
 
char *envp[] = {
name_string,
-   slot_string,
vid_string,
pid_string,
intf_id_string,
@@ -183,7 +170,6 @@ static void send_add_uevent(struct gb_audio_manager_module 
*module)
};
 
snprintf(name_string, 128, "NAME=%s", module->desc.name);
-   snprintf(slot_string, 64, "SLOT=%d", module->desc.slot);
snprintf(vid_string, 64, "VID=%d", module->desc.vid);
snprintf(pid_string, 64, "PID=%d", module->desc.pid);
snprintf(intf_id_string, 64, "INTF_ID=%d", module->desc.intf_id);
@@ -246,10 +232,9 @@ int gb_audio_manager_module_create(
 
 void gb_audio_manager_module_dump(struct gb_audio_manager_module *module)
 {
-   pr_info("audio module #%d name=%s slot=%d vid=%d pid=%d intf_id=%d i/p 
devices=0x%X o/p devices=0x%X\n",
+   pr_info("audio module #%d name=%s vid=%d pid=%d intf_id=%d i/p 
devices=0x%X o/p devices=0x%X\n",
module->id,
module->desc.name,
-   module->desc.slot,
module->desc.vid,
module->desc.pid,
module->desc.intf_id,
diff --git a/drivers/staging/greybus/audio_manager_sysfs.c 
b/drivers/staging/greybus/audio_manager_sysfs.c
index fc0aca6..9eae70f 100644
--- a/drivers/staging/greybus/audio_manager_sysfs.c
+++ b/drivers/staging/greybus/audio_manager_sysfs.c
@@ -20,10 +20,9 @@ static ssize_t manager_sysfs_add_store(
 
int num = sscanf(buf,
"name=%" GB_AUDIO_MANAGER_MODULE_NAME_LEN_SSCANF "s "
-   &q

[PATCH v2 2/2] staging: dgnc: Replace CamelCase namings with underscores

2016-10-17 Thread Pankaj Bharadiya
Replace CamelCase names with underscores to comply with the standard
kernel coding style.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/dgnc/dgnc_tty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 8d557fa..52af3ef 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -64,7 +64,7 @@
  * This defines a raw port at 9600 baud, 8 data bits, no parity,
  * 1 stop bit.
  */
-static struct ktermios DgncDefaultTermios = {
+static struct ktermios default_termios = {
.c_iflag =  (DEFAULT_IFLAGS),   /* iflags */
.c_oflag =  (DEFAULT_OFLAGS),   /* oflags */
.c_cflag =  (DEFAULT_CFLAGS),   /* cflags */
@@ -164,7 +164,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->serial_driver->minor_start = 0;
brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->serial_driver->subtype = SERIAL_TYPE_NORMAL;
-   brd->serial_driver->init_termios = DgncDefaultTermios;
+   brd->serial_driver->init_termios = default_termios;
brd->serial_driver->driver_name = DRVSTR;
 
/*
@@ -203,7 +203,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->print_driver->minor_start = 0x80;
brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL;
brd->print_driver->subtype = SERIAL_TYPE_NORMAL;
-   brd->print_driver->init_termios = DgncDefaultTermios;
+   brd->print_driver->init_termios = default_termios;
brd->print_driver->driver_name = DRVSTR;
 
/*
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/2] staging: dgnc: Code cleaup

2016-10-17 Thread Pankaj Bharadiya
Hi,

This patchset does minor cleanup for dgnc driver.

v1->v2: 
- Split into multiple patches
- remove redundant dgnc_tmp_write_buf variable and function calls
- rename dgnc_default_termios to default_termios

Pankaj Bharadiya (2):
  staging: dgnc: Remove some redundant functions
  staging: dgnc: Replace CamelCase namings with underscores

 drivers/staging/dgnc/dgnc_driver.c | 13 --
 drivers/staging/dgnc/dgnc_tty.c| 51 --
 drivers/staging/dgnc/dgnc_tty.h|  2 --
 3 files changed, 5 insertions(+), 61 deletions(-)

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/2] staging: dgnc: Remove some redundant functions

2016-10-17 Thread Pankaj Bharadiya
dgnc_tty_preinit() and dgnc_tty_post_uninit() functions are used to
allocate and free "dgnc_TmpWriteBuf" and this "dgnc_TmpWriteBuf" is
not really getting used. Hence remove these redundant functions.

Also remove dgnc_TmpWriteBuf variable as it is not used anymore.

Signed-off-by: Pankaj Bharadiya 
---
 drivers/staging/dgnc/dgnc_driver.c | 13 ---
 drivers/staging/dgnc/dgnc_tty.c| 45 ++
 drivers/staging/dgnc/dgnc_tty.h|  2 --
 3 files changed, 2 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index fd372d3..0fe7e85 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -151,7 +151,6 @@ static void cleanup(bool sysfiles)
dgnc_cleanup_board(dgnc_board[i]);
}
 
-   dgnc_tty_post_uninit();
 }
 
 /*
@@ -241,16 +240,6 @@ static int dgnc_start(void)
goto failed_device;
}
 
-   /*
-* Init any global tty stuff.
-*/
-   rc = dgnc_tty_preinit();
-
-   if (rc < 0) {
-   pr_err(DRVSTR ": tty preinit - not enough memory (%d)\n", rc);
-   goto failed_tty;
-   }
-
/* Start the poller */
spin_lock_irqsave(&dgnc_poll_lock, flags);
setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
@@ -262,8 +251,6 @@ static int dgnc_start(void)
 
return 0;
 
-failed_tty:
-   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
 failed_device:
class_destroy(dgnc_class);
 failed_class:
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ef9a45b..8d557fa 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -43,11 +43,6 @@
 #include "dgnc_utils.h"
 
 /*
- * internal variables
- */
-static unsigned char   *dgnc_TmpWriteBuf;
-
-/*
  * Default transparent print information.
  */
 static struct digi_t dgnc_digi_init = {
@@ -144,31 +139,6 @@ static void dgnc_tty_set_termios(struct tty_struct *tty,
  /
 
 /*
- * dgnc_tty_preinit()
- *
- * Initialize any global tty related data before we download any boards.
- */
-int dgnc_tty_preinit(void)
-{
-   /*
-* Allocate a buffer for doing the copy from user space to
-* kernel space in dgnc_write().  We only use one buffer and
-* control access to it with a semaphore.  If we are paging, we
-* are already in trouble so one buffer won't hurt much anyway.
-*
-* We are okay to sleep in the malloc, as this routine
-* is only called during module load, (not in interrupt context),
-* and with no locks held.
-*/
-   dgnc_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_KERNEL);
-
-   if (!dgnc_TmpWriteBuf)
-   return -ENOMEM;
-
-   return 0;
-}
-
-/*
  * dgnc_tty_register()
  *
  * Init the tty subsystem for this board.
@@ -365,17 +335,6 @@ int dgnc_tty_init(struct dgnc_board *brd)
 }
 
 /*
- * dgnc_tty_post_uninit()
- *
- * UnInitialize any global tty related data.
- */
-void dgnc_tty_post_uninit(void)
-{
-   kfree(dgnc_TmpWriteBuf);
-   dgnc_TmpWriteBuf = NULL;
-}
-
-/*
  * dgnc_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
@@ -1543,7 +1502,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
int ret = 0;
unsigned long flags;
 
-   if (!tty || !dgnc_TmpWriteBuf)
+   if (!tty)
return 0;
 
un = tty->driver_data;
@@ -1623,7 +1582,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
ushort tmask;
uint remain;
 
-   if (!tty || !dgnc_TmpWriteBuf)
+   if (!tty)
return 0;
 
un = tty->driver_data;
diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h
index 24c9a41..85a1310 100644
--- a/drivers/staging/dgnc/dgnc_tty.h
+++ b/drivers/staging/dgnc/dgnc_tty.h
@@ -21,10 +21,8 @@
 intdgnc_tty_register(struct dgnc_board *brd);
 void dgnc_tty_unregister(struct dgnc_board *brd);
 
-intdgnc_tty_preinit(void);
 int dgnc_tty_init(struct dgnc_board *);
 
-void   dgnc_tty_post_uninit(void);
 void   dgnc_cleanup_tty(struct dgnc_board *);
 
 void   dgnc_input(struct channel_t *ch);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: Replace CamelCase namings with underscores.

2016-10-17 Thread Pankaj Bharadiya
On Mon, Oct 17, 2016 at 1:16 PM, Greg KH  wrote:
>
> On Mon, Oct 17, 2016 at 01:13:55AM +0530, Pankaj Bharadiya wrote:
> > Replace CamelCase names with underscores to comply with the standard
> > kernel coding style.
> >
> > Signed-off-by: Pankaj Bharadiya 
> > ---
> >  drivers/staging/dgnc/dgnc_tty.c | 20 ++--
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/staging/dgnc/dgnc_tty.c 
> > b/drivers/staging/dgnc/dgnc_tty.c
> > index ef9a45b..1a21902 100644
> > --- a/drivers/staging/dgnc/dgnc_tty.c
> > +++ b/drivers/staging/dgnc/dgnc_tty.c
> > @@ -45,7 +45,7 @@
> >  /*
> >   * internal variables
> >   */
> > -static unsigned char *dgnc_TmpWriteBuf;
> > +static unsigned char *dgnc_tmp_write_buf;
>
> Why not just fix the code to not have this variable at all?  It's not
> correct to have it from what I can tell...
>
> Also, you modify many different variables all at once, can you please
> just modify one at a time (one per patch), to make it more obvious it is
> correct?
>
> >  /*
> >   * Default transparent print information.
> > @@ -69,7 +69,7 @@
> >   * This defines a raw port at 9600 baud, 8 data bits, no parity,
> >   * 1 stop bit.
> >   */
> > -static struct ktermios DgncDefaultTermios = {
> > +static struct ktermios dgnc_default_termios = {
>
> rename to "default_termios"?
>
> No need to keep the driver name prefix on a static variable, right?
>
Hi Greg,

Thank you for your comments.
I have submitted v2 patchset. I hope that makes more sense now.

Thanks,
Pankaj

> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel