Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1195091pxb; Thu, 9 Sep 2021 23:46:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyQSG+r6YWr65/r4rSK5ix8dO5AwAbO0tn+BWw8bl7XQj6/snvGA4qNS4BDaZ4I9Aktq2v X-Received: by 2002:a92:3012:: with SMTP id x18mr5307254ile.249.1631256364868; Thu, 09 Sep 2021 23:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631256364; cv=none; d=google.com; s=arc-20160816; b=eFNTjff2Yd4JsvwGIllfNf/zRehl5ONxeOQugggaQPb16yJWUfitHdX0am1iP1v5Oo DYKMTW16GAbmDoSm5+9X2EczlYYwb+zyjVHc0EL//KR/NliThDkOMTzFB7V6ySr+II8M CeKJmsMlR1EUeNMU1gZRuDZ6fmQFTiYq9l2f6onCAax9GyZ8PlcvBXGSoBasx3ux4NAo 0vrYrG7rqSlGtyynzKkO+BvxY24ZHTg7xWpgLViyuPRl6X7kDCtMyOPtnYCUOV4w4nZy 2TC7zrF4kqGkru41VbOAzUM913pkOLkxQK7h0LtcWYQrAPEN6Cwib7VCqT/Vls3F0B22 lH6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IFVQ1jeIev12TTM6Zy0z6ARtoJRJRQI7WupWvFArDKc=; b=dVYOOFoo+lORIut2ozVEnV0T2GzHSv+6p/EXmYxWYoHiX4NjvsfW8iEfHEFV4AL+Yv NA4Z9RhtR0J2bk7dractW1Mv2VQwM6MtL9dWHxdVp4nPBPvD+RbHw+A5RRQzY8ORUlnn kiVetpNUJgllUcqk62ohXdW/0VjtOrdHAcrlMKRhmrkpSmvDyrYVk26CKNTz5X9hg5u7 SLj33SP1gM/R+dCAHlVluJ3UIl6ZwblHh+5ABMO0BoCNmxfIUqeUCHjRJyCrJCPyvNGM bdvlM2uXrThkGfp3Va/s1D4pu0zMkujg+bo7lCxxyH8TgX2Zf+qcPOhSRPOcfWwXGy+S tYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=arZpI6Vb; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si4220587jao.55.2021.09.09.23.45.52; Thu, 09 Sep 2021 23:46:04 -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=@linuxfoundation.org header.s=korg header.b=arZpI6Vb; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbhIJGqU (ORCPT + 99 others); Fri, 10 Sep 2021 02:46:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:34178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbhIJGqT (ORCPT ); Fri, 10 Sep 2021 02:46:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71E3E6109F; Fri, 10 Sep 2021 06:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631256308; bh=zs4kHzRc2dEOg/Ypc3inBLRklRqv/MDp+aMdgAMUJvo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=arZpI6Vbkd1Q4i3uXv3VOMwXkAB9fZUzJYRhC8canCV48cmeaid4vVaHL6S35gBYk 1r2JfmDm9NFy+1X6JVvhICj3bQFHl/EVf52LImze8YXwP8PGLdAUmQV84ndyDMvxTv NXCgtswiAFDW6aYrzFAElN/he9LdzZHmHPxjjlG0= Date: Fri, 10 Sep 2021 08:45:06 +0200 From: Greg KH To: Ian Pilcher Cc: axboe@kernel.dk, pavel@ucw.cz, linux-leds@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, kabel@kernel.org Subject: Re: [PATCH v2 06/15] leds: trigger: blkdev: Add function to get gendisk by name Message-ID: References: <20210909222513.2184795-1-arequipeno@gmail.com> <20210909222513.2184795-7-arequipeno@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909222513.2184795-7-arequipeno@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 05:25:04PM -0500, Ian Pilcher wrote: > Add ledtrig_blkdev_get_disk() to find block device by name and increment > its reference count. (Caller must call put_disk().) Must be built-in to > access block_class and disk_type symbols. > > Signed-off-by: Ian Pilcher > --- > drivers/leds/trigger/ledtrig-blkdev-core.c | 20 ++++++++++++++++++++ > drivers/leds/trigger/ledtrig-blkdev.h | 3 +++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/leds/trigger/ledtrig-blkdev-core.c b/drivers/leds/trigger/ledtrig-blkdev-core.c > index d7b02e760b06..5fd741aa14a6 100644 > --- a/drivers/leds/trigger/ledtrig-blkdev-core.c > +++ b/drivers/leds/trigger/ledtrig-blkdev-core.c > @@ -33,3 +33,23 @@ void ledtrig_blkdev_disk_cleanup(struct gendisk *const gd) > > mutex_unlock(&ledtrig_blkdev_mutex); > } > + > +/* class_find_device() callback. Must be built-in to access disk_type. */ > +static int blkdev_match_name(struct device *const dev, const void *const name) > +{ > + return dev->type == &disk_type > + && sysfs_streq(dev_to_disk(dev)->disk_name, name); > +} > + > +/* Must be built-in to access block_class */ > +struct gendisk *ledtrig_blkdev_get_disk(const char *const name) > +{ > + struct device *dev; > + > + dev = class_find_device(&block_class, NULL, name, blkdev_match_name); > + if (dev == NULL) > + return NULL; You now have bumped the reference count on this structure. Where do you decrement it when you are finished with it? thanks, greg k-h