From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1669224802601283543==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix kobj_to_dev.cocci warnings Date: Thu, 27 Aug 2020 07:27:10 +0800 Message-ID: <20200826232710.GA28737@d10202f75172> In-Reply-To: <202008270751.hp4RBpOO%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============1669224802601283543== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: Keith Busch CC: Jens Axboe CC: Christoph Hellwig CC: Sagi Grimberg CC: linux-nvme(a)lists.infradead.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/nvme/host/core.c:3646:60-61: WARNING opportunity for kobj_to_dev() drivers/nvme/host/core.c:3403:60-61: WARNING opportunity for kobj_to_dev() Use kobj_to_dev() instead of container_of() Generated by: scripts/coccinelle/api/kobj_to_dev.cocci Fixes: a2fc3718bc22 ("coccinelle: api: add kobj_to_dev.cocci script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git f= or-5.10 head: a2fc3718bc22e85378085568ecc5765fb28cabce commit: a2fc3718bc22e85378085568ecc5765fb28cabce [3/3] coccinelle: api: add= kobj_to_dev.cocci script :::::: branch date: 5 days ago :::::: commit date: 5 days ago Please take the patch only if it's a positive warning. Thanks! core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3400,7 +3400,7 @@ static struct attribute *nvme_ns_id_attr static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { - struct device *dev =3D container_of(kobj, struct device, kobj); + struct device *dev =3D kobj_to_dev(kobj); struct nvme_ns_ids *ids =3D &dev_to_ns_head(dev)->ids; = if (a =3D=3D &dev_attr_uuid.attr) { @@ -3643,7 +3643,7 @@ static struct attribute *nvme_dev_attrs[ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { - struct device *dev =3D container_of(kobj, struct device, kobj); + struct device *dev =3D kobj_to_dev(kobj); struct nvme_ctrl *ctrl =3D dev_get_drvdata(dev); = if (a =3D=3D &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl) --===============1669224802601283543==--