From patchwork Tue Nov 11 17:37:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 409575 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7B4EC140100 for ; Wed, 12 Nov 2014 04:44:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751689AbaKKRiq (ORCPT ); Tue, 11 Nov 2014 12:38:46 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:48919 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbaKKRio (ORCPT ); Tue, 11 Nov 2014 12:38:44 -0500 Received: by mail-lb0-f176.google.com with SMTP id 10so7876229lbg.21 for ; Tue, 11 Nov 2014 09:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fGft9pnOhRSSd5OWiwnwhm8PlY32ws5GyXiogSSCNns=; b=rRNuaqm4VeF/h8sNU+Pi0tMS+D1VqGgqod3hyJZt/I5yUI97rXxEIIEzNXfi32Xjc8 xvZqejFc4w+icz61sO26KlQxxJK0N5QDKb2RhTRqf5clC1/oHeSTNHmnLibHTpChdljQ QXXFSVFrLHyuqNebpCVZr7R67wYpkbzKlim6zF33o9JtQ3F51veqMpvUpMsfqm8ETgKp DwtEAY/Q9owrEws98smuGWI7jVdnV1GhVmAh5yACU76qnFrB97SBuqV859yrnbRHKA9F F07W78k8oUIgzmlg1GXtblOv69FpjLZxs1pvGHXNmIJpUfNEx4sJ5zB00bKEMOKB4DDm LMzg== X-Received: by 10.112.133.138 with SMTP id pc10mr37646641lbb.48.1415727522890; Tue, 11 Nov 2014 09:38:42 -0800 (PST) Received: from xi.terra (s83-177-171-8.cust.tele2.se. [83.177.171.8]) by mx.google.com with ESMTPSA id e10sm4932482lbq.1.2014.11.11.09.38.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Nov 2014 09:38:40 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.84) (envelope-from ) id 1XoFOr-0005Kq-Eo; Tue, 11 Nov 2014 18:38:41 +0100 From: Johan Hovold To: Florian Fainelli Cc: "David S. Miller" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Johan Hovold Subject: [PATCH 02/22] net: phy: add module_phy_driver macro Date: Tue, 11 Nov 2014 18:37:20 +0100 Message-Id: <1415727460-20417-3-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1415727460-20417-1-git-send-email-johan@kernel.org> References: <1415727460-20417-1-git-send-email-johan@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add helper macro for PHY drivers which do not do anything special in module init/exit. This will allow us to eliminate a lot of boilerplate code. Signed-off-by: Johan Hovold --- include/linux/phy.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index ed39956b5613..c50e1f1f46e0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -745,4 +745,28 @@ int __init mdio_bus_init(void); void mdio_bus_exit(void); extern struct bus_type mdio_bus_type; + +/** + * module_phy_driver() - Helper macro for registering PHY drivers + * @__phy_drivers: array of PHY drivers to register + * + * Helper macro for PHY drivers which do not do anything special in module + * init/exit. Each module may only use this macro once, and calling it + * replaces module_init() and module_exit(). + */ +#define phy_module_driver(__phy_drivers, __count) \ +static int __init phy_module_init(void) \ +{ \ + return phy_drivers_register(__phy_drivers, __count); \ +} \ +module_init(phy_module_init); \ +static void __exit phy_module_exit(void) \ +{ \ + phy_drivers_unregister(__phy_drivers, __count); \ +} \ +module_exit(phy_module_exit) + +#define module_phy_driver(__phy_drivers) \ + phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers)) + #endif /* __PHY_H */