Received: by 10.213.65.68 with SMTP id h4csp1177882imn; Wed, 14 Mar 2018 11:57:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELuXgQNT0M54gmDH5v5RJ8g8fXL7vKOhXGRBEhS2er2Z+c8FZb/DRXi+uLD+pKORD1j62710 X-Received: by 10.99.99.194 with SMTP id x185mr4518740pgb.4.1521053828475; Wed, 14 Mar 2018 11:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521053828; cv=none; d=google.com; s=arc-20160816; b=ZvLUBnYEIB+1/VOQq5/K4rxhb0xDTwYb609beANWsCZ8L05W+9aE2PNIy5v/PLhooa 0VmSgaskQNSFV8HyODFJg8344PQrmxAmFDiBhbLv3Il/SqODTzcNG51ZS42Akh1x8DEu IJWjITF4RjjMJa/4F09sz59fqalxJJt1ZEP9eT5Q8PMUHqPc5hENrNOMl3ve3XgAKlOV D3+1r3ZA70iPUTdrN2uDlc9mcgQtFckCFJ0ddoJZ68+DFHyqKbqOFM2JCLppFt6f8+Gl 9GpnRSXAse+ZMyTAMZE4MPj3yGxAsfF6Ofi3FLdLqIHclRi5QYgStqeDKSGA1NDBzEld mLZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=KcKSZ2qrmCfsgLfPT+idsADfe0JTvauXwVO6F3MHrVI=; b=oKJmRgaLZ/3ifdxG1wX2B7jNQw3vobqZYu/sDJFVWc2jjyZoJ8YLdqyb0gJE6GIHuT IYturLpmyBfdpP0LSWk8rIXQD/qwTA0jP1gacZBd1AkK90pbk37Zvh52Ehx6EBzLN9g2 PNwPvwxcRNnWCiPds0KQqtMUSl23I/4YNAwLEg0l6x9DDNFsNNqkICRWxAOOvGYYj4N8 pn2qHtXvaBlyiFtj7ZUMzZZTdxFL65zPCkuWTuNK2NvFGKW2P88Xc+0UtqvD5opTKMhW eY8BNxy5nmru/sq6VWTpREnTplwaNtzL04Wab+SmhzFCgMLSWq4ZD+nUrbWtRIA3pegT oWBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jkycjl/Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bb5-v6si2291527plb.407.2018.03.14.11.56.54; Wed, 14 Mar 2018 11:57:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jkycjl/Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752004AbeCNSzr (ORCPT + 99 others); Wed, 14 Mar 2018 14:55:47 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:43453 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751791AbeCNSzp (ORCPT ); Wed, 14 Mar 2018 14:55:45 -0400 Received: by mail-pl0-f68.google.com with SMTP id f23-v6so2208227plr.10; Wed, 14 Mar 2018 11:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KcKSZ2qrmCfsgLfPT+idsADfe0JTvauXwVO6F3MHrVI=; b=jkycjl/Q0FGCmo9Pxx4j3X3pedEbt6x0mWpaEoVho3qOoR8c5nqZJyxHNE4gQCy7hl M1HQg0pAXjmcBn9cZzKqoHJFEHI96eh/53ZRnd12JlYd/bj3kEo/sud1qPNmlceGBeqE /VLX5g1jKgcKcdPgX3pJiXTXE3D5jzxuYDDTJljMae1bcEnU3qr8UwRgYOzwas7IdGnc ugWUIj1TO5ODXogAIrN3hvmR7rYF8PfNuzaycqBy3CCPwG4yJThinh1SO4zxW+o0l2XQ 4qxuHN1YTH40TsIG4xAkVW6RKlvPSTrWSUWheVcmZYkorcGi7OoPGVvwl1NI/trqqMqa RWJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=KcKSZ2qrmCfsgLfPT+idsADfe0JTvauXwVO6F3MHrVI=; b=WuTkL9b3UJrvQMWCeJqW3GsSUR2mxfXMfq+KarlQ5oYzB/GZtrlvAWYjJTDqevJjjU Iargw58KJo/XYa5jkzpbh9gniVA+PjHyiNHBaGGeOnieKJ8DE81LHVoqWCN6fzmols8U korH+hrYG7+3V94tC4kd+ILMHBSv/pQbIWMQW9N4KhB+62e272sIGqPALiaht67nBc8Q Qzg1cKrYEhvU+pqE6CPgs68EC2X7/VgWJ0KKxAQptNYb7lbeccsziTXXmgzv02Jp5nnL fEvpGuhYlUvWTQ8adT5LdWxDCXXoYmb8ydkgTn1z3eFinlSpO8hFqwel0CKxW1t0iMs3 qifw== X-Gm-Message-State: AElRT7Gin54Rm1HyDoaevjyLdxHD2LBfM7eIg5+ygbcUH7ernMXcWPVU i4002SCttny26sF16wBYjaRlJw== X-Received: by 2002:a17:902:3124:: with SMTP id w33-v6mr5172632plb.119.1521053745097; Wed, 14 Mar 2018 11:55:45 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id e82sm6098285pfh.89.2018.03.14.11.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 11:55:43 -0700 (PDT) Date: Wed, 14 Mar 2018 11:55:42 -0700 From: Guenter Roeck To: Andy Shevchenko Cc: Eddie James , linux-hwmon@vger.kernel.org, Linux Kernel Mailing List , Jean Delvare , Joel Stanley , Christopher Bostic , Andrew Jeffery Subject: Re: [PATCH v2 1/2] hwmon: (ucd9000) Add gpio chip interface Message-ID: <20180314185542.GA23989@roeck-us.net> References: <1520974749-5372-1-git-send-email-eajames@linux.vnet.ibm.com> <1520974749-5372-2-git-send-email-eajames@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 11:13:04PM +0200, Andy Shevchenko wrote: > On Tue, Mar 13, 2018 at 10:59 PM, Eddie James > wrote: > > From: Christopher Bostic > > > > Add a struct gpio_chip and define some methods so that this device's > > I/O can be accessed via /sys/class/gpio. > > > + /* > > + * Note: > > + * > > + * Pinmux support has not been added to the new gpio_chip. > > + * This support should be added when possible given the mux > > + * behavior of these IO devices. > > + */ > > > + data->gpio.label = (const char *)&client->name; > > Hmm... Why do you need this casting? > > > + data->gpio.get_direction = ucd9000_gpio_get_direction; > > + data->gpio.direction_input = ucd9000_gpio_direction_input; > > + data->gpio.direction_output = ucd9000_gpio_direction_output; > > + data->gpio.get = ucd9000_gpio_get; > > + data->gpio.set = ucd9000_gpio_set; > > > + data->gpio.can_sleep = 1; > > Isn't it type of boolean? > You are right. > > + data->gpio.base = -1; > > > + data->gpio.parent = &client->dev; > > + data->gpio.owner = THIS_MODULE; > > > + data->gpio.of_node = client->dev.of_node; > > I think GPIO core does this for you. > Same here. I checked and found that it also sets the owner, so maybe this can be dropped as well. > > + if (data->gpio.ngpio) { > > Hmm... > > I would rather reorganize the above part to a separate helper, like > > static int ..._probe_gpio() > { > ... > switch () { > default: > return 0; /* GPIO part is optional */ > } > return 0; > } > > ret = _probe_gpio(); > if (ret) > dev_warn(); > I am neutral to positiva on that. Might as well add the call to devm_gpiochip_add_data() into that function as well. > > + ret = devm_gpiochip_add_data(&client->dev, &data->gpio, > > + client); > > + if (ret) > > + dev_warn(&client->dev, "Could not add gpiochip: %d\n", > > + ret); > > + } > > + > > return pmbus_do_probe(client, mid, info); > > } > > > > -- > > 1.8.3.1 > > > > > > -- > With Best Regards, > Andy Shevchenko