public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Clifton Barnes <cabarnes@indesign-llc.com>
Cc: <ryan@bluewatersys.com>, <haojian.zhuang@marvell.com>,
	<johnpol@2ka.mipt.ru>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] w1: Add Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC support.
Date: Thu, 19 May 2011 12:03:34 -0700	[thread overview]
Message-ID: <20110519120334.69ccb4b6.akpm@linux-foundation.org> (raw)
In-Reply-To: <4DD50B35.2000005@indesign-llc.com>

On Thu, 19 May 2011 08:21:09 -0400
Clifton Barnes <cabarnes@indesign-llc.com> wrote:

> Add support for the Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC.
> 
> I've updated the driver based on feedback from the last version.
> I believe the locking is correct because the w1_ds2780_io function
> has locking in it.  If there's still a problem that I'm missing let 
> me know and I can correct it.
> 
> Changes for v3:
>  - Formatting changes suggested from last version
>  - Moved read/write functions to battery driver
>  - Corrected temperature calculation
>  - Changed EEPROM access to bin_attribute
> 

We have a min_t() helper to avoid (or hide) the typecasts:

--- a/drivers/power/ds2780_battery.c~w1-add-maxim-dallas-ds2780-stand-alone-fuel-gauge-ic-support-v3-fix
+++ a/drivers/power/ds2780_battery.c
@@ -628,7 +628,7 @@ static ssize_t ds2780_read_param_eeprom_
 	struct power_supply *psy = to_power_supply(dev);
 	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 
-	count = min((loff_t)count,
+	count = min_t(loff_t, count,
 		DS2780_EEPROM_BLOCK1_END -
 		DS2780_EEPROM_BLOCK1_START + 1 - off);
 
@@ -646,7 +646,7 @@ static ssize_t ds2780_write_param_eeprom
 	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 	int ret;
 
-	count = min((loff_t)count,
+	count = min_t(loff_t, count,
 		DS2780_EEPROM_BLOCK1_END -
 		DS2780_EEPROM_BLOCK1_START + 1 - off);
 
@@ -681,7 +681,7 @@ static ssize_t ds2780_read_user_eeprom_b
 	struct power_supply *psy = to_power_supply(dev);
 	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 
-	count = min((loff_t)count,
+	count = min_t(loff_t, count,
 		DS2780_EEPROM_BLOCK0_END -
 		DS2780_EEPROM_BLOCK0_START + 1 - off);
 
@@ -700,7 +700,7 @@ static ssize_t ds2780_write_user_eeprom_
 	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 	int ret;
 
-	count = min((loff_t)count,
+	count = min_t(loff_t, count,
 		DS2780_EEPROM_BLOCK0_END -
 		DS2780_EEPROM_BLOCK0_START + 1 - off);
 
--- a/drivers/w1/slaves/w1_ds2780.c~w1-add-maxim-dallas-ds2780-stand-alone-fuel-gauge-ic-support-v3-fix
+++ a/drivers/w1/slaves/w1_ds2780.c
@@ -40,7 +40,7 @@ int w1_ds2780_io(struct device *dev, cha
 		count = 0;
 		goto out;
 	}
-	count = min((int)count, DS2780_DATA_SIZE - addr);
+	count = min_t(int, count, DS2780_DATA_SIZE - addr);
 
 	if (w1_reset_select_slave(sl) == 0) {
 		if (io) {
_


However its use is often a sign that some types were unwisely chosen.

  reply	other threads:[~2011-05-19 19:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 12:21 [PATCH v3] w1: Add Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC support Clifton Barnes
2011-05-19 19:03 ` Andrew Morton [this message]
2011-05-19 20:21 ` Ryan Mallon
     [not found] ` <20110519115859.e11a7ca3.akpm@linux-foundation.org>
     [not found]   ` <1305909981.4209.33.camel@Joe-Laptop>
     [not found]     ` <20110520095037.25eadc0a.akpm@linux-foundation.org>
     [not found]       ` <1305912602.4209.41.camel@Joe-Laptop>
     [not found]         ` <20110520103529.1ef3917c.akpm@linux-foundation.org>
     [not found]           ` <1305915161.4209.56.camel@Joe-Laptop>
     [not found]             ` <20110520113830.3faf5230.akpm@linux-foundation.org>
2011-05-20 20:24               ` [PATCH] checkpatch: Suggest using min_t or max_t Joe Perches
2011-05-24 23:35                 ` Andrew Morton
2011-05-25  0:11                   ` Joe Perches
2011-05-25 23:53                     ` Andrew Morton
2011-05-27  0:35                       ` [PATCH v2] " Joe Perches
2012-09-05 11:21                         ` Philippe De Muyter
2012-09-05 17:07                           ` Joe Perches
2012-09-06  0:16                             ` Philippe De Muyter
2012-09-06  0:35                               ` Joe Perches
     [not found] <4DE3C363.2030503@goobie.fr>
     [not found] ` <A8DC7EA93EFCBD4498E3857AFE65E5F13A3DD762@IND07.indesign.net>
2011-08-11  8:19   ` [PATCH v3] w1: Add Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC support Simon INIZAN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110519120334.69ccb4b6.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cabarnes@indesign-llc.com \
    --cc=haojian.zhuang@marvell.com \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ryan@bluewatersys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox