summaryrefslogtreecommitdiff
path: root/drivers/platform/mellanox
diff options
context:
space:
mode:
authorVadim Pasternak <vadimp@mellanox.com>2018-01-22 18:50:20 -0800
committerDarren Hart (VMware) <dvhart@infradead.org>2018-01-31 10:36:49 -0800
commit752849e69715fdc2190945f5532d70e8c80bf384 (patch)
tree1e6b5c6bbbb9f46d3b01a289bcc376745a8bbcbd /drivers/platform/mellanox
parent3d838f5514ca5318f46bdb5b3f997cee66091695 (diff)
downloadlinux-next-752849e69715fdc2190945f5532d70e8c80bf384.tar.gz
platform/mellanox: Group create/destroy with attribute functions
Move the mlxreg_hotplug_device_create and _destroy functions up with the related attribute functions. No functional changes. Signed-off-by: Vadim Pasternak <vadimp@mellanox.com> Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> [dvhart: refactored commit into smaller functional changes] Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
Diffstat (limited to 'drivers/platform/mellanox')
-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 {
u8 fan_cache;
};
+static int mlxreg_hotplug_device_create(struct device *dev,
+ struct mlxreg_hotplug_device *item)
+{
+ item->adapter = i2c_get_adapter(item->nr);
+ if (!item->adapter) {
+ dev_err(dev, "Failed to get adapter for bus %d\n",
+ item->nr);
+ return -EFAULT;
+ }
+
+ item->client = i2c_new_device(item->adapter, &item->brdinfo);
+ if (!item->client) {
+ dev_err(dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
+ item->brdinfo.type, item->nr, item->brdinfo.addr);
+ i2c_put_adapter(item->adapter);
+ item->adapter = NULL;
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *item)
+{
+ if (item->client) {
+ i2c_unregister_device(item->client);
+ item->client = NULL;
+ }
+
+ if (item->adapter) {
+ i2c_put_adapter(item->adapter);
+ item->adapter = NULL;
+ }
+}
+
static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -183,41 +218,6 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
return 0;
}
-static int mlxreg_hotplug_device_create(struct device *dev,
- struct mlxreg_hotplug_device *item)
-{
- item->adapter = i2c_get_adapter(item->nr);
- if (!item->adapter) {
- dev_err(dev, "Failed to get adapter for bus %d\n",
- item->nr);
- return -EFAULT;
- }
-
- item->client = i2c_new_device(item->adapter, &item->brdinfo);
- if (!item->client) {
- dev_err(dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
- item->brdinfo.type, item->nr, item->brdinfo.addr);
- i2c_put_adapter(item->adapter);
- item->adapter = NULL;
- return -EFAULT;
- }
-
- return 0;
-}
-
-static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *item)
-{
- if (item->client) {
- i2c_unregister_device(item->client);
- item->client = NULL;
- }
-
- if (item->adapter) {
- i2c_put_adapter(item->adapter);
- item->adapter = NULL;
- }
-}
-
static inline void
mlxreg_hotplug_work_helper(struct device *dev,
struct mlxreg_hotplug_device *item, u8 is_inverse,