From patchwork Tue Feb 16 05:00:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 8321021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFCCAC02AA for ; Tue, 16 Feb 2016 05:08:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C55B2025A for ; Tue, 16 Feb 2016 05:08:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44576202E6 for ; Tue, 16 Feb 2016 05:08:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVXqb-0002x0-1I; Tue, 16 Feb 2016 05:06:49 +0000 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVXqP-0002pF-L1 for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2016 05:06:38 +0000 Received: by mail-pf0-x232.google.com with SMTP id x65so98355742pfb.1 for ; Mon, 15 Feb 2016 21:06:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Bnet9PosVcfs56lQFX+PxwAsnN0FCx506nZXbvBdPpY=; b=sQnHIE3sFFhsXS11OsGIuwKYWSlHyNnHPIMRzlTqhCUO9gLLWB3bR3TKRbhEYLbbyW o+bivDWiXPSSjmpY/0ztsG8lVFh7aTENBl/bv470f8BaUpVp9yU1mBwhC0twvxN0D73r ivyqK3UXcxhm7eB7i86qhE1B8MUYmibEaZ6CS63R16rTNSntAdUbC38a3mvMwMSMbXTm cdD/EGhlZmRYB/Wg6F7earwAomqsRry/g7prfIyHJg9ESYFsPLJqhqF7GD4x7GJx2Ne/ AYlJXD/ZOja20GDZTQ2daFQ97bNyOmTR+pmCl+7Mci0hNfd+DbjFYX+q3QTLmIegOXv+ LQkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Bnet9PosVcfs56lQFX+PxwAsnN0FCx506nZXbvBdPpY=; b=YowGu1gDwtTrnrtBqkPPmxuH7QaDESpTslnJfsZBADru8XB/+I+74NQM5urXR/btoa a1gR9/ISoLQN0Ytor311GQt7zhPjWT1W2qfJAXMNcObpClxTjZVAudMIAbMhQLmzIc5/ IjonVTKuCsqXvEO+IVNAzoZjJ4PWAMlusCeds1GMIlNVQDEYxUmug3jsU+JrLUHjVwdA mJ51iggVFjF2WjEtWAn95l/FcNiLkl3o1bXCD/qkZXMR6UwnNsGil9f+Q3/gUpPXkvsB hbz3Wdb7LX1LQrOW1eWeCNS0yi0/S72dd+sOIqiRvhjRIS+Dj/T87Fgr4DNgrydikLjn pEew== X-Gm-Message-State: AG10YOQMt5xd4YhdHuwlK9gqP0jTQxC7unCPJs0sL55lSy2yJ2k84+q3cO2NDBrJ9xMIog== X-Received: by 10.98.12.133 with SMTP id 5mr28685560pfm.20.1455599176355; Mon, 15 Feb 2016 21:06:16 -0800 (PST) Received: from localhost ([115.115.225.206]) by smtp.gmail.com with ESMTPSA id m5sm42045240pfi.84.2016.02.15.21.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2016 21:06:15 -0800 (PST) From: Sanchayan Maity To: linux@roeck-us.net, shawnguo@kernel.org Subject: [PATCH v3 1/3] hwmon: iio_hwmon: Allow the driver to accept hypen in device tree node names Date: Tue, 16 Feb 2016 10:30:53 +0530 Message-Id: X-Mailer: git-send-email 2.7.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160215_210637_866869_721D008F X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jdelvare@suse.com, linux-kernel@vger.kernel.org, stefan@agner.ch, lm-sensors@lm-sensors.org, Sanchayan Maity , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the driver calls hwmon_device_register_with_groups which does not accept hypen in node name and returns EINVAL. Use of hypen in device tree node name results in probe failure., however use of hypen in device tree node name is perfectly acceptable. Change this by allocating a duplicate managed string, replacing hypen with underscore and then calling hwmon_device_register_with_groups. This allows the use of hypen in device tree node name while maintaining backwards compatibility and preventing any possible regressions with user space. Signed-off-by: Sanchayan Maity --- drivers/hwmon/iio_hwmon.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c index 17ae2eb..b550ba5 100644 --- a/drivers/hwmon/iio_hwmon.c +++ b/drivers/hwmon/iio_hwmon.c @@ -67,6 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev) enum iio_chan_type type; struct iio_channel *channels; const char *name = "iio_hwmon"; + char *sname; if (dev->of_node && dev->of_node->name) name = dev->of_node->name; @@ -144,7 +145,15 @@ static int iio_hwmon_probe(struct platform_device *pdev) st->attr_group.attrs = st->attrs; st->groups[0] = &st->attr_group; - st->hwmon_dev = hwmon_device_register_with_groups(dev, name, st, + + sname = devm_kstrdup(dev, name, GFP_KERNEL); + if (!sname) { + ret = -ENOMEM; + goto error_release_channels; + } + + strreplace(sname, '-', '_'); + st->hwmon_dev = hwmon_device_register_with_groups(dev, sname, st, st->groups); if (IS_ERR(st->hwmon_dev)) { ret = PTR_ERR(st->hwmon_dev);