Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp226758ybt; Tue, 7 Jul 2020 21:21:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkndEnXkO3x/2W8VqQCKSDNlOPStDF1WqNZg/8llS6M2BER82bmw0pBiZkRsGPFLQm/oTT X-Received: by 2002:a50:e791:: with SMTP id b17mr68280422edn.366.1594182065629; Tue, 07 Jul 2020 21:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594182065; cv=none; d=google.com; s=arc-20160816; b=GT1Jy5gDVa4hqpnALhlLQL+8yK4pwLs0JGF9vLr5vPGAZ5oGMGvKYcEjr9Ao08AxY+ X3qCHUWguUOpQj47UIB8r2/PcUtNB0FkVvJHESZ1oqK2r8IG+Zdlbrq+AjP24GvlyCTO i6C26cpFRDrm01PCJQFCqQnezch6U2oCkoQrGMxC/M0W7Pwk2J7wB02N5Zjs4jspdrNJ P827NCFjCGoSPeKDfQpdIt0YQC/pGHMKVRmfSqsuCnTYq4bB9N7tFTlJ4spsh9Iz/dyw 2cUkt6MTD7AiPPKiqUS+g8WjMGDt9Xu308l7fqnxlByybo1gF6DfPQSkHqdWlbQY1ZdO HfWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zs9gcJh1GuqENL0684ED+OEV5vC6ieHQPjBw7Yiioes=; b=GkdnMUDevcoHLz3qsA0MvV9BZtFsLKNZS4ftyX9FDmjo75nSvpr6iAc6Ijyp6oBj24 a86DSB6oSTUPeihUonMX5liYT3ExxnGzVpV/UXLWieGDXgfB07fpvLIzb0t8YSlIKSRJ Q8Unin/dJT0eZCHIuWMwCcE5/j64MAi2ZU17/r9OA/qKbwPLNjORu8+SYhAzW4m8OBNZ FhDqehvJ/P+DXzjz4K9OvsrFn4JwCpGZSXeFKUdPWqz3SVz34SIc2ygfgV9C0A5rryxn Ox7+BcINeGAjMSO2JVvfZvlNSIUJlMW0SpWiONbhf2EoUj4puBQWAAoTNS8DIJ0jZ/bg sGzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eWEtjuky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds16si19185147ejc.112.2020.07.07.21.20.42; Tue, 07 Jul 2020 21:21:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eWEtjuky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729403AbgGHETr (ORCPT + 99 others); Wed, 8 Jul 2020 00:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgGHETq (ORCPT ); Wed, 8 Jul 2020 00:19:46 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86101C061755; Tue, 7 Jul 2020 21:19:46 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id u5so19392020pfn.7; Tue, 07 Jul 2020 21:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zs9gcJh1GuqENL0684ED+OEV5vC6ieHQPjBw7Yiioes=; b=eWEtjukyd4B/iIk4TZaUcjglHYlXoeXyGUov5TUBdYgyWmefN8mZa4hRd1Mv9tmN26 FucBcYfPQtavumQL0O1wxvd3mlJOblp9aPp8VYVX5x/O82Uz7n5o0vlE8eSWvgdLgig8 c9JsiNNQrTC9J8KLkt4lwi4B6lxHfadd36v4PH/X9hzUd6Yk0aD+/drXGl40K+CRtRuq QyUrpqvsoNHp1Kn+4qHcnLNfA+TFIzzjfPhs1Gn3k7Dav823EAD7zn5d076Nb1JPusYm qOZXk2r/diryGAf0M9+2JhkKmpWYagURTNJhrYkwd8saNtfigR3ErjDpREQmrVLnlqeG X8Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zs9gcJh1GuqENL0684ED+OEV5vC6ieHQPjBw7Yiioes=; b=uEEFufeqmk8tkVFO0xOAiFb46xIArwax32dugjwzC+jOD+wz7JRJw6BsCDhKvt81b1 pQLlieT88GLc4D5SVD8JA8yIaKbYvS86jg/xMlmanohzLYOMKSaLa9GlDrICtYoYO+Dz DOlFWzJUwqs7x1Fu+6f2rI7N7GHMPEXlyRagGLY9JV5XTqMN+1tuJWAk+LrIsgrT5B9F rRolEJ9auuVU6kx96O7qwK+ezQOI1v685cjLxazHv2BxVN3IXkmVdlelfj2akB5ZjzWi EX7mfH8EN8WVycr3NMQ7PVs3xM/rXoas+SYYQZ+rnbOIBrfHy7kDStMLGTeiA/tNeikM iYkA== X-Gm-Message-State: AOAM531uOVJYjUwoGgKZ+NzEMityb0F++Sx7X7L7Glyf2hSYUjBK1wwl Yu5+U03f28VY4Oh8oaCUm4Pi88Zp X-Received: by 2002:a05:6a00:148c:: with SMTP id v12mr51188651pfu.171.1594181985478; Tue, 07 Jul 2020 21:19:45 -0700 (PDT) Received: from sol.lan (106-69-191-222.dyn.iinet.net.au. [106.69.191.222]) by smtp.gmail.com with ESMTPSA id gx23sm3821951pjb.39.2020.07.07.21.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 21:19:44 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH 09/17] gpiolib: cdev: rename priv to cdev Date: Wed, 8 Jul 2020 12:15:52 +0800 Message-Id: <20200708041600.768775-10-warthog618@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200708041600.768775-1-warthog618@gmail.com> References: <20200708041600.768775-1-warthog618@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename priv to cdev to improve readability. The name "priv" indicates that the object is pointed to by file->private_data, not what the object is actually is. As it is always used to point to a struct gpio_chardev_data, renaming it to cdev is more appropriate. Signed-off-by: Kent Gibson --- drivers/gpio/gpiolib-cdev.c | 90 ++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 352d815bbd07..fe1b385deecc 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -826,8 +826,8 @@ struct gpio_chardev_data { */ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct gpio_chardev_data *priv = file->private_data; - struct gpio_device *gdev = priv->gdev; + struct gpio_chardev_data *cdev = file->private_data; + struct gpio_device *gdev = cdev->gdev; struct gpio_chip *gc = gdev->chip; void __user *ip = (void __user *)arg; struct gpio_desc *desc; @@ -887,7 +887,7 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) hwgpio = gpio_chip_hwgpio(desc); - if (test_bit(hwgpio, priv->watched_lines)) + if (test_bit(hwgpio, cdev->watched_lines)) return -EBUSY; gpio_desc_to_lineinfo(desc, &lineinfo); @@ -895,7 +895,7 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) return -EFAULT; - set_bit(hwgpio, priv->watched_lines); + set_bit(hwgpio, cdev->watched_lines); return 0; } else if (cmd == GPIO_GET_LINEINFO_UNWATCH_IOCTL) { if (copy_from_user(&offset, ip, sizeof(offset))) @@ -907,10 +907,10 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) hwgpio = gpio_chip_hwgpio(desc); - if (!test_bit(hwgpio, priv->watched_lines)) + if (!test_bit(hwgpio, cdev->watched_lines)) return -EBUSY; - clear_bit(hwgpio, priv->watched_lines); + clear_bit(hwgpio, cdev->watched_lines); return 0; } return -EINVAL; @@ -933,12 +933,12 @@ to_gpio_chardev_data(struct notifier_block *nb) static int lineinfo_changed_notify(struct notifier_block *nb, unsigned long action, void *data) { - struct gpio_chardev_data *priv = to_gpio_chardev_data(nb); + struct gpio_chardev_data *cdev = to_gpio_chardev_data(nb); struct gpioline_info_changed chg; struct gpio_desc *desc = data; int ret; - if (!test_bit(gpio_chip_hwgpio(desc), priv->watched_lines)) + if (!test_bit(gpio_chip_hwgpio(desc), cdev->watched_lines)) return NOTIFY_DONE; memset(&chg, 0, sizeof(chg)); @@ -947,9 +947,9 @@ static int lineinfo_changed_notify(struct notifier_block *nb, chg.timestamp = ktime_get_ns(); gpio_desc_to_lineinfo(desc, &chg.info); - ret = kfifo_in_spinlocked(&priv->events, &chg, 1, &priv->wait.lock); + ret = kfifo_in_spinlocked(&cdev->events, &chg, 1, &cdev->wait.lock); if (ret) - wake_up_poll(&priv->wait, EPOLLIN); + wake_up_poll(&cdev->wait, EPOLLIN); else pr_debug_ratelimited("lineinfo event FIFO is full - event dropped\n"); @@ -959,13 +959,13 @@ static int lineinfo_changed_notify(struct notifier_block *nb, static __poll_t lineinfo_watch_poll(struct file *file, struct poll_table_struct *pollt) { - struct gpio_chardev_data *priv = file->private_data; + struct gpio_chardev_data *cdev = file->private_data; __poll_t events = 0; - poll_wait(file, &priv->wait, pollt); + poll_wait(file, &cdev->wait, pollt); - if (!kfifo_is_empty_spinlocked_noirqsave(&priv->events, - &priv->wait.lock)) + if (!kfifo_is_empty_spinlocked_noirqsave(&cdev->events, + &cdev->wait.lock)) events = EPOLLIN | EPOLLRDNORM; return events; @@ -974,7 +974,7 @@ static __poll_t lineinfo_watch_poll(struct file *file, static ssize_t lineinfo_watch_read(struct file *file, char __user *buf, size_t count, loff_t *off) { - struct gpio_chardev_data *priv = file->private_data; + struct gpio_chardev_data *cdev = file->private_data; struct gpioline_info_changed event; ssize_t bytes_read = 0; int ret; @@ -983,28 +983,28 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf, return -EINVAL; do { - spin_lock(&priv->wait.lock); - if (kfifo_is_empty(&priv->events)) { + spin_lock(&cdev->wait.lock); + if (kfifo_is_empty(&cdev->events)) { if (bytes_read) { - spin_unlock(&priv->wait.lock); + spin_unlock(&cdev->wait.lock); return bytes_read; } if (file->f_flags & O_NONBLOCK) { - spin_unlock(&priv->wait.lock); + spin_unlock(&cdev->wait.lock); return -EAGAIN; } - ret = wait_event_interruptible_locked(priv->wait, - !kfifo_is_empty(&priv->events)); + ret = wait_event_interruptible_locked(cdev->wait, + !kfifo_is_empty(&cdev->events)); if (ret) { - spin_unlock(&priv->wait.lock); + spin_unlock(&cdev->wait.lock); return ret; } } - ret = kfifo_out(&priv->events, &event, 1); - spin_unlock(&priv->wait.lock); + ret = kfifo_out(&cdev->events, &event, 1); + spin_unlock(&cdev->wait.lock); if (ret != 1) { ret = -EIO; break; @@ -1029,33 +1029,33 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) { struct gpio_device *gdev = container_of(inode->i_cdev, struct gpio_device, chrdev); - struct gpio_chardev_data *priv; + struct gpio_chardev_data *cdev; int ret = -ENOMEM; /* Fail on open if the backing gpiochip is gone */ if (!gdev->chip) return -ENODEV; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); + if (!cdev) return -ENOMEM; - priv->watched_lines = bitmap_zalloc(gdev->chip->ngpio, GFP_KERNEL); - if (!priv->watched_lines) - goto out_free_priv; + cdev->watched_lines = bitmap_zalloc(gdev->chip->ngpio, GFP_KERNEL); + if (!cdev->watched_lines) + goto out_free_cdev; - init_waitqueue_head(&priv->wait); - INIT_KFIFO(priv->events); - priv->gdev = gdev; + init_waitqueue_head(&cdev->wait); + INIT_KFIFO(cdev->events); + cdev->gdev = gdev; - priv->lineinfo_changed_nb.notifier_call = lineinfo_changed_notify; + cdev->lineinfo_changed_nb.notifier_call = lineinfo_changed_notify; ret = blocking_notifier_chain_register(&gdev->notifier, - &priv->lineinfo_changed_nb); + &cdev->lineinfo_changed_nb); if (ret) goto out_free_bitmap; get_device(&gdev->dev); - file->private_data = priv; + file->private_data = cdev; ret = nonseekable_open(inode, file); if (ret) @@ -1065,11 +1065,11 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) out_unregister_notifier: blocking_notifier_chain_unregister(&gdev->notifier, - &priv->lineinfo_changed_nb); + &cdev->lineinfo_changed_nb); out_free_bitmap: - bitmap_free(priv->watched_lines); -out_free_priv: - kfree(priv); + bitmap_free(cdev->watched_lines); +out_free_cdev: + kfree(cdev); return ret; } @@ -1081,14 +1081,14 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) */ static int gpio_chrdev_release(struct inode *inode, struct file *file) { - struct gpio_chardev_data *priv = file->private_data; - struct gpio_device *gdev = priv->gdev; + struct gpio_chardev_data *cdev = file->private_data; + struct gpio_device *gdev = cdev->gdev; - bitmap_free(priv->watched_lines); + bitmap_free(cdev->watched_lines); blocking_notifier_chain_unregister(&gdev->notifier, - &priv->lineinfo_changed_nb); + &cdev->lineinfo_changed_nb); put_device(&gdev->dev); - kfree(priv); + kfree(cdev); return 0; } -- 2.27.0