Deleted Added
full compact
mmcsd.c (331722) mmcsd.c (333768)
1/*-
2 * Copyright (c) 2006 Bernd Walter. All rights reserved.
3 * Copyright (c) 2006 M. Warner Losh. All rights reserved.
4 * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 38 unchanged lines hidden (view full) ---

47 * implication, estoppel or otherwise under any patent or other rights of the
48 * SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
49 * herein shall be construed as an obligation by the SD Group, the SD-3C LLC
50 * or the SD Card Association to disclose or distribute any technical
51 * information, know-how or other confidential information to any third party.
52 */
53
54#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 Bernd Walter. All rights reserved.
3 * Copyright (c) 2006 M. Warner Losh. All rights reserved.
4 * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 38 unchanged lines hidden (view full) ---

47 * implication, estoppel or otherwise under any patent or other rights of the
48 * SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
49 * herein shall be construed as an obligation by the SD Group, the SD-3C LLC
50 * or the SD Card Association to disclose or distribute any technical
51 * information, know-how or other confidential information to any third party.
52 */
53
54#include <sys/cdefs.h>
55__FBSDID("$FreeBSD: stable/11/sys/dev/mmc/mmcsd.c 331722 2018-03-29 02:50:57Z eadler $");
55__FBSDID("$FreeBSD: stable/11/sys/dev/mmc/mmcsd.c 333768 2018-05-17 21:23:14Z marius $");
56
57#include <sys/param.h>
58#include <sys/systm.h>
59#include <sys/bio.h>
60#include <sys/bus.h>
61#include <sys/conf.h>
62#include <sys/fcntl.h>
63#include <sys/ioccom.h>
64#include <sys/kernel.h>
65#include <sys/kthread.h>
66#include <sys/lock.h>
67#include <sys/malloc.h>
68#include <sys/module.h>
69#include <sys/mutex.h>
56
57#include <sys/param.h>
58#include <sys/systm.h>
59#include <sys/bio.h>
60#include <sys/bus.h>
61#include <sys/conf.h>
62#include <sys/fcntl.h>
63#include <sys/ioccom.h>
64#include <sys/kernel.h>
65#include <sys/kthread.h>
66#include <sys/lock.h>
67#include <sys/malloc.h>
68#include <sys/module.h>
69#include <sys/mutex.h>
70#include <sys/priv.h>
70#include <sys/slicer.h>
71#include <sys/time.h>
72
73#include <geom/geom.h>
74#include <geom/geom_disk.h>
75
76#include <dev/mmc/bridge.h>
77#include <dev/mmc/mmc_ioctl.h>

--- 94 unchanged lines hidden (view full) ---

172 int fflag, struct thread *td);
173
174static void mmcsd_add_part(struct mmcsd_softc *sc, u_int type,
175 const char *name, u_int cnt, off_t media_size, bool ro);
176static int mmcsd_bus_bit_width(device_t dev);
177static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp);
178static const char *mmcsd_errmsg(int e);
179static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data,
71#include <sys/slicer.h>
72#include <sys/time.h>
73
74#include <geom/geom.h>
75#include <geom/geom_disk.h>
76
77#include <dev/mmc/bridge.h>
78#include <dev/mmc/mmc_ioctl.h>

--- 94 unchanged lines hidden (view full) ---

173 int fflag, struct thread *td);
174
175static void mmcsd_add_part(struct mmcsd_softc *sc, u_int type,
176 const char *name, u_int cnt, off_t media_size, bool ro);
177static int mmcsd_bus_bit_width(device_t dev);
178static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp);
179static const char *mmcsd_errmsg(int e);
180static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data,
180 int fflag);
181 int fflag, struct thread *td);
181static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic,
182 int fflag);
183static uintmax_t mmcsd_pretty_size(off_t size, char *unit);
184static daddr_t mmcsd_rw(struct mmcsd_part *part, struct bio *bp);
185static int mmcsd_set_blockcount(struct mmcsd_softc *sc, u_int count, bool rel);
186static int mmcsd_slicer(device_t dev, const char *provider,
187 struct flash_slice *slices, int *nslices);
188static int mmcsd_switch_part(device_t bus, device_t dev, uint16_t rca,

--- 577 unchanged lines hidden (view full) ---

766 } else {
767 MMCSD_DISK_UNLOCK(part);
768 biofinish(bp, NULL, ENXIO);
769 }
770}
771
772static int
773mmcsd_ioctl_rpmb(struct cdev *dev, u_long cmd, caddr_t data,
182static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic,
183 int fflag);
184static uintmax_t mmcsd_pretty_size(off_t size, char *unit);
185static daddr_t mmcsd_rw(struct mmcsd_part *part, struct bio *bp);
186static int mmcsd_set_blockcount(struct mmcsd_softc *sc, u_int count, bool rel);
187static int mmcsd_slicer(device_t dev, const char *provider,
188 struct flash_slice *slices, int *nslices);
189static int mmcsd_switch_part(device_t bus, device_t dev, uint16_t rca,

--- 577 unchanged lines hidden (view full) ---

767 } else {
768 MMCSD_DISK_UNLOCK(part);
769 biofinish(bp, NULL, ENXIO);
770 }
771}
772
773static int
774mmcsd_ioctl_rpmb(struct cdev *dev, u_long cmd, caddr_t data,
774 int fflag, struct thread *td __unused)
775 int fflag, struct thread *td)
775{
776
776{
777
777 return (mmcsd_ioctl(dev->si_drv1, cmd, data, fflag));
778 return (mmcsd_ioctl(dev->si_drv1, cmd, data, fflag, td));
778}
779
780static int
781mmcsd_ioctl_disk(struct disk *disk, u_long cmd, void *data, int fflag,
779}
780
781static int
782mmcsd_ioctl_disk(struct disk *disk, u_long cmd, void *data, int fflag,
782 struct thread *td __unused)
783 struct thread *td)
783{
784
784{
785
785 return (mmcsd_ioctl(disk->d_drv1, cmd, data, fflag));
786 return (mmcsd_ioctl(disk->d_drv1, cmd, data, fflag, td));
786}
787
788static int
787}
788
789static int
789mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag)
790mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag,
791 struct thread *td)
790{
791 struct mmc_ioc_cmd *mic;
792 struct mmc_ioc_multi_cmd *mimc;
793 int i, err;
794 u_long cnt, size;
795
796 if ((fflag & FREAD) == 0)
797 return (EBADF);
798
792{
793 struct mmc_ioc_cmd *mic;
794 struct mmc_ioc_multi_cmd *mimc;
795 int i, err;
796 u_long cnt, size;
797
798 if ((fflag & FREAD) == 0)
799 return (EBADF);
800
801 err = priv_check(td, PRIV_DRIVER);
802 if (err != 0)
803 return (err);
804
799 err = 0;
800 switch (cmd) {
801 case MMC_IOC_CMD:
802 mic = data;
803 err = mmcsd_ioctl_cmd(part, mic, fflag);
804 break;
805 case MMC_IOC_MULTI_CMD:
806 mimc = data;

--- 678 unchanged lines hidden ---
805 err = 0;
806 switch (cmd) {
807 case MMC_IOC_CMD:
808 mic = data;
809 err = mmcsd_ioctl_cmd(part, mic, fflag);
810 break;
811 case MMC_IOC_MULTI_CMD:
812 mimc = data;

--- 678 unchanged lines hidden ---