[PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-19 Thread Pratik Jain
Refactored the function `XGIfb_search_refresh_rate` by removing a level
of `if...else` block nesting. Removed unnecessary parantheses.

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 63 +++--
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..ef9a726cd35d 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -544,41 +544,44 @@ static u8 XGIfb_search_refresh_rate(struct 
xgifb_video_info *xgifb_info,
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
 
xgifb_info->rate_idx = 0;
-   while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-   if ((XGIfb_vrate[i].xres == xres) &&
-   (XGIfb_vrate[i].yres == yres)) {
-   if (XGIfb_vrate[i].refresh == rate) {
+   
+   // Skip values with less xres
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres < xres)
+   ++i;
+
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
+   if (XGIfb_vrate[i].yres != yres) {
+   ++i;
+   continue;
+   }
+   if (XGIfb_vrate[i].refresh == rate) {
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
+   } else if (XGIfb_vrate[i].refresh > rate) {
+   if (XGIfb_vrate[i].refresh - rate <= 3) {
+   pr_debug("Adjusting rate from %d up to %d\n",
+   rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
-   } else if (XGIfb_vrate[i].refresh > rate) {
-   if ((XGIfb_vrate[i].refresh - rate) <= 3) {
-   pr_debug("Adjusting rate from %d up to 
%d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i].refresh;
-   } else if (((rate - XGIfb_vrate[i - 1].refresh)
-   <= 2) && (XGIfb_vrate[i].idx
-   != 1)) {
-   pr_debug("Adjusting rate from %d down 
to %d\n",
-rate,
-XGIfb_vrate[i - 1].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i - 1].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i - 1].refresh;
-   }
-   break;
-   } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i].refresh;
+   } else if ((rate - XGIfb_vrate[i - 1].refresh <= 2)
+   && (XGIfb_vrate[i].idx != 1)) {
pr_debug("Adjusting rate from %d down to %d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
+   rate, XGIfb_vrate[i - 1].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx;
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i - 1].refresh;
}
+   break;
+   } else if (rate - XGIfb_vrate[i].refresh <= 2) {
+   pr_debug("Adjusting rate from %d down to %d\n",
+   rate, XGIfb_vrate[i].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
}
-   i++;
+   ++i;
}
+
if (xgifb_info->rate_idx > 0)
return xgifb_info->rate_idx;
pr_info("Unsupported rate %d for %dx%d\n",
-- 
2.16.2



[PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-20 Thread Pratik Jain
Refactored the function `XGIfb_search_refresh_rate` by removing a level
of `if...else` block nesting. Removed unnecessary parantheses.

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 63 +++--
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..ef9a726cd35d 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -544,41 +544,44 @@ static u8 XGIfb_search_refresh_rate(struct 
xgifb_video_info *xgifb_info,
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
 
xgifb_info->rate_idx = 0;
-   while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-   if ((XGIfb_vrate[i].xres == xres) &&
-   (XGIfb_vrate[i].yres == yres)) {
-   if (XGIfb_vrate[i].refresh == rate) {
+   
+   // Skip values with less xres
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres < xres)
+   ++i;
+
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
+   if (XGIfb_vrate[i].yres != yres) {
+   ++i;
+   continue;
+   }
+   if (XGIfb_vrate[i].refresh == rate) {
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
+   } else if (XGIfb_vrate[i].refresh > rate) {
+   if (XGIfb_vrate[i].refresh - rate <= 3) {
+   pr_debug("Adjusting rate from %d up to %d\n",
+   rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
-   } else if (XGIfb_vrate[i].refresh > rate) {
-   if ((XGIfb_vrate[i].refresh - rate) <= 3) {
-   pr_debug("Adjusting rate from %d up to 
%d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i].refresh;
-   } else if (((rate - XGIfb_vrate[i - 1].refresh)
-   <= 2) && (XGIfb_vrate[i].idx
-   != 1)) {
-   pr_debug("Adjusting rate from %d down 
to %d\n",
-rate,
-XGIfb_vrate[i - 1].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i - 1].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i - 1].refresh;
-   }
-   break;
-   } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i].refresh;
+   } else if ((rate - XGIfb_vrate[i - 1].refresh <= 2)
+   && (XGIfb_vrate[i].idx != 1)) {
pr_debug("Adjusting rate from %d down to %d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
+   rate, XGIfb_vrate[i - 1].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx;
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i - 1].refresh;
}
+   break;
+   } else if (rate - XGIfb_vrate[i].refresh <= 2) {
+   pr_debug("Adjusting rate from %d down to %d\n",
+   rate, XGIfb_vrate[i].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
}
-   i++;
+   ++i;
}
+
if (xgifb_info->rate_idx > 0)
return xgifb_info->rate_idx;
pr_info("Unsupported rate %d for %dx%d\n",
-- 
2.16.2



Re: [PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-20 Thread Pratik Jain
You got a valid point about `++i` and `i++`. But I still feel
that it is less complicated than previous one. I am explicitly
saying(in first loop) that we are skipping some values to get
to a specific index. Apart from that, we can avoid unncessary
wrapping and indentation. Logic becomes much more explicit if
broken down to two loops.


[PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-20 Thread Pratik Jain
Refactored the function `XGIfb_search_refresh_rate` by removing a level
of `if...else` block nesting. Removed unnecessary parantheses.

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 61 +++--
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..7bbc12f3146f 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -544,41 +544,44 @@ static u8 XGIfb_search_refresh_rate(struct 
xgifb_video_info *xgifb_info,
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
 
xgifb_info->rate_idx = 0;
-   while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-   if ((XGIfb_vrate[i].xres == xres) &&
-   (XGIfb_vrate[i].yres == yres)) {
-   if (XGIfb_vrate[i].refresh == rate) {
+   
+   // Skip values with less xres
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres < xres)
+   i++;
+
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
+   if (XGIfb_vrate[i].yres != yres) {
+   i++;
+   continue;
+   }
+   if (XGIfb_vrate[i].refresh == rate) {
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
+   } else if (XGIfb_vrate[i].refresh > rate) {
+   if (XGIfb_vrate[i].refresh - rate <= 3) {
+   pr_debug("Adjusting rate from %d up to %d\n",
+   rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
-   } else if (XGIfb_vrate[i].refresh > rate) {
-   if ((XGIfb_vrate[i].refresh - rate) <= 3) {
-   pr_debug("Adjusting rate from %d up to 
%d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i].refresh;
-   } else if (((rate - XGIfb_vrate[i - 1].refresh)
-   <= 2) && (XGIfb_vrate[i].idx
-   != 1)) {
-   pr_debug("Adjusting rate from %d down 
to %d\n",
-rate,
-XGIfb_vrate[i - 1].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i - 1].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i - 1].refresh;
-   }
-   break;
-   } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i].refresh;
+   } else if ((rate - XGIfb_vrate[i - 1].refresh <= 2)
+   && (XGIfb_vrate[i].idx != 1)) {
pr_debug("Adjusting rate from %d down to %d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
+   rate, XGIfb_vrate[i - 1].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx;
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i - 1].refresh;
}
+   break;
+   } else if (rate - XGIfb_vrate[i].refresh <= 2) {
+   pr_debug("Adjusting rate from %d down to %d\n",
+   rate, XGIfb_vrate[i].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
}
i++;
}
+
if (xgifb_info->rate_idx > 0)
return xgifb_info->rate_idx;
pr_info("Unsupported rate %d for %dx%d\n",
-- 
2.16.2



[PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-20 Thread Pratik Jain
Refactored the function `XGIfb_search_refresh_rate` by removing a level
of `if...else` block nesting. Removed unnecessary parantheses.

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 59 +++--
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..aee969aab681 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -544,41 +544,42 @@ static u8 XGIfb_search_refresh_rate(struct 
xgifb_video_info *xgifb_info,
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
 
xgifb_info->rate_idx = 0;
-   while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-   if ((XGIfb_vrate[i].xres == xres) &&
-   (XGIfb_vrate[i].yres == yres)) {
-   if (XGIfb_vrate[i].refresh == rate) {
+
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
+   /* Skip values with xres or yres less than specified */
+   if ((XGIfb_vrate[i].yres != yres) ||
+   (XGIfb_vrate[i].xres < xres)) {
+   i++;
+   continue;
+   }
+   if (XGIfb_vrate[i].refresh == rate) {
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
+   } else if (XGIfb_vrate[i].refresh > rate) {
+   if (XGIfb_vrate[i].refresh - rate <= 3) {
+   pr_debug("Adjusting rate from %d up to %d\n",
+   rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
-   } else if (XGIfb_vrate[i].refresh > rate) {
-   if ((XGIfb_vrate[i].refresh - rate) <= 3) {
-   pr_debug("Adjusting rate from %d up to 
%d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i].refresh;
-   } else if (((rate - XGIfb_vrate[i - 1].refresh)
-   <= 2) && (XGIfb_vrate[i].idx
-   != 1)) {
-   pr_debug("Adjusting rate from %d down 
to %d\n",
-rate,
-XGIfb_vrate[i - 1].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i - 1].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i - 1].refresh;
-   }
-   break;
-   } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i].refresh;
+   } else if ((i > 0) &&
+  (rate - XGIfb_vrate[i - 1].refresh <= 2)) {
pr_debug("Adjusting rate from %d down to %d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
+   rate, XGIfb_vrate[i - 1].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx;
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i - 1].refresh;
}
+   break;
+   } else if (rate - XGIfb_vrate[i].refresh <= 2) {
+   pr_debug("Adjusting rate from %d down to %d\n",
+   rate, XGIfb_vrate[i].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
}
i++;
}
+
if (xgifb_info->rate_idx > 0)
return xgifb_info->rate_idx;
pr_info("Unsupported rate %d for %dx%d\n",
-- 
2.16.2



[PATCH] Staging: xgifb: XGI_main_26.c: Refactored the function

2018-03-21 Thread Pratik Jain
Refactored the function `XGIfb_search_refresh_rate` by removing a level
of `if...else` block nesting. Removed unnecessary parantheses. Removed
potential bug of array underflow.

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 59 +++--
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..eca0b50f0df6 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -544,41 +544,42 @@ static u8 XGIfb_search_refresh_rate(struct 
xgifb_video_info *xgifb_info,
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
 
xgifb_info->rate_idx = 0;
-   while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-   if ((XGIfb_vrate[i].xres == xres) &&
-   (XGIfb_vrate[i].yres == yres)) {
-   if (XGIfb_vrate[i].refresh == rate) {
+
+   while (XGIfb_vrate[i].idx != 0 && XGIfb_vrate[i].xres <= xres) {
+   /* Skip values with xres or yres less than specified */
+   if ((XGIfb_vrate[i].yres != yres) ||
+   (XGIfb_vrate[i].xres != xres)) {
+   i++;
+   continue;
+   }
+   if (XGIfb_vrate[i].refresh == rate) {
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
+   } else if (XGIfb_vrate[i].refresh > rate) {
+   if (XGIfb_vrate[i].refresh - rate <= 3) {
+   pr_debug("Adjusting rate from %d up to %d\n",
+   rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
-   } else if (XGIfb_vrate[i].refresh > rate) {
-   if ((XGIfb_vrate[i].refresh - rate) <= 3) {
-   pr_debug("Adjusting rate from %d up to 
%d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i].refresh;
-   } else if (((rate - XGIfb_vrate[i - 1].refresh)
-   <= 2) && (XGIfb_vrate[i].idx
-   != 1)) {
-   pr_debug("Adjusting rate from %d down 
to %d\n",
-rate,
-XGIfb_vrate[i - 1].refresh);
-   xgifb_info->rate_idx =
-   XGIfb_vrate[i - 1].idx;
-   xgifb_info->refresh_rate =
-   XGIfb_vrate[i - 1].refresh;
-   }
-   break;
-   } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i].refresh;
+   } else if ((XGIfb_vrate[i].idx != 1) &&
+  (rate - XGIfb_vrate[i - 1].refresh <= 2)) {
pr_debug("Adjusting rate from %d down to %d\n",
-rate, XGIfb_vrate[i].refresh);
-   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
-   break;
+   rate, XGIfb_vrate[i - 1].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx;
+   xgifb_info->refresh_rate =
+   XGIfb_vrate[i - 1].refresh;
}
+   break;
+   } else if (rate - XGIfb_vrate[i].refresh <= 2) {
+   pr_debug("Adjusting rate from %d down to %d\n",
+   rate, XGIfb_vrate[i].refresh);
+   xgifb_info->rate_idx = XGIfb_vrate[i].idx;
+   break;
}
i++;
}
+
if (xgifb_info->rate_idx > 0)
return xgifb_info->rate_idx;
pr_info("Unsupported rate %d for %dx%d\n",
-- 
2.16.2



[PATCH] Staging:Comedi:comedi_compat32.c: Lindent changes

2018-05-14 Thread Pratik Jain
Recommended indentation by Lindent on file comedi_compat32.c

Signed-off-by: Pratik Jain 
---
 drivers/staging/comedi/comedi_compat32.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/comedi_compat32.c 
b/drivers/staging/comedi/comedi_compat32.c
index 97fb9388bc22..fa9d239474ee 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -34,7 +34,7 @@
 struct comedi32_chaninfo_struct {
unsigned int subdev;
compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */
-   compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
+   compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
compat_uptr_t rangelist;/* 32-bit 'unsigned int *' */
unsigned int unused[4];
 };
@@ -57,16 +57,16 @@ struct comedi32_cmd_struct {
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
-   compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
+   compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
unsigned int chanlist_len;
-   compat_uptr_t data; /* 32-bit 'short *' */
+   compat_uptr_t data; /* 32-bit 'short *' */
unsigned int data_len;
 };
 
 struct comedi32_insn_struct {
unsigned int insn;
unsigned int n;
-   compat_uptr_t data; /* 32-bit 'unsigned int *' */
+   compat_uptr_t data; /* 32-bit 'unsigned int *' */
unsigned int subdev;
unsigned int chanspec;
unsigned int unused[3];
@@ -74,7 +74,7 @@ struct comedi32_insn_struct {
 
 struct comedi32_insnlist_struct {
unsigned int n_insns;
-   compat_uptr_t insns;/* 32-bit 'struct comedi_insn *' */
+   compat_uptr_t insns;/* 32-bit 'struct comedi_insn *' */
 };
 
 /* Handle translated ioctl. */
@@ -194,7 +194,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
err |= __put_user(temp.uint, &cmd->stop_arg);
err |= __get_user(temp.uptr, &cmd32->chanlist);
err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr),
-   &cmd->chanlist);
+ &cmd->chanlist);
err |= __get_user(temp.uint, &cmd32->chanlist_len);
err |= __put_user(temp.uint, &cmd->chanlist_len);
err |= __get_user(temp.uptr, &cmd32->data);
-- 
2.17.0



[PATCH] Staging: xgifb: XGI_main_26.c: Fixed multi-line dereference warning

2018-03-18 Thread Pratik Jain
Fixed coding style issues detected by checkpatch.pl

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..d4d289f6fe87 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -770,7 +770,9 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
xgifb_reg_and(vb->Part2Port, 0x3a, 0x1f);
 
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
-   xgifb_reg_and(vb->Part2Port, 0x30, 
0xdf);
+   xgifb_reg_and(vb->Part2Port,
+   0x30,
+   0xdf);
 
} else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) {
@@ -826,11 +828,15 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
xgifb_reg_and(vb->Part2Port, 0x3A, 0x1F);
 
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
-   xgifb_reg_and(vb->Part2Port, 0x30, 
0xDF);
+   xgifb_reg_and(vb->Part2Port,
+   0x30,
+   0xDF);
 
} else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) {
-   xgifb_reg_or(vb->Part2Port, 0x30, 0x20);
+   xgifb_reg_or(vb->Part2Port,
+   0x30,
+   0x20);
 
switch (xgifb_info->video_width) {
case 640:
@@ -1024,7 +1030,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo 
*var, int isactive,
xgifb_info->XGI310_AccelDepth = 0x0001;
 #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
-   xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 
0x0B));
+   xgifb_reg_set(vb->P3d4,
+   0x4D,
+   ((cr_data & 0xE0) | 0x0B));
 #endif
xgifb_info->video_cmap_len = 16;
break;
@@ -1034,7 +1042,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo 
*var, int isactive,
xgifb_info->video_cmap_len = 16;
 #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
-   xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 
0x15));
+   xgifb_reg_set(vb->P3d4,
+   0x4D,
+   ((cr_data & 0xE0) | 0x15));
 #endif
break;
default:
@@ -1894,7 +1904,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
xgifb_info->refresh_rate = refresh_rate;
if (xgifb_info->refresh_rate == 0)
xgifb_info->refresh_rate = 60;
-   if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 
0) {
+   if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate)
+   == 0) {
xgifb_info->rate_idx = 1;
xgifb_info->refresh_rate = 60;
}
-- 
2.16.2



[PATCH] Staging: xgifb: XGI_main_26.c: Fixed over 80 column characters

2018-03-18 Thread Pratik Jain
Fixed coding style issues detected by checkpatch.pl

Signed-off-by: Pratik Jain 
---
 drivers/staging/xgifb/XGI_main_26.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 10107de0119a..d4d289f6fe87 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -770,7 +770,9 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
xgifb_reg_and(vb->Part2Port, 0x3a, 0x1f);
 
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
-   xgifb_reg_and(vb->Part2Port, 0x30, 
0xdf);
+   xgifb_reg_and(vb->Part2Port,
+   0x30,
+   0xdf);
 
} else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) {
@@ -826,11 +828,15 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
xgifb_reg_and(vb->Part2Port, 0x3A, 0x1F);
 
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
-   xgifb_reg_and(vb->Part2Port, 0x30, 
0xDF);
+   xgifb_reg_and(vb->Part2Port,
+   0x30,
+   0xDF);
 
} else if (xgifb_info->TV_plug
== TVPLUG_COMPOSITE) {
-   xgifb_reg_or(vb->Part2Port, 0x30, 0x20);
+   xgifb_reg_or(vb->Part2Port,
+   0x30,
+   0x20);
 
switch (xgifb_info->video_width) {
case 640:
@@ -1024,7 +1030,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo 
*var, int isactive,
xgifb_info->XGI310_AccelDepth = 0x0001;
 #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
-   xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 
0x0B));
+   xgifb_reg_set(vb->P3d4,
+   0x4D,
+   ((cr_data & 0xE0) | 0x0B));
 #endif
xgifb_info->video_cmap_len = 16;
break;
@@ -1034,7 +1042,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo 
*var, int isactive,
xgifb_info->video_cmap_len = 16;
 #if defined(__BIG_ENDIAN)
cr_data = xgifb_reg_get(vb->P3d4, 0x4D);
-   xgifb_reg_set(vb->P3d4, 0x4D, ((cr_data & 0xE0) | 
0x15));
+   xgifb_reg_set(vb->P3d4,
+   0x4D,
+   ((cr_data & 0xE0) | 0x15));
 #endif
break;
default:
@@ -1894,7 +1904,8 @@ static int xgifb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
xgifb_info->refresh_rate = refresh_rate;
if (xgifb_info->refresh_rate == 0)
xgifb_info->refresh_rate = 60;
-   if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate) == 
0) {
+   if (XGIfb_search_refresh_rate(xgifb_info, xgifb_info->refresh_rate)
+   == 0) {
xgifb_info->rate_idx = 1;
xgifb_info->refresh_rate = 60;
}
-- 
2.16.2



Re: [PATCH] Staging: xgifb: XGI_main_26.c: Fixed multi-line dereference warning

2018-03-18 Thread Pratik Jain
IGNORE THIS THREAD


Re: [PATCH] Staging: xgifb: XGI_main_26.c: Fixed over 80 column characters

2018-03-18 Thread Pratik Jain
Thanks for the advice. I will work on it.


[PATCH] Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue

2018-03-15 Thread Pratik Jain
Fixed coding style issue.

Signed-off-by: Pratik Jain 
---
 drivers/staging/comedi/drivers/ni_atmio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
b/drivers/staging/comedi/drivers/ni_atmio.c
index b9e9ab548c4b..e82fbe987dd8 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -226,8 +226,8 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
isapnp_dev = pnp_find_dev(NULL,
  ISAPNP_VENDOR('N', 'I', 'C'),
- ISAPNP_FUNCTION(ni_boards[i].
- isapnp_id), NULL);
+ 
ISAPNP_FUNCTION(ni_boards[i].isapnp_id),
+ NULL);
 
if (!isapnp_dev || !isapnp_dev->card)
continue;
@@ -356,4 +356,3 @@ module_comedi_driver(ni_atmio_driver);
 MODULE_AUTHOR("Comedi http://www.comedi.org";);
 MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");
-
-- 
2.16.2



[PATCH] Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue

2018-03-15 Thread Pratik Jain
Fixed coding style issue.

Signed-off-by: Pratik Jain 
---
 drivers/staging/comedi/drivers/ni_atmio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
b/drivers/staging/comedi/drivers/ni_atmio.c
index b9e9ab548c4b..4e27a2959b64 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -226,8 +226,8 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
isapnp_dev = pnp_find_dev(NULL,
  ISAPNP_VENDOR('N', 'I', 'C'),
- ISAPNP_FUNCTION(ni_boards[i].
- isapnp_id), NULL);
+ 
ISAPNP_FUNCTION(ni_boards[i].isapnp_id),
+ NULL);
 
if (!isapnp_dev || !isapnp_dev->card)
continue;
-- 
2.16.2



Re: [PATCH] Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue

2018-03-15 Thread Pratik Jain
Resending the email because it was sent only to Greg.

Context:
In my previous patch, I had removed an extra newline
at the end of the code.

My Reply:
It was unintentional, but does it violate any coding or
other standard?






Re: [PATCH] Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue

2018-03-16 Thread Pratik Jain
Yes that can be done. But isn't 80 column limit more of a
historical convention?

On Fri, Mar 16, 2018 at 10:17:28AM +, Ian Abbott wrote:
> On 15/03/2018 18:59, Pratik Jain wrote:
> > Fixed coding style issue.
> > 
> > Signed-off-by: Pratik Jain 
> > ---
> >   drivers/staging/comedi/drivers/ni_atmio.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
> > b/drivers/staging/comedi/drivers/ni_atmio.c
> > index b9e9ab548c4b..4e27a2959b64 100644
> > --- a/drivers/staging/comedi/drivers/ni_atmio.c
> > +++ b/drivers/staging/comedi/drivers/ni_atmio.c
> > @@ -226,8 +226,8 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
> > for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
> > isapnp_dev = pnp_find_dev(NULL,
> >   ISAPNP_VENDOR('N', 'I', 'C'),
> > - ISAPNP_FUNCTION(ni_boards[i].
> > - isapnp_id), NULL);
> > + 
> > ISAPNP_FUNCTION(ni_boards[i].isapnp_id),
> > + NULL);
> > if (!isapnp_dev || !isapnp_dev->card)
> > continue;
> > 
> 
> I suggest splitting the expression just after the '=' to avoid going over 80
> columns.
> 
> -- 
> -=( Ian Abbott @ MEV Ltd.E-mail:  )=-
> -=(  Web: http://www.mev.co.uk/  )=-


[PATCH] Staging: comedi: drivers: ni_atmio.c: fixed multi-line derefernce issue

2018-03-16 Thread Pratik Jain
Fixed coding style issue.

Signed-off-by: Pratik Jain 
---
 drivers/staging/comedi/drivers/ni_atmio.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
b/drivers/staging/comedi/drivers/ni_atmio.c
index b9e9ab548c4b..2b7bfe0dd7f3 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -224,10 +224,11 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
int i;
 
for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
-   isapnp_dev = pnp_find_dev(NULL,
- ISAPNP_VENDOR('N', 'I', 'C'),
- ISAPNP_FUNCTION(ni_boards[i].
- isapnp_id), NULL);
+   isapnp_dev =
+   pnp_find_dev(NULL,
+ISAPNP_VENDOR('N', 'I', 'C'),
+ISAPNP_FUNCTION(ni_boards[i].isapnp_id),
+NULL);
 
if (!isapnp_dev || !isapnp_dev->card)
continue;
-- 
2.16.2