* [PATCH] sfc: I2C adapter initialisation fixes
[not found] <cover.1213035602.git.bhutchings@solarflare.com>
@ 2008-06-09 18:25 ` Ben Hutchings
2008-06-09 19:05 ` Jean Delvare
2008-06-18 3:48 ` Jeff Garzik
0 siblings, 2 replies; 5+ messages in thread
From: Ben Hutchings @ 2008-06-09 18:25 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Jean Delvare, netdev, linux-net-drivers
As recommended by Jean Delvare:
- Increase timeout to 50 ms
- Leave adapter class clear so that unwanted drivers do not probe our bus
- Use strlcpy() for name initialisation
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/falcon.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 630406e..e086100 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -223,13 +223,8 @@ static struct i2c_algo_bit_data falcon_i2c_bit_operations = {
.getsda = falcon_getsda,
.getscl = falcon_getscl,
.udelay = 5,
- /*
- * This is the number of system clock ticks after which
- * i2c-algo-bit gives up waiting for SCL to become high.
- * It must be at least 2 since the first tick can happen
- * immediately after it starts waiting.
- */
- .timeout = 2,
+ /* Wait up to 50 ms to begin command */
+ .timeout = DIV_ROUND_UP(HZ, 20),
};
/**************************************************************************
@@ -2479,12 +2474,11 @@ int falcon_probe_nic(struct efx_nic *efx)
/* Initialise I2C adapter */
efx->i2c_adap.owner = THIS_MODULE;
- efx->i2c_adap.class = I2C_CLASS_HWMON;
nic_data->i2c_data = falcon_i2c_bit_operations;
nic_data->i2c_data.data = efx;
efx->i2c_adap.algo_data = &nic_data->i2c_data;
efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
- strcpy(efx->i2c_adap.name, "SFC4000 GPIO");
+ strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
rc = i2c_bit_add_bus(&efx->i2c_adap);
if (rc)
goto fail5;
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] sfc: I2C adapter initialisation fixes
2008-06-09 18:25 ` [PATCH] sfc: I2C adapter initialisation fixes Ben Hutchings
@ 2008-06-09 19:05 ` Jean Delvare
2008-06-18 3:48 ` Jeff Garzik
1 sibling, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2008-06-09 19:05 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Jeff Garzik, netdev, linux-net-drivers
Hi Ben,
On Mon, 9 Jun 2008 19:25:10 +0100, Ben Hutchings wrote:
> As recommended by Jean Delvare:
> - Increase timeout to 50 ms
> - Leave adapter class clear so that unwanted drivers do not probe our bus
> - Use strlcpy() for name initialisation
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---
> drivers/net/sfc/falcon.c | 12 +++---------
> 1 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
> index 630406e..e086100 100644
> --- a/drivers/net/sfc/falcon.c
> +++ b/drivers/net/sfc/falcon.c
> @@ -223,13 +223,8 @@ static struct i2c_algo_bit_data falcon_i2c_bit_operations = {
> .getsda = falcon_getsda,
> .getscl = falcon_getscl,
> .udelay = 5,
> - /*
> - * This is the number of system clock ticks after which
> - * i2c-algo-bit gives up waiting for SCL to become high.
> - * It must be at least 2 since the first tick can happen
> - * immediately after it starts waiting.
> - */
> - .timeout = 2,
> + /* Wait up to 50 ms to begin command */
The timeout value affects every bit sent on the wire, it doesn't have
much to do with "begin command". The first half of the previous comment
was IMHO better.
> + .timeout = DIV_ROUND_UP(HZ, 20),
> };
>
> /**************************************************************************
> @@ -2479,12 +2474,11 @@ int falcon_probe_nic(struct efx_nic *efx)
>
> /* Initialise I2C adapter */
> efx->i2c_adap.owner = THIS_MODULE;
> - efx->i2c_adap.class = I2C_CLASS_HWMON;
> nic_data->i2c_data = falcon_i2c_bit_operations;
> nic_data->i2c_data.data = efx;
> efx->i2c_adap.algo_data = &nic_data->i2c_data;
> efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
> - strcpy(efx->i2c_adap.name, "SFC4000 GPIO");
> + strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
> rc = i2c_bit_add_bus(&efx->i2c_adap);
> if (rc)
> goto fail5;
>
But other than that, patch looks good, thanks.
--
Jean Delvare
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sfc: I2C adapter initialisation fixes
2008-06-09 18:25 ` [PATCH] sfc: I2C adapter initialisation fixes Ben Hutchings
2008-06-09 19:05 ` Jean Delvare
@ 2008-06-18 3:48 ` Jeff Garzik
2008-06-18 10:58 ` Ben Hutchings
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2008-06-18 3:48 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Jean Delvare, netdev, linux-net-drivers
Ben Hutchings wrote:
> As recommended by Jean Delvare:
> - Increase timeout to 50 ms
> - Leave adapter class clear so that unwanted drivers do not probe our bus
> - Use strlcpy() for name initialisation
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---
> drivers/net/sfc/falcon.c | 12 +++---------
> 1 files changed, 3 insertions(+), 9 deletions(-)
I didn't see a resend of this with Jean's requested change?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sfc: I2C adapter initialisation fixes
2008-06-18 3:48 ` Jeff Garzik
@ 2008-06-18 10:58 ` Ben Hutchings
2008-06-18 11:07 ` Jean Delvare
0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2008-06-18 10:58 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Jean Delvare, netdev, linux-net-drivers
As recommended by Jean Delvare:
- Increase timeout to 50 ms
- Leave adapter class clear so that unwanted drivers do not probe our bus
- Use strlcpy() for name initialisation
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 630406e..9138ee5 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -223,13 +223,8 @@ static struct i2c_algo_bit_data falcon_i2c_bit_operations = {
.getsda = falcon_getsda,
.getscl = falcon_getscl,
.udelay = 5,
- /*
- * This is the number of system clock ticks after which
- * i2c-algo-bit gives up waiting for SCL to become high.
- * It must be at least 2 since the first tick can happen
- * immediately after it starts waiting.
- */
- .timeout = 2,
+ /* Wait up to 50 ms for slave to let us pull SCL high */
+ .timeout = DIV_ROUND_UP(HZ, 20),
};
/**************************************************************************
@@ -2479,12 +2474,11 @@ int falcon_probe_nic(struct efx_nic *efx)
/* Initialise I2C adapter */
efx->i2c_adap.owner = THIS_MODULE;
- efx->i2c_adap.class = I2C_CLASS_HWMON;
nic_data->i2c_data = falcon_i2c_bit_operations;
nic_data->i2c_data.data = efx;
efx->i2c_adap.algo_data = &nic_data->i2c_data;
efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
- strcpy(efx->i2c_adap.name, "SFC4000 GPIO");
+ strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
rc = i2c_bit_add_bus(&efx->i2c_adap);
if (rc)
goto fail5;
---
I've corrected the comment about what timeout means.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] sfc: I2C adapter initialisation fixes
2008-06-18 10:58 ` Ben Hutchings
@ 2008-06-18 11:07 ` Jean Delvare
0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2008-06-18 11:07 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Jeff Garzik, netdev, linux-net-drivers
On Wed, 18 Jun 2008 11:58:41 +0100, Ben Hutchings wrote:
> As recommended by Jean Delvare:
> - Increase timeout to 50 ms
> - Leave adapter class clear so that unwanted drivers do not probe our bus
> - Use strlcpy() for name initialisation
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
> index 630406e..9138ee5 100644
> --- a/drivers/net/sfc/falcon.c
> +++ b/drivers/net/sfc/falcon.c
> @@ -223,13 +223,8 @@ static struct i2c_algo_bit_data falcon_i2c_bit_operations = {
> .getsda = falcon_getsda,
> .getscl = falcon_getscl,
> .udelay = 5,
> - /*
> - * This is the number of system clock ticks after which
> - * i2c-algo-bit gives up waiting for SCL to become high.
> - * It must be at least 2 since the first tick can happen
> - * immediately after it starts waiting.
> - */
> - .timeout = 2,
> + /* Wait up to 50 ms for slave to let us pull SCL high */
> + .timeout = DIV_ROUND_UP(HZ, 20),
> };
>
> /**************************************************************************
> @@ -2479,12 +2474,11 @@ int falcon_probe_nic(struct efx_nic *efx)
>
> /* Initialise I2C adapter */
> efx->i2c_adap.owner = THIS_MODULE;
> - efx->i2c_adap.class = I2C_CLASS_HWMON;
> nic_data->i2c_data = falcon_i2c_bit_operations;
> nic_data->i2c_data.data = efx;
> efx->i2c_adap.algo_data = &nic_data->i2c_data;
> efx->i2c_adap.dev.parent = &efx->pci_dev->dev;
> - strcpy(efx->i2c_adap.name, "SFC4000 GPIO");
> + strlcpy(efx->i2c_adap.name, "SFC4000 GPIO", sizeof(efx->i2c_adap.name));
> rc = i2c_bit_add_bus(&efx->i2c_adap);
> if (rc)
> goto fail5;
> ---
>
> I've corrected the comment about what timeout means.
Thanks Ben.
Acked-by: Jean Delvare <khali@linux-fr.org>
(Technically speaking, high is the natural state of SCL, so it's pulled
down and released up - but that's nitpicking.)
--
Jean Delvare
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-18 11:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1213035602.git.bhutchings@solarflare.com>
2008-06-09 18:25 ` [PATCH] sfc: I2C adapter initialisation fixes Ben Hutchings
2008-06-09 19:05 ` Jean Delvare
2008-06-18 3:48 ` Jeff Garzik
2008-06-18 10:58 ` Ben Hutchings
2008-06-18 11:07 ` Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).