[PATCH] staging: pi433: add dependency to PA0, 1, 2 setting for output power level

2019-04-09 Thread Sidong Yang
When setting output power level called, the power level should be
checked by power amplifier level register and high power option. There
was todo about it. Add some variables for checking power level range.
The values that used for checking high power or minimum power are from
rf69 datasheets. The maximum power level is always same regardless of
mode.

Signed-off-by: Sidong Yang 
---
 drivers/staging/pi433/rf69.c | 45 ++--
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 340ffa7ccf18..4cd16257f0aa 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -349,18 +349,51 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask)
 
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level)
 {
-   // TODO: Dependency to PA0,1,2 setting
-   power_level += 18;
+   u8 pa_level, ocp, test_pa1, test_pa2;
+   bool pa0, pa1, pa2, high_power;
+   u8 min_power_level;
+
+   // check register pa_level
+   pa_level = rf69_read_reg(spi, REG_PALEVEL);
+   pa0 = pa_level & MASK_PALEVEL_PA0;
+   pa1 = pa_level & MASK_PALEVEL_PA1;
+   pa2 = pa_level & MASK_PALEVEL_PA2;
+
+   // check high power mode
+   ocp = rf69_read_reg(spi, REG_OCP);
+   test_pa1 = rf69_read_reg(spi, REG_TESTPA1);
+   test_pa2 = rf69_read_reg(spi, REG_TESTPA2);
+   high_power = (ocp == 0x0f) && (test_pa1 == 0x5d) && (test_pa2 == 0x7c);
+
+   if (pa0 && !pa1 && !pa2) {
+   power_level += 18;
+   min_power_level = 0;
+   } else if (!pa0 && pa1 && !pa2) {
+   power_level += 18;
+   min_power_level = 16;
+   } else if (!pa0 && pa1 && pa2) {
+   if (high_power)
+   power_level += 11;
+   else
+   power_level += 14;
+   min_power_level = 16;
+   } else {
+   goto failed;
+   }
 
// check input value
-   if (power_level > 0x1f) {
-   dev_dbg(>dev, "set: illegal input param");
-   return -EINVAL;
-   }
+   if (power_level > 0x1f)
+   goto failed;
+
+   if (power_level < min_power_level)
+   goto failed;
 
// write value
return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER,
   power_level);
+failed:
+   dev_dbg(>dev, "set: illegal input param");
+   return -EINVAL;
 }
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
-- 
2.11.0

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


[PATCH] staging: pi433: Return thread immediately when kthread_should_stop() call.

2019-04-02 Thread Sidong Yang
When kthread_stop() called by removing module, running thread should
return immediately. Otherwise, It is very dangerous that thread may access
any released data like struct pi433_device.

Signed-off-by: Sidong Yang 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ab90d6f80931..16dc380eb176 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -736,7 +736,7 @@ pi433_tx_thread(void *data)
 device->free_in_fifo == FIFO_SIZE ||
 kthread_should_stop());
if (kthread_should_stop())
-   dev_dbg(device->dev, "ABORT\n");
+   return 0;
 
/* STOP_TRANSMISSION */
dev_dbg(device->dev, "thread: Packet sent. Set mode to stby.");
-- 
2.11.0

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


[PATCH v2] staging: pi433: Fix rf69_set_tx_cfg() logic

2019-03-28 Thread Sidong Yang
Moved code to configure sync to where check enable_sync option before.
There is no need to check enable_sync twice. Configuring sync should be
executed immediately after enabling sync.

Signed-off-by: Sidong Yang 
---
v2: remove obvious comment. reordered size/value/enable sync functions.

 drivers/staging/pi433/pi433_if.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 53928af696a6..8fa7b3346170 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -319,6 +319,12 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
}
 
if (tx_cfg->enable_sync == OPTION_ON) {
+   ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern);
+   if (ret < 0)
+   return ret;
ret = rf69_enable_sync(dev->spi);
if (ret < 0)
return ret;
@@ -348,16 +354,6 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
return ret;
}
 
-   /* configure sync, if enabled */
-   if (tx_cfg->enable_sync == OPTION_ON) {
-   ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length);
-   if (ret < 0)
-   return ret;
-   ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern);
-   if (ret < 0)
-   return ret;
-   }
-
return 0;
 }
 
-- 
2.17.1

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


[PATCH] staging: pi433: Fix rf69_set_tx_cfg() logic

2019-03-27 Thread Sidong Yang
Moved code to configure sync to where check enable_sync option before.
There is no need to check enable_sync twice. Configuring sync should be
executed immediately after enabling sync.

Signed-off-by: Sidong Yang 
---
 drivers/staging/pi433/pi433_if.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 53928af696a6..0a48d6cb9547 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -318,10 +318,17 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
return ret;
}
 
+   /* configure sync, if enabled */
if (tx_cfg->enable_sync == OPTION_ON) {
ret = rf69_enable_sync(dev->spi);
if (ret < 0)
return ret;
+   ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern);
+   if (ret < 0)
+   return ret;
} else {
ret = rf69_disable_sync(dev->spi);
if (ret < 0)
@@ -348,16 +355,6 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
return ret;
}
 
-   /* configure sync, if enabled */
-   if (tx_cfg->enable_sync == OPTION_ON) {
-   ret = rf69_set_sync_size(dev->spi, tx_cfg->sync_length);
-   if (ret < 0)
-   return ret;
-   ret = rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern);
-   if (ret < 0)
-   return ret;
-   }
-
return 0;
 }
 
-- 
2.17.1

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


[PATCH] staging: pi433: remove unnecessary calling rf69_set_mode()

2019-03-24 Thread Sidong Yang
Remove unnecessary rf69_set_mode() function call when rx is waiting for
a telegram. There is waste to call rf69_set_mode() twice for becoming
standby mode.

Signed-off-by: Sidong Yang 
---
 drivers/staging/pi433/pi433_if.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 53928af696a6..e822f87fc533 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -650,21 +650,19 @@ pi433_tx_thread(void *data)
disable_irq(device->irq_num[DIO0]);
device->tx_active = true;
 
+   /* clear fifo, set fifo threshold, set payload length */
+   retval = rf69_set_mode(spi, standby); /* this clears the fifo */
+   if (retval < 0)
+   return retval;
+
if (device->rx_active && !rx_interrupted) {
/*
 * rx is currently waiting for a telegram;
 * we need to set the radio module to standby
 */
-   retval = rf69_set_mode(device->spi, standby);
-   if (retval < 0)
-   return retval;
rx_interrupted = true;
}
 
-   /* clear fifo, set fifo threshold, set payload length */
-   retval = rf69_set_mode(spi, standby); /* this clears the fifo */
-   if (retval < 0)
-   return retval;
retval = rf69_set_fifo_threshold(spi, FIFO_THRESHOLD);
if (retval < 0)
return retval;
-- 
2.11.0

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


[PATCH] staging: vboxvideo: fix vbox_dumb_create fail logic

2019-03-14 Thread Sidong Yang
In function vbox_dumb_create() of vbox_main.c, It calls vbox_gem_create()
for creating drm_gem_object. and it calls  vbox_gem_handle_create() for handle.
If handle creation fails only, drm_gem_object should be released by calling
drm_gem_object_put_unlocked().

Signed-off-by: Sidong Yang 
---
 drivers/staging/vboxvideo/vbox_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index e1fb70a42d32..ca676ba37bb4 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -312,9 +312,10 @@ int vbox_dumb_create(struct drm_file *file,
return ret;
 
ret = drm_gem_handle_create(file, gobj, );
-   drm_gem_object_put_unlocked(gobj);
-   if (ret)
+   if (ret) {
+   drm_gem_object_put_unlocked(gobj);
return ret;
+   }
 
args->handle = handle;
 
-- 
2.11.0

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


[PATCH] staging: rtl8192u: Add required spaces before open parenthesis

2019-03-12 Thread Sidong Yang
Fix error reported by checkpatch.pl

Signed-off-by: Sidong Yang 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  | 22 +++
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c| 68 +++---
 2 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 024fa2702546..ea9c69eeceae 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -318,17 +318,17 @@ static void ieee80211_tx_query_agg_cap(struct 
ieee80211_device *ieee,
return;
//check packet and mode later
 #ifdef TO_DO_LIST
-   if(pTcb->PacketLength >= 4096)
+   if (pTcb->PacketLength >= 4096)
return;
// For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation.
-   if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
+   if (!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
return;
 #endif
-   if(!ieee->GetNmodeSupportBySecCfg(ieee->dev))
+   if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
{
return;
}
-   if(pHTInfo->bCurrentAMPDUEnable)
+   if (pHTInfo->bCurrentAMPDUEnable)
{
if (!GetTs(ieee, (struct ts_common_info **)(), 
hdr->addr1, skb->priority, TX_DIR, true))
{
@@ -398,18 +398,18 @@ ieee80211_query_HTCapShortGI(struct ieee80211_device 
*ieee, struct cb_desc *tcb_
 
tcb_desc->bUseShortGI   = false;
 
-   if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
+   if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
return;
 
-   if(pHTInfo->bForcedShortGI)
+   if (pHTInfo->bForcedShortGI)
{
tcb_desc->bUseShortGI = true;
return;
}
 
-   if((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz)
+   if ((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz)
tcb_desc->bUseShortGI = true;
-   else if((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz)
+   else if ((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz)
tcb_desc->bUseShortGI = true;
 }
 
@@ -420,13 +420,13 @@ static void ieee80211_query_BandwidthMode(struct 
ieee80211_device *ieee,
 
tcb_desc->bPacketBW = false;
 
-   if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
+   if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
return;
 
-   if(tcb_desc->bMulticast || tcb_desc->bBroadcast)
+   if (tcb_desc->bMulticast || tcb_desc->bBroadcast)
return;
 
-   if((tcb_desc->data_rate & 0x80)==0) // If using legacy rate, it shall 
use 20MHz channel.
+   if ((tcb_desc->data_rate & 0x80)==0) // If using legacy rate, it shall 
use 20MHz channel.
return;
//BandWidthAutoSwitch is for auto switch to 20 or 40 in long distance
if(pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && 
!ieee->bandwidth_auto_switch.bforced_tx20Mhz)
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 0368e5e3e95d..4bb6c32b9bf0 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -37,18 +37,18 @@ static void RxPktPendingTimeout(struct timer_list *t)
 
spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
IEEE80211_DEBUG(IEEE80211_DL_REORDER, "==>%s()\n", 
__func__);
-   if(pRxTs->rx_timeout_indicate_seq != 0x) {
+   if (pRxTs->rx_timeout_indicate_seq != 0x) {
// Indicate the pending packets sequentially according to 
SeqNum until meet the gap.
-   while(!list_empty(>rx_pending_pkt_list)) {
+   while (!list_empty(>rx_pending_pkt_list)) {
pReorderEntry = 
list_entry(pRxTs->rx_pending_pkt_list.prev, struct rx_reorder_entry, List);
-   if(index == 0)
+   if (index == 0)
pRxTs->rx_indicate_seq = pReorderEntry->SeqNum;
 
-   if( SN_LESS(pReorderEntry->SeqNum, 
pRxTs->rx_indicate_seq) ||
-   SN_EQUAL(pReorderEntry->SeqNum, 
pRxTs->rx_indicate_seq) ) {
+   if (SN_LESS(pReorderEntry->SeqNum, 
pRxTs->rx_indicate_seq) ||
+   SN_EQUAL(pReorderEntry->SeqNum, 
pRxTs->rx_indicate_seq)) {
list_del_init(>List);
 
-   if(SN_EQUAL(pReorderEntry->SeqNum, 
pRxTs-

Re: [PATCH] staging: vboxvideo: vbox_main: Remove unnecessary local variable

2019-01-10 Thread Sidong Yang
On Thu, Jan 10, 2019 at 10:44:08PM +0300, Dan Carpenter wrote:
> On Thu, Jan 10, 2019 at 05:00:24PM +0000, Sidong Yang wrote:
> > I think you just point out that my code isn't obvious because the
> > function returns negative error codes. I agree with you. But what if
> > change my code like if(hgsmi_query_conf() != 0). 
> > 
> 
> That's even worse!  :P
> 
> You should do comparisons with zero when you are talking about zero
> meaning the number zero.  In this case, hgsmi_query_conf() returns "zezro
> meaning success" not "zero meaning the number zero".  How many bytes?
> Zero.  That is the number zero.
> 
> != zero is a double negative, because NOT and ZERO are negatives.  If
> double negatives simplified the code we would add four of them instead
> of just the one:
> 
>   if hgsmi_query_conf() != 0) != 0) != 0) != 0) {
> 
> See?  Adding != 0 doesn't make it simpler...
> 
> The other place where != 0 is appropriate besides talking about the
> number is when you're using a strcmp() function because it works like
> this:
> 
>   if (strcmp(a, b) < 0) {  <-- means a < b
>   if (strcmp(a, b) == 0) { <-- means a == b
>   if (strcmp(a, b) != 0) { <-- means a != b
> 
> regards,
> dan carpenter
> 

You're right. that is even worse. I understand and thank you for pointing out.

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


Re: [PATCH] staging: vboxvideo: vbox_main: Remove unnecessary local variable

2019-01-10 Thread Sidong Yang
On Thu, Jan 10, 2019 at 03:23:58PM +0300, Dan Carpenter wrote:
> On Thu, Jan 10, 2019 at 06:13:47AM +0000, Sidong Yang wrote:
> > Removed unnecessary local variable in have_hgsmi_mode_hints.
> > The result of hgsmi_query_conf should be directly compared without
> > assigning to local variable.
> > 
> > Signed-off-by: Sidong Yang 
> > ---
> 
> I sort of prefer the original...
> 
> The hgsmi_query_conf() function returns negative error codes if it
> can't complete the query because of allocation failures.  To me that's
> more obvious, when we write it in the original way.
> 
> In the new code it looks like it returns bool or something.  The
> copy_to/from_user() are normally written like if (copy_to_user()) {
> but those don't return negative error codes so it's a different
> situation.
> 

Hi, Dan.

I think you just point out that my code isn't obvious because the
function returns negative error codes. I agree with you. But what if
change my code like if(hgsmi_query_conf() != 0). 

> This isn't something in checkpatch or CodingStyle so there isn't a
> standard.  It's just personal opinion vs personal opinion.  If you were
> going to do a lot of vboxvideo development, then it would be your
> opinion which matters the most because you are doing the work.  But
> this is your first vboxvideo patch...
> 
> Let's just leave it as-is.

I agree with this comment. I'm just a newbie for this module and It
isn't about checkpatch or CodingStyle. but I just wondered if my code
has problem.

regards,
Sidong Yang

> 
> regards,
> dan carpenter
> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vboxvideo: vbox_main: Remove unnecessary local variable

2019-01-09 Thread Sidong Yang
Removed unnecessary local variable in have_hgsmi_mode_hints.
The result of hgsmi_query_conf should be directly compared without
assigning to local variable.

Signed-off-by: Sidong Yang 
---
 drivers/staging/vboxvideo/vbox_main.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index e1fb70a42d32..62a69fde7435 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -170,18 +170,15 @@ static void vbox_accel_fini(struct vbox_private *vbox)
 static bool have_hgsmi_mode_hints(struct vbox_private *vbox)
 {
u32 have_hints, have_cursor;
-   int ret;
 
-   ret = hgsmi_query_conf(vbox->guest_pool,
-  VBOX_VBVA_CONF32_MODE_HINT_REPORTING,
-  _hints);
-   if (ret)
+   if (hgsmi_query_conf(vbox->guest_pool,
+VBOX_VBVA_CONF32_MODE_HINT_REPORTING,
+_hints))
return false;
 
-   ret = hgsmi_query_conf(vbox->guest_pool,
-  VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING,
-  _cursor);
-   if (ret)
+   if (hgsmi_query_conf(vbox->guest_pool,
+VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING,
+_cursor))
return false;
 
return have_hints == VINF_SUCCESS && have_cursor == VINF_SUCCESS;
-- 
2.17.1

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


[PATCH v2] staging: erofs: Add identifier for function definition arguments

2019-01-08 Thread Sidong Yang
Add identifier for function definition arguments in xattr_iter_handlers,
this change clears the checkpatch.pl issue and make code more explicit.

Signed-off-by: Sidong Yang 
---
 drivers/staging/erofs/xattr.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 80dca6a4adbe..59bc5641c4e7 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -117,10 +117,12 @@ static int init_inode_xattrs(struct inode *inode)
  *and need to be handled
  */
 struct xattr_iter_handlers {
-   int (*entry)(struct xattr_iter *, struct erofs_xattr_entry *);
-   int (*name)(struct xattr_iter *, unsigned int, char *, unsigned int);
-   int (*alloc_buffer)(struct xattr_iter *, unsigned int);
-   void (*value)(struct xattr_iter *, unsigned int, char *, unsigned int);
+   int (*entry)(struct xattr_iter *_it, struct erofs_xattr_entry *entry);
+   int (*name)(struct xattr_iter *_it, unsigned int processed, char *buf,
+   unsigned int len);
+   int (*alloc_buffer)(struct xattr_iter *_it, unsigned int value_sz);
+   void (*value)(struct xattr_iter *_it, unsigned int processed, char *buf,
+ unsigned int len);
 };
 
 static inline int xattr_iter_fixup(struct xattr_iter *it)
-- 
2.17.1

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


[PATCH] staging: most: replace function name to __func__

2018-01-21 Thread Sidong Yang
Fix checkpatch.pl warning message about logging code. Previous code
contains hard coded function name. Fix this code by using __func__
macro.

Signed-off-by: Sidong Yang <realwa...@gmail.com>
---
 drivers/staging/most/dim2/dim2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index 21e3fb48bdb4..f9bc7dea75b8 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -151,7 +151,7 @@ void dimcb_io_write(u32 __iomem *ptr32, u32 value)
  */
 void dimcb_on_error(u8 error_id, const char *error_message)
 {
-   pr_err("dimcb_on_error: error_id - %d, error_message - %s\n", error_id,
+   pr_err("%s: error_id - %d, error_message - %s\n", __func__, error_id,
   error_message);
 }
 
-- 
2.11.0

Greg, 

You're right that other source with tracing code should be removed.
I sended my patch that only contains replace function name in 'pr_err'.

Thanks.

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


[PATCH] staging: most: replace function name to __func__

2018-01-16 Thread Sidong Yang
Fix checkpatch.pl warning message about logging code. Previous code
contains hard coded function name. Fix this code by using __func__
macro.

Signed-off-by: Sidong Yang <realwa...@gmail.com>
---
 drivers/staging/most/dim2/dim2.c   |  2 +-
 drivers/staging/most/video/video.c | 24 
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index 21e3fb48bdb4..f9bc7dea75b8 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -151,7 +151,7 @@ void dimcb_io_write(u32 __iomem *ptr32, u32 value)
  */
 void dimcb_on_error(u8 error_id, const char *error_message)
 {
-   pr_err("dimcb_on_error: error_id - %d, error_message - %s\n", error_id,
+   pr_err("%s: error_id - %d, error_message - %s\n", __func__, error_id,
   error_message);
 }
 
diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index 098873851646..22d9b1fc622f 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -73,7 +73,7 @@ static int comp_vdev_open(struct file *filp)
struct most_video_dev *mdev = video_drvdata(filp);
struct comp_fh *fh;
 
-   v4l2_info(>v4l2_dev, "comp_vdev_open()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
@@ -122,7 +122,7 @@ static int comp_vdev_close(struct file *filp)
struct most_video_dev *mdev = fh->mdev;
struct mbo *mbo, *tmp;
 
-   v4l2_info(>v4l2_dev, "comp_vdev_close()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
/*
 * We need to put MBOs back before we call most_stop_channel()
@@ -250,7 +250,7 @@ static int vidioc_querycap(struct file *file, void *priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_querycap()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
strlcpy(cap->driver, "v4l2_component", sizeof(cap->driver));
strlcpy(cap->card, "MOST", sizeof(cap->card));
@@ -270,7 +270,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void 
*priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_enum_fmt_vid_cap() %d\n", f->index);
+   v4l2_info(>v4l2_dev, "%s() %d\n", __func__, f->index);
 
if (f->index)
return -EINVAL;
@@ -289,7 +289,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_g_fmt_vid_cap()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
comp_set_format_struct(f);
return 0;
@@ -318,7 +318,7 @@ static int vidioc_g_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_g_std()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
*norm = V4L2_STD_UNKNOWN;
return 0;
@@ -355,7 +355,7 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int index)
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_s_input(%d)\n", index);
+   v4l2_info(>v4l2_dev, "%s(%d)\n", __func__, index);
 
if (index >= V4L2_CMP_MAX_INPUT)
return -EINVAL;
@@ -435,7 +435,7 @@ static int comp_register_videodev(struct most_video_dev 
*mdev)
 {
int ret;
 
-   v4l2_info(>v4l2_dev, "comp_register_videodev()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
init_waitqueue_head(>wait_data);
 
@@ -465,7 +465,7 @@ static int comp_register_videodev(struct most_video_dev 
*mdev)
 
 static void comp_unregister_videodev(struct most_video_dev *mdev)
 {
-   v4l2_info(>v4l2_dev, "comp_unregister_videodev()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
video_unregister_device(mdev->vdev);
 }
@@ -485,7 +485,7 @@ static int comp_probe_channel(struct most_interface *iface, 
int channel_idx,
int ret;
struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
 
-   pr_info("comp_probe_channel(%s)\n", name);
+   pr_info("%s(%s)\n", __func__, name);
 
if (mdev) {
pr_err("channel already linked\n");
@@ -531,7 +531,7 @@ static int comp_probe_channel(struct most_interface *iface, 
int channel_idx,
spin_lock_irq(_lock);
lis

Re: Re: [PATCH] staging: vc04_services: Fix checkpatch.pl warnings

2018-01-14 Thread Sidong Yang
Hi Stefan,

I'm really glad to review my commit!

I think that your suggestion that changes subject is good.

> i'm okay with the changes, but the subject is too general. We get fixes for 
> checkpach warning nearly once a week. Suggestion:
> 
> staging: vchiq_version: Use tabs for identation
> 
> In case there are more files in vc04_services affected by this particular 
> issue, you are invited to fix them, too.

It's okay to keep working about issue like this? or is there other way to work 
with others?

I'm newbie and don't know how to contribute to linux.

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


[PATCH] staging: vc04_services: Fix checkpatch.pl warnings

2018-01-14 Thread Sidong Yang
Replace spaces to tabs for indents in beginning of statements.

Signed-off-by: Sidong Yang <realwa...@gmail.com>
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c
index 994b81798134..65b2b9966695 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c
@@ -40,20 +40,20 @@ VC_DEBUG_DECLARE_STRING_VAR(vchiq_build_date,__DATE__);
 
 const char *vchiq_get_build_hostname(void)
 {
-   return vchiq_build_hostname;
+   return vchiq_build_hostname;
 }
 
 const char *vchiq_get_build_version(void)
 {
-   return vchiq_build_version;
+   return vchiq_build_version;
 }
 
 const char *vchiq_get_build_date(void)
 {
-   return vchiq_build_date;
+   return vchiq_build_date;
 }
 
 const char *vchiq_get_build_time(void)
 {
-   return vchiq_build_time;
+   return vchiq_build_time;
 }
-- 
2.11.0

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


[PATCH] staging: vc05_services: fix checkpatch.pl errors

2017-12-25 Thread Sidong Yang
Fix some errors for wrong brace position reported by checkpatch.

Signed-off-by: Sidong Yang <realwa...@gmail.com>
---
 .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c   |  3 +--
 .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c| 12 
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 315b49c1de3b..edff4fb99781 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -485,8 +485,7 @@ create_pagelist(char __user *buf, size_t count, unsigned 
short type)
   __func__, actual_pages, num_pages);
 
/* This is probably due to the process being killed */
-   while (actual_pages > 0)
-   {
+   while (actual_pages > 0) {
actual_pages--;
put_page(pages[actual_pages]);
}
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 411539f8ff8c..c2c440009cac 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -682,8 +682,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
if (user_service->close_pending &&
down_interruptible(_service->close_event))
status = VCHIQ_RETRY;
-   }
-   else
+   } else
ret = -EINVAL;
} break;
 
@@ -708,8 +707,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
if (user_service->close_pending &&
down_interruptible(_service->close_event))
status = VCHIQ_RETRY;
-   }
-   else
+   } else
ret = -EINVAL;
} break;
 
@@ -1171,8 +1169,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
close_delivered(user_service);
-   }
-   else
+   } else
ret = -EINVAL;
} break;
 
@@ -1810,8 +1807,7 @@ vchiq_release(struct inode *inode, struct file *file)
instance->completion_remove &
(MAX_COMPLETIONS - 1)];
service = completion->service_userdata;
-   if (completion->reason == VCHIQ_SERVICE_CLOSED)
-   {
+   if (completion->reason == VCHIQ_SERVICE_CLOSED) {
USER_SERVICE_T *user_service =
service->base.userdata;
 
-- 
2.11.0

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