Ignore:
Timestamp:
Oct 3, 2022, 4:24:46 AM (3 years ago)
Author:
Paul Smedley
Message:

Update linux core to the 6.0 kernel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-exp/lib32/misc.c

    r737 r750  
    4040#include <linux/firmware.h>
    4141#include <linux/ctype.h>
     42#include <linux/math64.h>
    4243#include <dbgos2.h>
    4344
     
    823824}
    824825EXPORT_SYMBOL(sysfs_streq);
     826
     827u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
     828{
     829        u32 high = divisor >> 32;
     830        u64 quot;
     831
     832        if (high == 0) {
     833                u32 rem32;
     834                quot = div_u64_rem(dividend, divisor, &rem32);
     835                *remainder = rem32;
     836        } else {
     837                int n = fls(high);
     838                quot = div_u64(dividend >> n, divisor >> n);
     839
     840                if (quot != 0)
     841                        quot--;
     842
     843                *remainder = dividend - quot * divisor;
     844                if (*remainder >= divisor) {
     845                        quot++;
     846                        *remainder -= divisor;
     847                }
     848        }
     849
     850        return quot;
     851}
     852
     853/**
     854 * memset32() - Fill a memory area with a uint32_t
     855 * @s: Pointer to the start of the area.
     856 * @v: The value to fill the area with
     857 * @count: The number of values to store
     858 *
     859 * Differs from memset() in that it fills with a uint32_t instead
     860 * of a byte.  Remember that @count is the number of uint32_ts to
     861 * store, not the number of bytes.
     862 */
     863void *memset32(uint32_t *s, uint32_t v, size_t count)
     864{
     865        uint32_t *xs = s;
     866
     867        while (count--)
     868                *xs++ = v;
     869        return s;
     870}
     871EXPORT_SYMBOL(memset32);
     872
     873/**
     874 *      sysfs_emit - scnprintf equivalent, aware of PAGE_SIZE buffer.
     875 *      @buf:   start of PAGE_SIZE buffer.
     876 *      @fmt:   format
     877 *      @...:   optional arguments to @format
     878 *
     879 *
     880 * Returns number of characters written to @buf.
     881 */
     882int sysfs_emit(char *buf, const char *fmt, ...)
     883{
     884        va_list args;
     885        int len;
     886
     887#ifdef NOT_USED
     888        if (WARN(!buf || offset_in_page(buf),
     889                 "invalid sysfs_emit: buf:%p\n", buf))
     890                return 0;
     891#endif
     892
     893        va_start(args, fmt);
     894        len = vscnprintf(buf, PAGE_SIZE, fmt, args);
     895        va_end(args);
     896
     897        return len;
     898}
     899EXPORT_SYMBOL_GPL(sysfs_emit);
     900
     901/**
     902 *      sysfs_emit_at - scnprintf equivalent, aware of PAGE_SIZE buffer.
     903 *      @buf:   start of PAGE_SIZE buffer.
     904 *      @at:    offset in @buf to start write in bytes
     905 *              @at must be >= 0 && < PAGE_SIZE
     906 *      @fmt:   format
     907 *      @...:   optional arguments to @fmt
     908 *
     909 *
     910 * Returns number of characters written starting at &@buf[@at].
     911 */
     912int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
     913{
     914        va_list args;
     915        int len;
     916
     917#ifdef NOT_USED
     918        if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE,
     919                 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
     920                return 0;
     921#endif
     922
     923        va_start(args, fmt);
     924        len = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args);
     925        va_end(args);
     926
     927        return len;
     928}
     929EXPORT_SYMBOL_GPL(sysfs_emit_at);
Note: See TracChangeset for help on using the changeset viewer.