From: Fenghua Yu Date: Sat, 21 Dec 2019 00:05:55 +0000 (-0800) Subject: mtd: rawnand: fsmc: Change to non-atomic bit operations X-Git-Tag: v5.10.7~2372^2~5^2~178 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c26e6ef96c95105d6b1dc828902067df9b0f076;p=platform%2Fkernel%2Flinux-rpi.git mtd: rawnand: fsmc: Change to non-atomic bit operations No need to use expensive atomic change_bit() on dat[] and err_idx[]: 1. fsmc_bch8_correct_data() is called while mutex chip->lock is held 2. err_idx[] is a local variable. To avoid big endian concern due to type cast to unsigned long, directly change the bit in the specified byte instead of using non-atomic __change_bit(). Suggested-by: Peter Zijlstra Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/1576886755-9788-1-git-send-email-fenghua.yu@intel.com --- diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c index a6964fe..7e28311 100644 --- a/drivers/mtd/nand/raw/fsmc_nand.c +++ b/drivers/mtd/nand/raw/fsmc_nand.c @@ -809,11 +809,12 @@ static int fsmc_bch8_correct_data(struct nand_chip *chip, u8 *dat, i = 0; while (num_err--) { - change_bit(0, (unsigned long *)&err_idx[i]); - change_bit(1, (unsigned long *)&err_idx[i]); + err_idx[i] ^= 3; if (err_idx[i] < chip->ecc.size * 8) { - change_bit(err_idx[i], (unsigned long *)dat); + int err = err_idx[i]; + + dat[err >> 3] ^= BIT(err & 7); i++; } }