Received: by 10.223.176.46 with SMTP id f43csp4537296wra; Tue, 23 Jan 2018 10:39:15 -0800 (PST) X-Google-Smtp-Source: AH8x227dGxCUhllkUkGNgWFPBRHmgyB8NHmlL0AQLXuUZy6UH8LehsFWKZ7RIabDlSmcwu/WlDI9 X-Received: by 10.36.85.206 with SMTP id e197mr4988235itb.124.1516732755852; Tue, 23 Jan 2018 10:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516732755; cv=none; d=google.com; s=arc-20160816; b=dhd/1XWdp7sH3N2lKJUeZkehFpQ0Wm4tSckk0rLloNAkDZgOIIlDdd4qFtZATW7EM9 X2wiUQIQ908o4yaEUiYoQfuHYzTZdqf1EJqtZ12NKpTSwdKj82KRiXZ5JFWd1pmlQvFI aMC3o3mRYd24FaeZ3GWgWy2hoHvGE1eEe13Vq1GjSdYR65qWyJ27zoWXA3M2YZjrDttI m0SGwzwj1OgLeuNNFmPiUHPkaYyH/ldiUYDqIX8Ghksm/A/JZROn1xnu07WUZildZrNY hUfzonfVw0cUyo1TkRuJETq+qm8jk0IlG34GC8r1eznsroZYEHNhW8f8dQiGlYwEKcc8 2DrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=i5JuFlHBYSId+FN8xj4gz4xi+qlcFbZXaZ7wZ/21h+Y=; b=NVWNwviMn/c+qgtsqukgdylkchlp7OfXiIUyfQjGLkt0bF+pFrZaAHylP7mjpD3s6K vQ8EWayUaGnsepDE6qtXMlxSdqJlGXLFqNuMCSci/Elinci6PyRq++5LfEIeGY8TfzVG dSz2gSlrZ7fPg2gRMI0t6t+Q9ayuyOuD93WucmC0qKhs9/+yx4cOeH888y+QBRSAB7tn v21AziIy2G0xWhxa+L+nV8dOhzu/5PqnyG9Fr6fxpw689YqQrPrkjhPHcl0XpgfoChKp 09hjG0+cZIP2pFKfAF8C+TgcL9nNVD8Gax16KrwUM7eSgS2kvPAr1TKafa7bm1Z2jSQ5 GbXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i205si11925674iof.130.2018.01.23.10.39.02; Tue, 23 Jan 2018 10:39:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752493AbeAWSiM (ORCPT + 99 others); Tue, 23 Jan 2018 13:38:12 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:40202 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752473AbeAWSiL (ORCPT ); Tue, 23 Jan 2018 13:38:11 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 23 Jan 2018 20:38:06 +0200 Received: from r-mgtswh-226.mtr.labs.mlnx. (r-mgtswh-226.mtr.labs.mlnx [10.209.1.51]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w0NIbwiJ013755; Tue, 23 Jan 2018 20:38:06 +0200 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 v10 2/6] platform/mellanox: Group create/destroy with attribute functions Date: Tue, 23 Jan 2018 20:34:21 +0000 Message-Id: <1516739665-132304-2-git-send-email-vadimp@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1516739665-132304-1-git-send-email-vadimp@mellanox.com> References: <1516739665-132304-1-git-send-email-vadimp@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v9->v10: Fixes provideded by Darren: - make separate patch for relocating create/destroy; --- drivers/platform/mellanox/mlxreg-hotplug.c | 70 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index c015fe9..1a04cb2 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->bus); + if (!item->adapter) { + dev_err(dev, "Failed to get adapter for bus %d\n", + item->bus); + 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->bus, 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->bus); - if (!item->adapter) { - dev_err(dev, "Failed to get adapter for bus %d\n", - item->bus); - 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->bus, 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, -- 2.1.4