[Outreachy kernel] [PATCH v2] Staging: rtl8188eu: hal: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~staging$ git diff -w drivers/staging/rtl8188eu/hal/ shreeya@Shreeya-Patel:~staging$ shreeya@Shreeya-Patel:~staging/drivers/staging/rtl8188eu/hal$ find . -name "*_old.o" -exec sh -c 'old=$0; new=$(echo $old | sed s/_old.o/.o/); diff $old $new' {} \; shreeya@Shreeya-Patel:~staging/drivers/staging/rtl8188eu/hal$ Changes in v2: - Merge the patch series into a single patch drivers/staging/rtl8188eu/hal/hal_com.c | 22 +-- drivers/staging/rtl8188eu/hal/odm.c | 48 +++--- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 54 +++ drivers/staging/rtl8188eu/hal/phy.c | 138 +- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- drivers/staging/rtl8188eu/hal/rf.c| 60 drivers/staging/rtl8188eu/hal/rf_cfg.c| 4 +- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 42 +++--- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 44 +++--- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- .../staging/rtl8188eu/hal/rtl8188eu_xmit.c| 32 ++-- 11 files changed, 224 insertions(+), 224 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index 95f1b1431373..ebe19e076ff2 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -18,26 +18,26 @@ void dump_chip_info(struct HAL_VERSION chip_vers) uint cnt = 0; char buf[128]; - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); + cnt += sprintf((buf + cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? + cnt += sprintf((buf + cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? "TSMC" : "UMC"); if (chip_vers.CUTVersion == A_CUT_VERSION) - cnt += sprintf((buf+cnt), "A_CUT_"); + cnt += sprintf((buf + cnt), "A_CUT_"); else if (chip_vers.CUTVersion == B_CUT_VERSION) - cnt += sprintf((buf+cnt), "B_CUT_"); + cnt += sprintf((buf + cnt), "B_CUT_"); else if (chip_vers.CUTVersion == C_CUT_VERSION) - cnt += sprintf((buf+cnt), "C_CUT_"); + cnt += sprintf((buf + cnt), "C_CUT_"); else if (chip_vers.CUTVersion == D_CUT_VERSION) - cnt += sprintf((buf+cnt), "D_CUT_"); + cnt += sprintf((buf + cnt), "D_CUT_"); else if (chip_vers.CUTVersion == E_CUT_VERSION) - cnt += sprintf((buf+cnt), "E_CUT_"); + cnt += sprintf((buf + cnt), "E_CUT_"); else - cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion); - cnt += sprintf((buf+cnt), "1T1R_"); - cnt += sprintf((buf+cnt), "RomVer(0)\n"); + cnt += sprintf((buf + cnt), "1T1R_"); + cnt += sprintf((buf + cnt), "RomVer(0)\n"); pr_info("%s", buf); } diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 7489491f5aaa..a6eb9798b6f8 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -342,7 +342,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) u8 CurrentIGI = pDM_DigTable->CurIGValue; ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); - if ((!(pDM_Odm->SupportAbility_BB_DIG)) || (!(pDM_Odm->SupportAbility_BB_FA_CNT))) { + if ((!(pDM_Odm->SupportAbility & ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); return; @@ -419,7 +419,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } if (pDM_DigTable->LargeFAHit >= 3) { - if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max)
Re: [Outreachy kernel] [PATCH 01/11] Staging: rtl8188eu: hal_com: Add space around operators
On Mon, 2020-03-23 at 02:04 +0100, Stefano Brivio wrote: > Hi Shreeya, > > On Mon, 23 Mar 2020 04:48:08 +0530 > Shreeya Patel wrote: > > > On Sun, 2020-03-22 at 08:09 -0700, Joe Perches wrote: > > > On Sun, 2020-03-22 at 12:27 +0100, Greg KH wrote: > > > > Hi Greg and Joe, > > > > > > On Sun, Mar 22, 2020 at 03:51:13AM +0530, Shreeya Patel > > > > wrote: > > > > > Add space around operators for improving the code > > > > > readability. > > > > > Reported by checkpatch.pl > > > > > > > > > > git diff -w shows no difference. > > > > > diff of the .o files before and after the changes shows no > > > > > difference. > > > > > > > > There is no need to have these two lines on every changelog > > > > comment > > > > in > > > > this series :( > > > > > > > > > > Yes I get that. > > > > > In my opinion, there's no need for a series here. > > > > > > Whitespace only changes _should_ be done all at once. > > > > > > Whitespace changes _could_ have changed string constants. > > > > > > So noting that the patch in only whitespace and that > > > there isn't a difference in object files is useful as > > > it shows any change has been compiled and tested. > > > > > > > Joe, I feel the same thing, there is no need of a patch series > > for it but I was given a suggestion that it becomes difficult for > > the > > reviewers to review the patch so it is good to send a patchset > > instead. > > In this case, reviewing the 224 lines you're touching in one shot > feels > the same as reviewing them over 11 patches, as the change is always > of > the same type. Maybe a single patch is actually even a bit quicker to > review. > > Are you sure the suggestion was referring to this, and it wasn't > about > different type of changes in the same patch? > Yes I am sure about it. But anyway I will send a single patch for these changes now. Thanks Stefano :) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH 01/11] Staging: rtl8188eu: hal_com: Add space around operators
On Sun, 2020-03-22 at 08:09 -0700, Joe Perches wrote: > On Sun, 2020-03-22 at 12:27 +0100, Greg KH wrote: Hi Greg and Joe, > > On Sun, Mar 22, 2020 at 03:51:13AM +0530, Shreeya Patel wrote: > > > Add space around operators for improving the code > > > readability. > > > Reported by checkpatch.pl > > > > > > git diff -w shows no difference. > > > diff of the .o files before and after the changes shows no > > > difference. > > > > There is no need to have these two lines on every changelog comment > > in > > this series :( > Yes I get that. > In my opinion, there's no need for a series here. > > Whitespace only changes _should_ be done all at once. > > Whitespace changes _could_ have changed string constants. > > So noting that the patch in only whitespace and that > there isn't a difference in object files is useful as > it shows any change has been compiled and tested. > Joe, I feel the same thing, there is no need of a patch series for it but I was given a suggestion that it becomes difficult for the reviewers to review the patch so it is good to send a patchset instead. But as you said, we are testing that there is no change in the object file so we can go ahead with a single patch for all the whitespace changes. If you feel this is right then can I go ahead and send a single patch for it? ( need your or Greg's confirmation before I do it ) Thanks > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 11/11] Staging: rtl8188eu: rtl8188eu_xmit: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188eu_xmit_old.o rtl8188eu_xmit.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ .../staging/rtl8188eu/hal/rtl8188eu_xmit.c| 32 +-- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 2808f2b119bf..7d315bd438d4 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -58,12 +58,12 @@ void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u /* offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff); /* 32 bytes for TX Desc */ - ptxdesc->txdw0 |= cpu_to_le32(BufferLen&0x); /* Buffer size + command header */ + ptxdesc->txdw0 |= cpu_to_le32(BufferLen & 0x); /* Buffer size + command header */ /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32((QSLT_MGNT << QSEL_SHT) & 0x1f00); /* Fixed queue of Mgnt queue */ /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ if (ispspoll) { @@ -91,16 +91,16 @@ static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxd /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ case _WEP40_: case _WEP104_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _TKIP_: case _TKIP_WTMIC_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _AES_: - ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw1 |= cpu_to_le32((0x03 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _NO_PRIVACY_: @@ -127,7 +127,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) *pdw |= cpu_to_le32(HW_RTS_EN); /* Set RTS BW */ if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << 28) & 0x3000); @@ -144,7 +144,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) { if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f); @@ -171,7 +171,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { - ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); + ptxdesc = (struct tx_desc *)(pmem + PACKET_OFFSET_SZ); pull = 1; } } @@ -263,11 +263,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); } - } else if ((pxmitframe->frame_
[Outreachy kernel] [PATCH 10/11] Staging: rtl8188eu: rtl8188e_rxdesc: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_rxdesc_old.o rtl8188e_rxdesc.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index 0a900827c4fc..7d0135fde795 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -182,7 +182,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, rtl8188e_process_phy_info(padapter, precvframe); } } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { - if (check_fwstate(>mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(>mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta) precvframe->psta = psta; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 09/11] Staging: rtl8188eu: rtl8188e_hal_init: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_hal_init_old.o rtl8188e_hal_init.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 44 +-- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 57ae0e83dd3e..740004d71a15 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -22,7 +22,7 @@ void iol_mode_enable(struct adapter *padapter, u8 enable) if (enable) { /* Enable initial offload */ reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); - usb_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + usb_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN); if (!padapter->bFWReady) { DBG_88E("bFWReady == false call reset 8051...\n"); @@ -42,9 +42,9 @@ s32 iol_execute(struct adapter *padapter, u8 control) u8 reg_0x88 = 0; unsigned long start = 0; - control = control&0x0f; + control = control & 0x0f; reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); - usb_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + usb_write8(padapter, REG_HMEBOX_E0, reg_0x88 | control); start = jiffies; while ((reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0)) & control && @@ -54,7 +54,7 @@ s32 iol_execute(struct adapter *padapter, u8 control) reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); status = (reg_0x88 & control) ? _FAIL : _SUCCESS; - if (reg_0x88 & control<<4) + if (reg_0x88 & control << 4) status = _FAIL; return status; } @@ -64,7 +64,7 @@ static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) s32 rst = _SUCCESS; iol_mode_enable(padapter, 1); - usb_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + usb_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); rst = iol_execute(padapter, CMD_INIT_LLT); iol_mode_enable(padapter, 0); return rst; @@ -92,9 +92,9 @@ void _8051Reset88E(struct adapter *padapter) { u8 u1bTmp; - u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN+1); - usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT(2))); - usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT(2))); + u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN + 1); + usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & (~BIT(2))); + usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp | (BIT(2))); DBG_88E("=> _8051Reset88E(): 8051 reset success .\n"); } @@ -122,7 +122,7 @@ void rtw_hal_read_chip_version(struct adapter *padapter) value32 = usb_read32(padapter, REG_SYS_CFG); ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); - ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ dump_chip_info(ChipVersion); @@ -163,10 +163,10 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable) { if (enable) { DBG_88E("Enable notch filter\n"); - usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) | BIT(1)); + usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); } else { DBG_88E("Disable notch filter\n"); - usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) & ~BIT(1)); + usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); } } @@ -308,7 +308,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + for (group = 0; group < MAX_CHNL_GROUP_24G - 1;
[Outreachy kernel] [PATCH 08/11] Staging: rtl8188eu: rtl8188e_cmd: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_cmd_old.o rtl8188e_cmd.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 42 ++-- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index 7646167a0b36..371e746915dd 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -113,24 +113,24 @@ void rtw_hal_add_ra_tid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_le struct odm_dm_struct *odmpriv = >HalData->odmpriv; u8 macid, init_rate, raid, shortGIrate = false; - macid = arg&0x1f; + macid = arg & 0x1f; - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fff; if (rssi_level != DM_RATR_STA_INIT) bitmap = ODM_Get_Rate_Bitmap(odmpriv, macid, bitmap, rssi_level); - bitmap |= ((raid<<28)&0xf000); + bitmap |= ((raid << 28) & 0xf000); - init_rate = get_highest_rate_idx(bitmap&0x0fff)&0x3f; + init_rate = get_highest_rate_idx(bitmap & 0x0fff) & 0x3f; shortGIrate = (arg & BIT(5)) ? true : false; if (shortGIrate) init_rate |= BIT(6); - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fff; @@ -172,7 +172,7 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) break; } - H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); + H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps << 4) & 0xf0) | (RLBM & 0x0f)); H2CSetPwrMode.AwakeInterval = 1; @@ -239,9 +239,9 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) pframe += 2; pktlen += 2; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { pktlen += cur_network->ie_length - sizeof(struct ndis_802_11_fixed_ie); - memcpy(pframe, cur_network->ies+sizeof(struct ndis_802_11_fixed_ie), pktlen); + memcpy(pframe, cur_network->ies + sizeof(struct ndis_802_11_fixed_ie), pktlen); goto _ConstructBeacon; } @@ -258,7 +258,7 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), ); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ ATIMWindow = 0; @@ -473,7 +473,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (2) ps-poll *1 page */ RsvdPageLoc.LocPsPoll = PageNum; ConstructPSPoll(adapt, [BufIndex], ); - rtl8188e_fill_fake_txdesc(adapt, [BufIndex-TxDescLen], PSPollLength, true, false); + rtl8188e_fill_fake_txdesc(adapt, [BufIndex - TxDescLen], PSPollLength, true, false); PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); PageNum += PageNeed; @@ -483,7 +483,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (3) null data * 1 page */ RsvdPageLoc.LocNullData = PageNum; ConstructNullFunctionData(adapt, [BufIndex], , pnetwork->MacAddress, false, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, [BufIndex-TxDescLen], NullDataLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, [BufIndex - TxDescLen], NullDataLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); PageNum += PageNeed; @@ -493,7 +493,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (4) probe response * 1page */ RsvdPageLoc.LocProbeRsp = PageNum; ConstructProbeRsp(adapt, [BufIndex], , pnetwork->MacAddress, false); - rtl8188e_fill_fake_txdesc(adapt, [BufIndex-TxDescLen], ProbeRspLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, [BufIndex - TxDescLen], ProbeRspLength,
[Outreachy kernel] [PATCH 07/11] Staging: rtl8188eu: rf_cfg: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rf_cfg.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rf_cfg_old.o rf_cfg.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rf_cfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c b/drivers/staging/rtl8188eu/hal/rf_cfg.c index 004e19301eae..0b20e62f9a68 100644 --- a/drivers/staging/rtl8188eu/hal/rf_cfg.c +++ b/drivers/staging/rtl8188eu/hal/rf_cfg.c @@ -143,7 +143,7 @@ static u32 Array_RadioA_1T_8188E[] = { #define READ_NEXT_PAIR(v1, v2, i) \ do { \ i += 2; v1 = array[i]; \ - v2 = array[i+1];\ + v2 = array[i + 1]; \ } while (0) #define RFREG_OFFSET_MASK 0xf @@ -190,7 +190,7 @@ static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt) for (i = 0; i < array_len; i += 2) { u32 v1 = array[i]; - u32 v2 = array[i+1]; + u32 v2 = array[i + 1]; if (v1 < 0xCDCDCDCD) { rtl8188e_config_rf_reg(adapt, v1, v2); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 06/11] Staging: rtl8188eu: rf: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rf.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rf_old.o rf.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rf.c | 60 +++--- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index 6fe4daea8fd5..00a9f692bb06 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -49,9 +49,9 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) tx_agc[RF_PATH_B] = 0x3f3f3f3f; for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1]<<8) | - (powerlevel[idx1]<<16) | - (powerlevel[idx1]<<24); + (powerlevel[idx1] << 8) | + (powerlevel[idx1] << 16) | + (powerlevel[idx1] << 24); } } else { if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { @@ -63,17 +63,17 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) } else { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1]<<8) | - (powerlevel[idx1]<<16) | - (powerlevel[idx1]<<24); + (powerlevel[idx1] << 8) | + (powerlevel[idx1] << 16) | + (powerlevel[idx1] << 24); } if (hal_data->EEPROMRegulatory == 0) { tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][6] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][7]<<8); + (hal_data->MCSTxPowerLevelOriginalOffset[0][7] << 8); tx_agc[RF_PATH_A] += tmpval; tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][14] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][15]<<24); + (hal_data->MCSTxPowerLevelOriginalOffset[0][15] << 24); tx_agc[RF_PATH_B] += tmpval; } } @@ -100,15 +100,15 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) } /* rf-A cck tx power */ - tmpval = tx_agc[RF_PATH_A]&0xff; + tmpval = tx_agc[RF_PATH_A] & 0xff; phy_set_bb_reg(adapt, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = tx_agc[RF_PATH_A]>>8; + tmpval = tx_agc[RF_PATH_A] >> 8; phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, 0xff00, tmpval); /* rf-B cck tx power */ - tmpval = tx_agc[RF_PATH_B]>>24; + tmpval = tx_agc[RF_PATH_B] >> 24; phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = tx_agc[RF_PATH_B]&0x00ff; + tmpval = tx_agc[RF_PATH_B] & 0x00ff; phy_set_bb_reg(adapt, rTxAGC_B_CCK1_55_Mcs32, 0xff00, tmpval); } @@ -124,9 +124,9 @@ static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, for (i = 0; i < 2; i++) { powerbase0 = pwr_level_ofdm[i]; - powerbase0 = (powerbase0<<24) | (powerbase0<<16) | -(powerbase0<<8) | powerbase0; - *(ofdmbase+i) = powerbase0; + powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) | +(powerbase0 << 8) | powerbase0; + *(ofdmbase + i) = powerbase0; } /* Check HT20 to HT40 diff */ if (adapt->HalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) @@ -134,8 +134,8 @@ static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, else powerlevel[0] = pwr_level_bw4
[Outreachy kernel] [PATCH 05/11] Staging: rtl8188eu: pwrseqcmd: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/pwrseqcmd.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff pwrseqcmd_old.o pwrseqcmd.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index 249cbc375074..77edd7ad19a1 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -85,7 +85,7 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 04/11] Staging: rtl8188eu: phy: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/phy.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff phy_old.o phy.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/phy.c | 138 ++-- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index afaf9e55195a..b9025815b682 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -69,10 +69,10 @@ static u32 rf_serial_read(struct adapter *adapt, bMaskDWord); tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | - (offset<<23) | bLSSIReadEdge; + (offset << 23) | bLSSIReadEdge; phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord, - tmplong&(~bLSSIReadEdge)); + tmplong & (~bLSSIReadEdge)); udelay(10); phy_set_bb_reg(adapt, phyreg->rfHSSIPara2, bMaskDWord, tmplong2); @@ -102,7 +102,7 @@ static void rf_serial_write(struct adapter *adapt, struct bb_reg_def *phyreg = >HalData->PHYRegDef[rfpath]; offset &= 0xff; - data_and_addr = ((offset<<20) | (data&0x000f)) & 0x0fff; + data_and_addr = ((offset << 20) | (data & 0x000f)) & 0x0fff; phy_set_bb_reg(adapt, phyreg->rf3wireOffset, bMaskDWord, data_and_addr); } @@ -143,20 +143,20 @@ static void get_tx_power_index(struct adapter *adapt, u8 channel, u8 *cck_pwr, for (TxCount = 0; TxCount < path_nums; TxCount++) { if (TxCount == RF_PATH_A) { cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + hal_data->OFDM_24G_Diff[TxCount][RF_PATH_A]; - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]; bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; } else if (TxCount == RF_PATH_B) { cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + + hal_data->BW20_24G_Diff[RF_PATH_A][index] + hal_data->BW20_24G_Diff[TxCount][index]; - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]+ + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A] + hal_data->BW20_24G_Diff[TxCount][index]; bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; } @@ -205,7 +205,7 @@ static void phy_set_bw_mode_callback(struct adapter *adapt) /* Set MAC register */ reg_bw_opmode = usb_read8(adapt, REG_BWOPMODE); - reg_prsr_rsc = usb_read8(adapt, REG_RRSR+2); + reg_prsr_rsc = usb_read8(adapt, REG_RRSR + 2); switch (hal_data->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: @@ -215,9 +215,9 @@ static void phy_set_bw_mode_callback(struct adapter *adapt) case HT_CHANNEL_WIDTH_40: reg_bw_opmode &= ~BW_OPMODE_20MHZ; usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); - reg_prsr_rsc = (reg_prsr_rsc&0x90) | - (hal_data->nCur40MhzPrimeSC<<5); - usb_write8(adapt, REG_RRSR+2, reg_prsr_rsc); + reg_prsr_rsc = (reg_prsr_rsc & 0x90) | + (hal_data->nCur40MhzPrimeSC << 5); + usb_write8(adapt, REG_RRSR + 2, reg_prsr_rsc); break; default:
[Outreachy kernel] [PATCH 03/11] Staging: rtl8188eu: odm_hwconfig: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/odm_hwconfig.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff odm_hwconfig_old.o odm_hwconfig.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 54 ++-- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index d5a9ac51e907..a6f2731b076d 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -103,33 +103,33 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, switch (LNA_idx) { case 7: if (VGA_idx <= 27) - rx_pwr_all = -100 + 2 * (27-VGA_idx); /* VGA_idx = 27~2 */ + rx_pwr_all = -100 + 2 * (27 - VGA_idx); /* VGA_idx = 27~2 */ else rx_pwr_all = -100; break; case 6: - rx_pwr_all = -48 + 2 * (2-VGA_idx); /* VGA_idx = 2~0 */ + rx_pwr_all = -48 + 2 * (2 - VGA_idx); /* VGA_idx = 2~0 */ break; case 5: - rx_pwr_all = -42 + 2 * (7-VGA_idx); /* VGA_idx = 7~5 */ + rx_pwr_all = -42 + 2 * (7 - VGA_idx); /* VGA_idx = 7~5 */ break; case 4: - rx_pwr_all = -36 + 2 * (7-VGA_idx); /* VGA_idx = 7~4 */ + rx_pwr_all = -36 + 2 * (7 - VGA_idx); /* VGA_idx = 7~4 */ break; case 3: - rx_pwr_all = -24 + 2 * (7-VGA_idx); /* VGA_idx = 7~0 */ + rx_pwr_all = -24 + 2 * (7 - VGA_idx); /* VGA_idx = 7~0 */ break; case 2: if (cck_highpwr) - rx_pwr_all = -12 + 2 * (5-VGA_idx); /* VGA_idx = 5~0 */ + rx_pwr_all = -12 + 2 * (5 - VGA_idx); /* VGA_idx = 5~0 */ else - rx_pwr_all = -6 + 2 * (5-VGA_idx); + rx_pwr_all = -6 + 2 * (5 - VGA_idx); break; case 1: - rx_pwr_all = 8-2 * VGA_idx; + rx_pwr_all = 8 - 2 * VGA_idx; break; case 0: - rx_pwr_all = 14-2 * VGA_idx; + rx_pwr_all = 14 - 2 * VGA_idx; break; default: break; @@ -138,7 +138,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); if (!cck_highpwr) { if (PWDB_ALL >= 80) - PWDB_ALL = ((PWDB_ALL-80)<<1) + ((PWDB_ALL-80)>>1) + 80; + PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80; else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) PWDB_ALL += 3; if (PWDB_ALL > 100) @@ -162,7 +162,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, else if (SQ_rpt < 20) SQ = 100; else - SQ = ((64-SQ_rpt) * 100) / 44; + SQ = ((64 - SQ_rpt) * 100) / 44; } pPhyInfo->SignalQuality = SQ; pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; @@ -200,8 +200,8 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; /* Get Rx snr value in DB */ - pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); - dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); + dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); } /* (2)PWDB, Average PWDB calcul
[Outreachy kernel] [PATCH 02/11] Staging: rtl8188eu: odm: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/odm.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff odm_old.o odm.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/odm.c | 48 ++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 7489491f5aaa..a6eb9798b6f8 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -342,7 +342,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) u8 CurrentIGI = pDM_DigTable->CurIGValue; ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); - if ((!(pDM_Odm->SupportAbility_BB_DIG)) || (!(pDM_Odm->SupportAbility_BB_FA_CNT))) { + if ((!(pDM_Odm->SupportAbility & ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); return; @@ -419,7 +419,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } if (pDM_DigTable->LargeFAHit >= 3) { - if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max) pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; else pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); @@ -432,7 +432,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) pDM_DigTable->Recover_cnt--; } else { if (pDM_DigTable->LargeFAHit < 3) { - if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); @@ -518,24 +518,24 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); - FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0x); - FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value & 0x); + FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); - FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0x); - FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value & 0x); + FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0x); - FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value & 0x); + FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0x); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value & 0x); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; ret_value = phy_query_bb_reg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_BW_LSC = (ret_value&0x); - FalseAlmCnt->Cnt_BW_US
[Outreachy kernel] [PATCH 01/11] Staging: rtl8188eu: hal_com: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/hal_com.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff hal_com_old.o hal_com.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/hal_com.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index 95f1b1431373..ebe19e076ff2 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -18,26 +18,26 @@ void dump_chip_info(struct HAL_VERSION chip_vers) uint cnt = 0; char buf[128]; - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); + cnt += sprintf((buf + cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? + cnt += sprintf((buf + cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? "TSMC" : "UMC"); if (chip_vers.CUTVersion == A_CUT_VERSION) - cnt += sprintf((buf+cnt), "A_CUT_"); + cnt += sprintf((buf + cnt), "A_CUT_"); else if (chip_vers.CUTVersion == B_CUT_VERSION) - cnt += sprintf((buf+cnt), "B_CUT_"); + cnt += sprintf((buf + cnt), "B_CUT_"); else if (chip_vers.CUTVersion == C_CUT_VERSION) - cnt += sprintf((buf+cnt), "C_CUT_"); + cnt += sprintf((buf + cnt), "C_CUT_"); else if (chip_vers.CUTVersion == D_CUT_VERSION) - cnt += sprintf((buf+cnt), "D_CUT_"); + cnt += sprintf((buf + cnt), "D_CUT_"); else if (chip_vers.CUTVersion == E_CUT_VERSION) - cnt += sprintf((buf+cnt), "E_CUT_"); + cnt += sprintf((buf + cnt), "E_CUT_"); else - cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion); - cnt += sprintf((buf+cnt), "1T1R_"); - cnt += sprintf((buf+cnt), "RomVer(0)\n"); + cnt += sprintf((buf + cnt), "1T1R_"); + cnt += sprintf((buf + cnt), "RomVer(0)\n"); pr_info("%s", buf); } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 00/11] Staging: rtl8188eu: hal: Add space around operators
This patchset adds space around operators and removes all the checkpatch warnings for the same from the files present under drivers/staging/rtl8188eu/hal/ directory. Shreeya Patel (11): Staging: rtl8188eu: hal_com: Add space around operators Staging: rtl8188eu: odm: Add space around operators Staging: rtl8188eu: odm_hwconfig: Add space around operators Staging: rtl8188eu: phy: Add space around operators Staging: rtl8188eu: pwrseqcmd: Add space around operators Staging: rtl8188eu: rf: Add space around operators Staging: rtl8188eu: rf_cfg: Add space around operators Staging: rtl8188eu: rtl8188e_cmd: Add space around operators Staging: rtl8188eu: rtl8188e_hal_init: Add space around operators Staging: rtl8188eu: rtl8188e_rxdesc: Add space around operators Staging: rtl8188eu: rtl8188eu_xmit: Add space around operators drivers/staging/rtl8188eu/hal/hal_com.c | 22 +-- drivers/staging/rtl8188eu/hal/odm.c | 48 +++--- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 54 +++ drivers/staging/rtl8188eu/hal/phy.c | 138 +- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- drivers/staging/rtl8188eu/hal/rf.c| 60 drivers/staging/rtl8188eu/hal/rf_cfg.c| 4 +- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 42 +++--- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 44 +++--- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- .../staging/rtl8188eu/hal/rtl8188eu_xmit.c| 32 ++-- 11 files changed, 224 insertions(+), 224 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH v2] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
On Fri, 2020-03-13 at 14:21 -0700, Joe Perches wrote: Hi Joe, > On Fri, 2020-03-13 at 15:59 +0530, Shreeya Patel wrote: > > Remove unnecessary if and else conditions since both are leading to > > the > > initialization of "phtpriv->ampdu_enable" with the same value. > > Also, remove the unnecessary else-if condition since it does > > nothing. > > [] > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > [] > > @@ -2772,16 +2772,7 @@ void rtw_update_ht_cap(struct adapter > > *padapter, u8 *pie, uint ie_len, u8 channe > > > > /* maybe needs check if ap supports rx ampdu. */ > > if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == > > 1) { > > - if (pregistrypriv->wifi_spec == 1) { > > - /* remove this part because testbed AP should > > disable RX AMPDU */ > > - /* phtpriv->ampdu_enable = false; */ > > - phtpriv->ampdu_enable = true; > > - } else { > > - phtpriv->ampdu_enable = true; > > - } > > - } else if (pregistrypriv->ampdu_enable == 2) { > > - /* remove this part because testbed AP should disable > > RX AMPDU */ > > - /* phtpriv->ampdu_enable = true; */ > > + phtpriv->ampdu_enable = true; > > This isn't the same test. > > This could be: > if ((!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == > 1)) || > pregistrypriv->ampdu_enable == 2) > phtpriv->ampdu_enable = true; > > Though it is probably more sensible to just set > phtpriv->ampdu_enable without testing whether or > not it's already set: > > if (pregistrypriv->ampdu_enable == 1 || > pregistrypriv->ampdu_enable == 2) > phtpriv->ampdu_enable = true; But the else-if block which I removed in v2 of this patch had nothing in the block. It was not assigning any value to "phtpriv->ampdu_enable". ( basically it was empty and useless) Now as per your suggestion if I do the change then the value of "phtpriv->ampdu_enable" will be changed to true when we have "pregistrypriv->ampdu_enable == 2" condition. But in real it should be the same as it was by default coming from the start of the function. ( This is because the else-if block was empty and doing nothing ) Please let me know if I was able to make you understand my point of view here. Also, please correct me if I am wrong. Thanks > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: wilc1000: cfg80211: Use kmemdup instead of kmalloc and memcpy
Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. The Coccinelle semantic patch used to make this change is as follows: @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); Signed-off-by: Shreeya Patel --- drivers/staging/wilc1000/cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/cfg80211.c b/drivers/staging/wilc1000/cfg80211.c index 54e02807cebf..4bdcbc5fd2fd 100644 --- a/drivers/staging/wilc1000/cfg80211.c +++ b/drivers/staging/wilc1000/cfg80211.c @@ -1142,14 +1142,13 @@ static int mgmt_tx(struct wiphy *wiphy, goto out; } - mgmt_tx->buff = kmalloc(len, GFP_KERNEL); + mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL); if (!mgmt_tx->buff) { ret = -ENOMEM; kfree(mgmt_tx); goto out; } - memcpy(mgmt_tx->buff, buf, len); mgmt_tx->size = len; if (ieee80211_is_probe_resp(mgmt->frame_control)) { -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments. drivers/staging/rtl8723bs/hal/sdio_halinit.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..4894f7d9a1d4 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,8 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = >registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments. drivers/staging/rtl8723bs/hal/sdio_halinit.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..4894f7d9a1d4 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,8 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = >registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
Remove unnecessary if and else conditions since both are leading to the initialization of "phtpriv->ampdu_enable" with the same value. Also, remove the unnecessary else-if condition since it does nothing. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments - Remove unnecessary else-if condition which does nothing. drivers/staging/rtl8723bs/core/rtw_mlme.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 71fcb466019a..d7a58af76ea0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2772,16 +2772,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* maybe needs check if ap supports rx ampdu. */ if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) { - if (pregistrypriv->wifi_spec == 1) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = false; */ - phtpriv->ampdu_enable = true; - } else { - phtpriv->ampdu_enable = true; - } - } else if (pregistrypriv->ampdu_enable == 2) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = true; */ + phtpriv->ampdu_enable = true; } /* check Max Rx A-MPDU Size */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
On Fri, 2020-03-13 at 10:20 +0300, Dan Carpenter wrote: > On Wed, Mar 11, 2020 at 07:08:11PM +0530, Shreeya Patel wrote: > > diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > b/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > index e813382e78a6..643592b0bd38 100644 > > --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter > > *padapter) > > > > pregistrypriv = >registrypriv; > > > > - if (pregistrypriv->wifi_spec) { > > - /* 2010.04.27 hpfan */ > > - /* Adjust RxAggrTimeout to close to zero disable > > RxAggr, suggested by designer */ > > - /* Timeout value is calculated by 34 / (2^n) */ > > - valueDMATimeout = 0x06; > > - valueDMAPageCount = 0x06; > > - } else { > > - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ > > - /* TX/RX Balance */ > > - valueDMATimeout = 0x06; > > - valueDMAPageCount = 0x06; > > - } > > + /* 2010.04.27 hpfan */ > > Delete these sorts of comments where it's just a name of someone and > a time stamp when they wrote it. We don't know how to contact > "hpfan" > so it's useless. > Thanks Joe and Dan for your explanation. I will remove the comments and send the patch again. > regards, > dan carpenter > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH v4] Staging: rtl8188eu: rtw_mlme: Add space around operators
On March 11, 2020 10:34:28 PM GMT+05:30, Stefano Brivio wrote: Hey Stefano, >On Wed, 11 Mar 2020 18:47:42 +0530 >Shreeya Patel wrote: > >> Add space around operators for improving the code >> readability. >> Reported by checkpatch.pl >> >> git diff -w shows no difference. >> diff of the .o files before and after the changes shows no >difference. >> >> Signed-off-by: Shreeya Patel > >This looks good to me. Further clean-ups here could probably make this >look less messy (there are long lines, unnecessary parentheses that are >rather confusing, especially on that 4/5 factor, "magic" constants that >might make sense to figure out the meaning of, etc.). > Thanks for reviewing. I will surely look at the other clean-ups as well :) Thanks >Reviewed-by: Stefano Brivio -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Hey Joe, On March 11, 2020 10:56:29 PM GMT+05:30, Joe Perches wrote: >On Wed, 2020-03-11 at 19:08 +0530, Shreeya Patel wrote: >> Remove if and else conditions since both are leading to the >> initialization of "valueDMATimeout" and "valueDMAPageCount" with >> the same value. > >You might consider removing the > /* Timeout value is calculated by 34 / (2^n) */ >comment entirely as it doesn't make much sense. > You want me to remove the other comments as well? Since Julia suggested in another email that the comments are not useful if we are removing the condition since they were applied to only one branch ( i.e. "if" branch ) Thanks >For what N is "(34 / (2 ^ N))" = 6 ? > >> diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c >b/drivers/staging/rtl8723bs/hal/sdio_halinit.c >[] >> @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter >*padapter) >> >> pregistrypriv = >registrypriv; >> >> -if (pregistrypriv->wifi_spec) { >> -/* 2010.04.27 hpfan */ >> -/* Adjust RxAggrTimeout to close to zero disable RxAggr, >suggested by designer */ >> -/* Timeout value is calculated by 34 / (2^n) */ >> -valueDMATimeout = 0x06; >> -valueDMAPageCount = 0x06; >> -} else { >> -/* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ >> -/* TX/RX Balance */ >> -valueDMATimeout = 0x06; >> -valueDMAPageCount = 0x06; >> -} >> +/* 2010.04.27 hpfan */ >> +/* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested >by designer */ >> +/* Timeout value is calculated by 34 / (2^n) */ >> +valueDMATimeout = 0x06; >> +valueDMAPageCount = 0x06; -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
Remove unnecessary if and else conditions since both are leading to the initialization of "phtpriv->ampdu_enable" with the same value. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 71fcb466019a..48e9faf27321 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2772,13 +2772,9 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* maybe needs check if ap supports rx ampdu. */ if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) { - if (pregistrypriv->wifi_spec == 1) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = false; */ - phtpriv->ampdu_enable = true; - } else { - phtpriv->ampdu_enable = true; - } + /* remove this part because testbed AP should disable RX AMPDU */ + /* phtpriv->ampdu_enable = false; */ + phtpriv->ampdu_enable = true; } else if (pregistrypriv->ampdu_enable == 2) { /* remove this part because testbed AP should disable RX AMPDU */ /* phtpriv->ampdu_enable = true; */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..643592b0bd38 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = >registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + /* 2010.04.27 hpfan */ + /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ + /* Timeout value is calculated by 34 / (2^n) */ + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v4] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ Changes in v4 - Move important statements into the commit message. Changes in v3 - Make the diff output explanation more readable. Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff of the .o files before and after the changes to show no difference. - Add the output of git diff -w to show no difference. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, _ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, _ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac
[Outreachy kernel] [PATCH v3] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w shows no difference. shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff of the .o files before and after the changes shows no difference Changes in v3 - Make the diff output explanation more readable. Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff of the .o files before and after the changes to show no difference. - Add the output of git diff -w to show no difference. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, _ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, _ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) { +
[Outreachy kernel] [PATCH v2] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- rtw_mlme_old.o - Previously produced object file before making any changes to the source code. rtw_mlme.o - Object file produced after compiling the changes done in source file. Following is the output of diff between the previously produced object file and the object file produced after compiling the changes. shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ Following output shows that there was no other change in the source code except for whitespace. shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff between the previously produced object file and the object file produced after compiling the changes. - Add the output of git diff -w to show no changes in source file except for whitespace. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, _ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, _ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Mon, 2020-03-09 at 08:35 +0100, Julia Lawall wrote: > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > > > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > > > Add space around operators for improving the code > > > > readability. > > > > > > Hello again Shreeya. > > > > > > > I have some questions here... > > > > > The subject isn't really quite appropriate as you > > > are not doing this space around operator addition > > > for the entire subsystem. > > > > > > IMO, the subject should be: > > > > > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > > > > > because you are only performing this change on this > > > single file. > > > > > > If you were to do this for every single file in the > > > subsystem, you could have many individual patches with > > > the exact same subject line. > > > > > > And it would be good to show in the changelog that you > > > have compiled the file pre and post patch without object > > > code change. > > > > > > > I'm not sure how to show this. Do you mean to add the output of > > "make drivers/staging/rtl8188eu/core" before and after the changes? > > You are working on one specific file, maybe foo.c. Compile before > making changes, which will give you foo.o. Rename that file to > something > else. Make your changes and compile again. Do a diff with the > previously > compiled file. It should produce nothing, indicating no difference. > > If this .o file doesn't change and you only changed this .c file, the > whole compiled driver won't change either. > ok, got it. > > I also don't understand the meaning of no object code change. If we > > are > > making the changes to code and then compiling it using the make > > command > > then a new file with .o extension is created and replaced by the > > previous one isn't it? > > > > > Also, it's good to show that git diff -w shows no source > > > file changes. > > > > > > > And this has to be... > > git diff -w --shortstat drivers/staging/rtl8188eu/core/ > > --shortstat does not seem useful. What you hope to see is that it > produces nothing. > Okay. I will send a V2 with all the changes required. Btw Joe, I am working against staging-testing tree > julia > > > Am I correct? > > > > Thanks > > > > > > Reported by checkpatch.pl > > > > > > > > Signed-off-by: Shreeya Patel > > > > --- > > > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > > > > > > > -- > > > > 1 file changed, 20 insertions(+), 20 deletions(-) > > > > > > When I try this using checkpatch --fix-inplace, I get > > > 21 changes against the latest -next tree. > > > > > > What tree are you doing this against? > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, > > send an email to outreachy-kernel+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/outreachy-kernel/af1a27fb8c5f7efbaf99ce3055cf3801b366d627.camel%40gmail.com > > . > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > Add space around operators for improving the code > > readability. > > Hello again Shreeya. > I have some questions here... > The subject isn't really quite appropriate as you > are not doing this space around operator addition > for the entire subsystem. > > IMO, the subject should be: > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > because you are only performing this change on this > single file. > > If you were to do this for every single file in the > subsystem, you could have many individual patches with > the exact same subject line. > > And it would be good to show in the changelog that you > have compiled the file pre and post patch without object > code change. > I'm not sure how to show this. Do you mean to add the output of "make drivers/staging/rtl8188eu/core" before and after the changes? I also don't understand the meaning of no object code change. If we are making the changes to code and then compiling it using the make command then a new file with .o extension is created and replaced by the previous one isn't it? > Also, it's good to show that git diff -w shows no source > file changes. > And this has to be... git diff -w --shortstat drivers/staging/rtl8188eu/core/ Am I correct? Thanks > > Reported by checkpatch.pl > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > -- > > 1 file changed, 20 insertions(+), 20 deletions(-) > > When I try this using checkpatch --fix-inplace, I get > 21 changes against the latest -next tree. > > What tree are you doing this against? > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > Add space around operators for improving the code > > readability. > > Hello again Shreeya. > > The subject isn't really quite appropriate as you > are not doing this space around operator addition > for the entire subsystem. > > IMO, the subject should be: > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > because you are only performing this change on this > single file. > > If you were to do this for every single file in the > subsystem, you could have many individual patches with > the exact same subject line. Oh yes, thanks for correcting me. > > And it would be good to show in the changelog that you > have compiled the file pre and post patch without object > code change. > > Also, it's good to show that git diff -w shows no source > file changes. okay will do this in v2. > > > Reported by checkpatch.pl > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > -- > > 1 file changed, 20 insertions(+), 20 deletions(-) > > When I try this using checkpatch --fix-inplace, I get > 21 changes against the latest -next tree. > > What tree are you doing this against? I am doing this against the latest -testing tree Thanks > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, _ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, _ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) { + for (mac_id = NUM_STA - 1; mac_id >= IBSS_START_MAC_ID; mac_id--) { if (pmlmeinfo->FW_sta_info[mac_id].status == 1) break; } @@ -1123,7 +1123,7 @@ void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) macid = search_max_mac_id(adapter); rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)); - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE:1 connect */ + media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE:1 connect */ rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)_status); } @@ -1213,7 +1213,7 @@ void rtw_stadel_event_callback(struct adapter *a
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 21:17 +0100, Julia Lawall wrote: > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: > > > > Hi Joe, > > > > > On Sun, 2020-03-08 at 20:31 +0100, Julia Lawall wrote: > > > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > > > > > > > Add space around & operator for improving the code > > > > > readability. > > > > > > > > I guess you found this with checkpatch. If so, it could be > > > > nice to > > > > add > > > > "Reported by checkpatch." to the log message. OK otherwise. > > > > > > It's also be nice to do all the whitespace changes at once. > > > > > > See below... > > > > > > > Acked-by: Julia Lawall > > > > > > > > > Signed-off-by: Shreeya Patel > > > > > > [] > > > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > > [] > > > > > @@ -924,7 +924,7 @@ static void > > > > > rtw_joinbss_update_network(struct > > > > > adapter *padapter, struct wlan_net > > > > > /* update fw_state will clr _FW_UNDER_LINKING here > > > > > indirectly > > > > > */ > > > > > switch (pnetwork->network.InfrastructureMode) { > > > > > case Ndis802_11Infrastructure: > > > > > - if (pmlmepriv->fw_state_UNDER_WPS) > > > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > > > pmlmepriv->fw_state = > > > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > > > > > Like adding spaces around the | here too. > > > > > > > I thought of doing this but then it was introducing another warning > > of > > "Line over 80 charachters" that is why I didn't proceed with it. > > > > What is your suggestion over it? Should I let the line be over 80 > > characters and add spaces around the operators? > > Maybe put the right side of the assignment on a separate line? With > an > extra tab in front of it. Yup we can try this as well but I think this will require manual effort to check whether alignment is proper or not. So I will first try to get rid of all the common warnings using the command suggested by Joe and then look after the 80 characters warning. > > julia > > > > > > An automated way to do this is: > > > > > > Here's the diff produced by the commands below > > > > > > $ git diff --shortstat drivers/staging/rtl8188eu > > > 32 files changed, 407 insertions(+), 407 deletions(-) > > > $ git diff -w --shortstat drivers/staging/rtl8188eu > > > 32 files changed, 0 insertions(+), 0 deletions(-) > > > > > > $ git ls-files drivers/staging/rtl8188eu | \ > > > xargs ./scripts/checkpatch.pl --fix-inplace -f --types=spacing > > > -- > > > terse --no-summary > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:152: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:252: CHECK: spaces > > > preferred around that '>>' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:253: CHECK: spaces > > > preferred around that '>>' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > driv
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 13:19 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 01:40 +0530, Shreeya Patel wrote: > > On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: > > Hi Joe, > > Hello. > [] > > > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > > [] > > > > > @@ -924,7 +924,7 @@ static void > > > > > rtw_joinbss_update_network(struct > > > > > adapter *padapter, struct wlan_net > > > > > /* update fw_state will clr _FW_UNDER_LINKING here > > > > > indirectly > > > > > */ > > > > > switch (pnetwork->network.InfrastructureMode) { > > > > > case Ndis802_11Infrastructure: > > > > > - if (pmlmepriv->fw_state_UNDER_WPS) > > > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > > > pmlmepriv->fw_state = > > > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > > > > > Like adding spaces around the | here too. > > > > > > > I thought of doing this but then it was introducing another warning > > of > > "Line over 80 charachters" that is why I didn't proceed with it. > > [] > > What is your suggestion over it? Should I let the line be over 80 > > characters and add spaces around the operators? > > Just ignore the long line warnings, there are many already > existing long > lines in that subsystem. > > That should be a style challenge for a later time. Okay got it. > > $ git ls-files drivers/staging/rtl8188eu | \ > xargs awk '{ print length($0); }' | \ > sort | uniq -c | sort -rn -k2 > 1 187 > 1 180 > 1 171 > 1 166 > 1 163 > 1 159 > 1 158 > 2 157 > 1 153 > 2 151 > 1 146 > 1 145 > 1 144 > 1 143 > 1 142 > 2 141 > 1 140 > 1 139 > 1 137 > 1 135 > 5 134 > 6 132 > 3 131 > 3 130 > 6 129 > 3 128 > 6 127 > 6 126 > 3 125 > 3 124 > 5 123 > 4 122 > 8 121 > 6 120 > 4 119 > 7 118 > 10 117 > 11 116 > 9 115 > 5 114 > 11 113 > 13 112 > 8 111 > 17 110 > 25 109 > 24 108 > 14 107 > 20 106 > 19 105 > 34 104 > 19 103 > 26 102 > 22 101 > 22 100 > 25 99 > 20 98 > 23 97 > 33 96 > 32 95 > 43 94 > 40 93 > 49 92 > 47 91 > 51 90 > 48 89 > 55 88 > 50 87 > 37 86 > 48 85 > 57 84 > 45 83 > 61 82 > 61 81 I think the idea of yours to automate the change for some common warnings will be really helpful to get rid of them. Thanks, I'm going to try doing it for other drivers as well :) > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8723bs: Remove comparison to true
Remove comparison to "true" from if statement to maintain the kernel coding style. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 7117d16a30f9..a76e81330756 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -2417,7 +2417,7 @@ void stop_ap_mode(struct adapter *padapter) paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); - if (paclnode->valid == true) { + if (paclnode->valid) { paclnode->valid = false; list_del_init(>list); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: Hi Joe, > On Sun, 2020-03-08 at 20:31 +0100, Julia Lawall wrote: > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > > > Add space around & operator for improving the code > > > readability. > > I guess you found this with checkpatch. If so, it could be nice to > > add > > "Reported by checkpatch." to the log message. OK otherwise. > > It's also be nice to do all the whitespace changes at once. > > See below... > > > Acked-by: Julia Lawall > > > > > Signed-off-by: Shreeya Patel > > [] > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > [] > > > @@ -924,7 +924,7 @@ static void rtw_joinbss_update_network(struct > > > adapter *padapter, struct wlan_net > > > /* update fw_state will clr _FW_UNDER_LINKING here indirectly > > > */ > > > switch (pnetwork->network.InfrastructureMode) { > > > case Ndis802_11Infrastructure: > > > - if (pmlmepriv->fw_state_UNDER_WPS) > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > pmlmepriv->fw_state = > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > Like adding spaces around the | here too. > I thought of doing this but then it was introducing another warning of "Line over 80 charachters" that is why I didn't proceed with it. What is your suggestion over it? Should I let the line be over 80 characters and add spaces around the operators? > An automated way to do this is: > > Here's the diff produced by the commands below > > $ git diff --shortstat drivers/staging/rtl8188eu > 32 files changed, 407 insertions(+), 407 deletions(-) > $ git diff -w --shortstat drivers/staging/rtl8188eu > 32 files changed, 0 insertions(+), 0 deletions(-) > > $ git ls-files drivers/staging/rtl8188eu | \ > xargs ./scripts/checkpatch.pl --fix-inplace -f --types=spacing -- > terse --no-summary > drivers/staging/rtl8188eu/core/rtw_mlme.c:152: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:252: CHECK: spaces > preferred around that '>>' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:253: CHECK: spaces > preferred around that '>>' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:513: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:513: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:927: CHECK: spaces > preferred around that '&' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:928: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1100: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1107: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1126: CHECK: spaces > preferred around that '<<' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1126: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1216: CHECK: spaces > preferred around that '<<' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1216: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1643: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1643: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1643: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1643: CHECK: spaces > preferred a
[Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
Add space around & operator for improving the code readability. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index e764436e120f..8da955e8343b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -924,7 +924,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: - if (pmlmepriv->fw_state_UNDER_WPS) + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 9dfe3be21849..167eafe3dd8c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -52,44 +52,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, [i]); - if (ret < 0) { - dev_err(>dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(>dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -101,8 +63,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(>dev, , id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index ec4848acec9f..06c943c2cc01 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, ); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, }; /* don't exceed max specified SPI CLK frequency */ diff --git a/drivers/staging/iio/
[PATCH v4 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 56 +++--- drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 134 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 95 insertions(+), 179 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 167eafe3dd8c..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,60 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(>dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(>dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(>dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, _regmap_config); + + if (IS_ERR(regmap)) { + dev_err(>dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(>dev, , id->name, client->irq); + return adt7316_probe(>dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 06c943c2cc01..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, _regmap_config); + if (IS_ERR(regmap)) { + dev_err(_dev->dev, "Error initializing spi regmap: %ld\n", + PTR_ERR(regmap)); + return P
[PATCH v4 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Changes in v4 -Rebase against iio's testing branch. Previous series was rebased against greg's testing branch. Changes in v3 -Fetch the changes from remote and rebase to have it in the current working directory. Changes in v2 -Change the val_bits to 8 and add two more patches having a different change before the final implemetation of regmap. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 97 ++- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 149 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 104 insertions(+), 252 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 0f26bc38edc6..9dfe3be21849 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -99,14 +99,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(>dev, , id->name); + return adt7316_probe(>dev, , id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 8294b9c1e3c2..ec4848acec9f 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(_dev->dev, , spi_dev->modalias); + return adt7316_probe(_dev->dev, , spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 6f7891b567b9..7c4f84822c18 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1799,12 +1799,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1820,13 +1820,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2126,7 +2125,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2179,8 +2178,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index 84ca4f6c88f5..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); @@ -30,6 +29,6 @@ extern const struct dev_pm_ops adt
Re: [PATCH v3 0/3] adt7316 regmap implementation
On Sat, 2019-01-26 at 10:42 +0530, Shreeya Patel wrote: > On Fri, 2019-01-25 at 18:22 -0700, Jeremy Fertic wrote: > > On Sun, Jan 20, 2019 at 09:06:30PM +0530, Shreeya Patel wrote: > > > This patchset consist of some initial patches for heading > > > towards the regmap implementation and also the final patch > > > which enables the driver to use regmap API thus removing > > > the redundant and common code. > > > > > > Changes in v3 > > > -Fetch the changes from remote and rebase to have it in > > > the current working directory. > > > > > > Changes in v2 > > > -Change the val_bits to 8 and add two more patches > > > having a different change before the final implemetation > > > of regmap. > > > > > > Shreeya Patel (3): > > > Staging: iio: adt7316: Remove irq from bus structure > > > Staging: iio: adt7316: Remove multi read and write functions > > > Staging: iio: adt7316: Add regmap support > > > > > > drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- > > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > > drivers/staging/iio/addac/adt7316.c | 147 -- > > > -- > > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > > 4 files changed, 103 insertions(+), 251 deletions(-) > > > > > > -- > > > 2.17.1 > > > > > > > The series doesn't apply to the current iio testing branch. If > > there's any > > value in a quick sanity testing, I can do that after a rebase. I > > wasn't > > planning to test everything the patch touches, but thought I could > > at > > least test a few register reads and writes to make sure we haven't > > missed > > anything obvious in the regmap implementation. > > Hi Jeremy, > > Is it still not applying? Jonathan told me that v2 of this series > wasn't applying so I rebased for this series. > > I hope I didn't mess things up while rebasing :( > > Thanks Yes it is my mistake. I've rebased against greg's staging tree. I will soon send a v4 for the series. Thanks > > > > > Jeremy > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 0/3] adt7316 regmap implementation
On Fri, 2019-01-25 at 18:22 -0700, Jeremy Fertic wrote: > On Sun, Jan 20, 2019 at 09:06:30PM +0530, Shreeya Patel wrote: > > This patchset consist of some initial patches for heading > > towards the regmap implementation and also the final patch > > which enables the driver to use regmap API thus removing > > the redundant and common code. > > > > Changes in v3 > > -Fetch the changes from remote and rebase to have it in > > the current working directory. > > > > Changes in v2 > > -Change the val_bits to 8 and add two more patches > > having a different change before the final implemetation > > of regmap. > > > > Shreeya Patel (3): > > Staging: iio: adt7316: Remove irq from bus structure > > Staging: iio: adt7316: Remove multi read and write functions > > Staging: iio: adt7316: Add regmap support > > > > drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > drivers/staging/iio/addac/adt7316.c | 147 -- > > -- > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > 4 files changed, 103 insertions(+), 251 deletions(-) > > > > -- > > 2.17.1 > > > > The series doesn't apply to the current iio testing branch. If > there's any > value in a quick sanity testing, I can do that after a rebase. I > wasn't > planning to test everything the patch touches, but thought I could at > least test a few register reads and writes to make sure we haven't > missed > anything obvious in the regmap implementation. Hi Jeremy, Is it still not applying? Jonathan told me that v2 of this series wasn't applying so I rebased for this series. I hope I didn't mess things up while rebasing :( Thanks > > Jeremy > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 56 +++--- drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 132 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 94 insertions(+), 178 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index c7f82c3fe27c..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,60 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(>dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(>dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(>dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, _regmap_config); + + if (IS_ERR(regmap)) { + dev_err(>dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(>dev, , id->name, client->irq); + return adt7316_probe(>dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 1a78dc1e2840..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, _regmap_config); + if (IS_ERR(regmap)) { + dev_err(_dev->dev, "Error initializing spi regmap: %ld\n", + PTR_ERR(regmap)); +
[PATCH v3 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index b6571db2e8d8..c7f82c3fe27c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -52,44 +52,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, [i]); - if (ret < 0) { - dev_err(>dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(>dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -101,8 +63,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(>dev, , id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index adaaa3eecd04..1a78dc1e2840 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret = 0; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, ); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, }; /* don't exceed max specified SPI CLK frequency */ diff --git a
[PATCH v3 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Changes in v3 -Fetch the changes from remote and rebase to have it in the current working directory. Changes in v2 -Change the val_bits to 8 and add two more patches having a different change before the final implemetation of regmap. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 251 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 2d51bd425662..b6571db2e8d8 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -99,14 +99,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(>dev, , id->name); + return adt7316_probe(>dev, , id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..adaaa3eecd04 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(_dev->dev, , spi_dev->modalias); + return adt7316_probe(_dev->dev, , spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 8cf3ff25eb62..30808a897fc2 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1809,12 +1809,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1830,13 +1830,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2136,7 +2135,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2182,8 +2181,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index 84ca4f6c88f5..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); @@ -30,6 +29,6 @@ extern const struct dev_pm_ops adt
Re: [PATCH v2 0/3] adt7316 regmap implementation
On Sat, 2019-01-19 at 19:04 +, Jonathan Cameron wrote: > On Sun, 20 Jan 2019 00:09:29 +0530 > Shreeya Patel wrote: > > > This patchset consist of some initial patches for heading > > towards the regmap implementation and also the final patch > > which enables the driver to use regmap API thus removing > > the redundant and common code. > > > > Shreeya Patel (3): > > Staging: iio: adt7316: Remove irq from bus structure > > Staging: iio: adt7316: Remove multi read and write functions > > Staging: iio: adt7316: Add regmap support > > > > drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > drivers/staging/iio/addac/adt7316.c | 147 -- > > -- > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > 4 files changed, 103 insertions(+), 255 deletions(-) > > > > Hi Shreeya, > > I'm not seeing a change log for any of these. Please make sure to > add one so we know what changed since V1. Saves a lot of trying > to remember things from a while back! > Sorry, I forgot to add it. I remembered it when I had already sent the patches. I'll also cc Jeremy in V3. Thanks > Thanks, > > Jonathan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 335c17731cf7..40aa9e2f1966 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -56,44 +56,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, [i]); - if (ret < 0) { - dev_err(>dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(>dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -105,8 +67,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(>dev, , id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index adaaa3eecd04..1a78dc1e2840 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret = 0; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, ); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, }; /* don't exceed max specified SPI CLK frequency */ diff --git a
[PATCH v2 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 60 +++ drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 132 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 94 insertions(+), 182 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 40aa9e2f1966..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,64 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(>dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - - if (!ret) - return -EIO; - - if (ret < 0) { - dev_err(>dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(>dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, _regmap_config); + + if (IS_ERR(regmap)) { + dev_err(>dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(>dev, , id->name, client->irq); + return adt7316_probe(>dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 1a78dc1e2840..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, _regmap_config); + if (IS_ERR(regmap)) { + dev_err(_dev->dev, "Error initializing spi regmap:
[PATCH v2 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index ac91163656b5..335c17731cf7 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -103,14 +103,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(>dev, , id->name); + return adt7316_probe(>dev, , id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..adaaa3eecd04 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(_dev->dev, , spi_dev->modalias); + return adt7316_probe(_dev->dev, , spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 1ca4ee0f30ee..6b4b80fd80cc 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,12 +1807,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1828,13 +1828,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2134,7 +2133,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2180,8 +2179,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index fd7c5c92b599..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); @@ -30,6 +29,6 @@ extern const struct dev_pm_ops adt
[PATCH v2 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 255 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Also remove multi_read and multi_write functions from i2c and spi driver as they are not being used anywhere. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- drivers/staging/iio/addac/adt7316-spi.c | 94 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 254 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index ac91163656b5..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,105 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(>dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - - if (!ret) - return -EIO; - - if (ret < 0) { - dev_err(>dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(>dev, "I2C write error\n"); - - return ret; -} - -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, [i]); - if (ret < 0) { - dev_err(>dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(>dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .irq = client->irq, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, _regmap_config); + + if (IS_ERR(regmap)) { + dev_err(>dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(>dev, , id->name); + return adt7316_probe(>dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..9e3decb5cb77 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,79 +11,12 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316
[PATCH v4] Staging: iio: adt7316: Add all irq related code in adt7316_irq_setup()
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field and implement this in adt7316_irq_setup function. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Move devm_request_threaded_irq() and assignment of chip->config1 into the adt7316_setup_irq() to unclutter the code in probe function. Signed-off-by: Shreeya Patel --- Changes in v4 - Merge patches *[1/3 v3], *[2/3 v3] and *[3/3 v3] to make it less complex to review. Changes in v3 - Add a new function for having all interrupt related code. Changes in v2 - Make the commit message of patch *[1/5] appropriate. drivers/staging/iio/addac/adt7316.c | 52 + 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..1ca4ee0f30ee 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,6 +1807,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } +static int adt7316_setup_irq(struct iio_dev *indio_dev) +{ + struct adt7316_chip_info *chip = iio_priv(indio_dev); + int irq_type, ret; + + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(_dev->dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } + + ret = devm_request_threaded_irq(_dev->dev, chip->bus.irq, + NULL, adt7316_event_handler, + irq_type | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) { + dev_err(_dev->dev, "failed to request irq %d\n", + chip->bus.irq); + return ret; + } + + if (irq_type & IRQF_TRIGGER_HIGH) + chip->config1 |= ADT7316_INT_POLARITY; + + return 0; +} + /* * Show mask of enabled interrupts in Hex. */ @@ -2101,8 +2138,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,20 +2181,9 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; - - ret = devm_request_threaded_irq(dev, chip->bus.irq, - NULL, - adt7316_event_handler, - irq_type | IRQF_ONESHOT, - indio_dev->name, - indio_dev); + ret = adt7316_setup_irq(indio_dev); if (ret) return ret; - - if (irq_type & IRQF_TRIGGER_HIGH) - chip->config1 |= ADT7316_INT_POLARITY; } ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 2/3] Staging: iio: adt7316: Move interrupt related code
On Sat, 2018-12-08 at 16:12 +, Jonathan Cameron wrote: > On Sat, 8 Dec 2018 20:46:37 +0530 > Shreeya Patel wrote: > > > There is a function adt7316_irq_setup() where irq_type is being > > set. It would be good to move devm_request_threaded_irq() function > > and assignment of chip->config1 in adt7316_irq_setup() to unclutter > > the code in probe function. > > > > Signed-off-by: Shreeya Patel > > As commented below, this didn't end up as tidy as it might have been. > It would I think have been simpler before patch 1 or just merged with > it. > As I was introducing a new function named "adt7316_setup_irq" so I thought patch 1 should come first because we are setting up the irq_type there. But yes, this made the code complex to review. I didn't merge both patches because both the patches were having different changes. If I would have done that then there was a possibility where someone would have said to split the patches. > Anyhow, I might combine the two whilst applying. However before I do > that I'd like to leave this on list for a few days to let Alex > or others have time for another look before I apply it. > It's ok, I'll merge both patches and send as a v4 to you. I'll send it after 3-4 days so we can get other reviews by that time if there are any to come. My vacation has started so I'll work faster now. > All heading in the right direction! > > Thanks, > > Jonathan > > > --- > > drivers/staging/iio/addac/adt7316.c | 34 ++--- > > > > 1 file changed, 17 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/staging/iio/addac/adt7316.c > > b/drivers/staging/iio/addac/adt7316.c > > index 86b2c3d53588..97dd48153293 100644 > > --- a/drivers/staging/iio/addac/adt7316.c > > +++ b/drivers/staging/iio/addac/adt7316.c > > @@ -1807,11 +1807,12 @@ static irqreturn_t > > adt7316_event_handler(int irq, void *private) > > return IRQ_HANDLED; > > } > > > > -static int adt7316_setup_irq(struct device *dev, int irq) > > +static int adt7316_setup_irq(struct iio_dev *indio_dev) > > Hmm. This has ended up a lot more complex than ideal due > to the effective two layers of rework. > > I would either have done patches 1 and 2 as one patch or > reordered them so the rework preceded the change > to DT. It's not that important but it would have lead > to code that was easier to review. > > > > { > > - int irq_type; > > + struct adt7316_chip_info *chip = iio_priv(indio_dev); > > + int irq_type, ret; > > > > - irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); > > + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip- > > >bus.irq)); > > > > switch (irq_type) { > > case IRQF_TRIGGER_HIGH: > > @@ -1821,13 +1822,23 @@ static int adt7316_setup_irq(struct device > > *dev, int irq) > > case IRQF_TRIGGER_FALLING: > > break; > > default: > > - dev_info(dev, "mode %d unsupported, using > > IRQF_TRIGGER_LOW\n", > > + dev_info(_dev->dev, "mode %d unsupported, > > using IRQF_TRIGGER_LOW\n", > > irq_type); > > irq_type = IRQF_TRIGGER_LOW; > > break; > > } > > > > - return irq_type; > > + ret = devm_request_threaded_irq(_dev->dev, chip- > > >bus.irq, > > + NULL, > > adt7316_event_handler, > > + irq_type | IRQF_ONESHOT, > > + indio_dev->name, > > indio_dev); > > + if (ret) > > + return ret; > > + > > + if (irq_type & IRQF_TRIGGER_HIGH) > > + chip->config1 |= ADT7316_INT_POLARITY; > > + > > + return ret; > > } > > > > /* > > @@ -2124,7 +2135,6 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > { > > struct adt7316_chip_info *chip; > > struct iio_dev *indio_dev; > > - int irq_type; > > int ret = 0; > > > > indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); > > @@ -2168,19 +2178,9 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > indio_dev->modes = INDIO_DIRECT_MODE; > > > > if (chip->bus.irq > 0) { > > - irq_type = adt7316_setup_irq(dev, chip->bus.irq); > > - > > - ret = devm_request_threaded_irq(dev, chip- > > >bus.irq, >
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Sat, 2018-12-08 at 11:17 +, Jonathan Cameron wrote: > On Sat, 08 Dec 2018 00:07:21 +0530 > Shreeya Patel wrote: > > > On Thu, 2018-12-06 at 15:40 +0300, Dan Carpenter wrote: > > > On Wed, Dec 05, 2018 at 02:59:53PM -0700, Jeremy Fertic wrote: > > > > On Thu, Dec 06, 2018 at 01:25:55AM +0530, Shreeya Patel > > > > wrote: > > > > > On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > > > > > > This reverts commit > > > > > > 00426e99789357dbff7e719a092ce36a3ce49d94. > > > > > > > > > > > > i2c_smbus_read_byte() returns 0 when a byte with the value > > > > > > 0 is > > > > > > read > > > > > > from > > > > > > the device. This is a valid read so revert the check for 0. > > > > > > > > > > > > Signed-off-by: Jeremy Fertic > > > > > > --- > > > > > > > > > > Hi Jeremy, > > > > > > > > > > As per my understanding, 0 value indicates no error but no > > > > > data > > > > > read. > > > > > Then how can this be a valid case? > > > > > > > > > > Can you please make me understand that how can we consider > > > > > this > > > > > as a > > > > > valid case even when no data has been read? > > > > > > It's not reading no data. It's reading one byte of data and > > > returning > > > it. > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > I'm not sure I understand why the value 0 would indicate no > > > > data > > > > read. > > > > Doesn't that just mean a byte was read with the value 0. > > > > > > Yes. It does mean that. Please don't ask rhetorical > > > questions... :( > > > This list is full of people who can't resist answering every > > > question. > > > > > > > For instance, if the input to the adc is 0V. Can you point me > > > > to > > > > where > > > > you're seeing that this would indicate no data read? > > > > > > drivers/i2c/i2c-core-smbus.c > > > 88 /** > > > 89 * i2c_smbus_read_byte - SMBus "receive byte" protocol > > > 90 * @client: Handle to slave device > > > 91 * > > > 92 * This executes the SMBus "receive byte" protocol, > > > returning > > > negative errno > > > 93 * else the byte received from the device. > > > 94 */ > > > 95 s32 i2c_smbus_read_byte(const struct i2c_client *client) > > > 96 { > > > 97 union i2c_smbus_data data; > > > 98 int status; > > > 99 > > >100 status = i2c_smbus_xfer(client->adapter, > > > client- > > > > addr, client->flags, > > > > > >101 I2C_SMBUS_READ, 0, > > >102 I2C_SMBUS_BYTE, ); > > >103 return (status < 0) ? status : data.byte; > > > ^ > > >104 } > > >105 EXPORT_SYMBOL(i2c_smbus_read_byte); > > > > Even I had sent the same code to Jonathan and we had a discussion > > on > > this. > > I asked him that this code clearly shows that there is an error > > condition only when status < 0 then why do we need a check for > > status = > > 0. > > > > Then he explained me that 0 isn't an error. The issue is the > > silliness > > of the i2c interface. > > > > Pretty much every other bus returns an error (negative) if less > > data is > > received than expected. Most i2c > > bus master's do as well but in theory it can return 0 to indicate > > no > > error but no data read (which doesn't make any sense) > > > > 0 doesn't ever happen in reality but it should be handled for > > correctness though. > > > > So we should wait for what Jonathan has to say on this :) > > Yup, I was being an idiot. Sorry about that! For some reason I'd > gotten it into my head that the particular function we were talking > about was i2c_master_send which does indeed do as discussed above. > > Apologies for misleading you on this. Definitely a proper idiot > moment of me not reading what the code actually was properly, even > when you questioned what I was going on about. It was not your mistake! There was a confusion because of delay in replying to you from my side. So it was just the case of human error :) > > Thanks to Jeremy for catching this one. > > Applied to the togreg branch of iio.git and pushed out as testing for > the autobuilders to play with it. > > Jonathan > > > > > Thanks > > > > > You are right. Commit 00426e997893 ("Staging: iio: adt7316: Add > > > an > > > extra check for 'ret' equals to 0") needs to be reverted... > > > > > > regards, > > > dan carpenter > > > > > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/3] Staging: iio: adt7316: Move interrupt related code
There is a function adt7316_irq_setup() where irq_type is being set. It would be good to move devm_request_threaded_irq() function and assignment of chip->config1 in adt7316_irq_setup() to unclutter the code in probe function. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 34 ++--- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 86b2c3d53588..97dd48153293 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,11 +1807,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct device *dev, int irq) +static int adt7316_setup_irq(struct iio_dev *indio_dev) { - int irq_type; + struct adt7316_chip_info *chip = iio_priv(indio_dev); + int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1821,13 +1822,23 @@ static int adt7316_setup_irq(struct device *dev, int irq) case IRQF_TRIGGER_FALLING: break; default: - dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", + dev_info(_dev->dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", irq_type); irq_type = IRQF_TRIGGER_LOW; break; } - return irq_type; + ret = devm_request_threaded_irq(_dev->dev, chip->bus.irq, + NULL, adt7316_event_handler, + irq_type | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) + return ret; + + if (irq_type & IRQF_TRIGGER_HIGH) + chip->config1 |= ADT7316_INT_POLARITY; + + return ret; } /* @@ -2124,7 +2135,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2168,19 +2178,9 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - irq_type = adt7316_setup_irq(dev, chip->bus.irq); - - ret = devm_request_threaded_irq(dev, chip->bus.irq, - NULL, - adt7316_event_handler, - irq_type | IRQF_ONESHOT, - indio_dev->name, - indio_dev); + ret = adt7316_setup_irq(indio_dev); if (ret) return ret; - - if (irq_type & IRQF_TRIGGER_HIGH) - chip->config1 |= ADT7316_INT_POLARITY; } ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 0/3] Remove platform data and introduce DT bindings
This patchset introduces the use of device tree bindings for setting up the irq_type and removes the usage of platform data. Also, code related to interrupt is moved to the new function adt7316_setup_irq to unclutter the code in adt7316_probe(). A dev_err() message is added to give more details about the error. Shreeya Patel (3): Staging: iio: adt7316: Use device tree data to assign irq_type Staging: iio: adt7316: Move interrupt related code Staging: iio: adt7316: Add a dev_err() message drivers/staging/iio/addac/adt7316.c | 52 + 1 file changed, 38 insertions(+), 14 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/3] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW All this is implemented in a new function called adt7316_setup_irq. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..86b2c3d53588 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,6 +1807,29 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } +static int adt7316_setup_irq(struct device *dev, int irq) +{ + int irq_type; + + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } + + return irq_type; +} + /* * Show mask of enabled interrupts in Hex. */ @@ -2101,8 +2124,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2168,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = adt7316_setup_irq(dev, chip->bus.irq); ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/3] Staging: iio: adt7316: Add a dev_err() message
Add a dev_err() message "failed to request irq" for describing what went wrong when an error contition is statisfied. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 97dd48153293..e3eb8ad06403 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1832,8 +1832,11 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); - if (ret) + if (ret) { + dev_err(_dev->dev, "failed to request irq %d\n", + chip->bus.irq); return ret; + } if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Thu, 2018-12-06 at 15:40 +0300, Dan Carpenter wrote: > On Wed, Dec 05, 2018 at 02:59:53PM -0700, Jeremy Fertic wrote: > > On Thu, Dec 06, 2018 at 01:25:55AM +0530, Shreeya Patel wrote: > > > On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > > > > This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. > > > > > > > > i2c_smbus_read_byte() returns 0 when a byte with the value 0 is > > > > read > > > > from > > > > the device. This is a valid read so revert the check for 0. > > > > > > > > Signed-off-by: Jeremy Fertic > > > > --- > > > > > > Hi Jeremy, > > > > > > As per my understanding, 0 value indicates no error but no data > > > read. > > > Then how can this be a valid case? > > > > > > Can you please make me understand that how can we consider this > > > as a > > > valid case even when no data has been read? > > It's not reading no data. It's reading one byte of data and > returning > it. > > > > > > > > > > Thanks > > > > I'm not sure I understand why the value 0 would indicate no data > > read. > > Doesn't that just mean a byte was read with the value 0. > > Yes. It does mean that. Please don't ask rhetorical > questions... :( > This list is full of people who can't resist answering every > question. > > > For instance, if the input to the adc is 0V. Can you point me to > > where > > you're seeing that this would indicate no data read? > > drivers/i2c/i2c-core-smbus.c > 88 /** > 89 * i2c_smbus_read_byte - SMBus "receive byte" protocol > 90 * @client: Handle to slave device > 91 * > 92 * This executes the SMBus "receive byte" protocol, returning > negative errno > 93 * else the byte received from the device. > 94 */ > 95 s32 i2c_smbus_read_byte(const struct i2c_client *client) > 96 { > 97 union i2c_smbus_data data; > 98 int status; > 99 >100 status = i2c_smbus_xfer(client->adapter, client- > >addr, client->flags, >101 I2C_SMBUS_READ, 0, >102 I2C_SMBUS_BYTE, ); >103 return (status < 0) ? status : data.byte; > ^ >104 } >105 EXPORT_SYMBOL(i2c_smbus_read_byte); Even I had sent the same code to Jonathan and we had a discussion on this. I asked him that this code clearly shows that there is an error condition only when status < 0 then why do we need a check for status = 0. Then he explained me that 0 isn't an error. The issue is the silliness of the i2c interface. Pretty much every other bus returns an error (negative) if less data is received than expected. Most i2c bus master's do as well but in theory it can return 0 to indicate no error but no data read (which doesn't make any sense) 0 doesn't ever happen in reality but it should be handled for correctness though. So we should wait for what Jonathan has to say on this :) Thanks > You are right. Commit 00426e997893 ("Staging: iio: adt7316: Add an > extra check for 'ret' equals to 0") needs to be reverted... > > regards, > dan carpenter > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. > > i2c_smbus_read_byte() returns 0 when a byte with the value 0 is read > from > the device. This is a valid read so revert the check for 0. > > Signed-off-by: Jeremy Fertic > --- Hi Jeremy, As per my understanding, 0 value indicates no error but no data read. Then how can this be a valid case? Can you please make me understand that how can we consider this as a valid case even when no data has been read? Thanks > drivers/staging/iio/addac/adt7316-i2c.c | 4 > 1 file changed, 4 deletions(-) > > diff --git a/drivers/staging/iio/addac/adt7316-i2c.c > b/drivers/staging/iio/addac/adt7316-i2c.c > index ac91163656b5..2d51bd425662 100644 > --- a/drivers/staging/iio/addac/adt7316-i2c.c > +++ b/drivers/staging/iio/addac/adt7316-i2c.c > @@ -30,10 +30,6 @@ static int adt7316_i2c_read(void *client, u8 reg, > u8 *data) > } > > ret = i2c_smbus_read_byte(client); > - > - if (!ret) > - return -EIO; > - > if (ret < 0) { > dev_err(>dev, "I2C read error\n"); > return ret; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 5/5] Staging: iio: adt7316: Use device tree data to assign irq_type
On Wed, 2018-11-21 at 08:21 +, Ardelean, Alexandru wrote: > On Tue, 2018-11-20 at 22:30 +0530, Shreeya Patel wrote: > > ADT7316 driver no more uses platform data and hence use device tree > > data instead of platform data for assigning irq_type field. > > Switch case figures out the type of irq and if it's the default > > case > > then assign the default value to the irq_type i.e. > > irq_type = IRQF_TRIGGER_LOW > > > > 1 comment inline > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/iio/addac/adt7316.c | 21 + > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/iio/addac/adt7316.c > > b/drivers/staging/iio/addac/adt7316.c > > index 9c72538baf9e..c647875a64f5 100644 > > --- a/drivers/staging/iio/addac/adt7316.c > > +++ b/drivers/staging/iio/addac/adt7316.c > > @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > { > > struct adt7316_chip_info *chip; > > struct iio_dev *indio_dev; > > - unsigned short *adt7316_platform_data = dev- > > >platform_data; > > - int irq_type = IRQF_TRIGGER_LOW; > > + int irq_type; > > int ret = 0; > > > > indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); > > @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > indio_dev->modes = INDIO_DIRECT_MODE; > > > > if (chip->bus.irq > 0) { > > - if (adt7316_platform_data[0]) > > - irq_type = adt7316_platform_data[0]; > > + irq_type = > > + irqd_get_trigger_type(irq_get_irq_data(chi > > p- > > > bus.irq)); > > > > + > > + switch (irq_type) { > > + case IRQF_TRIGGER_HIGH: > > + case IRQF_TRIGGER_RISING: > > + break; > > + case IRQF_TRIGGER_LOW: > > + case IRQF_TRIGGER_FALLING: > > + break; > > + default: > > + dev_info(dev, "mode %d unsupported, using > > IRQF_TRIGGER_LOW\n", > > +irq_type); > > + irq_type = IRQF_TRIGGER_LOW; > > + break; > > + } > > It would be an idea to move this part [together with > devm_request_threaded_irq()] into a "adt7316_setup_irq()" function. > To un- > clutter the code in the adt7316_probe() function. > Yes, seems like a good idea! Even other drivers are doing the same as you told me to do...thanks :) I'll do the change after Jonathan picks up the other patches and will wait for some other reviews to come up if there are any. Thanks > > > > ret = devm_request_threaded_irq(dev, chip- > > >bus.irq, > > NULL, ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 5/5] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..c647875a64f5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = + irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 4/5] Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dfae22619287..9c72538baf9e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,7 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2147,18 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/5] Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 41bc4ca008bc..ac91163656b5 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index deb2f7b40f60..dfae22619287 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,6 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,19 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..fd7c5c92b599 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/5] Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..deb2f7b40f60 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc*ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2120,7 +2120,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/5] Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. But if there is no dt table then there should be a fall back path with which desired kernel modules can be loaded. Hence, add of_device_id table in the i2c driver to be able to use when there is no dt table. Signed-off-by: Shreeya Patel --- Changes in v2: - Make the commit message appropriate and assign of_match_table in the driver structure. drivers/staging/iio/addac/adt7316-i2c.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..41bc4ca008bc 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,9 +126,22 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", + .of_match_table = adt7316_of_match, .pm = ADT7316_PM_OPS, }, .probe = adt7316_i2c_probe, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/5] Remove platform data and introduce DT bindings
This patchset introduces device tree bindings for adt7316 driver and removes the usage of platform data from it. Also, it sets the data field to it's appropriate value in the i2c read function which was nowhere being set before. Changes in v2: - Make the commit message of patch *[1/5] appropriate. Shreeya Patel (5): Staging: iio: adt7316: Add of_device_id table Staging: iio: adt7316: Use device tree data to set ldac_pin Staging: iio: adt7316: Switch irq_flags to a local variable Staging: iio: adt7316: Change the name from irq_flags to irq_type Staging: iio: adt7316: Use device tree data to assign irq_type drivers/staging/iio/addac/adt7316-i2c.c | 14 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 39 ++--- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 42 insertions(+), 13 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..c647875a64f5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = + irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dfae22619287..9c72538baf9e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,7 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2147,18 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index d4b5060c18ee..91d6cdcb747e 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index deb2f7b40f60..dfae22619287 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,6 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,19 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..fd7c5c92b599 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..deb2f7b40f60 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc*ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2120,7 +2120,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. Hence to be able to use device tree for ADT7316, add of_device_id table which specifies the supported devices through compatible property. Note that there is a fall back path in i2c that will result in i2c_device_id table being used if there is no of_devcie_id table. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..d4b5060c18ee 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,6 +126,18 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] Staging: iio: adt7316: Add an extra check for 'ret' equals to 0
ret = 0 indicates a case of no error but no data read from the bus which is an invalid case. This case doesn't ever happen in reality. It should perhaps be handled for correctness though. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 856bcfa60c6c..473e5e34ec00 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,6 +30,10 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); + + if (!ret) + return -EIO; + if (ret < 0) { dev_err(>dev, "I2C read error\n"); return ret; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] Staging: iio: adt7316: Set the data field
adt7316_i2c_read function nowhere sets the data field. It is necessary to have an appropriate value for it. Hence, assign the value stored in 'ret' variable to data field. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index f66dd3ebbab1..856bcfa60c6c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -35,6 +35,8 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) return ret; } + *data = ret; + return 0; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/7] Remove platform data and introduce DT bindings
This patchset introduces device tree bindings for adt7316 driver and removes the usage of platform data from it. Also, it sets the data field to it's appropriate value in the i2c read function which was nowhere being set before. Shreeya Patel (7): Staging: iio: adt7316: Set the data field Staging: iio: adt7316: Add an extra check for 'ret' equals to 0 Staging: iio: adt7316: Add of_device_id table Staging: iio: adt7316: Use device tree data to set ldac_pin Staging: iio: adt7316: Switch irq_flags to a local variable Staging: iio: adt7316: Change the name from irq_flags to irq_type Staging: iio: adt7316: Use device tree data to assign irq_type drivers/staging/iio/addac/adt7316-i2c.c | 19 +++- drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 39 ++--- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 47 insertions(+), 13 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: iio: adt7316: Switch to the gpio descriptor interface
On Mon, 2018-10-22 at 22:44 +0530, Nishad Kamdar wrote: > Use the gpiod interface instead of the deprecated old non-descriptor > interface for ldac_pin. > > Signed-off-by: Nishad Kamdar > --- Hi Nishad, I have been working on implementing device tree bindings for this driver and removing platform data from it. I've sent a series of patches for it to Jonathan. I didn't send it on the mailing list as I wanted to confirm from Jonathan if we wants something more to be done in the series. That series also includes the change which you are proposing here. I am really sorry that you didn't know about this. If you are planning to send any other patches for this driver then let me know before you start implementing it so that we can co-ordinate before doing any work. Thanks > drivers/staging/iio/addac/adt7316.c | 17 - > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/iio/addac/adt7316.c > b/drivers/staging/iio/addac/adt7316.c > index 3f22d1088713..94f945ba0097 100644 > --- a/drivers/staging/iio/addac/adt7316.c > +++ b/drivers/staging/iio/addac/adt7316.c > @@ -8,7 +8,7 @@ > */ > > #include > -#include > +#include > #include > #include > #include > @@ -177,7 +177,7 @@ > > struct adt7316_chip_info { > struct adt7316_bus bus; > - u16 ldac_pin; > + struct gpio_desc*ldac_pin; > u16 int_mask; /* 0x2f */ > u8 config1; > u8 config2; > @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct > device *dev, > if (ret) > return -EIO; > } else { > - gpio_set_value(chip->ldac_pin, 0); > - gpio_set_value(chip->ldac_pin, 1); > + gpiod_set_value(chip->ldac_pin, 0); > + gpiod_set_value(chip->ldac_pin, 1); > } > > return len; > @@ -2120,7 +2120,14 @@ int adt7316_probe(struct device *dev, struct > adt7316_bus *bus, > else > return -ENODEV; > > - chip->ldac_pin = adt7316_platform_data[1]; > + chip->ldac_pin = devm_gpiod_get(dev, "ldac", > GPIOD_OUT_HIGH); > + if (IS_ERR(chip->ldac_pin)) { > + ret = PTR_ERR(chip->ldac_pin); > + dev_err(dev, "Failed to request ldac GPIO: %d\n", > + ret); > + return ret; > + } > + > if (chip->ldac_pin) { > chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; > if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging iio/adc: fixes parenthesis alignment
On Tue, 2018-10-16 at 13:01 -0300, Marcelo Schmitt wrote: > Fixes close parenthesis alignment to match open parenthesis at > iio/drivers/staging/iio/adc/ad7606.c line 379. > > Signed-of-by: Marcelo Schmitt Hi Marcelo, Some suggestions from my side 1) Your subject line should look like "Staging: iio: adc:" instead of "Staging iio/adc:" This is the pattern that everyone in the Linux Kernel community has to follow for having consistency around. 2) Your subject line and commit message should be in the imperative form. For example :- Staging: iio: adc: Match alignment with open parenthesis Similar should be the case for commit message. 3) Try to avoid the word 'fix' as it becomes an easy way for people to avoid explanation for the patch. Try giving more information about what you are doing and why are you doing that. You can have a look here https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/comm it/?id=efd44cf468fe7e7ff9150dc52879426e0d0801eb Bdw, good try if it's your first patch :) Thanks > --- > drivers/staging/iio/adc/ad7606.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7606.c > b/drivers/staging/iio/adc/ad7606.c > index 0b728b6ea135..230faae38c12 100644 > --- a/drivers/staging/iio/adc/ad7606.c > +++ b/drivers/staging/iio/adc/ad7606.c > @@ -376,7 +376,7 @@ static int ad7606_request_gpios(struct > ad7606_state *st) > return 0; > > st->gpio_os = devm_gpiod_get_array_optional(dev, > "oversampling-ratio", > - GPIOD_OUT_LOW); > + GPIOD_OUT_LOW); > return PTR_ERR_OR_ZERO(st->gpio_os); > } > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
Replace calls to kzalloc or kmalloc followed by a memcpy with a direct call to kmemdup to shorten the code. The Coccinelle semantic patch used to make this change is as follows: @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); Signed-off-by: Shreeya Patel --- drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index f9ed697..36ea14e 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1271,15 +1271,14 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf) lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk; if (lnd_tunables) { - ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables), + ni->ni_lnd_tunables = kmemdup(lnd_tunables, + sizeof(*ni->ni_lnd_tunables), GFP_NOFS); if (!ni->ni_lnd_tunables) { mutex_unlock(_lnet.ln_lnd_mutex); rc = -ENOMEM; goto failed0; } - memcpy(ni->ni_lnd_tunables, lnd_tunables, - sizeof(*ni->ni_lnd_tunables)); } /* -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 6/6] Staging: iio: adis16209: Move adis16209 driver out of staging
Move the adis16209 driver out of staging directory and merge to the mainline IIO subsystem. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v6 -Move driver adis16209 from staging to mainline IIO subsystem after complete cleanup of it. drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile| 1 + drivers/iio/accel/adis16209.c | 330 ++ drivers/staging/iio/accel/Kconfig | 12 -- drivers/staging/iio/accel/Makefile| 1 - drivers/staging/iio/accel/adis16209.c | 330 -- 6 files changed, 343 insertions(+), 343 deletions(-) create mode 100644 drivers/iio/accel/adis16209.c delete mode 100644 drivers/staging/iio/accel/adis16209.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index c6d9517..f95f43c 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -5,6 +5,18 @@ menu "Accelerometers" +config ADIS16209 +tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" +depends on SPI +select IIO_ADIS_LIB +select IIO_ADIS_LIB_BUFFER if IIO_BUFFER +help + Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer + and accelerometer. + + To compile this driver as a module, say M here: the module will be + called adis16209. + config ADXL345 tristate diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 368aedb..40861b9 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -4,6 +4,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_ADIS16209) += adis16209.o obj-$(CONFIG_ADXL345) += adxl345_core.o obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c new file mode 100644 index 000..cc50667 --- /dev/null +++ b/drivers/iio/accel/adis16209.c @@ -0,0 +1,330 @@ +/* + * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer + * + * Copyright 2010 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define ADIS16209_STARTUP_DELAY_MS 220 +#define ADIS16209_FLASH_CNT_REG0x00 + +/* Data Output Register Definitions */ +#define ADIS16209_SUPPLY_OUT_REG 0x02 +#define ADIS16209_XACCL_OUT_REG0x04 +#define ADIS16209_YACCL_OUT_REG0x06 +/* Output, auxiliary ADC input */ +#define ADIS16209_AUX_ADC_REG 0x08 +/* Output, temperature */ +#define ADIS16209_TEMP_OUT_REG 0x0A +/* Output, +/- 90 degrees X-axis inclination */ +#define ADIS16209_XINCL_OUT_REG0x0C +#define ADIS16209_YINCL_OUT_REG0x0E +/* Output, +/-180 vertical rotational position */ +#define ADIS16209_ROT_OUT_REG 0x10 + +/* + * Calibration Register Definitions. + * Acceleration, inclination or rotation offset null. + */ +#define ADIS16209_XACCL_NULL_REG 0x12 +#define ADIS16209_YACCL_NULL_REG 0x14 +#define ADIS16209_XINCL_NULL_REG 0x16 +#define ADIS16209_YINCL_NULL_REG 0x18 +#define ADIS16209_ROT_NULL_REG 0x1A + +/* Alarm Register Definitions */ +#define ADIS16209_ALM_MAG1_REG 0x20 +#define ADIS16209_ALM_MAG2_REG 0x22 +#define ADIS16209_ALM_SMPL1_REG0x24 +#define ADIS16209_ALM_SMPL2_REG0x26 +#define ADIS16209_ALM_CTRL_REG 0x28 + +#define ADIS16209_AUX_DAC_REG 0x30 +#define ADIS16209_GPIO_CTRL_REG0x32 +#define ADIS16209_SMPL_PRD_REG 0x36 +#define ADIS16209_AVG_CNT_REG 0x38 +#define ADIS16209_SLP_CNT_REG 0x3A + +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TESTBIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_ENBIT(2) +/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) + +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 +/* Power supply above 3.625 V */ +#define ADIS16209_STAT_POWER_HIGH_BIT 1 +/* Power supply below 3.15 V */ +#define ADIS16209_STAT_POWER_LOW_BIT 0 + +#define ADIS16209_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESETBIT(7) +#define ADIS16209_CMD_CLEAR_STAT BIT(4) +#define
[PATCH v6 5/6] Staging: iio: adis16209: Use GENMASK
Use GENMASK to improve readability and remove the local variables used to store intermediate data. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v6 -Introduce this new patch in the series. drivers/staging/iio/accel/adis16209.c | 19 --- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index ed6d7c7..cc50667 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -112,25 +112,22 @@ static int adis16209_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *st = iio_priv(indio_dev); - int bits; - s16 val16; - u8 addr; + int m; + + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: switch (chan->type) { case IIO_ACCEL: case IIO_INCLI: - bits = 14; + m = GENMASK(13, 0); break; default: return -EINVAL; } - val16 = val & ((1 << bits) - 1); - addr = adis16209_addresses[chan->scan_index][0]; - return adis_write_reg_16(st, addr, val16); - } - return -EINVAL; + + return adis_write_reg_16(st, adis16209_addresses[chan->scan_index][0], +val & m); } static int adis16209_read_raw(struct iio_dev *indio_dev, -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 4/6] Staging: iio: adis16209: Remove unused headers
Remove few unused header files since the adis core handles the sysfs and buffer support. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v6 -Introduce this new patch in the series. drivers/staging/iio/accel/adis16209.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index ee7e87b..ed6d7c7 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -6,7 +6,6 @@ * Licensed under the GPL-2 or later. */ -#include #include #include #include @@ -16,8 +15,6 @@ #include #include -#include -#include #include #define ADIS16209_STARTUP_DELAY_MS 220 -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 3/6] Staging: iio: adis16209: Add a blank line after return statements
Add a blank line after return statements to improve the code readability. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v6 -Introduce this new patch in the series. drivers/staging/iio/accel/adis16209.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 8f4fa6b..ee7e87b 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -277,6 +277,7 @@ static int adis16209_probe(struct spi_device *spi) indio_dev = devm_iio_device_alloc(>dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; + st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); @@ -290,6 +291,7 @@ static int adis16209_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, _data); if (ret) return ret; + ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) return ret; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 2/6] Staging: iio: adis16209: Prefer reverse christmas tree ordering
Prefer reverse christmas tree ordering of declarations to improve readability. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v6 -Introduce this new patch in the series. drivers/staging/iio/accel/adis16209.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 0e6366a..8f4fa6b 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -270,9 +270,9 @@ static const struct adis_data adis16209_data = { static int adis16209_probe(struct spi_device *spi) { - int ret; - struct adis *st; struct iio_dev *indio_dev; + struct adis *st; + int ret; indio_dev = devm_iio_device_alloc(>dev, sizeof(*st)); if (!indio_dev) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 1/6] Staging: iio: adis16209: Indent the field definitions
Have indentation in field definitions to make them clearly different from the register addresses. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v5 -Change some macro names and have indentation in the field definitions. Changes in v6 -Have indentation in the field definitions and do not change the names of the macros as the patch for changing the names has already been applied. drivers/staging/iio/accel/adis16209.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index a8453bf..0e6366a 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -71,13 +71,13 @@ #define ADIS16209_STAT_REG 0x3C #define ADIS16209_STAT_ALARM2 BIT(9) #define ADIS16209_STAT_ALARM1 BIT(8) -#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_STAT_SPI_FAIL_BIT3 -#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 /* Power supply above 3.625 V */ -#define ADIS16209_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_STAT_POWER_HIGH_BIT 1 /* Power supply below 3.15 V */ -#define ADIS16209_STAT_POWER_LOW_BIT 0 +#define ADIS16209_STAT_POWER_LOW_BIT 0 #define ADIS16209_CMD_REG 0x3E #define ADIS16209_CMD_SW_RESETBIT(7) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 0/6] adis16209 driver cleanup
This patchset has been introduced for the cleanup of adis16209 driver. This patchset cleans up miscellaneous code fragments and improves the code readability. After the cleanup, driver is moved from staging to mailine IIO subsystem directory. Changes in v6 -This patchset has some new patches introduced for more cleanup and from the previous version, patch *[1/6] has been included in this patch series. Shreeya Patel (6): Staging: iio: adis16209: Indent the field definitions Staging: iio: adis16209: Prefer reverse christmas tree ordering Staging: iio: adis16209: Add blank lines Staging: iio: adis16209: Remove unused headers Staging: iio: adis16209: Use GENMASK Staging: iio: adis16209: Move adis16209 driver out of staging drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile| 1 + drivers/iio/accel/adis16209.c | 330 + drivers/staging/iio/accel/Kconfig | 12 -- drivers/staging/iio/accel/Makefile| 1 - drivers/staging/iio/accel/adis16209.c | 334 -- 6 files changed, 343 insertions(+), 347 deletions(-) create mode 100644 drivers/iio/accel/adis16209.c delete mode 100644 drivers/staging/iio/accel/adis16209.c -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] Staging: iio: adis16209: Move adis16209 driver out of staging
On 10 March 2018 21:27:31 GMT+05:30, Jonathan Cameron <ji...@kernel.org> Hi Jonathan >On Sat, 10 Mar 2018 15:50:23 +0530 >Shreeya Patel <shreeya.patel23...@gmail.com> wrote: > >> Move the adis16209 driver out of staging directory and merge to the >> mainline IIO subsystem. >> >> Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> >As this has a clear dependency on the previous patch, please put them >in the same series for the next version. That way I won't miss one! > >This also doesn't actually seem to have all the patches in place. >The sign extend one is definitely missing for some reason. > >One question on the ABI choice of X for the rotation axis. >I think the logical choice is actually Z but would like to know what >you and others think. > >All existing users of IIO_ROT (outside staging) have been magnetometer >where we don't have an axis, but rather a magnetic reference frame or >a quaternion output which includes all the axes. > >Jonathan > >> --- >> >> Changes in v2 >> -Re-send the patch after having some cleanups in the >> file included in this patch. >> >> drivers/iio/accel/Kconfig | 12 ++ >> drivers/iio/accel/Makefile| 1 + >> drivers/iio/accel/adis16209.c | 329 >++ >> drivers/staging/iio/accel/Kconfig | 12 -- >> drivers/staging/iio/accel/Makefile| 1 - >> drivers/staging/iio/accel/adis16209.c | 329 >-- >> 6 files changed, 342 insertions(+), 342 deletions(-) >> create mode 100644 drivers/iio/accel/adis16209.c >> delete mode 100644 drivers/staging/iio/accel/adis16209.c >> >> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig >> index c6d9517..f95f43c 100644 >> --- a/drivers/iio/accel/Kconfig >> +++ b/drivers/iio/accel/Kconfig >> @@ -5,6 +5,18 @@ >> >> menu "Accelerometers" >> >> +config ADIS16209 >> +tristate "Analog Devices ADIS16209 Dual-Axis Digital >Inclinometer and Accelerometer" >> +depends on SPI >> +select IIO_ADIS_LIB >> +select IIO_ADIS_LIB_BUFFER if IIO_BUFFER >> +help >> + Say Y here to build support for Analog Devices adis16209 >dual-axis digital inclinometer >> + and accelerometer. >> + >> + To compile this driver as a module, say M here: the module >will be >> + called adis16209. >> + >> config ADXL345 >> tristate >> >> diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile >> index 368aedb..40861b9 100644 >> --- a/drivers/iio/accel/Makefile >> +++ b/drivers/iio/accel/Makefile >> @@ -4,6 +4,7 @@ >> # >> >> # When adding new entries keep the list in alphabetical order >> +obj-$(CONFIG_ADIS16209) += adis16209.o >> obj-$(CONFIG_ADXL345) += adxl345_core.o >> obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o >> obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o >> diff --git a/drivers/iio/accel/adis16209.c >b/drivers/iio/accel/adis16209.c >> new file mode 100644 >> index 000..ed2e89f >> --- /dev/null >> +++ b/drivers/iio/accel/adis16209.c >> @@ -0,0 +1,329 @@ >> +/* >> + * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer >> + * >> + * Copyright 2010 Analog Devices Inc. >> + * >> + * Licensed under the GPL-2 or later. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#define ADIS16209_STARTUP_DELAY_MS 220 >> +#define ADIS16209_FLASH_CNT_REG 0x00 >> + >> +/* Data Output Register Definitions */ >> +#define ADIS16209_SUPPLY_OUT_REG0x02 >> +#define ADIS16209_XACCL_OUT_REG 0x04 >> +#define ADIS16209_YACCL_OUT_REG 0x06 >> +/* Output, auxiliary ADC input */ >> +#define ADIS16209_AUX_ADC_REG 0x08 >> +/* Output, temperature */ >> +#define ADIS16209_TEMP_OUT_REG 0x0A >> +/* Output, +/- 90 degrees X-axis inclination */ >> +#define ADIS16209_XINCL_OUT_REG 0x0C >> +#define ADIS16209_YINCL_OUT_REG 0x0E >> +/* Output, +/-180 vertical rotational position */ >> +#define ADIS16209_ROT_OUT_REG 0x10 >> + >> +/* >> + * Calibration Register Definitions. >> + * Acceleration, inclina
Re: [PATCH v2] Staging: iio: adis16209: Move adis16209 driver out of staging
On 16 March 2018 00:31:53 GMT+05:30, Shreeya Patel <shreeya.patel23...@gmail.com> wrote: >On Sat, 2018-03-10 at 15:57 +, Jonathan Cameron wrote: > >Hi Jonathan, > >> On Sat, 10 Mar 2018 15:50:23 +0530 >> Shreeya Patel <shreeya.patel23...@gmail.com> wrote: >> >> > >> > Move the adis16209 driver out of staging directory and merge to the >> > mainline IIO subsystem. >> > >> > Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> >> As this has a clear dependency on the previous patch, please put them >> in the same series for the next version. That way I won't miss one! >> >> This also doesn't actually seem to have all the patches in place. >> The sign extend one is definitely missing for some reason. >> >> One question on the ABI choice of X for the rotation axis. >> I think the logical choice is actually Z but would like to know what >> you and others think. >> >> All existing users of IIO_ROT (outside staging) have been >> magnetometer >> where we don't have an axis, but rather a magnetic reference frame or >> a quaternion output which includes all the axes. >> >> Jonathan >> >> > >> > --- >> > >> > Changes in v2 >> > -Re-send the patch after having some cleanups in the >> > file included in this patch. >> > >> > drivers/iio/accel/Kconfig | 12 ++ >> > drivers/iio/accel/Makefile| 1 + >> > drivers/iio/accel/adis16209.c | 329 >> > ++ >> > drivers/staging/iio/accel/Kconfig | 12 -- >> > drivers/staging/iio/accel/Makefile| 1 - >> > drivers/staging/iio/accel/adis16209.c | 329 -- >> > >> > 6 files changed, 342 insertions(+), 342 deletions(-) >> > create mode 100644 drivers/iio/accel/adis16209.c >> > delete mode 100644 drivers/staging/iio/accel/adis16209.c >> > >> > diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig >> > index c6d9517..f95f43c 100644 >> > --- a/drivers/iio/accel/Kconfig >> > +++ b/drivers/iio/accel/Kconfig >> > @@ -5,6 +5,18 @@ >> > >> > menu "Accelerometers" >> > >> > +config ADIS16209 >> > +tristate "Analog Devices ADIS16209 Dual-Axis Digital >> > Inclinometer and Accelerometer" >> > +depends on SPI >> > +select IIO_ADIS_LIB >> > +select IIO_ADIS_LIB_BUFFER if IIO_BUFFER >> > +help >> > + Say Y here to build support for Analog Devices adis16209 >> > dual-axis digital inclinometer >> > + and accelerometer. >> > + >> > + To compile this driver as a module, say M here: the >> > module will be >> > + called adis16209. >> > + >> > config ADXL345 >> > tristate >> > >> > diff --git a/drivers/iio/accel/Makefile >> > b/drivers/iio/accel/Makefile >> > index 368aedb..40861b9 100644 >> > --- a/drivers/iio/accel/Makefile >> > +++ b/drivers/iio/accel/Makefile >> > @@ -4,6 +4,7 @@ >> > # >> > >> > # When adding new entries keep the list in alphabetical order >> > +obj-$(CONFIG_ADIS16209) += adis16209.o >> > obj-$(CONFIG_ADXL345) += adxl345_core.o >> > obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o >> > obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o >> > diff --git a/drivers/iio/accel/adis16209.c >> > b/drivers/iio/accel/adis16209.c >> > new file mode 100644 >> > index 000..ed2e89f >> > --- /dev/null >> > +++ b/drivers/iio/accel/adis16209.c >> > @@ -0,0 +1,329 @@ >> > +/* >> > + * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer >> > + * >> > + * Copyright 2010 Analog Devices Inc. >> > + * >> > + * Licensed under the GPL-2 or later. >> > + */ >> > + >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > + >> > +#include >> > +#include >> > +#include >> > +#include >> > + >> > +#define ADIS16209_STARTUP_DELAY_MS220 >> > +#define ADIS16209_FLASH_CNT_REG 0x00 >> > + >> > +/* Data Output Register Definitions */ >> > +#define A
[PATCH v2] Staging: iio: adis16209: Move adis16209 driver out of staging
Move the adis16209 driver out of staging directory and merge to the mainline IIO subsystem. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v2 -Re-send the patch after having some cleanups in the file included in this patch. drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile| 1 + drivers/iio/accel/adis16209.c | 329 ++ drivers/staging/iio/accel/Kconfig | 12 -- drivers/staging/iio/accel/Makefile| 1 - drivers/staging/iio/accel/adis16209.c | 329 -- 6 files changed, 342 insertions(+), 342 deletions(-) create mode 100644 drivers/iio/accel/adis16209.c delete mode 100644 drivers/staging/iio/accel/adis16209.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index c6d9517..f95f43c 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -5,6 +5,18 @@ menu "Accelerometers" +config ADIS16209 +tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" +depends on SPI +select IIO_ADIS_LIB +select IIO_ADIS_LIB_BUFFER if IIO_BUFFER +help + Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer + and accelerometer. + + To compile this driver as a module, say M here: the module will be + called adis16209. + config ADXL345 tristate diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 368aedb..40861b9 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -4,6 +4,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_ADIS16209) += adis16209.o obj-$(CONFIG_ADXL345) += adxl345_core.o obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c new file mode 100644 index 000..ed2e89f --- /dev/null +++ b/drivers/iio/accel/adis16209.c @@ -0,0 +1,329 @@ +/* + * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer + * + * Copyright 2010 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define ADIS16209_STARTUP_DELAY_MS 220 +#define ADIS16209_FLASH_CNT_REG0x00 + +/* Data Output Register Definitions */ +#define ADIS16209_SUPPLY_OUT_REG 0x02 +#define ADIS16209_XACCL_OUT_REG0x04 +#define ADIS16209_YACCL_OUT_REG0x06 +/* Output, auxiliary ADC input */ +#define ADIS16209_AUX_ADC_REG 0x08 +/* Output, temperature */ +#define ADIS16209_TEMP_OUT_REG 0x0A +/* Output, +/- 90 degrees X-axis inclination */ +#define ADIS16209_XINCL_OUT_REG0x0C +#define ADIS16209_YINCL_OUT_REG0x0E +/* Output, +/-180 vertical rotational position */ +#define ADIS16209_ROT_OUT_REG 0x10 + +/* + * Calibration Register Definitions. + * Acceleration, inclination or rotation offset null. + */ +#define ADIS16209_XACCL_NULL_REG 0x12 +#define ADIS16209_YACCL_NULL_REG 0x14 +#define ADIS16209_XINCL_NULL_REG 0x16 +#define ADIS16209_YINCL_NULL_REG 0x18 +#define ADIS16209_ROT_NULL_REG 0x1A + +/* Alarm Register Definitions */ +#define ADIS16209_ALM_MAG1_REG 0x20 +#define ADIS16209_ALM_MAG2_REG 0x22 +#define ADIS16209_ALM_SMPL1_REG0x24 +#define ADIS16209_ALM_SMPL2_REG0x26 +#define ADIS16209_ALM_CTRL_REG 0x28 + +#define ADIS16209_AUX_DAC_REG 0x30 +#define ADIS16209_GPIO_CTRL_REG0x32 +#define ADIS16209_SMPL_PRD_REG 0x36 +#define ADIS16209_AVG_CNT_REG 0x38 +#define ADIS16209_SLP_CNT_REG 0x3A + +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TESTBIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_ENBIT(2) +/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) + +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 +/* Power supply above 3.625 V */ +#define ADIS16209_STAT_POWER_HIGH_BIT 1 +/* Power supply below 3.15 V */ +#define ADIS16209_STAT_POWER_LOW_BIT 0 + +#define ADIS16209_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESETBIT(7) +#define ADIS16209_CMD_CLEAR_STAT
[PATCH v5] Staging: iio: adis16209: Change some macro names
Make some of the macro names according to the names given in the datasheet of the adis16209 driver and have slight indentation in field definitions to make them clearly different from the register addresses. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v5 -Re-send the corrected patch. drivers/staging/iio/accel/adis16209.c | 48 +-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index d8aef9c..ed2e89f 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -68,21 +68,21 @@ #define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) #define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -#define ADIS16209_DIAG_STAT_REG0x3C -#define ADIS16209_DIAG_STAT_ALARM2BIT(9) -#define ADIS16209_DIAG_STAT_ALARM1BIT(8) -#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 /* Power supply above 3.625 V */ -#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_STAT_POWER_HIGH_BIT 1 /* Power supply below 3.15 V */ -#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 +#define ADIS16209_STAT_POWER_LOW_BIT 0 -#define ADIS16209_GLOB_CMD_REG 0x3E -#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) -#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) -#define ADIS16209_GLOB_CMD_FACTORY_CALBIT(1) +#define ADIS16209_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESETBIT(7) +#define ADIS16209_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_CMD_FACTORY_CAL BIT(1) #define ADIS16209_ERROR_ACTIVE BIT(14) @@ -238,29 +238,29 @@ static const struct iio_info adis16209_info = { }; static const char * const adis16209_status_error_msgs[] = { - [ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT] = "Self test failure", - [ADIS16209_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", - [ADIS16209_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", - [ADIS16209_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16209_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16209_STAT_SELFTEST_FAIL_BIT] = "Self test failure", + [ADIS16209_STAT_SPI_FAIL_BIT] = "SPI failure", + [ADIS16209_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed", + [ADIS16209_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", + [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", }; static const struct adis_data adis16209_data = { .read_delay = 30, .msc_ctrl_reg = ADIS16209_MSC_CTRL_REG, - .glob_cmd_reg = ADIS16209_GLOB_CMD_REG, - .diag_stat_reg = ADIS16209_DIAG_STAT_REG, + .glob_cmd_reg = ADIS16209_CMD_REG, + .diag_stat_reg = ADIS16209_STAT_REG, .self_test_mask = ADIS16209_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, .startup_delay = ADIS16209_STARTUP_DELAY_MS, .status_error_msgs = adis16209_status_error_msgs, - .status_error_mask = BIT(ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT) | - BIT(ADIS16209_DIAG_STAT_SPI_FAIL_BIT) | - BIT(ADIS16209_DIAG_STAT_FLASH_UPT_BIT) | - BIT(ADIS16209_DIAG_STAT_POWER_HIGH_BIT) | - BIT(ADIS16209_DIAG_STAT_POWER_LOW_BIT), + .status_error_mask = BIT(ADIS16209_STAT_SELFTEST_FAIL_BIT) | + BIT(ADIS16209_STAT_SPI_FAIL_BIT) | + BIT(ADIS16209_STAT_FLASH_UPT_FAIL_BIT) | + BIT(ADIS16209_STAT_POWER_HIGH_BIT) | + BIT(ADIS16209_STAT_POWER_LOW_BIT), }; static int adis16209_probe(struct spi_device *spi) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4] Staging: iio: adis16209: Change some macro names
On 9 March 2018 00:41:12 GMT+05:30, Himanshu Jha <himanshujha199...@gmail.com> wrote: >On Thu, Mar 08, 2018 at 11:46:17PM +0530, Shreeya Patel wrote: >> Make some of the macro names according to the names >> given in the datasheet of the adis16209 driver and >> have slight indentation in field definitions to make >> them clearly different from the register addresses. >> >> Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> >> --- >> >> Changes in v4 >> -Have slight indentation in field definitions. >> >> drivers/staging/iio/accel/adis16209.c | 48 >+-- >> 1 file changed, 24 insertions(+), 24 deletions(-) >> >> diff --git a/drivers/staging/iio/accel/adis16209.c >b/drivers/staging/iio/accel/adis16209.c >> index eb5c878..19636e2 100644 >> --- a/drivers/staging/iio/accel/adis16209.c >> +++ b/drivers/staging/iio/accel/adis16209.c >> @@ -68,21 +68,21 @@ >> #define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) >> #define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) >> >> -#define ADIS16209_STAT_REG 0x3C >> -#define ADIS16209_STAT_ALARM2 BIT(9) >> -#define ADIS16209_STAT_ALARM1 BIT(8) >> -#define ADIS16209_STAT_SELFTEST_FAIL_BIT5 >> -#define ADIS16209_STAT_SPI_FAIL_BIT 3 >> -#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 >> +#define ADIS16209_DIAG_STAT_REG 0x3C >> +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) >> +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) >> +#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 >> +#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 >> +#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 > >#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT2 >? >It represents flash update fail bit! I think so that I have sent the wrong patch :( This is totally the reverse of the change that I wanted to have. Maybe I messed up with this patch. Jonathan, please avoid this patch. I'll send the corrected one soon. Thanks -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: iio: adis16209: Move adis16209 driver out of staging
Move the adis16209 driver out of staging directory and merge to the mainline IIO subsystem. --- drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile| 1 + drivers/iio/accel/adis16209.c | 334 ++ drivers/staging/iio/accel/Kconfig | 12 -- drivers/staging/iio/accel/Makefile| 1 - drivers/staging/iio/accel/adis16209.c | 334 -- 6 files changed, 347 insertions(+), 347 deletions(-) create mode 100644 drivers/iio/accel/adis16209.c delete mode 100644 drivers/staging/iio/accel/adis16209.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index c6d9517..f95f43c 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -5,6 +5,18 @@ menu "Accelerometers" +config ADIS16209 +tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" +depends on SPI +select IIO_ADIS_LIB +select IIO_ADIS_LIB_BUFFER if IIO_BUFFER +help + Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer + and accelerometer. + + To compile this driver as a module, say M here: the module will be + called adis16209. + config ADXL345 tristate diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 368aedb..40861b9 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -4,6 +4,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_ADIS16209) += adis16209.o obj-$(CONFIG_ADXL345) += adxl345_core.o obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c new file mode 100644 index 000..4fe93ae --- /dev/null +++ b/drivers/iio/accel/adis16209.c @@ -0,0 +1,334 @@ +/* + * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer + * + * Copyright 2010 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define ADIS16209_STARTUP_DELAY_MS 220 +#define ADIS16209_FLASH_CNT_REG0x00 + +/* Data Output Register Definitions */ +#define ADIS16209_SUPPLY_OUT_REG 0x02 +#define ADIS16209_XACCL_OUT_REG0x04 +#define ADIS16209_YACCL_OUT_REG0x06 +/* Output, auxiliary ADC input */ +#define ADIS16209_AUX_ADC_REG 0x08 +/* Output, temperature */ +#define ADIS16209_TEMP_OUT_REG 0x0A +/* Output, +/- 90 degrees X-axis inclination */ +#define ADIS16209_XINCL_OUT_REG0x0C +#define ADIS16209_YINCL_OUT_REG0x0E +/* Output, +/-180 vertical rotational position */ +#define ADIS16209_ROT_OUT_REG 0x10 + +/* + * Calibration Register Definitions. + * Acceleration, inclination or rotation offset null. + */ +#define ADIS16209_XACCL_NULL_REG 0x12 +#define ADIS16209_YACCL_NULL_REG 0x14 +#define ADIS16209_XINCL_NULL_REG 0x16 +#define ADIS16209_YINCL_NULL_REG 0x18 +#define ADIS16209_ROT_NULL_REG 0x1A + +/* Alarm Register Definitions */ +#define ADIS16209_ALM_MAG1_REG 0x20 +#define ADIS16209_ALM_MAG2_REG 0x22 +#define ADIS16209_ALM_SMPL1_REG0x24 +#define ADIS16209_ALM_SMPL2_REG0x26 +#define ADIS16209_ALM_CTRL_REG 0x28 + +#define ADIS16209_AUX_DAC_REG 0x30 +#define ADIS16209_GPIO_CTRL_REG0x32 +#define ADIS16209_SMPL_PRD_REG 0x36 +#define ADIS16209_AVG_CNT_REG 0x38 +#define ADIS16209_SLP_CNT_REG 0x3A + +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TESTBIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_ENBIT(2) +/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) + +#define ADIS16209_DIAG_STAT_REG0x3C +#define ADIS16209_DIAG_STAT_ALARM2BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1BIT(8) +#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 +/* Power supply above 3.625 V */ +#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT1 +/* Power supply below 3.15 V */ +#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 + +#define ADIS16209_GLOB_CMD_REG 0x3E +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CALBIT(1) + +#define ADIS16209_ERROR_ACTIVE BIT(14) + +enum adis16209_scan { + ADIS16209_SCAN_SUPPLY, +
[PATCH v4] Staging: iio: adis16209: Change some macro names
Make some of the macro names according to the names given in the datasheet of the adis16209 driver and have slight indentation in field definitions to make them clearly different from the register addresses. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v4 -Have slight indentation in field definitions. drivers/staging/iio/accel/adis16209.c | 48 +-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index eb5c878..19636e2 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -68,21 +68,21 @@ #define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) #define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -#define ADIS16209_STAT_REG 0x3C -#define ADIS16209_STAT_ALARM2 BIT(9) -#define ADIS16209_STAT_ALARM1 BIT(8) -#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_STAT_SPI_FAIL_BIT3 -#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 +#define ADIS16209_DIAG_STAT_REG0x3C +#define ADIS16209_DIAG_STAT_ALARM2BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1BIT(8) +#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 /* Power supply above 3.625 V */ -#define ADIS16209_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT1 /* Power supply below 3.15 V */ -#define ADIS16209_STAT_POWER_LOW_BIT 0 +#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 -#define ADIS16209_CMD_REG 0x3E -#define ADIS16209_CMD_SW_RESETBIT(7) -#define ADIS16209_CMD_CLEAR_STAT BIT(4) -#define ADIS16209_CMD_FACTORY_CAL BIT(1) +#define ADIS16209_GLOB_CMD_REG 0x3E +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CALBIT(1) #define ADIS16209_ERROR_ACTIVE BIT(14) @@ -238,29 +238,29 @@ static const struct iio_info adis16209_info = { }; static const char * const adis16209_status_error_msgs[] = { - [ADIS16209_STAT_SELFTEST_FAIL_BIT] = "Self test failure", - [ADIS16209_STAT_SPI_FAIL_BIT] = "SPI failure", - [ADIS16209_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed", - [ADIS16209_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT] = "Self test failure", + [ADIS16209_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", + [ADIS16209_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", + [ADIS16209_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", + [ADIS16209_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", }; static const struct adis_data adis16209_data = { .read_delay = 30, .msc_ctrl_reg = ADIS16209_MSC_CTRL_REG, - .glob_cmd_reg = ADIS16209_CMD_REG, - .diag_stat_reg = ADIS16209_STAT_REG, + .glob_cmd_reg = ADIS16209_GLOB_CMD_REG, + .diag_stat_reg = ADIS16209_DIAG_STAT_REG, .self_test_mask = ADIS16209_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, .startup_delay = ADIS16209_STARTUP_DELAY_MS, .status_error_msgs = adis16209_status_error_msgs, - .status_error_mask = BIT(ADIS16209_STAT_SELFTEST_FAIL_BIT) | - BIT(ADIS16209_STAT_SPI_FAIL_BIT) | - BIT(ADIS16209_STAT_FLASH_UPT_FAIL_BIT) | - BIT(ADIS16209_STAT_POWER_HIGH_BIT) | - BIT(ADIS16209_STAT_POWER_LOW_BIT), + .status_error_mask = BIT(ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT) | + BIT(ADIS16209_DIAG_STAT_SPI_FAIL_BIT) | + BIT(ADIS16209_DIAG_STAT_FLASH_UPT_BIT) | + BIT(ADIS16209_DIAG_STAT_POWER_HIGH_BIT) | + BIT(ADIS16209_DIAG_STAT_POWER_LOW_BIT), }; static int adis16209_probe(struct spi_device *spi) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 03/11] Staging: iio: accel: Remove unnecessary comments
On Mon, 2018-03-05 at 13:19 +0530, Himanshu Jha wrote: > Remove unnecessary comments since the definitions are pretty clear > with their macro names. > > Signed-off-by: Himanshu Jha> --- > drivers/staging/iio/accel/adis16201.c | 82 +-- > > 1 file changed, 10 insertions(+), 72 deletions(-) > > diff --git a/drivers/staging/iio/accel/adis16201.c > b/drivers/staging/iio/accel/adis16201.c > index 0fae8aa..59c1166 100644 > --- a/drivers/staging/iio/accel/adis16201.c > +++ b/drivers/staging/iio/accel/adis16201.c > @@ -20,87 +20,42 @@ > #include > #include > > -#define ADIS16201_STARTUP_DELAY 220 /* ms */ > +#define ADIS16201_STARTUP_DELAY 220 > > -/* Flash memory write count */ > #define ADIS16201_FLASH_CNT 0x00 > > -/* Output, power supply */ > +/* Data Output Register Information */ > #define ADIS16201_SUPPLY_OUT 0x02 > - > -/* Output, x-axis accelerometer */ > #define ADIS16201_XACCL_OUT 0x04 > - > -/* Output, y-axis accelerometer */ > #define ADIS16201_YACCL_OUT 0x06 > - > -/* Output, auxiliary ADC input */ > #define ADIS16201_AUX_ADC0x08 > - > -/* Output, temperature */ > #define ADIS16201_TEMP_OUT 0x0A > - > -/* Output, x-axis inclination */ > #define ADIS16201_XINCL_OUT 0x0C > - > -/* Output, y-axis inclination */ > #define ADIS16201_YINCL_OUT 0x0E > > -/* Calibration, x-axis acceleration offset */ > +/* Calibration Register Definition */ > #define ADIS16201_XACCL_OFFS 0x10 > - > -/* Calibration, y-axis acceleration offset */ > #define ADIS16201_YACCL_OFFS 0x12 > - > -/* x-axis acceleration scale factor */ > #define ADIS16201_XACCL_SCALE0x14 > - > -/* y-axis acceleration scale factor */ > #define ADIS16201_YACCL_SCALE0x16 > - > -/* Calibration, x-axis inclination offset */ > #define ADIS16201_XINCL_OFFS 0x18 > - > -/* Calibration, y-axis inclination offset */ > #define ADIS16201_YINCL_OFFS 0x1A > - > -/* x-axis inclination scale factor */ > #define ADIS16201_XINCL_SCALE0x1C > - > -/* y-axis inclination scale factor */ > #define ADIS16201_YINCL_SCALE0x1E > > -/* Alarm 1 amplitude threshold */ > +/* Alarm Register Definition */ > #define ADIS16201_ALM_MAG1 0x20 > - > -/* Alarm 2 amplitude threshold */ > #define ADIS16201_ALM_MAG2 0x22 > - > -/* Alarm 1, sample period */ > #define ADIS16201_ALM_SMPL1 0x24 > - > -/* Alarm 2, sample period */ > #define ADIS16201_ALM_SMPL2 0x26 > - > -/* Alarm control */ > #define ADIS16201_ALM_CTRL 0x28 > > -/* Auxiliary DAC data */ > #define ADIS16201_AUX_DAC0x30 > - > -/* General-purpose digital input/output control */ > #define ADIS16201_GPIO_CTRL 0x32 > - > -/* Miscellaneous control */ > #define ADIS16201_MSC_CTRL 0x34 > > -/* Internal sample period (rate) control */ > #define ADIS16201_SMPL_PRD 0x36 > - > -/* Operation, filter configuration */ > #define ADIS16201_AVG_CNT0x38 > - > -/* Operation, sleep mode control */ > #define ADIS16201_SLP_CNT0x3A > > /* Diagnostics, system status register */ > @@ -109,42 +64,28 @@ > /* Operation, system command register */ > #define ADIS16201_GLOB_CMD 0x3E > > -/* MSC_CTRL */ > > -/* Self-test enable */ > #define ADIS16201_MSC_CTRL_SELF_TEST_EN BIT(8) > > -/* Data-ready enable: 1 = enabled, 0 = disabled */ > #define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2) > > -/* Data-ready polarity: 1 = active high, 0 = active low */ > #define ADIS16201_MSC_CTRL_ACTIVE_HIGH BIT(1) > > -/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ > #define ADIS16201_MSC_CTRL_DATA_RDY_DIO1 BIT(0) > > -/* DIAG_STAT */ > > -/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ > #define ADIS16201_DIAG_STAT_ALARM2BIT(9) > > -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ > #define ADIS16201_DIAG_STAT_ALARM1BIT(8) > > -/* SPI communications failure */ > #define ADIS16201_DIAG_STAT_SPI_FAIL_BIT 3 > > -/* Flash update failure */ > #define ADIS16201_DIAG_STAT_FLASH_UPT_BIT 2 > > -/* Power supply above 3.625 V */ > #define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1 > > -/* Power supply below 3.15 V */ > #define ADIS16201_DIAG_STAT_POWER_LOW_BIT 0 > > -/* GLOB_CMD */ > - > #define ADIS16201_GLOB_CMD_SW_RESET BIT(7) > #define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1) I was just going through your patch for giving myself a habit of reading patches. I see here that there are many comments which are necessary have also been removed. Jonathan told that some of the names do not explain much about the how registers are related to the orientation. So it is necessary for some comments to be there here. I saw your next patch too, in which you are changing some of the names for betterment, but again, that doesn't cover everything which was told by Jonathan. Here is the link to the
Re: [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions
On Sun, 2018-03-04 at 18:26 +0530, Himanshu Jha wrote: > Hi Shreeya, > > On Sun, Mar 04, 2018 at 06:06:22PM +0530, Shreeya Patel wrote: > > > > Remove some unnecessay comments and group the control > > register and register field macros together. > > Some of the register names does not make it's puporse > > very clear and hence, add some comments for more > > information. > > Also there are certain unit based comments which are not > > providing sufficient information, so expand those comments. > > > > Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> > > --- > > > > Changes in v3 > > -This patch is the combination of two patches from the > > previous series. Also add some more comments. > > > > > > drivers/staging/iio/accel/adis16209.c | 132 ++-- > > -- > > 1 file changed, 39 insertions(+), 93 deletions(-) > > > > diff --git a/drivers/staging/iio/accel/adis16209.c > > b/drivers/staging/iio/accel/adis16209.c > > index 151120f..d8aef9c 100644 > > --- a/drivers/staging/iio/accel/adis16209.c > > +++ b/drivers/staging/iio/accel/adis16209.c > > @@ -21,135 +21,70 @@ > > #include > > > > #define ADIS16209_STARTUP_DELAY_MS 220 > > - > > -/* Flash memory write count */ > > #define ADIS16209_FLASH_CNT_REG0x00 > > > > -/* Output, power supply */ > > +/* Data Output Register Definitions */ > > #define ADIS16209_SUPPLY_OUT_REG 0x02 > > - > > -/* Output, x-axis accelerometer */ > > #define ADIS16209_XACCL_OUT_REG0x04 > > - > > -/* Output, y-axis accelerometer */ > > #define ADIS16209_YACCL_OUT_REG0x06 > > - > > /* Output, auxiliary ADC input */ > > #define ADIS16209_AUX_ADC_REG 0x08 > > - > > /* Output, temperature */ > > #define ADIS16209_TEMP_OUT_REG 0x0A > > - > > -/* Output, x-axis inclination */ > > +/* Output, +/- 90 degrees X-axis inclination */ > > #define ADIS16209_XINCL_OUT_REG0x0C > > - > > -/* Output, y-axis inclination */ > > #define ADIS16209_YINCL_OUT_REG0x0E > > - > > /* Output, +/-180 vertical rotational position */ > > #define ADIS16209_ROT_OUT_REG 0x10 > > > > -/* Calibration, x-axis acceleration offset null */ > > +/* > > + * Calibration Register Definitions. > > + * Acceleration, inclination or rotation offset null. > > + */ > > #define ADIS16209_XACCL_NULL_REG 0x12 > > - > > -/* Calibration, y-axis acceleration offset null */ > > #define ADIS16209_YACCL_NULL_REG 0x14 > > - > > -/* Calibration, x-axis inclination offset null */ > > #define ADIS16209_XINCL_NULL_REG 0x16 > > - > > -/* Calibration, y-axis inclination offset null */ > > #define ADIS16209_YINCL_NULL_REG 0x18 > > - > > -/* Calibration, vertical rotation offset null */ > > #define ADIS16209_ROT_NULL_REG 0x1A > > > > -/* Alarm 1 amplitude threshold */ > > +/* Alarm Register Definitions */ > > #define ADIS16209_ALM_MAG1_REG 0x20 > > - > > -/* Alarm 2 amplitude threshold */ > > #define ADIS16209_ALM_MAG2_REG 0x22 > > - > > -/* Alarm 1, sample period */ > > #define ADIS16209_ALM_SMPL1_REG0x24 > > - > > -/* Alarm 2, sample period */ > > #define ADIS16209_ALM_SMPL2_REG0x26 > > - > > -/* Alarm control */ > > #define ADIS16209_ALM_CTRL_REG 0x28 > > > > -/* Auxiliary DAC data */ > > #define ADIS16209_AUX_DAC_REG 0x30 > > - > > -/* General-purpose digital input/output control */ > > #define ADIS16209_GPIO_CTRL_REG0x32 > > - > > -/* Miscellaneous control */ > > -#define ADIS16209_MSC_CTRL_REG 0x34 > > - > > -/* Internal sample period (rate) control */ > > #define ADIS16209_SMPL_PRD_REG 0x36 > > - > > -/* Operation, filter configuration */ > > #define ADIS16209_AVG_CNT_REG 0x38 > > - > > -/* Operation, sleep mode control */ > > #define ADIS16209_SLP_CNT_REG 0x3A > > > > -/* Diagnostics, system status register */ > > -#define ADIS16209_DIAG_STAT_REG0x3C > > - > > -/* Operation, system command register */ > > -#define ADIS16209_GLOB_CMD_REG 0x3E > > - > > -/* MSC_CTRL */ > > - > > -/* Self-test at power-on: 1 = disabled, 0 = enabled */ > > -#define AD
[PATCH v3 4/4] Staging: iio: adis16209: Use sign_extend32 function
Use sign_extend32 function instead of manually coding it. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v3 -After split patch. drivers/staging/iio/accel/adis16209.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 9cb1ce0..a8453bf 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -212,9 +212,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, ret = adis_read_reg_16(st, addr, ); if (ret) return ret; - val16 &= (1 << bits) - 1; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + + *val = sign_extend32(val16, bits - 1); return IIO_VAL_INT; } return -EINVAL; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/4] Staging: iio: adis16209: Adjust a switch statement
Adjust a switch block to explicitly match channels and return -EINVAL as default case which makes the code semantically more clear. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v3 -After split patch. drivers/staging/iio/accel/adis16209.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index eb5c878..9cb1ce0 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -155,10 +155,16 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_VOLTAGE: *val = 0; - if (chan->channel == 0) + switch (chan->channel) { + case 0: *val2 = 305180; /* 0.30518 mV */ - else + break; + case 1: *val2 = 610500; /* 0.6105 mV */ + break; + default: + return -EINVAL; + } return IIO_VAL_INT_PLUS_MICRO; case IIO_TEMP: *val = -470; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/4] Staging: iio: adis16209: Change some macro names
Make some of the macro names according to the names given in the datasheet of the adis16209 driver. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v3 -Introduce this new patch for v3 of the series. drivers/staging/iio/accel/adis16209.c | 48 +-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index d8aef9c..eb5c878 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -68,21 +68,21 @@ #define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) #define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -#define ADIS16209_DIAG_STAT_REG0x3C -#define ADIS16209_DIAG_STAT_ALARM2BIT(9) -#define ADIS16209_DIAG_STAT_ALARM1BIT(8) -#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 /* Power supply above 3.625 V */ -#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_STAT_POWER_HIGH_BIT 1 /* Power supply below 3.15 V */ -#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 +#define ADIS16209_STAT_POWER_LOW_BIT 0 -#define ADIS16209_GLOB_CMD_REG 0x3E -#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) -#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) -#define ADIS16209_GLOB_CMD_FACTORY_CALBIT(1) +#define ADIS16209_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESETBIT(7) +#define ADIS16209_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_CMD_FACTORY_CAL BIT(1) #define ADIS16209_ERROR_ACTIVE BIT(14) @@ -238,29 +238,29 @@ static const struct iio_info adis16209_info = { }; static const char * const adis16209_status_error_msgs[] = { - [ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT] = "Self test failure", - [ADIS16209_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", - [ADIS16209_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", - [ADIS16209_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16209_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16209_STAT_SELFTEST_FAIL_BIT] = "Self test failure", + [ADIS16209_STAT_SPI_FAIL_BIT] = "SPI failure", + [ADIS16209_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed", + [ADIS16209_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", + [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", }; static const struct adis_data adis16209_data = { .read_delay = 30, .msc_ctrl_reg = ADIS16209_MSC_CTRL_REG, - .glob_cmd_reg = ADIS16209_GLOB_CMD_REG, - .diag_stat_reg = ADIS16209_DIAG_STAT_REG, + .glob_cmd_reg = ADIS16209_CMD_REG, + .diag_stat_reg = ADIS16209_STAT_REG, .self_test_mask = ADIS16209_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, .startup_delay = ADIS16209_STARTUP_DELAY_MS, .status_error_msgs = adis16209_status_error_msgs, - .status_error_mask = BIT(ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT) | - BIT(ADIS16209_DIAG_STAT_SPI_FAIL_BIT) | - BIT(ADIS16209_DIAG_STAT_FLASH_UPT_BIT) | - BIT(ADIS16209_DIAG_STAT_POWER_HIGH_BIT) | - BIT(ADIS16209_DIAG_STAT_POWER_LOW_BIT), + .status_error_mask = BIT(ADIS16209_STAT_SELFTEST_FAIL_BIT) | + BIT(ADIS16209_STAT_SPI_FAIL_BIT) | + BIT(ADIS16209_STAT_FLASH_UPT_FAIL_BIT) | + BIT(ADIS16209_STAT_POWER_HIGH_BIT) | + BIT(ADIS16209_STAT_POWER_LOW_BIT), }; static int adis16209_probe(struct spi_device *spi) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions
Remove some unnecessay comments and group the control register and register field macros together. Some of the register names does not make it's puporse very clear and hence, add some comments for more information. Also there are certain unit based comments which are not providing sufficient information, so expand those comments. Signed-off-by: Shreeya Patel <shreeya.patel23...@gmail.com> --- Changes in v3 -This patch is the combination of two patches from the previous series. Also add some more comments. drivers/staging/iio/accel/adis16209.c | 132 ++ 1 file changed, 39 insertions(+), 93 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 151120f..d8aef9c 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -21,135 +21,70 @@ #include #define ADIS16209_STARTUP_DELAY_MS 220 - -/* Flash memory write count */ #define ADIS16209_FLASH_CNT_REG0x00 -/* Output, power supply */ +/* Data Output Register Definitions */ #define ADIS16209_SUPPLY_OUT_REG 0x02 - -/* Output, x-axis accelerometer */ #define ADIS16209_XACCL_OUT_REG0x04 - -/* Output, y-axis accelerometer */ #define ADIS16209_YACCL_OUT_REG0x06 - /* Output, auxiliary ADC input */ #define ADIS16209_AUX_ADC_REG 0x08 - /* Output, temperature */ #define ADIS16209_TEMP_OUT_REG 0x0A - -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define ADIS16209_XINCL_OUT_REG0x0C - -/* Output, y-axis inclination */ #define ADIS16209_YINCL_OUT_REG0x0E - /* Output, +/-180 vertical rotational position */ #define ADIS16209_ROT_OUT_REG 0x10 -/* Calibration, x-axis acceleration offset null */ +/* + * Calibration Register Definitions. + * Acceleration, inclination or rotation offset null. + */ #define ADIS16209_XACCL_NULL_REG 0x12 - -/* Calibration, y-axis acceleration offset null */ #define ADIS16209_YACCL_NULL_REG 0x14 - -/* Calibration, x-axis inclination offset null */ #define ADIS16209_XINCL_NULL_REG 0x16 - -/* Calibration, y-axis inclination offset null */ #define ADIS16209_YINCL_NULL_REG 0x18 - -/* Calibration, vertical rotation offset null */ #define ADIS16209_ROT_NULL_REG 0x1A -/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define ADIS16209_ALM_MAG1_REG 0x20 - -/* Alarm 2 amplitude threshold */ #define ADIS16209_ALM_MAG2_REG 0x22 - -/* Alarm 1, sample period */ #define ADIS16209_ALM_SMPL1_REG0x24 - -/* Alarm 2, sample period */ #define ADIS16209_ALM_SMPL2_REG0x26 - -/* Alarm control */ #define ADIS16209_ALM_CTRL_REG 0x28 -/* Auxiliary DAC data */ #define ADIS16209_AUX_DAC_REG 0x30 - -/* General-purpose digital input/output control */ #define ADIS16209_GPIO_CTRL_REG0x32 - -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define ADIS16209_SMPL_PRD_REG 0x36 - -/* Operation, filter configuration */ #define ADIS16209_AVG_CNT_REG 0x38 - -/* Operation, sleep mode control */ #define ADIS16209_SLP_CNT_REG 0x3A -/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_ENBIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TESTBIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_ENBIT(2) /* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGHBIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) - -/* DIAG_STAT */ - -/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM2BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ +#define ADIS16209_DIAG_STAT_REG0x3C +#define ADIS16209_DIAG_STAT_ALARM2BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1BIT(8) #define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 - -