From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225uKWqyNQWfmzIwDgl+i3o5uyf6kOXmHzg/eiNluUuF5GHpzTKyi8mxmapc3oPjWDmuupUM ARC-Seal: i=1; a=rsa-sha256; t=1516819035; cv=none; d=google.com; s=arc-20160816; b=BRRPxbweomfDTV8FrsW67WnXsInoyzJxmlLAPAZ27bkYm9nsVHP/UYx4cQlCW8b07R w/Ah+aHN5+DffOOlVOGsSQFzo9KnVBenzlMPaCo9/L/UjL1OFjN1nP9GENJ9ejrYrt/H 3gl85dCnuSEUa1DFxkHYhGTkqvZbRu2F6HAIuLD8F2tPYYEOSlpAL6sKNI0j8yl/VQRY DtAtKWT2sq3l2flLIvKz50fb6OBiPsa6NW8S4hJCENU3d+ipzqJlxGU6Ems3Xbhk3obW nJSNfJaMVkECZeVEN4wSDAShpHs438CQdMynAZ8pjs1h52H+wAK13dmI6avWapnDNUde pxrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=t9MhPcbBRCoeBzOC0XYlyZxBjN5ervKoZNSGnzT6q4g=; b=Zvm3CibUoAbC3IijxwrO9lfttiAG8m3FewF0P3W/imyFHHuWW+SNC6M11Oyzr5EEQT +8QCjzW21hVDRMbCg2Otgh0M+Oo5buvz5NQt3deyPjc6yhBgelQ2LV6MfTBqTHYkJxHc 2N8glU7wdp3mv0VM7nkER97uvNNJdQfcd86Cn4KKJyu7zyZXoHv/jLHxUX4nvxvlBMNu jqA8rGzTxQRn8MBqpenGEr9vrdTW844Pq4LK9+IcOsLPGdY/akOjZAT+pSLBdIiYH20h 1gl1PYzH5pqz2oHXDLkZecQrT1L6GyBjIi1cgMfl2gWY9Uxjntr28gsWTwfifvC99s+h SFhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vadimp@mellanox.com designates 193.47.165.129 as permitted sender) smtp.mailfrom=vadimp@mellanox.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of vadimp@mellanox.com designates 193.47.165.129 as permitted sender) smtp.mailfrom=vadimp@mellanox.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com From: Vadim Pasternak To: dvhart@infradead.org, andy.shevchenko@gmail.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, jiri@resnulli.us, Vadim Pasternak Subject: [patch v11 - re-ordered 04/12] platform/mellanox: Group create/destroy with attribute functions Date: Wed, 24 Jan 2018 20:33:38 +0000 Message-Id: <1516826019-124903-2-git-send-email-vadimp@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1516826019-124903-1-git-send-email-vadimp@mellanox.com> References: <1516826019-124903-1-git-send-email-vadimp@mellanox.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590500036052820702?= X-GMAIL-MSGID: =?utf-8?q?1590500036052820702?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Move the mlxreg_hotplug_device_create and _destroy functions up with the related attribute functions. No functional changes. Signed-off-by: Vadim Pasternak Acked-by: Andy Shevchenko [dvhart: refactored commit into smaller functional changes] Signed-off-by: Darren Hart (VMware) --- drivers/platform/mellanox/mlxreg-hotplug.c | 60 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index 0ccd327..4b67909 100644 --- a/drivers/platform/mellanox/mlxreg-hotplug.c +++ b/drivers/platform/mellanox/mlxreg-hotplug.c @@ -98,6 +98,36 @@ 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->bus); + if (!item->adapter) + return -EFAULT; + + item->client = i2c_new_device(item->adapter, &item->brdinfo); + if (!item->client) { + 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,36 +213,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->bus); - if (!item->adapter) - return -EFAULT; - - item->client = i2c_new_device(item->adapter, &item->brdinfo); - if (!item->client) { - 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, -- 2.1.4