aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/platform/mellanox/mlxreg-hotplug.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 752f756723e0..e4f7e8efd397 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -98,6 +98,41 @@ struct mlxreg_hotplug_priv_data {
98 u8 fan_cache; 98 u8 fan_cache;
99}; 99};
100 100
101static int mlxreg_hotplug_device_create(struct device *dev,
102 struct mlxreg_hotplug_device *item)
103{
104 item->adapter = i2c_get_adapter(item->nr);
105 if (!item->adapter) {
106 dev_err(dev, "Failed to get adapter for bus %d\n",
107 item->nr);
108 return -EFAULT;
109 }
110
111 item->client = i2c_new_device(item->adapter, &item->brdinfo);
112 if (!item->client) {
113 dev_err(dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
114 item->brdinfo.type, item->nr, item->brdinfo.addr);
115 i2c_put_adapter(item->adapter);
116 item->adapter = NULL;
117 return -EFAULT;
118 }
119
120 return 0;
121}
122
123static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *item)
124{
125 if (item->client) {
126 i2c_unregister_device(item->client);
127 item->client = NULL;
128 }
129
130 if (item->adapter) {
131 i2c_put_adapter(item->adapter);
132 item->adapter = NULL;
133 }
134}
135
101static ssize_t mlxreg_hotplug_attr_show(struct device *dev, 136static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
102 struct device_attribute *attr, 137 struct device_attribute *attr,
103 char *buf) 138 char *buf)
@@ -183,41 +218,6 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
183 return 0; 218 return 0;
184} 219}
185 220
186static int mlxreg_hotplug_device_create(struct device *dev,
187 struct mlxreg_hotplug_device *item)
188{
189 item->adapter = i2c_get_adapter(item->nr);
190 if (!item->adapter) {
191 dev_err(dev, "Failed to get adapter for bus %d\n",
192 item->nr);
193 return -EFAULT;
194 }
195
196 item->client = i2c_new_device(item->adapter, &item->brdinfo);
197 if (!item->client) {
198 dev_err(dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
199 item->brdinfo.type, item->nr, item->brdinfo.addr);
200 i2c_put_adapter(item->adapter);
201 item->adapter = NULL;
202 return -EFAULT;
203 }
204
205 return 0;
206}
207
208static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *item)
209{
210 if (item->client) {
211 i2c_unregister_device(item->client);
212 item->client = NULL;
213 }
214
215 if (item->adapter) {
216 i2c_put_adapter(item->adapter);
217 item->adapter = NULL;
218 }
219}
220
221static inline void 221static inline void
222mlxreg_hotplug_work_helper(struct device *dev, 222mlxreg_hotplug_work_helper(struct device *dev,
223 struct mlxreg_hotplug_device *item, u8 is_inverse, 223 struct mlxreg_hotplug_device *item, u8 is_inverse,