[PATCH v2 1/3] iio: pressure: bmp280: Use uint8 to store chip ids

Angel Iglesias posted 3 patches 2 years, 3 months ago
[PATCH v2 1/3] iio: pressure: bmp280: Use uint8 to store chip ids
Posted by Angel Iglesias 2 years, 3 months ago
Represent the device id reg values using uint8 to optimize memory use.

Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com>

diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h
index 5c0563ce7572..ff72e82f55ad 100644
--- a/drivers/iio/pressure/bmp280.h
+++ b/drivers/iio/pressure/bmp280.h
@@ -418,7 +418,7 @@ struct bmp280_data {
 
 struct bmp280_chip_info {
 	unsigned int id_reg;
-	const unsigned int chip_id;
+	uint8_t chip_id;
 
 	const struct regmap_config *regmap_config;
 
-- 
2.42.0
Re: [PATCH v2 1/3] iio: pressure: bmp280: Use uint8 to store chip ids
Posted by Andy Shevchenko 2 years, 3 months ago
On Wed, Aug 23, 2023 at 05:58:05PM +0200, Angel Iglesias wrote:
> Represent the device id reg values using uint8 to optimize memory use.

This doesn't correspond to the code, in the code you used uint8_t.

...

>  struct bmp280_chip_info {
>  	unsigned int id_reg;
> -	const unsigned int chip_id;
> +	uint8_t chip_id;

While this will compile and even work properly in kernel we use uXX types,
here u8.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/3] iio: pressure: bmp280: Use uint8 to store chip ids
Posted by Andy Shevchenko 2 years, 3 months ago
On Wed, Aug 23, 2023 at 07:10:33PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 23, 2023 at 05:58:05PM +0200, Angel Iglesias wrote:
> > Represent the device id reg values using uint8 to optimize memory use.
> 
> This doesn't correspond to the code, in the code you used uint8_t.

...

> >  struct bmp280_chip_info {
> >  	unsigned int id_reg;
> > -	const unsigned int chip_id;
> > +	uint8_t chip_id;
> 
> While this will compile and even work properly in kernel we use uXX types,
> here u8.

Actually this patch doesn't optimize memory use. The alignment will create
a gap anyway.

That said, this patch is simply redundant.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/3] iio: pressure: bmp280: Use uint8 to store chip ids
Posted by Angel Iglesias 2 years, 3 months ago
On Wed, 2023-08-23 at 19:17 +0300, Andy Shevchenko wrote:
> On Wed, Aug 23, 2023 at 07:10:33PM +0300, Andy Shevchenko wrote:
> > On Wed, Aug 23, 2023 at 05:58:05PM +0200, Angel Iglesias wrote:
> > > Represent the device id reg values using uint8 to optimize memory use.
> > 
> > This doesn't correspond to the code, in the code you used uint8_t.
> 
> ...
> 
> > >  struct bmp280_chip_info {
> > >         unsigned int id_reg;
> > > -       const unsigned int chip_id;
> > > +       uint8_t chip_id;
> > 
> > While this will compile and even work properly in kernel we use uXX types,
> > here u8.
> 
> Actually this patch doesn't optimize memory use. The alignment will create
> a gap anyway.
> 
> That said, this patch is simply redundant.
> 
OK, I'll drop it on v3 then