Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp108336lqh; Mon, 6 May 2024 12:51:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVir1rXMuuWnlk2fpJ3xNvH3MzC9U0bBCamePobdKcyJoiCuHjIYlB8k0xgnSeaOdAbRoEvRaNA26QNULHsw1+POjVAm0ueH5+X+r+PFQ== X-Google-Smtp-Source: AGHT+IGcZj+yoh8j/HIipHEt9eVhGBkM1FQyXQ7If7KGHJIWOFpYBSW0iHWLUvYAEW2hN4ga0pE5 X-Received: by 2002:a05:6358:3105:b0:183:90a2:f4ce with SMTP id c5-20020a056358310500b0018390a2f4cemr13665217rwe.0.1715025061513; Mon, 06 May 2024 12:51:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715025061; cv=pass; d=google.com; s=arc-20160816; b=EEmY39kfozRsATPM+POQrSHaOjBN8cRVdqnwu5GAsUc/AGqIUkHE8hQlJMyd8y5RV8 vY5xKZ5mfDog9qONdaYBrn/ZKSyvt6AB31R+hbx90g5elgKJv8+pkA2kMS4of/oSBHgG ek3T+1QtSKCyaPWHgJCL13m1YSHlToyjDU/XOx/SMl/CEDkBjn6KkXERe2cSPlWodYi7 DQpRFqrUlS/jSfHJUPW3QNmCwUUxq9tNEhL5PakaYHO0YTc8FbPaCl73BfgOy2caCi69 va63gYg4RgmOcXvzqjxkQbBpwt1qPzian3S0LKpxPYtbLJLLa08eWC8nGewNVkd66gPc iC/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ss4WavEiatm1ir88BkwsnzQ07rzsa9F6DU8Ne8r2NDw=; fh=+ublBM+9GGWYoKbssKiMLEYTC/PmLwBCGlvV+Nagl9Q=; b=UxQlah90hPeLZFhInpYOeDAPJKiujcKbGqHt2SA5TCla1CHRJBXINkNRlN+9AsrNWJ 27BhviqcrgSqkpbFn8v1kD92uL+OmOz39OLoX49vMWWOHD8OoJxjPriZmRTKgWZMLahy igyzrjAM4QrLBYCnmXDQAAjTZFAZdPTcCkWVWNg5B01P9kyagppjypcg6TCCrqnOCqT7 uh3lvi/gpufdDUNPdcvkLdBGny/5pF5gRODHGkiu1pM3YWrvxd/Gj3+WrXACOS7D2ApB wbyWnrFWOwUOX0SN0vrK/mDKxdzn1XfJ++x6vP3RserHOzJarKChK3wBiDmAHPb9t+62 /JNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=m8vOlx5e; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-170369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170369-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h36-20020a635324000000b0061c26673e52si7745177pgb.286.2024.05.06.12.51.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 12:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=m8vOlx5e; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-170369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170369-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 66D24B23FC8 for ; Mon, 6 May 2024 19:47:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DFA015E21A; Mon, 6 May 2024 19:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="m8vOlx5e" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33EFB15B12E; Mon, 6 May 2024 19:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715024712; cv=none; b=kFAjx+U+Zf0BNFNBKGtuc4D8kUq42GDuGP2mSjc5wToIOp4zjQlus/UdJsBtlV3exAD+3UmJkgC0kuG7iWROI733BIcDMjHPpOqZaQl+mNDS9TvJg93c0Xz4cV0nb1/IxhDWsjQD0/nkp6+2y1Tb10td+h1+GFiG3EN1GVHZ78w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715024712; c=relaxed/simple; bh=IPEkwIxoEulrJ72TUcnrk2IFwrdAChz+rfxSTwedrfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nF5XEbx1tMLw5rDe8iipNVfH2zSgjKnqVLMNxk4Dj1Ibc9+ZyQzj2UMCM2k5wCEqYfiL7Fa6i4ez+4HE1hSYrPEh83rv//ZFCsvm2UCn91xS3RS8U4jZwOgunu81PSRGbUjV2MFH5+glfEuSDepCQECoCEdla916dEhzhhACkpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=m8vOlx5e; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446JgUp4019316; Mon, 6 May 2024 19:45:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Ss4WavEiatm1ir88BkwsnzQ07rzsa9F6DU8Ne8r2NDw=; b=m8vOlx5etgKVTxL0HvFNlx9/5mo7EfXu/NbfSNwZPBYMAffef9887EV/hqxFzAuoe6zQ VEb81paUtpekpIHppbvdAXmYxDpBIu81n72qvx9HWQsgr456y9BjfKdUUqETD4aoxQ2K WEcnPvvnm6R/+iWkXfEZsx8R6tlKCCZhonOzN801qxnuC+fmd6PWqWe480SrM4tcXNwF U+TX0yxuQMWCUAs3Gv+35PVrgh7mNmoOz3uHoyI2ehvbW3gQW7wNd1UYwxyY9Wofa2/j UKH9+CCFDDWtxnEO0RauYDbPJscbF41Pa8vZf2rOUIb2opB3fdB9lmF7HWSxiWFLILil OA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xy5kg805e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 May 2024 19:45:03 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 446Jj2Pk023400; Mon, 6 May 2024 19:45:02 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xy5kg805a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 May 2024 19:45:02 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 446J9SSD010584; Mon, 6 May 2024 19:45:01 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xx0bp1vhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 May 2024 19:45:01 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 446JitEe57475558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 May 2024 19:44:57 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4281A20040; Mon, 6 May 2024 19:44:55 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F48C2004E; Mon, 6 May 2024 19:44:55 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 May 2024 19:44:55 +0000 (GMT) From: Heiko Carstens To: Nathan Chancellor , Arnd Bergmann , Thomas Huth , Alexandra Winter , Thorsten Winkler , Andrew Morton , Jiri Slaby , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Vasily Gorbik , Alexander Gordeev , netdev@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Sven Schnelle , Christian Borntraeger Subject: [PATCH 1/6] s390/iucv: Provide iucv_alloc_device() / iucv_release_device() Date: Mon, 6 May 2024 21:44:49 +0200 Message-Id: <20240506194454.1160315-2-hca@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240506194454.1160315-1-hca@linux.ibm.com> References: <20240506194454.1160315-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NI5UqJqy5yI21YRFMWhlVVdMDHGq3wxT X-Proofpoint-GUID: 3I0mMeMmdoUrsRpXqKpTJR846LFxVYfN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_14,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=716 impostorscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060142 Provide iucv_alloc_device() and iucv_release_device() helper functions, which can be used to deduplicate more or less identical IUCV device allocation and release code in four different drivers. Suggested-by: Arnd Bergmann Signed-off-by: Heiko Carstens --- include/net/iucv/iucv.h | 6 ++++++ net/iucv/iucv.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h index 5cd7871127c9..b3736e66fe1a 100644 --- a/include/net/iucv/iucv.h +++ b/include/net/iucv/iucv.h @@ -84,6 +84,12 @@ struct iucv_array { extern const struct bus_type iucv_bus; extern struct device *iucv_root; +struct device_driver; + +struct device *iucv_alloc_device(const struct attribute_group **attrs, + struct device_driver *driver, void *priv, + const char *fmt, ...) __printf(4, 5); + /* * struct iucv_path * pathid: 16 bit path identification diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index a4ab615ca3e3..9db7c2c0ae72 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c @@ -76,6 +76,41 @@ EXPORT_SYMBOL(iucv_bus); struct device *iucv_root; EXPORT_SYMBOL(iucv_root); +static void iucv_release_device(struct device *device) +{ + kfree(device); +} + +struct device *iucv_alloc_device(const struct attribute_group **attrs, + struct device_driver *driver, + void *priv, const char *fmt, ...) +{ + struct device *dev; + va_list vargs; + int rc; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + goto out_error; + va_start(vargs, fmt); + rc = dev_set_name(dev, fmt, vargs); + va_end(vargs); + if (rc) + goto out_error; + dev->bus = &iucv_bus; + dev->parent = iucv_root; + dev->driver = driver; + dev->groups = attrs; + dev->release = iucv_release_device; + dev_set_drvdata(dev, priv); + return dev; + +out_error: + kfree(dev); + return NULL; +} +EXPORT_SYMBOL(iucv_alloc_device); + static int iucv_available; /* General IUCV interrupt structure */ -- 2.40.1