Re: [PATCH 09/30] staging: mt7621-mmc: Remove function uffs
On Mon, Apr 30 2018, Christian Lütke-Stetzkamp wrote: > On Mon, Apr 30, 2018 at 08:28:26AM +1000, NeilBrown wrote: >> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote: >> >> > The function uffs that is implemented by this driver returns the same >> > values as the kernel function ffs. So the uffs function is removed and >> > the calls to it are replaced with calls to ffs. >> >> This difference is that uffs receives and returns an "unsigned int". >> Maybe not a significant difference, but worth mentioning that you >> noticed it and reasoned that it wasn't significant. >> > Yes the type of the uffs function is unsigned int but I tested it for > all values, that the number returned is the same (in binary form). So > I don't think that it is significant. > >> > @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, >> > u32 bs) >> > do { \ >> >volatile unsigned int tv = sdr_read32(reg); \ >> >tv &= ~(field); \ >> > - tv |= ((val) << (uffs((unsigned int)field) - 1)); \ >> > + tv |= ((val) << (ffs((unsigned int)field) - 1));\ >> >> Given that ffs() takes an "int", it is odd to cast "field" to an >> unsigned int to pass it. >> "field" is always a constant int, so no cast is needed. > > That's correct, but I took it that way, because that is how the mtk-sd > driver does it. This makes the similarities more significant, but if > you like I'll change it. Ahhh, OK. I guess it makes sense to say "bug-for-bug" (sort-of) compatible with the mtk-sd driver code. I'll try to remember to fix that up once this all lands. Thanks, NeilBrown signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 09/30] staging: mt7621-mmc: Remove function uffs
On Mon, Apr 30, 2018 at 08:28:26AM +1000, NeilBrown wrote: > On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote: > > > The function uffs that is implemented by this driver returns the same > > values as the kernel function ffs. So the uffs function is removed and > > the calls to it are replaced with calls to ffs. > > This difference is that uffs receives and returns an "unsigned int". > Maybe not a significant difference, but worth mentioning that you > noticed it and reasoned that it wasn't significant. > Yes the type of the uffs function is unsigned int but I tested it for all values, that the number returned is the same (in binary form). So I don't think that it is significant. > > @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, > > u32 bs) > > do { \ > > volatile unsigned int tv = sdr_read32(reg); \ > > tv &= ~(field); \ > > - tv |= ((val) << (uffs((unsigned int)field) - 1)); \ > > + tv |= ((val) << (ffs((unsigned int)field) - 1));\ > > Given that ffs() takes an "int", it is odd to cast "field" to an > unsigned int to pass it. > "field" is always a constant int, so no cast is needed. That's correct, but I took it that way, because that is how the mtk-sd driver does it. This makes the similarities more significant, but if you like I'll change it. Regards, Christian ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 09/30] staging: mt7621-mmc: Remove function uffs
On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote: > The function uffs that is implemented by this driver returns the same > values as the kernel function ffs. So the uffs function is removed and > the calls to it are replaced with calls to ffs. This difference is that uffs receives and returns an "unsigned int". Maybe not a significant difference, but worth mentioning that you noticed it and reasoned that it wasn't significant. > @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, u32 > bs) > do { \ > volatile unsigned int tv = sdr_read32(reg); \ > tv &= ~(field); \ > - tv |= ((val) << (uffs((unsigned int)field) - 1)); \ > + tv |= ((val) << (ffs((unsigned int)field) - 1));\ Given that ffs() takes an "int", it is odd to cast "field" to an unsigned int to pass it. "field" is always a constant int, so no cast is needed. Thanks, NeilBrown > sdr_write32(reg, tv); \ > } while (0) > #define sdr_get_field(reg, field, val) > \ > do { \ > volatile unsigned int tv = sdr_read32(reg); \ > - val = ((tv & (field)) >> (uffs((unsigned int)field) - 1)); \ > + val = ((tv & (field)) >> (ffs((unsigned int)field) - 1)); \ > } while (0) > > #endif > -- > 2.16.1 signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/30] staging: mt7621-mmc: Remove function uffs
The function uffs that is implemented by this driver returns the same values as the kernel function ffs. So the uffs function is removed and the calls to it are replaced with calls to ffs. Signed-off-by: Christian Lütke-Stetzkamp --- drivers/staging/mt7621-mmc/mt6575_sd.h | 33 ++--- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 62e6beefa3db..5a50b6a47469 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -950,35 +950,6 @@ struct msdc_host { u32 app_cmd_arg; }; -static inline unsigned int uffs(unsigned int x) -{ - unsigned int r = 1; - - if (!x) - return 0; - if (!(x & 0x)) { - x >>= 16; - r += 16; - } - if (!(x & 0xff)) { - x >>= 8; - r += 8; - } - if (!(x & 0xf)) { - x >>= 4; - r += 4; - } - if (!(x & 3)) { - x >>= 2; - r += 2; - } - if (!(x & 1)) { - x >>= 1; - r += 1; - } - return r; -} - #define sdr_read8(reg)readb(reg) #define sdr_read32(reg) readl(reg) #define sdr_write8(reg, val) writeb(val, reg) @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, u32 bs) do { \ volatile unsigned int tv = sdr_read32(reg); \ tv &= ~(field); \ - tv |= ((val) << (uffs((unsigned int)field) - 1)); \ + tv |= ((val) << (ffs((unsigned int)field) - 1));\ sdr_write32(reg, tv); \ } while (0) #define sdr_get_field(reg, field, val) \ do { \ volatile unsigned int tv = sdr_read32(reg); \ - val = ((tv & (field)) >> (uffs((unsigned int)field) - 1)); \ + val = ((tv & (field)) >> (ffs((unsigned int)field) - 1)); \ } while (0) #endif -- 2.16.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel