Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932795AbdC2Rod (ORCPT ); Wed, 29 Mar 2017 13:44:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44469 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932702AbdC2RoX (ORCPT ); Wed, 29 Mar 2017 13:44:23 -0400 From: Christopher Bostic To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, rostedt@goodmis.org, mingo@redhat.com, gregkh@linuxfoundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Chris Bostic , joel@jms.id.au, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: [PATCH v4 13/23] drivers/fsi: Add client driver register utilities Date: Wed, 29 Mar 2017 12:43:30 -0500 X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170329174340.89109-1-cbostic@linux.vnet.ibm.com> References: <20170329174340.89109-1-cbostic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17032917-0004-0000-0000-000011DE35C3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006872; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00840411; UDB=6.00413637; IPR=6.00618406; BA=6.00005248; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014855; XFM=3.00000013; UTC=2017-03-29 17:44:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032917-0005-0000-0000-00007E342AA1 Message-Id: <20170329174340.89109-14-cbostic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-29_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703290150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1953 Lines: 64 From: Chris Bostic Add driver_register and driver_unregister wrappers for FSI. Signed-off-by: Chris Bostic Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 17 +++++++++++++++++ include/linux/fsi.h | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 75d2a88..4359e26 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -585,6 +585,23 @@ static int fsi_bus_match(struct device *dev, struct device_driver *drv) return 0; } +int fsi_driver_register(struct fsi_driver *fsi_drv) +{ + if (!fsi_drv) + return -EINVAL; + if (!fsi_drv->id_table) + return -EINVAL; + + return driver_register(&fsi_drv->drv); +} +EXPORT_SYMBOL_GPL(fsi_driver_register); + +void fsi_driver_unregister(struct fsi_driver *fsi_drv) +{ + driver_unregister(&fsi_drv->drv); +} +EXPORT_SYMBOL_GPL(fsi_driver_unregister); + struct bus_type fsi_bus_type = { .name = "fsi", .match = fsi_bus_match, diff --git a/include/linux/fsi.h b/include/linux/fsi.h index 66bce48..34f1e9a 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -54,6 +54,18 @@ struct fsi_driver { #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev) #define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv) +extern int fsi_driver_register(struct fsi_driver *fsi_drv); +extern void fsi_driver_unregister(struct fsi_driver *fsi_drv); + +/* module_fsi_driver() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit() + */ +#define module_fsi_driver(__fsi_driver) \ + module_driver(__fsi_driver, fsi_driver_register, \ + fsi_driver_unregister) + extern struct bus_type fsi_bus_type; #endif /* LINUX_FSI_H */ -- 1.8.2.2