Re: [PATCH] usb: storage: ene_ub6250: Fix right shift warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 30.07.24 19:56, Abhishek Tamboli wrote:
On Tue, Jul 30, 2024 at 09:09:05AM +0200, Oliver Neukum wrote:

1. use a constant, where a constant is used
I think you are suggesting that I should replace hard-coded values like the
buffer size with named constants. For example:

#define BUF_SIZE 8
unsigned char buf[BUF_SIZE];

Yes, but the constant we need to look at here is bl_len.
This is a variable needlessly.

2. use the macros for converting endianness
Can I use macros like cpu_to_le32 for converting the bl_num and bl_len values.
Should I replace all instances of manual bitwise shifts with these macros?

Yes.

For example:

     u32 bl_len = 0x200;
     buf[0] = cpu_to_le32(bl_num) >> 24;
     buf[4] = cpu_to_le32(bl_len) >> 24;

Is using cpu_to_le32 appropriate for the data format required by this
device?

Well, the format is big endian. So, cpu_to_be32() will be required.

	Regards
		Oliver





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux