
On Mon, 9 Feb 2009, Heiko Schocher wrote:
Hello ksi,
ksi@koi8.net wrote: [...]
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index ce646fd..f7998e3 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -1,4 +1,8 @@ /*
- Copyright (c) 2009 Sergey Kubushyn ksi@koi8.net
- Changes for multibus/multiadapter I2C support.
- Copyright 2006 Freescale Semiconductor, Inc.
- This program is free software; you can redistribute it and/or
@@ -18,7 +22,7 @@
#include <common.h>
-#ifdef CONFIG_HARD_I2C +#ifdef CONFIG_FSL_I2C
#include <command.h> #include <i2c.h> /* Functional interface */ @@ -31,24 +35,15 @@ #define I2C_READ_BIT 1 #define I2C_WRITE_BIT 0
-DECLARE_GLOBAL_DATA_PTR;
-/* Initialize the bus pointer to whatever one the SPD EEPROM is on.
- Default is bus 0. This is necessary because the DDR initialization
- runs from ROM, and we can't switch buses because we can't modify
- the global variables.
- */
-#ifndef CONFIG_SYS_SPD_BUS_NUM -#define CONFIG_SYS_SPD_BUS_NUM 0 -#endif -static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = CONFIG_SYS_SPD_BUS_NUM; +#define FSL_NAME(arg) "fsl_i2c@" MK_NAME(arg) +#define MK_NAME(arg) #arg
-static unsigned int i2c_bus_speed[2] = {CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SPEED}; +DECLARE_GLOBAL_DATA_PTR;
static const struct fsl_i2c *i2c_dev[2] = {
- (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET),
-#ifdef CONFIG_SYS_I2C2_OFFSET
- (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C2_OFFSET)
- (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C_OFFSET),
+#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
- (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_I2C2_OFFSET)
#endif };
@@ -126,6 +121,8 @@ static const struct { #endif };
+i2c_adap_t fsl_i2c_adap[];
/**
- Set the I2C bus speed for a given I2C device
@@ -169,43 +166,29 @@ static unsigned int set_i2c_bus_speed(const struct fsl_i2c *dev, return speed; }
-void -i2c_init(int speed, int slaveadd)
+static void __i2c_init(int adap_no, int speed, int slaveadd) {
struct fsl_i2c *dev; unsigned int temp;
dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
writeb(0, &dev->cr); /* stop I2C controller */
- writeb(0, &i2c_dev[adap_no]->cr); /* stop I2C controller */
Why do you here substitute a "dev->" with "&i2c_dev[adap_no]"? Why not dev = &i2c_dev[adap_no] and you can let the dev-> unchanged.
This eliminates one variable, dev. Another reason is uniformity through the entire driver source.
Anyway, keeping that dev won't make any difference other than making the patch a tad shorter...
--- ****************************************************************** * KSI@home KOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ******************************************************************