From patchwork Wed Jan 18 10:06:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13106149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CAFAC004D4 for ; Wed, 18 Jan 2023 11:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjARLAs (ORCPT ); Wed, 18 Jan 2023 06:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbjARK5o (ORCPT ); Wed, 18 Jan 2023 05:57:44 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE3A8CE6A; Wed, 18 Jan 2023 02:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674036355; x=1705572355; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=sGwCRk+5/82kviy26W1sAKCGQVjy71ZrSmzZw9BkOwI=; b=lRzQtKfP3fVkmVH8EwEGLHzHVZq2i3MEULAm/IuXucPg+VVQ7IVnBIfw a8jm5qhhj0HD9q5CBNO+59CDvBP8cZ843owWvRDQPg6r06jYZNr6MT5GV YjbTOKpArb1dgWJgDU1vpJ1qePFlTMW7/Ynx3+Cx5/3BjmWhpcS5+5/aq pepl+MtT7epb0gvUaDRivQ8T87/8V5KetvVb+Uor9pRcXg8Cq3vfBXrY9 Q8qCLFUcarmSHrFwVDXaazSN4bgEyE6CvD6IVAF1C2ofP7F9eELUz4oWc CF1hxgTfOUn7PIM+lQIf5j50zDVqIISB+XYRfxGtXQuPginD59OTmA7Vf Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10593"; a="308509831" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="308509831" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 02:05:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10593"; a="691946163" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="691946163" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 18 Jan 2023 02:05:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DCAD0368; Wed, 18 Jan 2023 12:06:25 +0200 (EET) From: Andy Shevchenko To: Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Marijn Suijten Subject: [PATCH v2 1/1] iio: adc: qcom-spmi-adc5: Fix the channel name Date: Wed, 18 Jan 2023 12:06:23 +0200 Message-Id: <20230118100623.42255-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The node name can contain an address part which is unused by the driver. Moreover, this string is propagated into the userspace label, sysfs filenames *and breaking ABI*. Cut the address part out before assigning the channel name. Fixes: 4f47a236a23d ("iio: adc: qcom-spmi-adc5: convert to device properties") Reported-by: Marijn Suijten Signed-off-by: Andy Shevchenko Reviewed-by: Marijn Suijten --- v2: rephrased commit message (Marijn), fixed compilation issue (Marijin) drivers/iio/adc/qcom-spmi-adc5.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index e90c299c913a..c2d5e06f137a 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -628,12 +628,20 @@ static int adc5_get_fw_channel_data(struct adc5_chip *adc, struct fwnode_handle *fwnode, const struct adc5_data *data) { - const char *name = fwnode_get_name(fwnode), *channel_name; + const char *channel_name; + char *name; u32 chan, value, varr[2]; u32 sid = 0; int ret; struct device *dev = adc->dev; + name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode); + if (!name) + return -ENOMEM; + + /* Cut the address part */ + name[strchrnul(name, '@') - name] = '\0'; + ret = fwnode_property_read_u32(fwnode, "reg", &chan); if (ret) { dev_err(dev, "invalid channel number %s\n", name);