From patchwork Wed Jan 25 09:34:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9536607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F70F601D7 for ; Wed, 25 Jan 2017 09:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A9FB2787C for ; Wed, 25 Jan 2017 09:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EF7226E94; Wed, 25 Jan 2017 09:34:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCD8926E94 for ; Wed, 25 Jan 2017 09:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbdAYJes (ORCPT ); Wed, 25 Jan 2017 04:34:48 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:35375 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbdAYJeq (ORCPT ); Wed, 25 Jan 2017 04:34:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=WPDKyWZaVuwfOfUAiw/qM/0LafaXRRNmBWvgb5aw3B4=; b=IyOaOdlsS2agVNQYx/d+LAIkoa 64v68qIOqkZ66ei8RIGU2agfdCVLKk+HIuFIMYSJPS5TYR3+yN2pzAU7sW/5lOoc0WGl76wXZCKvM 3BMNKaZo88Cwr9MbMFEs74Bkzn5Q3VbTCkqAnZwtR16YrCRvnVesjxH5/Nk/a/TyYuuVsbqJoM675 W41m/JVNVfJWs/0p7H7oQ3CvW/X2cdKxILtaQL26prFBSx6FZAOdmS787sNkF5bi3PcNOYcJOy7KO Tdgtlu0QPoYF/ZC/G2dWzTwQOr6xiqBnSfeoFQyImI1Z7TWpYdZT3BvvTG2EljO/QYwaQrOiGnYgd 4qW7Bu8A==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:60456 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cWJyW-002flQ-Lj; Wed, 25 Jan 2017 09:34:45 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH v3] hwmon: Make name attribute mandatory for new APIs Date: Wed, 25 Jan 2017 01:34:40 -0800 Message-Id: <1485336880-16958-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It does not make sense to use one of the the new APIs when not even providing a name attribute. Make it mandatory. Signed-off-by: Guenter Roeck Reviewed-by: Jean Delvare --- v3: hwmon_device_register() needs to call __hwmon_device_register() directly. v2: One should use ERR_PTR where appropriate drivers/hwmon/hwmon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 0c5660ccdbf4..affff8195fff 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, const struct attribute_group **groups) { + if (!name) + return ERR_PTR(-EINVAL); + return __hwmon_device_register(dev, name, drvdata, NULL, groups); } EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups); @@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name, const struct hwmon_chip_info *chip, const struct attribute_group **extra_groups) { + if (!name) + return ERR_PTR(-EINVAL); + if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) return ERR_PTR(-EINVAL); @@ -695,7 +701,7 @@ struct device *hwmon_device_register(struct device *dev) dev_warn(dev, "hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().\n"); - return hwmon_device_register_with_groups(dev, NULL, NULL, NULL); + return __hwmon_device_register(dev, NULL, NULL, NULL, NULL); } EXPORT_SYMBOL_GPL(hwmon_device_register);