diff options
author | Carolyn Wyborny <carolyn.wyborny@intel.com> | 2013-02-20 02:40:55 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2013-03-05 04:25:27 -0500 |
commit | 603e86fa39cd48edba5ee8a4d19637bd41e2a8bf (patch) | |
tree | 3108146bd51cbeec1ff9a790990791e8276d8ad4 /drivers/net/ethernet/intel | |
parent | ed65bdd8c0086d69948e6380dba0cc279a6906de (diff) |
igb: Fix for lockdep issue in igb_get_i2c_client
This patch fixes a lockdep warning in igb_get_i2c_client by
refactoring the initialization and usage of the i2c_client
completely. There is no on the fly allocation of the single
client needed today.
Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel')
-rw-r--r-- | drivers/net/ethernet/intel/igb/igb.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/igb_hwmon.c | 14 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/igb_main.c | 69 |
3 files changed, 17 insertions, 68 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h index d27edbc63923..25151401c2ab 100644 --- a/drivers/net/ethernet/intel/igb/igb.h +++ b/drivers/net/ethernet/intel/igb/igb.h | |||
@@ -447,7 +447,7 @@ struct igb_adapter { | |||
447 | #endif | 447 | #endif |
448 | struct i2c_algo_bit_data i2c_algo; | 448 | struct i2c_algo_bit_data i2c_algo; |
449 | struct i2c_adapter i2c_adap; | 449 | struct i2c_adapter i2c_adap; |
450 | struct igb_i2c_client_list *i2c_clients; | 450 | struct i2c_client *i2c_client; |
451 | }; | 451 | }; |
452 | 452 | ||
453 | #define IGB_FLAG_HAS_MSI (1 << 0) | 453 | #define IGB_FLAG_HAS_MSI (1 << 0) |
diff --git a/drivers/net/ethernet/intel/igb/igb_hwmon.c b/drivers/net/ethernet/intel/igb/igb_hwmon.c index 0a9b073d0b03..4623502054d5 100644 --- a/drivers/net/ethernet/intel/igb/igb_hwmon.c +++ b/drivers/net/ethernet/intel/igb/igb_hwmon.c | |||
@@ -39,6 +39,10 @@ | |||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | 40 | ||
41 | #ifdef CONFIG_IGB_HWMON | 41 | #ifdef CONFIG_IGB_HWMON |
42 | struct i2c_board_info i350_sensor_info = { | ||
43 | I2C_BOARD_INFO("i350bb", (0Xf8 >> 1)), | ||
44 | }; | ||
45 | |||
42 | /* hwmon callback functions */ | 46 | /* hwmon callback functions */ |
43 | static ssize_t igb_hwmon_show_location(struct device *dev, | 47 | static ssize_t igb_hwmon_show_location(struct device *dev, |
44 | struct device_attribute *attr, | 48 | struct device_attribute *attr, |
@@ -188,6 +192,7 @@ int igb_sysfs_init(struct igb_adapter *adapter) | |||
188 | unsigned int i; | 192 | unsigned int i; |
189 | int n_attrs; | 193 | int n_attrs; |
190 | int rc = 0; | 194 | int rc = 0; |
195 | struct i2c_client *client = NULL; | ||
191 | 196 | ||
192 | /* If this method isn't defined we don't support thermals */ | 197 | /* If this method isn't defined we don't support thermals */ |
193 | if (adapter->hw.mac.ops.init_thermal_sensor_thresh == NULL) | 198 | if (adapter->hw.mac.ops.init_thermal_sensor_thresh == NULL) |
@@ -198,6 +203,15 @@ int igb_sysfs_init(struct igb_adapter *adapter) | |||
198 | if (rc) | 203 | if (rc) |
199 | goto exit; | 204 | goto exit; |
200 | 205 | ||
206 | /* init i2c_client */ | ||
207 | client = i2c_new_device(&adapter->i2c_adap, &i350_sensor_info); | ||
208 | if (client == NULL) { | ||
209 | dev_info(&adapter->pdev->dev, | ||
210 | "Failed to create new i2c device..\n"); | ||
211 | goto exit; | ||
212 | } | ||
213 | adapter->i2c_client = client; | ||
214 | |||
201 | /* Allocation space for max attributes | 215 | /* Allocation space for max attributes |
202 | * max num sensors * values (loc, temp, max, caution) | 216 | * max num sensors * values (loc, temp, max, caution) |
203 | */ | 217 | */ |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 4d53a17959fa..4dbd62968c7a 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
@@ -1923,10 +1923,6 @@ void igb_set_fw_version(struct igb_adapter *adapter) | |||
1923 | return; | 1923 | return; |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | static const struct i2c_board_info i350_sensor_info = { | ||
1927 | I2C_BOARD_INFO("i350bb", 0Xf8), | ||
1928 | }; | ||
1929 | |||
1930 | /* igb_init_i2c - Init I2C interface | 1926 | /* igb_init_i2c - Init I2C interface |
1931 | * @adapter: pointer to adapter structure | 1927 | * @adapter: pointer to adapter structure |
1932 | * | 1928 | * |
@@ -7717,67 +7713,6 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba) | |||
7717 | } | 7713 | } |
7718 | } | 7714 | } |
7719 | 7715 | ||
7720 | static DEFINE_SPINLOCK(i2c_clients_lock); | ||
7721 | |||
7722 | /* igb_get_i2c_client - returns matching client | ||
7723 | * in adapters's client list. | ||
7724 | * @adapter: adapter struct | ||
7725 | * @dev_addr: device address of i2c needed. | ||
7726 | */ | ||
7727 | static struct i2c_client * | ||
7728 | igb_get_i2c_client(struct igb_adapter *adapter, u8 dev_addr) | ||
7729 | { | ||
7730 | ulong flags; | ||
7731 | struct igb_i2c_client_list *client_list; | ||
7732 | struct i2c_client *client = NULL; | ||
7733 | struct i2c_board_info client_info = { | ||
7734 | I2C_BOARD_INFO("igb", 0x00), | ||
7735 | }; | ||
7736 | |||
7737 | spin_lock_irqsave(&i2c_clients_lock, flags); | ||
7738 | client_list = adapter->i2c_clients; | ||
7739 | |||
7740 | /* See if we already have an i2c_client */ | ||
7741 | while (client_list) { | ||
7742 | if (client_list->client->addr == (dev_addr >> 1)) { | ||
7743 | client = client_list->client; | ||
7744 | goto exit; | ||
7745 | } else { | ||
7746 | client_list = client_list->next; | ||
7747 | } | ||
7748 | } | ||
7749 | |||
7750 | /* no client_list found, create a new one */ | ||
7751 | client_list = kzalloc(sizeof(*client_list), GFP_ATOMIC); | ||
7752 | if (client_list == NULL) | ||
7753 | goto exit; | ||
7754 | |||
7755 | /* dev_addr passed to us is left-shifted by 1 bit | ||
7756 | * i2c_new_device call expects it to be flush to the right. | ||
7757 | */ | ||
7758 | client_info.addr = dev_addr >> 1; | ||
7759 | client_info.platform_data = adapter; | ||
7760 | client_list->client = i2c_new_device(&adapter->i2c_adap, &client_info); | ||
7761 | if (client_list->client == NULL) { | ||
7762 | dev_info(&adapter->pdev->dev, | ||
7763 | "Failed to create new i2c device..\n"); | ||
7764 | goto err_no_client; | ||
7765 | } | ||
7766 | |||
7767 | /* insert new client at head of list */ | ||
7768 | client_list->next = adapter->i2c_clients; | ||
7769 | adapter->i2c_clients = client_list; | ||
7770 | |||
7771 | client = client_list->client; | ||
7772 | goto exit; | ||
7773 | |||
7774 | err_no_client: | ||
7775 | kfree(client_list); | ||
7776 | exit: | ||
7777 | spin_unlock_irqrestore(&i2c_clients_lock, flags); | ||
7778 | return client; | ||
7779 | } | ||
7780 | |||
7781 | /* igb_read_i2c_byte - Reads 8 bit word over I2C | 7716 | /* igb_read_i2c_byte - Reads 8 bit word over I2C |
7782 | * @hw: pointer to hardware structure | 7717 | * @hw: pointer to hardware structure |
7783 | * @byte_offset: byte offset to read | 7718 | * @byte_offset: byte offset to read |
@@ -7791,7 +7726,7 @@ s32 igb_read_i2c_byte(struct e1000_hw *hw, u8 byte_offset, | |||
7791 | u8 dev_addr, u8 *data) | 7726 | u8 dev_addr, u8 *data) |
7792 | { | 7727 | { |
7793 | struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); | 7728 | struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); |
7794 | struct i2c_client *this_client = igb_get_i2c_client(adapter, dev_addr); | 7729 | struct i2c_client *this_client = adapter->i2c_client; |
7795 | s32 status; | 7730 | s32 status; |
7796 | u16 swfw_mask = 0; | 7731 | u16 swfw_mask = 0; |
7797 | 7732 | ||
@@ -7828,7 +7763,7 @@ s32 igb_write_i2c_byte(struct e1000_hw *hw, u8 byte_offset, | |||
7828 | u8 dev_addr, u8 data) | 7763 | u8 dev_addr, u8 data) |
7829 | { | 7764 | { |
7830 | struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); | 7765 | struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); |
7831 | struct i2c_client *this_client = igb_get_i2c_client(adapter, dev_addr); | 7766 | struct i2c_client *this_client = adapter->i2c_client; |
7832 | s32 status; | 7767 | s32 status; |
7833 | u16 swfw_mask = E1000_SWFW_PHY0_SM; | 7768 | u16 swfw_mask = E1000_SWFW_PHY0_SM; |
7834 | 7769 | ||