From patchwork Tue Aug 20 14:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 11103853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FA8A184E for ; Tue, 20 Aug 2019 14:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E8B522DD3 for ; Tue, 20 Aug 2019 14:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="T+dL1ssF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730113AbfHTOLu (ORCPT ); Tue, 20 Aug 2019 10:11:50 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56170 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729961AbfHTOLu (ORCPT ); Tue, 20 Aug 2019 10:11:50 -0400 Received: by mail-wm1-f66.google.com with SMTP id f72so2753733wmf.5 for ; Tue, 20 Aug 2019 07:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2gZBRBMoTtxBnUUQUMgmv/Co/uEPvWKvt1ic6Ud7+dk=; b=T+dL1ssFUIdUpMoMpCYeZxUeiYq6z0OFcwvolNe82M9FDXIvwx3RQReCIltmCEmMJs CWQ9N6YCwiVWz3YuzcWScw0ucrDUqV4yBV/gMjdrs8gCf2vLS0OeL7nqzIaGv1qv4eB5 CQajQ5HQnoPDQuiHoe6B7FasPlJ7H5Lc4If3L5eF4106Ph7TG23A/82ygoGBcG5QORn6 XsqIqe9t6bQwW4YQgunnIU6F7lJ9QeDIZAcRCW1/fj1Z3vRHi9blAaA71KxYr/ZNyqIA GuVxjecw1ovnLWvKQLffYzgkD36p+LAh8q9218offxYuAK5SnX3u1uElq1vpV0GjTITW L8EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=2gZBRBMoTtxBnUUQUMgmv/Co/uEPvWKvt1ic6Ud7+dk=; b=b5enJnmUK17ZKViUQBuhqz1QoLgkPtXYReYcMHtwCyL8dlAPu9k3is3Rqm38aXQ1Cl NeZ2m+SwTJz++rqjidLZUWb2Q3SlbzCBWZqYaxqsPt8t4XlqQVK+jGvaB+XmqMTruwbp HVtCiR9HvA1hRZWRAwZevDuEo4VR6+5kff6nx71rL+1yYN4XxzqZx0g/A6COfaiCZW2U aNwQsFvF/4Jj4hW4yMJdIROV4t2vRQK8sK+8UPQY9bWtrJKh6cwEKgOrseYtACPBRt/O dpB5LWELTL1x3p9RdckIf+NCRLlm6Drta931W9Ho6SZ/SFrPEJc4jErH2s45r3FBfbVm GwOQ== X-Gm-Message-State: APjAAAWpUr6OyH2ObfX+xntf3XxzSVz9nvaHTOQYLHqcjUSMR32T2Mxf qIZq/dCcGlYngwpwBk0qzp7k2Q== X-Google-Smtp-Source: APXvYqwOpXWWfQkrSmxlW+dDzFrwROAmgDH8mO7cWLuxIpOZsMB3v+78Zw7sxK75f9hByv/fW7dNqQ== X-Received: by 2002:a1c:9ec5:: with SMTP id h188mr221409wme.176.1566310308440; Tue, 20 Aug 2019 07:11:48 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id f10sm13960332wrs.22.2019.08.20.07.11.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 07:11:47 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, linux@roeck-us.net Cc: Colin Ian King , linux-iio@vger.kernel.org, =?utf-8?q?Stefan_Br=C3=BCns?= , Lars-Peter Clausen , Jonathan Cameron , Peter Meerwald-Stadler , Hartmut Knaack Subject: [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Date: Tue, 20 Aug 2019 16:11:38 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org There is no reason to c&p full client->dev.of_node link when simple variable can keep it. Signed-off-by: Michal Simek --- drivers/iio/adc/ina2xx-adc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index bdd7cba6f6b0..37058d9c2054 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -951,6 +951,7 @@ static int ina2xx_probe(struct i2c_client *client, struct ina2xx_chip_info *chip; struct iio_dev *indio_dev; struct iio_buffer *buffer; + struct device_node *np = client->dev.of_node; unsigned int val; enum ina2xx_ids type; int ret; @@ -970,7 +971,7 @@ static int ina2xx_probe(struct i2c_client *client, return PTR_ERR(chip->regmap); } - if (client->dev.of_node) + if (np) type = (enum ina2xx_ids)of_device_get_match_data(&client->dev); else type = id->driver_data; @@ -978,7 +979,7 @@ static int ina2xx_probe(struct i2c_client *client, mutex_init(&chip->state_lock); - if (of_property_read_u32(client->dev.of_node, + if (of_property_read_u32(np, "shunt-resistor", &val) < 0) { struct ina2xx_platform_data *pdata = dev_get_platdata(&client->dev); @@ -1016,7 +1017,7 @@ static int ina2xx_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; indio_dev->dev.parent = &client->dev; - indio_dev->dev.of_node = client->dev.of_node; + indio_dev->dev.of_node = np; if (id->driver_data == ina226) { indio_dev->channels = ina226_channels; indio_dev->num_channels = ARRAY_SIZE(ina226_channels); From patchwork Tue Aug 20 14:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 11103847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4318184E for ; Tue, 20 Aug 2019 14:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82A5C214DA for ; Tue, 20 Aug 2019 14:11:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="f3bIV3Sr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbfHTOLw (ORCPT ); Tue, 20 Aug 2019 10:11:52 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32781 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730115AbfHTOLw (ORCPT ); Tue, 20 Aug 2019 10:11:52 -0400 Received: by mail-wr1-f67.google.com with SMTP id u16so12579494wrr.0 for ; Tue, 20 Aug 2019 07:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=FGBKHCq8FJWMnIUa/LWFL4TzsPl3MOXhcThUateMRtc=; b=f3bIV3SrHFrMQrtixm3U82rRcligpygZElE9yXd5V8V9ltf6yCrcMipHXrommhcqfw TFOHb/OanU4gCVrKHQ4rz/c+Lfhl0tvYf7X1dwxm6Wgsb0V3lZi6+l3NjxduRxirIBhg hWW408Mo9CNtLPe2K1XsYTiZwLTBeRtkzcdT6kM94Gw7kC4ZCx5uxEncz8qyBoj/iayH QSjw5kDf4YeSbhEFMhXZb9Y5o+cnR5cHW72PjEkakxrM2G28a8rEre+NOZ/qpC3DNmKh lUQzqHDbg+0ReV5HhEvmxRDpMVa7i8/eh+1DlHByywQhWXJivmNVoag839ISQcYEypA3 OXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=FGBKHCq8FJWMnIUa/LWFL4TzsPl3MOXhcThUateMRtc=; b=trqe4JEdlFfnwer+MnG9QLjTbiNXCV07V20NZ3ogZ67Mf3wcJdOoYZ0Y8/H/vsNb7X tL8yn/38Ghu+/S5woUbVLUrv3ETh3YtJQUVy3vQR/6gMRwOQgfEF5MJcy9XH/8Df5Dr6 vaSBMJn4G0QMKLDFAygbM/yY/+p4fBDKLvbcBgFi81Tua4zwPueHHF4rZDSbbIp433ol G2b0+3psbPDDjQVTbf6L0d17SltNuOjGJ2iWgEmGGQTpfaVsoizzz/9m5CobF+iAwNtK sGiBTXMc5in4n4XWLfZU3Y0HmTprXoWZvzpG1NJ0XT3GzjZwhBDP4O+0QT6Xs2Ri7u1S uCYg== X-Gm-Message-State: APjAAAXmMoaIBrbrFYk+LULsg5OUKIpdNoxGNMTDS/43miMaAlvzkh14 ocL7AYhBXtAIKV68XCH9PJw5hw== X-Google-Smtp-Source: APXvYqxobUNDMTRwNWh7KrFllFIt6Sw6gQaq/G0HklprIHThax3CILx4Cq6GYMtvbluPatyRvV4Qqw== X-Received: by 2002:adf:ef05:: with SMTP id e5mr34863140wro.158.1566310310222; Tue, 20 Aug 2019 07:11:50 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id u186sm229705wmu.26.2019.08.20.07.11.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 07:11:49 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, linux@roeck-us.net Cc: Colin Ian King , linux-iio@vger.kernel.org, =?utf-8?q?Stefan_Br=C3=BCns?= , Lars-Peter Clausen , Jonathan Cameron , Peter Meerwald-Stadler , Hartmut Knaack Subject: [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx Date: Tue, 20 Aug 2019 16:11:39 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On systems with multiple ina2xx chips it is impossible to find out which iio device is which one based on probe order. That's why it is necessary to setup better name based on possition. The patch is reusing dev_name which is setup by core with client->name. name char array was setup to 128 byte length to correspond the same name length by HID device. Before this patch: iio:device9: ina226 (buffer capable) After: iio:device9: ina226-3-004a (buffer capable) Signed-off-by: Michal Simek --- Also id->name can be used as prefix. On ina226 output is the same. Also I am happy to change that space for name will be dynamicky allocated to save a space if needed. --- drivers/iio/adc/ina2xx-adc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 37058d9c2054..7c7c63677bf4 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -146,6 +146,7 @@ struct ina2xx_chip_info { int range_vbus; /* Bus voltage maximum in V */ int pga_gain_vshunt; /* Shunt voltage PGA gain */ bool allow_async_readout; + char name[128]; }; static const struct ina2xx_config ina2xx_config[] = { @@ -1027,7 +1028,12 @@ static int ina2xx_probe(struct i2c_client *client, indio_dev->num_channels = ARRAY_SIZE(ina219_channels); indio_dev->info = &ina219_info; } - indio_dev->name = id->name; + + /* Compose chip name to unified i2c format */ + snprintf(chip->name, sizeof(chip->name), "%s-%s", + client->name, dev_name(&client->dev)); + + indio_dev->name = chip->name; indio_dev->setup_ops = &ina2xx_setup_ops; buffer = devm_iio_kfifo_allocate(&indio_dev->dev); From patchwork Tue Aug 20 14:11:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 11103849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2701314DB for ; Tue, 20 Aug 2019 14:12:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0570E22DA9 for ; Tue, 20 Aug 2019 14:12:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="ft6JmqWg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730249AbfHTOL7 (ORCPT ); Tue, 20 Aug 2019 10:11:59 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41569 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730229AbfHTOLz (ORCPT ); Tue, 20 Aug 2019 10:11:55 -0400 Received: by mail-wr1-f67.google.com with SMTP id j16so12563428wrr.8 for ; Tue, 20 Aug 2019 07:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RwUl0tIvIWQJjsPo9IUx0TKimtG4MbaxDyHxqkSvC5A=; b=ft6JmqWgSOSM4d24X1q0N2J56uYy/FU4k08SXAeJ6pgdaXJ5cYbZX2WQ70C3sFnKQV 4iXZe7h92gIl9tNrovxEYNUXt04plhsbh4BJqzGndjegbiJfrB7N8xhJCG7ZvR1SACp2 2/VVKPaWXVbDNH6tijKiFQui4GLWVWScAtnfxqMAHfmJrd4GRQlK/NOJn59hI/ng/kYf fOlUF2vWVCwdU9uOBqJSgHdWj5Qe8GwEov/sD7ufWQpV2T2WdzrCQXAy44eL123/Vasu 1hPW9gsS/nzyJbhHGtH25EisfEton7FtFTT1lySEcdQk8smMI55NJB2JUdY5gRJKv5Kz G5yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=RwUl0tIvIWQJjsPo9IUx0TKimtG4MbaxDyHxqkSvC5A=; b=HXLg4mmC+3AaPMPl2jVSegQ0qvOknZEgiDat+Rvr3gCutmXn2RPOHobfEGLdRiNcU9 lT6q4laFV98LFNpg6CvZKqpQm4zHdtSb589X62IC/ulpQfldzT9lMMO0gN6J01NDMbRn 9MoVlVeWNpN7waVFez0odBhAQrx0uxy84kMxIx5br//vYwdntLcmQe7aw5pDEaxy8H96 b1Ru9lH0nfOc/oeQOUk0Edk8vbOtPAq3mMUmHHNum/L486fn1T629ZOezqejSeBSQQDF uoh8H06+kmYM6PcZhnODh9V7kA3SC0syWK8IXEVDBM+ysiAdSY9Bs0FZm8W/j4TKX4dg FGwQ== X-Gm-Message-State: APjAAAUxMC5FiikCCyGo3Ip1/gIVjBtUicnxo1zapPJpowdUPZc+y2dD NrvNl/fFiVuGYY/dbKkpsJmsRA== X-Google-Smtp-Source: APXvYqzEIh6wkeygw1xRCd3/+HZRcK6Zad12CN+JWvrC+aemT0aFfIfzYCUHEgz9nu5K7xswVg1Ejw== X-Received: by 2002:adf:b64b:: with SMTP id i11mr35140281wre.114.1566310313897; Tue, 20 Aug 2019 07:11:53 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 2sm84660wmz.16.2019.08.20.07.11.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 07:11:53 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, linux@roeck-us.net Cc: Colin Ian King , linux-iio@vger.kernel.org, =?utf-8?q?Stefan_Br=C3=BCns?= , Lars-Peter Clausen , Jonathan Cameron , Peter Meerwald-Stadler , Hartmut Knaack Subject: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification Date: Tue, 20 Aug 2019 16:11:41 +0200 Message-Id: <0542b562a813c5c22c42484ac24bbb626ac3c022.1566310292.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add support for using label property for easier device identification via iio framework. Signed-off-by: Michal Simek --- drivers/iio/adc/ina2xx-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 7c7c63677bf4..077c54915f70 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client, snprintf(chip->name, sizeof(chip->name), "%s-%s", client->name, dev_name(&client->dev)); - indio_dev->name = chip->name; + indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name; indio_dev->setup_ops = &ina2xx_setup_ops; buffer = devm_iio_kfifo_allocate(&indio_dev->dev);